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 #############################################################
34 USE_UCLIBC_SNAPSHOT
:=$(SNAPSHOT
)
35 USE_UCLIBC_LDSO_0_9_24
:=false
36 USE_BUSYBOX_SNAPSHOT
:=$(SNAPSHOT
)
37 USE_NETFILTER_SNAPSHOT
:=$(SNAPSHOT
)
38 USE_BRIDGE_VERSION
:=0.9.7
39 BUILD_WITH_LARGEFILE
:=true
41 OPTIMIZE_FOR_CPU
=$(ARCH
)
43 # directory used by 'make publish'
44 PUB_DIR
:=/var
/www
/html
/testsite
/ipkg
46 # Command used to download source code
47 WGET
:=wget
--passive-ftp
49 # Soft floating point options.
51 # Currently builds with gcc 3.3 for arm, mips, mipsel, powerpc.
52 # (i386 support will be added back in at some point.)
53 # Only tested with multilib enabled.
54 # For i386, long double is the same as double (64 bits). While this
55 # is unusual for x86, it seemed the best approach considering the
56 # limitations in the gcc floating point emulation library.
57 # For arm, soft float uses the usual libfloat routines.
58 # Custom specs files are used to set the default gcc mode to soft float
59 # as a convenience, since you shouldn't link hard and soft float
60 # together. In fact, arm won't even let you.
61 # (Un)comment the appropriate line below.
65 TARGET_OPTIMIZATION
=-Os
-mips2
68 # Currently the unwind stuff seems to work for staticly linked apps but
69 # not dynamic. So use setjmp/longjmp exceptions by default.
70 # GCC_USE_SJLJ_EXCEPTIONS:=--enable-sjlj-exceptions
71 GCC_USE_SJLJ_EXCEPTIONS
:=
73 # Any additional gcc options you may want to include....
74 EXTRA_GCC_CONFIG_OPTIONS
:=
76 # Enable the following if you want locale/gettext/i18n support.
77 # NOTE! Currently the pregnerated locale stuff only works for x86!
81 # If you want multilib enabled, enable this...
82 MULTILIB
:=--enable-multilib
84 # Build/install c++ compiler and libstdc++?
85 #INSTALL_LIBSTDCPP:=true
86 INSTALL_LIBSTDCPP
:=false
88 # Build/install java compiler and libgcj? (requires c++)
89 # WARNING!!! DOES NOT BUILD FOR TARGET WITHOUT INTERVENTION!!! mjn3
93 # For SMP machines some stuff can be run in parallel
96 #############################################################
98 # The list of stuff to build for the target filesystem
100 #############################################################
101 TARGETS
:=host-sed gcc3_3 ipkg-utils openwrt-base openwrt-code.bin
103 PACKAGES
:=oidentd iproute2 sched-modules wshaper
105 #############################################################
107 # You should probably leave this stuff alone unless you know
108 # what you are doing.
110 #############################################################
112 ifeq ($(SOFT_FLOAT
),true
)
113 SOFT_FLOAT_CONFIG_OPTION
:=--without-float
114 TARGET_SOFT_FLOAT
:=-msoft-float
115 ARCH_FPU_SUFFIX
:=_nofpu
117 SOFT_FLOAT_CONFIG_OPTION
:=
122 ifeq ($(INSTALL_LIBGCJ
),true
)
123 INSTALL_LIBSTDCPP
:=true
126 # WARNING -- uClibc currently disables large file support on cris.
127 ifeq ("$(strip $(ARCH))","cris")
128 BUILD_WITH_LARGEFILE
:=false
131 ifneq ($(BUILD_WITH_LARGEFILE
),true
)
132 DISABLE_LARGEFILE
= --disable-largefile
134 TARGET_CFLAGS
=$(TARGET_OPTIMIZATION
) $(TARGET_DEBUGGING
)
137 BASE_DIR
:=${shell pwd
}
138 SOURCE_DIR
:=$(BASE_DIR
)/sources
139 DL_DIR
:=$(SOURCE_DIR
)/dl
140 PATCH_DIR
=$(SOURCE_DIR
)/patches
141 BUILD_DIR
:=$(BASE_DIR
)/build_
$(ARCH
)$(ARCH_FPU_SUFFIX
)
142 TARGET_DIR
:=$(BUILD_DIR
)/root
143 STAGING_DIR
=$(BUILD_DIR
)/staging_dir
144 TOOL_BUILD_DIR
=$(BASE_DIR
)/toolchain_build_
$(ARCH
)$(ARCH_FPU_SUFFIX
)
145 TARGET_PATH
=$(STAGING_DIR
)/bin
:/bin
:/sbin
:/usr
/bin
:/usr
/sbin
146 IMAGE
:=$(BASE_DIR
)/root_fs_
$(ARCH
)$(ARCH_FPU_SUFFIX
)
147 REAL_GNU_TARGET_NAME
=$(OPTIMIZE_FOR_CPU
)-linux-uclibc
148 GNU_TARGET_NAME
=$(OPTIMIZE_FOR_CPU
)-linux
149 KERNEL_CROSS
=$(STAGING_DIR
)/bin
/$(OPTIMIZE_FOR_CPU
)-linux-uclibc-
150 TARGET_CROSS
=$(STAGING_DIR
)/bin
/$(OPTIMIZE_FOR_CPU
)-linux-uclibc-
151 TARGET_CC
=$(TARGET_CROSS
)gcc
152 STRIP
=$(TARGET_CROSS
)strip --remove-section
=.comment
--remove-section
=.note
155 HOST_ARCH
:=$(shell $(HOSTCC
) -dumpmachine | sed
-e s
'/-.*//' \
156 -e
's/sparc.*/sparc/' \
158 -e
's/m68k.*/m68k/' \
159 -e
's/ppc/powerpc/g' \
160 -e
's/v850.*/v850/g' \
162 -e
's/mips-.*/mips/' \
163 -e
's/mipsel-.*/mipsel/' \
164 -e
's/cris.*/cris/' \
165 -e
's/i[3-9]86/i386/' \
167 GNU_HOST_NAME
:=$(HOST_ARCH
)-pc-linux-gnu
168 TARGET_CONFIGURE_OPTS
=PATH
=$(TARGET_PATH
) \
169 AR
=$(TARGET_CROSS
)ar \
170 AS
=$(TARGET_CROSS
)as \
171 LD
=$(TARGET_CROSS
)ld \
172 NM
=$(TARGET_CROSS
)nm \
173 CC
=$(TARGET_CROSS
)gcc \
174 GCC
=$(TARGET_CROSS
)gcc \
175 CXX
=$(TARGET_CROSS
)g
++ \
176 RANLIB
=$(TARGET_CROSS
)ranlib
178 ifeq ($(ENABLE_LOCALE
),true
)
181 DISABLE_NLS
:=--disable-nls
186 TARGETS_CLEAN
:=$(patsubst %,%-clean,$(TARGETS
))
187 TARGETS_SOURCE
:=$(patsubst %,%-source
,$(TARGETS
))
188 TARGETS_DIRCLEAN
:=$(patsubst %,%-dirclean
,$(TARGETS
))
191 PACKAGES_IPK
:=$(patsubst %,%-ipk
,$(PACKAGES
))
192 OPENWRT_IPK_DIR
=$(SOURCE_DIR
)/openwrt
/ipkg
194 $(BUILD_DIR
)/Packages
: $(PACKAGES_IPK
)
195 (cd
$(BUILD_DIR
) ; $(IPKG_MAKE_INDEX
) .
> Packages
)
197 world
: $(DL_DIR
) $(BUILD_DIR
) $(STAGING_DIR
) $(TARGET_DIR
) $(TARGETS
) $(PACKAGES_IPK
) $(BUILD_DIR
)/Packages
200 .PHONY
: all world
clean dirclean
distclean source
$(TARGETS
) \
201 $(TARGETS_CLEAN
) $(TARGETS_DIRCLEAN
) $(TARGETS_SOURCE
)
205 #############################################################
207 # staging and target directories do NOT list these as
208 # dependancies anywhere else
210 #############################################################
218 rm -rf
$(STAGING_DIR
)
219 mkdir
-p
$(STAGING_DIR
)/lib
220 mkdir
-p
$(STAGING_DIR
)/usr
221 ln
-fs
$(REAL_GNU_TARGET_NAME
)/include $(STAGING_DIR
)/include
222 ln
-fs ..
/lib
$(STAGING_DIR
)/usr
/lib
223 ln
-fs ..
/$(REAL_GNU_TARGET_NAME
)/include $(STAGING_DIR
)/usr
/include
226 $(TARGET_DIR
): $(DL_DIR
)/$(OPENWRT_ROOT_SKEL
)
228 zcat
$(DL_DIR
)/$(OPENWRT_ROOT_SKEL
) |
tar -C
$(BUILD_DIR
) -xf
-
229 -find
$(TARGET_DIR
) -type d
-name CVS
-exec
rm -rf
{} \
; > /dev
/null
2>&1
231 source
: $(TARGETS_SOURCE
)
233 #############################################################
235 # Cleanup and misc junk
237 #############################################################
239 rm -rf
$(TOOL_BUILD_DIR
) $(BUILD_DIR
) $(IMAGE
) \
240 openwrt-linux.trx openwrt-g-code.bin openwrt-gs-code.bin \
241 openwrt-kmodules.
tar.bz2
243 dirclean
: $(TARGETS_DIRCLEAN
)
244 rm -rf
$(TARGET_DIR
) $(STAGING_DIR
) $(IMAGE
) \
245 openwrt-linux.trx openwrt-g-code.bin openwrt-gs-code.bin \
246 openwrt-kmodules.
tar.bz2
249 rm -rf
$(DL_DIR
) $(BUILD_DIR
) $(LINUX_KERNEL
) $(IMAGE
) \
250 openwrt-linux.trx openwrt-g-code.bin openwrt-gs-code.bin \
251 openwrt-kmodules.
tar.bz2
254 chmod
644 $(BUILD_DIR
)/Packages
255 chmod
644 $(BUILD_DIR
)/Packages.filelist
256 chmod
644 $(BUILD_DIR
)/*.ipk
257 cp
$(BUILD_DIR
)/Packages
$(PUB_DIR
)
258 cp
$(BUILD_DIR
)/Packages.filelist
$(PUB_DIR
)
259 cp
$(BUILD_DIR
)/*.ipk
$(PUB_DIR
)
265 rm -f buildroot.
tar.bz2
; \
266 tar -cvf buildroot.
tar buildroot
; \
267 bzip2
-9 buildroot.
tar; \