1 # Makefile for a simple busybox/uClibc root filesystem
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU Library General Public License as
9 # published by the Free Software Foundation; either version 2 of the
10 # License, or (at your option) any later version.
12 # This program is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Library General Public License for more details.
17 # You should have received a copy of the GNU Library General Public
18 # License along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 #############################################################
25 # EDIT this stuff to suit your system and preferences
27 # Use := when possible to get precomputation, thereby
28 # speeding up the build process.
30 #############################################################
32 # What sort of target system shall we compile this for?
47 # Choose the kernel headers to use for kernel-headers target. This is
48 # ignored if you are building your own kernel or using the system kernel.
50 DEFAULT_KERNEL_HEADERS:=2.4.25
51 #DEFAULT_KERNEL_HEADERS:=2.6.7
54 # WARNING -- 2.95 currently only builds for i386, arm, mips*, and powerpc.
55 # WARNING -- 2.95 does not currently build natively for the target.
63 # Choose binutils version.
65 #BINUTILS_VERSION:=2.14.90.0.6
66 #BINUTILS_VERSION:=2.14.90.0.7
67 #BINUTILS_VERSION:=2.14.90.0.8
68 #BINUTILS_VERSION:=2.15
69 #BINUTILS_VERSION:=2.15.90.0.1
70 #BINUTILS_VERSION:=2.15.90.0.1.1
71 #BINUTILS_VERSION:=2.15.90.0.2
72 BINUTILS_VERSION:=2.15.90.0.3
73 #BINUTILS_VERSION:=2.15.91.0.1
74 #BINUTILS_VERSION:=2.15.91.0.2
83 # Enable this to use the uClibc daily snapshot instead of a released
84 # version. Daily snapshots may contain new features and bugfixes. Or
85 # they may not even compile at all, depending on what Erik is doing.
87 # Do you wish to use the latest release (), latest snapshot (snapshot),
88 # or the snapshot from a specific date (yyyymmdd)? Note that snapshots
89 # may contain new features and bugfixes. Or they may not even compile
90 # at all, depending on what Erik and Manuel are doing.
92 #USE_UCLIBC_SNAPSHOT:=
93 USE_UCLIBC_SNAPSHOT:=snapshot
94 #USE_UCLIBC_SNAPSHOT:=20040807
96 # Do you wish to use the latest release (), latest snapshot (snapshot),
97 # or the snapshot from a specific date (yyyymmdd)? Note that snapshots
98 # may contain new features and bugfixes. Or they may not even compile
101 #USE_BUSYBOX_SNAPSHOT:=
102 USE_BUSYBOX_SNAPSHOT:=snapshot
103 #USE_BUSYBOX_SNAPSHOT:=20040807
105 # Enable large file (files > 2 GB) support
106 BUILD_WITH_LARGEFILE:=true
108 # Command used to download source code
109 WGET:=wget --passive-ftp
111 # Optimize toolchain for which type of CPU?
112 OPTIMIZE_FOR_CPU=$(ARCH)
113 #OPTIMIZE_FOR_CPU=i686
114 # Note... gcc 2.95 does not seem to like anything higher than i586.
115 #OPTIMIZE_FOR_CPU=i586
116 #OPTIMIZE_FOR_CPU=whatever
118 # Might be worth experimenting with for gcc 3.4.x.
123 #GCC_WITH_CPU:=--with-cpu=
124 #GCC_WITH_ARCH:=--with-arch=
125 #GCC_WITH_TUNE:=--with-tune=
127 # Soft floating point options.
129 # Currently builds with gcc 3.3 for arm, mips, mipsel, powerpc.
130 # (i386 support will be added back in at some point.)
131 # Only tested with multilib enabled.
132 # For i386, long double is the same as double (64 bits). While this
133 # is unusual for x86, it seemed the best approach considering the
134 # limitations in the gcc floating point emulation library.
135 # For arm, soft float uses the usual libfloat routines.
136 # Custom specs files are used to set the default gcc mode to soft float
137 # as a convenience, since you shouldn't link hard and soft float
138 # together. In fact, arm won't even let you.
139 # (Un)comment the appropriate line below.
143 TARGET_OPTIMIZATION=-Os
144 TARGET_DEBUGGING= #-g
146 # Currently the unwind stuff seems to work for staticly linked apps but
147 # not dynamic. So use setjmp/longjmp exceptions by default.
148 GCC_USE_SJLJ_EXCEPTIONS:=--enable-sjlj-exceptions
149 #GCC_USE_SJLJ_EXCEPTIONS:=
151 # Any additional gcc options you may want to include....
152 EXTRA_GCC_CONFIG_OPTIONS:=
154 # Enable the following if you want locale/gettext/i18n support.
155 # NOTE! Currently the pregnerated locale stuff only works for x86!
159 # If you want multilib enabled, enable this...
160 MULTILIB:=--enable-multilib
162 # Build/install c++ compiler and libstdc++?
163 INSTALL_LIBSTDCPP:=true
165 # Build/install java compiler and libgcj? (requires c++)
166 # WARNING!!! DOES NOT BUILD FOR TARGET WITHOUT INTERVENTION!!! mjn3
167 #INSTALL_LIBGCJ:=true
168 INSTALL_LIBGCJ:=false
170 # For SMP machines some stuff can be run in parallel
173 #############################################################
175 # The list of stuff to build for the target filesystem
177 #############################################################
180 TARGETS+=uclibc-configured binutils gcc ccache
182 # Are you building your own kernel? Perhaps you have a kernel
183 # you have already configured and you want to use that? The
184 # default is to just use a set of known working kernel headers.
185 # Unless you want to build a kernel, I recommend just using
187 TARGETS+=kernel-headers
189 #TARGETS+=system-linux
191 # The default minimal set
192 TARGETS+=busybox #tinylogin
195 #TARGETS+=zlib openssl openssh
196 # Dropbear sshd is much smaller than openssl + openssh
197 #TARGETS+=dropbear_sshd
199 # Everything needed to build a full uClibc development system!
200 #TARGETS+=coreutils findutils bash make diffutils patch sed
201 #TARGETS+=ed flex bison file gawk tar grep bzip2
203 #If you want a development system, you probably want gcc built
204 # with uClibc so it can run within your dev system...
205 #TARGETS+=gcc_target ccache_target
207 # Of course, if you are installing a development system, you
208 # may want some header files so you can compile stuff....
209 #TARGETS+=ncurses-headers zlib-headers openssl-headers
211 # More development system stuff for those that want it
212 #TARGETS+=m4 autoconf automake libtool
214 # Some nice debugging tools
215 #TARGETS+=gdb strace ltrace
217 # The Valgrind debugger (x86 only)
220 # Some stuff for access points and firewalls
221 #TARGETS+=iptables hostap wtools dhcp_relay bridge
222 #TARGETS+=iproute2 netsnmp
224 # Run customize.mk at the very end to add your own special config.
225 # This is useful for making your own distro within the buildroot
229 #############################################################
231 # Pick your root filesystem type.
233 #############################################################
236 # Must mount cramfs with 'ramdisk_blocksize=4096'
239 # You may need to edit make/jffs2root.mk to change target
240 # endian-ness or similar, but this is sufficient for most
244 #############################################################
246 # You should probably leave this stuff alone unless you know
247 # what you are doing.
249 #############################################################
251 ifeq ($(SOFT_FLOAT),true)
252 # gcc 3.4.x soft float configuration is different than previous versions.
253 ifeq ($(findstring 3.4.,$(GCC_VERSION)),3.4.)
254 SOFT_FLOAT_CONFIG_OPTION:=--with-float=soft
256 SOFT_FLOAT_CONFIG_OPTION:=--without-float
258 TARGET_SOFT_FLOAT:=-msoft-float
259 ARCH_FPU_SUFFIX:=_nofpu
261 SOFT_FLOAT_CONFIG_OPTION:=
266 ifeq ($(INSTALL_LIBGCJ),true)
267 INSTALL_LIBSTDCPP:=true
270 # WARNING -- uClibc currently disables large file support on cris.
271 ifeq ("$(strip $(ARCH))","cris")
272 BUILD_WITH_LARGEFILE:=false
275 ifneq ($(BUILD_WITH_LARGEFILE),true)
276 DISABLE_LARGEFILE= --disable-largefile
278 TARGET_CFLAGS=$(TARGET_OPTIMIZATION) $(TARGET_DEBUGGING)
281 BASE_DIR:=${shell pwd}
282 SOURCE_DIR:=$(BASE_DIR)/sources
283 DL_DIR:=$(SOURCE_DIR)/dl
284 PATCH_DIR=$(SOURCE_DIR)/patches
285 BUILD_DIR:=$(BASE_DIR)/build_$(ARCH)$(ARCH_FPU_SUFFIX)
286 TARGET_DIR:=$(BUILD_DIR)/root
287 STAGING_DIR=$(BUILD_DIR)/staging_dir
288 TOOL_BUILD_DIR=$(BASE_DIR)/toolchain_build_$(ARCH)$(ARCH_FPU_SUFFIX)
289 TARGET_PATH=$(STAGING_DIR)/bin:/bin:/sbin:/usr/bin:/usr/sbin
290 IMAGE:=$(BASE_DIR)/root_fs_$(ARCH)$(ARCH_FPU_SUFFIX)
291 REAL_GNU_TARGET_NAME=$(OPTIMIZE_FOR_CPU)-linux-uclibc
292 GNU_TARGET_NAME=$(OPTIMIZE_FOR_CPU)-linux
293 KERNEL_CROSS=$(STAGING_DIR)/bin/$(OPTIMIZE_FOR_CPU)-linux-uclibc-
294 TARGET_CROSS=$(STAGING_DIR)/bin/$(OPTIMIZE_FOR_CPU)-linux-uclibc-
295 TARGET_CC=$(TARGET_CROSS)gcc
296 STRIP=$(TARGET_CROSS)strip --remove-section=.comment --remove-section=.note
299 HOST_ARCH:=$(shell $(HOSTCC) -dumpmachine | sed -e s'/-.*//' \
300 -e 's/sparc.*/sparc/' \
302 -e 's/m68k.*/m68k/' \
303 -e 's/ppc/powerpc/g' \
304 -e 's/v850.*/v850/g' \
306 -e 's/mips-.*/mips/' \
307 -e 's/mipsel-.*/mipsel/' \
308 -e 's/cris.*/cris/' \
309 -e 's/i[3-9]86/i386/' \
311 GNU_HOST_NAME:=$(HOST_ARCH)-pc-linux-gnu
312 TARGET_CONFIGURE_OPTS=PATH=$(TARGET_PATH) \
313 AR=$(TARGET_CROSS)ar \
314 AS=$(TARGET_CROSS)as \
315 LD=$(TARGET_CROSS)ld \
316 NM=$(TARGET_CROSS)nm \
317 CC=$(TARGET_CROSS)gcc \
318 GCC=$(TARGET_CROSS)gcc \
319 CXX=$(TARGET_CROSS)g++ \
320 RANLIB=$(TARGET_CROSS)ranlib
322 ifeq ($(ENABLE_LOCALE),true)
325 DISABLE_NLS:=--disable-nls
331 TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS))
332 TARGETS_SOURCE:=$(patsubst %,%-source,$(TARGETS))
333 TARGETS_DIRCLEAN:=$(patsubst %,%-dirclean,$(TARGETS))
335 world: $(DL_DIR) $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) $(TARGETS)
337 .PHONY: all world clean dirclean distclean source $(TARGETS) \
338 $(TARGETS_CLEAN) $(TARGETS_DIRCLEAN) $(TARGETS_SOURCE)
342 #############################################################
344 # staging and target directories do NOT list these as
345 # dependancies anywhere else
347 #############################################################
355 mkdir $(TOOL_BUILD_DIR)
358 rm -rf $(STAGING_DIR)
359 mkdir -p $(STAGING_DIR)/lib
360 mkdir -p $(STAGING_DIR)/include
361 mkdir -p $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)
362 ln -sf ../lib $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/lib
366 zcat $(SOURCE_DIR)/skel.tar.gz | tar -C $(BUILD_DIR) -xf -
367 cp -a $(SOURCE_DIR)/target_skeleton/* $(TARGET_DIR)/
368 -find $(TARGET_DIR) -type d -name CVS -exec rm -rf {} \; > /dev/null 2>&1
370 source: $(TARGETS_SOURCE)
372 #############################################################
374 # Cleanup and misc junk
376 #############################################################
377 clean: $(TARGETS_CLEAN)
378 rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE)
380 dirclean: $(TARGETS_DIRCLEAN)
381 rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE)
384 rm -rf $(DL_DIR) $(BUILD_DIR) $(LINUX_KERNEL) $(IMAGE)
390 rm -f buildroot.tar.bz2; \
391 tar -cvf buildroot.tar buildroot; \
392 bzip2 -9 buildroot.tar; \