1 # Makefile for a simple busybox/uClibc root filesystem
3 # Copyright (C) 2001-2004 Erik Andersen <andersen@codepoet.org>
4 # Copyright (C) 2002 by Tim Riker <Tim@Rikers.org>
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU Library General Public License as
8 # published by the Free Software Foundation; either version 2 of the
9 # License, or (at your option) any later version.
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Library General Public License for more details.
16 # You should have received a copy of the GNU Library General Public
17 # License along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 #############################################################
24 # EDIT this stuff to suit your system and preferences
26 # Use := when possible to get precomputation, thereby
27 # speeding up the build process.
29 #############################################################
31 # What sortof target system shall we compile this for?
38 # Busybox link failing due to needing libgcc functions that are statics.
41 # The following currently fail to build since no shared lib support.
48 # If you are building a native gcc toolchain, do you want to
49 # build the old gcc-2.95 based toolchain, or would you prefer
50 # a nice and shiny new gcc-3.3.2 toolchain?
51 # WARNING -- 2.95 currently only builds for i386, arm, mips*, and powerpc.
52 # WARNING -- 2.95 does not currently build natively for the target.
53 GCC_2_95_TOOLCHAIN
:=false
55 # Enable this to use the uClibc daily snapshot instead of a released
56 # version. Daily snapshots may contain new features and bugfixes. Or
57 # they may not even compile at all, depending on what Erik is doing...
58 #USE_UCLIBC_SNAPSHOT:=
59 #USE_UCLIBC_SNAPSHOT:=snapshot
60 USE_UCLIBC_SNAPSHOT
:=20040509
62 # Temporary option... Fall back to (slightly modified) ldso 0.9.24 code?
63 # This is here temporarily since I'm having problems with the current
64 # cvs ldso code on mipsel.
65 USE_UCLIBC_LDSO_0_9_24
:=true
66 #USE_UCLIBC_LDSO_0_9_24:=false
68 # Enable this to use the busybox daily snapshot instead of a released
69 # version. Daily snapshots may contain new features and bugfixes. Or
70 # they may not even compile at all....
71 #USE_BUSYBOX_SNAPSHOT:=
72 #USE_BUSYBOX_SNAPSHOT:=snapshot
73 USE_BUSYBOX_SNAPSHOT
:=20040509
75 # Enable large file (files > 2 GB) support
76 BUILD_WITH_LARGEFILE
:=true
78 # Command used to download source code
79 WGET
:=wget
--passive-ftp
81 # Optimize toolchain for which type of CPU?
82 OPTIMIZE_FOR_CPU
=$(ARCH
)
83 #OPTIMIZE_FOR_CPU=i686
84 # Note... gcc 2.95 does not seem to like anything higher than i586.
85 #OPTIMIZE_FOR_CPU=i586
86 #OPTIMIZE_FOR_CPU=whatever
88 # Soft floating point options.
90 # Currently builds with gcc 3.3 for arm, mips, mipsel, powerpc.
91 # (i386 support will be added back in at some point.)
92 # Only tested with multilib enabled.
93 # For i386, long double is the same as double (64 bits). While this
94 # is unusual for x86, it seemed the best approach considering the
95 # limitations in the gcc floating point emulation library.
96 # For arm, soft float uses the usual libfloat routines.
97 # Custom specs files are used to set the default gcc mode to soft float
98 # as a convenience, since you shouldn't link hard and soft float
99 # together. In fact, arm won't even let you.
100 # (Un)comment the appropriate line below.
104 TARGET_OPTIMIZATION
=-Os
-mips2
105 TARGET_DEBUGGING
= #-g
107 # Currently the unwind stuff seems to work for staticly linked apps but
108 # not dynamic. So use setjmp/longjmp exceptions by default.
109 GCC_USE_SJLJ_EXCEPTIONS
:=--enable-sjlj-exceptions
110 #GCC_USE_SJLJ_EXCEPTIONS:=
112 # Any additional gcc options you may want to include....
113 EXTRA_GCC_CONFIG_OPTIONS
:=
115 # Enable the following if you want locale/gettext/i18n support.
116 # NOTE! Currently the pregnerated locale stuff only works for x86!
120 # If you want multilib enabled, enable this...
121 MULTILIB
:=--enable-multilib
123 # Build/install c++ compiler and libstdc++?
124 #INSTALL_LIBSTDCPP:=true
125 INSTALL_LIBSTDCPP
:=false
127 # Build/install java compiler and libgcj? (requires c++)
128 # WARNING!!! DOES NOT BUILD FOR TARGET WITHOUT INTERVENTION!!! mjn3
129 #INSTALL_LIBGCJ:=true
130 INSTALL_LIBGCJ
:=false
132 # For SMP machines some stuff can be run in parallel
135 #############################################################
137 # The list of stuff to build for the target filesystem
139 #############################################################
142 ifeq ($(GCC_2_95_TOOLCHAIN
),true
)
143 TARGETS
+=uclibc-configured binutils gcc2_95
145 TARGETS
+=uclibc-configured binutils gcc3_3
148 # Do you want user mode Linux (x86 only), or are you building a
149 # your own kernel that will run on its own? Perhaps you have a
150 # kernel you have already configured and you want to use that?
151 # The default is to just use a set of known working kernel
152 # headers. Unless you want to build a kernel, I recommend just
154 #TARGETS+=kernel-headers
156 #TARGETS+=user-mode-linux
157 #TARGETS+=system-linux
158 TARGETS
+= openwrt-base
160 # The default minimal set
161 #TARGETS+=busybox tinylogin
164 #TARGETS+=zlib openssl openssh
165 # Dropbear sshd is much smaller than openssl + openssh
166 #TARGETS+=dropbear_sshd
168 # Everything needed to build a full uClibc development system!
169 #TARGETS+=coreutils findutils bash make diffutils patch sed
170 #TARGETS+=ed flex bison file gawk tar grep bzip2
172 #If you want a development system, you probably want gcc built
173 # with uClibc so it can run within your dev system...
174 #TARGETS+=gcc2_95_target ccache_target # NOT WORKING!!!
175 #TARGETS+=gcc3_3_target ccache_target
177 # Of course, if you are installing a development system, you
178 # may want some header files so you can compile stuff....
179 #TARGETS+=ncurses-headers zlib-headers openssl-headers
181 # More development system stuff for those that want it
182 #TARGETS+=m4 autoconf automake libtool
187 # Some nice debugging tools
188 #TARGETS+=gdb strace ltrace
190 # The Valgrind debugger (x86 only)
193 # Some stuff for access points and firewalls
194 #TARGETS+=iptables hostap wtools dhcp_relay bridge
195 #TARGETS+=iproute2 netsnmp
197 # Run customize.mk at the very end to add your own special config.
198 # This is useful for making your own distro within the buildroot
202 #############################################################
204 # Pick your root filesystem type.
206 #############################################################
209 # Must mount cramfs with 'ramdisk_blocksize=4096'
212 # You may need to edit make/jffs2root.mk to change target
213 # endian-ness or similar, but this is sufficient for most
217 #TARGETS+= openwrt-linux.trx
218 TARGETS
+= openwrt-code.bin
220 #############################################################
222 # You should probably leave this stuff alone unless you know
223 # what you are doing.
225 #############################################################
227 ifeq ($(SOFT_FLOAT
),true
)
228 SOFT_FLOAT_CONFIG_OPTION
:=--without-float
229 TARGET_SOFT_FLOAT
:=-msoft-float
230 ARCH_FPU_SUFFIX
:=_nofpu
232 SOFT_FLOAT_CONFIG_OPTION
:=
237 ifeq ($(INSTALL_LIBGCJ
),true
)
238 INSTALL_LIBSTDCPP
:=true
241 # WARNING -- uClibc currently disables large file support on cris.
242 ifeq ("$(strip $(ARCH))","cris")
243 BUILD_WITH_LARGEFILE
:=false
246 ifneq ($(BUILD_WITH_LARGEFILE
),true
)
247 DISABLE_LARGEFILE
= --disable-largefile
249 TARGET_CFLAGS
=$(TARGET_OPTIMIZATION
) $(TARGET_DEBUGGING
)
252 BASE_DIR
:=${shell pwd
}
253 SOURCE_DIR
:=$(BASE_DIR
)/sources
254 DL_DIR
:=$(SOURCE_DIR
)/dl
255 PATCH_DIR
=$(SOURCE_DIR
)/patches
256 BUILD_DIR
:=$(BASE_DIR
)/build_
$(ARCH
)$(ARCH_FPU_SUFFIX
)
257 TARGET_DIR
:=$(BUILD_DIR
)/root
258 STAGING_DIR
=$(BUILD_DIR
)/staging_dir
259 TOOL_BUILD_DIR
=$(BASE_DIR
)/toolchain_build_
$(ARCH
)$(ARCH_FPU_SUFFIX
)
260 TARGET_PATH
=$(STAGING_DIR
)/bin
:/bin
:/sbin
:/usr
/bin
:/usr
/sbin
261 IMAGE
:=$(BASE_DIR
)/root_fs_
$(ARCH
)$(ARCH_FPU_SUFFIX
)
262 REAL_GNU_TARGET_NAME
=$(OPTIMIZE_FOR_CPU
)-linux-uclibc
263 GNU_TARGET_NAME
=$(OPTIMIZE_FOR_CPU
)-linux
264 KERNEL_CROSS
=$(STAGING_DIR
)/bin
/$(OPTIMIZE_FOR_CPU
)-linux-uclibc-
265 TARGET_CROSS
=$(STAGING_DIR
)/bin
/$(OPTIMIZE_FOR_CPU
)-linux-uclibc-
266 TARGET_CC
=$(TARGET_CROSS
)gcc
267 STRIP
=$(TARGET_CROSS
)strip --remove-section
=.comment
--remove-section
=.note
270 HOST_ARCH
:=$(shell $(HOSTCC
) -dumpmachine | sed
-e s
'/-.*//' \
271 -e
's/sparc.*/sparc/' \
273 -e
's/m68k.*/m68k/' \
274 -e
's/ppc/powerpc/g' \
275 -e
's/v850.*/v850/g' \
277 -e
's/mips-.*/mips/' \
278 -e
's/mipsel-.*/mipsel/' \
279 -e
's/cris.*/cris/' \
280 -e
's/i[3-9]86/i386/' \
282 GNU_HOST_NAME
:=$(HOST_ARCH
)-pc-linux-gnu
283 TARGET_CONFIGURE_OPTS
=PATH
=$(TARGET_PATH
) \
284 AR
=$(TARGET_CROSS
)ar \
285 AS
=$(TARGET_CROSS
)as \
286 LD
=$(TARGET_CROSS
)ld \
287 NM
=$(TARGET_CROSS
)nm \
288 CC
=$(TARGET_CROSS
)gcc \
289 GCC
=$(TARGET_CROSS
)gcc \
290 CXX
=$(TARGET_CROSS
)g
++ \
291 RANLIB
=$(TARGET_CROSS
)ranlib
293 ifeq ($(ENABLE_LOCALE
),true
)
296 DISABLE_NLS
:=--disable-nls
302 TARGETS_CLEAN
:=$(patsubst %,%-clean,$(TARGETS
))
303 TARGETS_SOURCE
:=$(patsubst %,%-source
,$(TARGETS
))
304 TARGETS_DIRCLEAN
:=$(patsubst %,%-dirclean
,$(TARGETS
))
306 world
: $(DL_DIR
) $(BUILD_DIR
) $(STAGING_DIR
) $(TARGET_DIR
) $(TARGETS
)
309 .PHONY
: all world
clean dirclean
distclean source
$(TARGETS
) \
310 $(TARGETS_CLEAN
) $(TARGETS_DIRCLEAN
) $(TARGETS_SOURCE
)
314 #############################################################
316 # staging and target directories do NOT list these as
317 # dependancies anywhere else
319 #############################################################
327 rm -rf
$(STAGING_DIR
)
328 mkdir
-p
$(STAGING_DIR
)/lib
329 mkdir
-p
$(STAGING_DIR
)/usr
330 ln
-fs
$(REAL_GNU_TARGET_NAME
)/include $(STAGING_DIR
)/include
331 ln
-fs ..
/lib
$(STAGING_DIR
)/usr
/lib
332 ln
-fs ..
/$(REAL_GNU_TARGET_NAME
)/include $(STAGING_DIR
)/usr
/include
335 $(TARGET_DIR
): $(DL_DIR
)/$(OPENWRT_ROOT_SKEL
)
337 #zcat $(SOURCE_DIR)/skel.tar.gz | tar -C $(BUILD_DIR) -xf -
338 zcat
$(DL_DIR
)/$(OPENWRT_ROOT_SKEL
) |
tar -C
$(BUILD_DIR
) -xf
-
339 #cp -a $(SOURCE_DIR)/target_skeleton/* $(TARGET_DIR)/
340 -find
$(TARGET_DIR
) -type d
-name CVS
-exec
rm -rf
{} \
; > /dev
/null
2>&1
342 source
: $(TARGETS_SOURCE
)
344 #############################################################
346 # Cleanup and misc junk
348 #############################################################
350 rm -rf
$(TOOL_BUILD_DIR
) $(BUILD_DIR
) $(IMAGE
) \
351 openwrt-linux.trx openwrt-g-code.bin openwrt-gs-code.bin \
352 openwrt-kmodules.
tar.bz2
354 dirclean
: $(TARGETS_DIRCLEAN
)
355 rm -rf
$(TARGET_DIR
) $(STAGING_DIR
) $(IMAGE
) \
356 openwrt-linux.trx openwrt-g-code.bin openwrt-gs-code.bin \
357 openwrt-kmodules.
tar.bz2
360 rm -rf
$(DL_DIR
) $(BUILD_DIR
) $(LINUX_KERNEL
) $(IMAGE
) \
361 openwrt-linux.trx openwrt-g-code.bin openwrt-gs-code.bin \
362 openwrt-kmodules.
tar.bz2
368 rm -f buildroot.
tar.bz2
; \
369 tar -cvf buildroot.
tar buildroot
; \
370 bzip2
-9 buildroot.
tar; \