blob: aa209ea5a61f2923a12f391a728b227ab91b9db8 [file] [log] [blame]
Eric Andersen08782ae2002-04-26 11:45:55 +00001# Makefile for a simple busybox/uClibc root filesystem
Eric Andersenffde94b2001-12-22 00:56:11 +00002#
Eric Andersen03c3fa22003-01-03 06:44:03 +00003# Copyright (C) 2001-2003 Erik Andersen <andersen@codepoet.org>
Eric Andersen08782ae2002-04-26 11:45:55 +00004# Copyright (C) 2002 by Tim Riker <Tim@Rikers.org>
Eric Andersenffde94b2001-12-22 00:56:11 +00005#
Eric Andersen08782ae2002-04-26 11:45:55 +00006# 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.
Eric Andersenffde94b2001-12-22 00:56:11 +000010#
Eric Andersen08782ae2002-04-26 11:45:55 +000011# 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.
Eric Andersenffde94b2001-12-22 00:56:11 +000015#
Eric Andersen08782ae2002-04-26 11:45:55 +000016# 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
19# USA
Eric Andersenffde94b2001-12-22 00:56:11 +000020
Eric Andersenffde94b2001-12-22 00:56:11 +000021
Eric Andersen08782ae2002-04-26 11:45:55 +000022#############################################################
23#
24# EDIT this stuff to suit your system and preferences
25#
26# Use := when possible to get precomputation, thereby
27# speeding up the build process.
28#
29#############################################################
Eric Andersenffde94b2001-12-22 00:56:11 +000030
Eric Andersen08782ae2002-04-26 11:45:55 +000031# What sortof target system shall we compile this for?
32ARCH:=i386
33#ARCH:=arm
Manuel Novoa III d632d422003-11-01 05:34:41 +000034#ARCH:=mipsel
35#ARCH:=mips
Eric Andersen27bc59d2003-01-17 04:31:36 +000036#ARCH:=powerpc
Eric Andersen08782ae2002-04-26 11:45:55 +000037#ARCH:=whatever
Eric Andersenffde94b2001-12-22 00:56:11 +000038
Eric Andersen95f81a52002-07-03 10:44:59 +000039# enable to build a native gcc toolchain with uclibc support
Eric Andersen5a9f7f22002-08-28 22:38:39 +000040USE_UCLIBC_TOOLCHAIN:=true
Eric Andersen95f81a52002-07-03 10:44:59 +000041
Eric Andersen18e33c22003-02-04 12:37:32 +000042# If you are building a native gcc toolchain, do you want to
43# build the old gcc-2.95 based toolchain, or would you prefer
44# a nice and shiny new gcc-3.2.1 toolchain?
45GCC_2_95_TOOLCHAIN:=false
46
Eric Andersen08782ae2002-04-26 11:45:55 +000047# Enable this to use the uClibc daily snapshot instead of a released
48# version. Daily snapshots may contain new features and bugfixes. Or
Eric Andersen95f81a52002-07-03 10:44:59 +000049# they may not even compile at all, depending on what Erik is doing...
Eric Andersend9064132003-04-26 02:59:09 +000050USE_UCLIBC_SNAPSHOT:=true
Jon Nelsonc38dccc2002-01-03 04:51:43 +000051
Eric Andersen085ba9f2002-04-26 21:20:45 +000052# Enable this to use the busybox daily snapshot instead of a released
53# version. Daily snapshots may contain new features and bugfixes. Or
54# they may not even compile at all....
Eric Andersen26da8032003-06-04 20:49:24 +000055USE_BUSYBOX_SNAPSHOT:=true
Eric Andersen085ba9f2002-04-26 21:20:45 +000056
Eric Andersen08782ae2002-04-26 11:45:55 +000057# Enable large file (files > 2 GB) support
Eric Andersen03c3fa22003-01-03 06:44:03 +000058BUILD_WITH_LARGEFILE:=true
Jon Nelsonc38dccc2002-01-03 04:51:43 +000059
Eric Andersen8a2597e2002-11-20 23:16:10 +000060# Command used to download source code
61WGET:=wget --passive-ftp
62
Eric Andersen27bc59d2003-01-17 04:31:36 +000063# Optimize toolchain for which type of CPU?
Eric Andersenef7784a2003-01-17 08:03:59 +000064OPTIMIZE_FOR_CPU=$(ARCH)
65#OPTIMIZE_FOR_CPU=i486
66#OPTIMIZE_FOR_CPU=strongarm
67#OPTIMIZE_FOR_CPU=whatever
Eric Andersen27bc59d2003-01-17 04:31:36 +000068
Manuel Novoa III d632d422003-11-01 05:34:41 +000069# Soft floating point options.
70# Notes:
71# Currently builds with gcc 3.3 for i386, arm, mips, mipsel.
72# Only tested with multilib enabled.
73# For i386, long double is the same as double (64 bits). While this
74# is unusual for x86, it seemed the best approach considering the
75# limitations in the gcc floating point emulation library.
76# For arm, soft float uses the usual libfloat routines.
77# The uClibc built will support _only_ applications compiled with the
78# -msoft-float flag. To avoid CFLAGS problems, you may want to use
79# scripts similar to those in the build*/staging_dir/bin directory.
80# Uncomment the next 2 lines to build a soft-float toolchain and rootfs.
81# SOFT_FLOAT_CONFIG_OPTION=--without-float
82# TARGET_SOFT_FLOAT=-msoft-float
83
84TARGET_OPTIMIZATION=-Os
85TARGET_DEBUGGING= #-g
86TARGET_CFLAGS=$(TARGET_OPTIMIZATION) $(TARGET_DEBUGGING) $(TARGET_SOFT_FLOAT)
87
Eric Andersen27bc59d2003-01-17 04:31:36 +000088# Any additional gcc options you may want to include....
Eric Andersenef7784a2003-01-17 08:03:59 +000089EXTRA_GCC_CONFIG_OPTIONS=
Eric Andersen27bc59d2003-01-17 04:31:36 +000090
Eric Andersencb7d5b82003-09-14 11:38:35 +000091# Enable the following if you want locale/gettext/i18n support.
92#ENABLE_LOCALE:=true
93ENABLE_LOCALE:=false
94
95# If you want multilib enabled, enable this...
96MULTILIB:=--enable-multilib
97
98#Install libstdc++?
99INSTALL_LIBSTDCPP=true
Manuel Novoa III 0e956fc2003-09-03 07:18:18 +0000100
Eric Andersen02bf5812003-10-18 11:09:54 +0000101# For SMP machines some stuff can be run in parallel
102#JLEVEL=-j3
103
Eric Andersen08782ae2002-04-26 11:45:55 +0000104#############################################################
105#
106# The list of stuff to build for the target filesystem
107#
108#############################################################
Eric Andersencb7d5b82003-09-14 11:38:35 +0000109TARGETS:=
Eric Andersen03c3fa22003-01-03 06:44:03 +0000110# The toolchain comes next if we are building one
111ifeq ($(USE_UCLIBC_TOOLCHAIN),true)
Eric Andersena0aef7c2003-09-26 21:18:46 +0000112ifeq ($(GCC_2_95_TOOLCHAIN),true)
113TARGETS+=binutils uclibc-configured gcc2_95
114else
Eric Andersencb7d5b82003-09-14 11:38:35 +0000115TARGETS+=binutils uclibc-configured gcc3_3
Eric Andersena0aef7c2003-09-26 21:18:46 +0000116endif
Eric Andersencb7d5b82003-09-14 11:38:35 +0000117else
118TARGETS+=uclibc
Eric Andersen03c3fa22003-01-03 06:44:03 +0000119endif
120
Eric Andersencb7d5b82003-09-14 11:38:35 +0000121# Do you want user mode Linux (x86 only), or are you building a
122# your own kernel that will run on its own? Perhaps you have a
Eric Andersen4edbe2c2003-01-15 10:20:58 +0000123# kernel you have already configured and you want to use that?
Eric Andersencb7d5b82003-09-14 11:38:35 +0000124# The default is to just use a set of known working kernel
125# headers. Unless you want to build a kernel, I recommend just
126# using that...
127TARGETS+=kernel-headers
Eric Andersen5455b5e2003-01-06 15:40:38 +0000128#TARGETS+=linux
Eric Andersen5eb46042003-03-04 07:14:03 +0000129#TARGETS+=user-mode-linux
Eric Andersen59759b82003-09-10 13:04:12 +0000130#TARGETS+=system-linux
Eric Andersen5455b5e2003-01-06 15:40:38 +0000131
Eric Andersencad58102002-11-14 12:16:04 +0000132# The default minimal set
Eric Andersenb8a23612002-12-12 01:57:57 +0000133TARGETS+=busybox tinylogin
Eric Andersencad58102002-11-14 12:16:04 +0000134
135# Openssh...
136#TARGETS+=zlib openssl openssh
Eric Andersen59759b82003-09-10 13:04:12 +0000137# Dropbear sshd is much smaller than openssl + openssh
138#TARGETS+=dropbear_sshd
Eric Andersencad58102002-11-14 12:16:04 +0000139
140# Everything needed to build a full uClibc development system!
Eric Andersende857762003-02-12 10:45:37 +0000141#TARGETS+=coreutils findutils bash make diffutils patch sed
Eric Andersena0aef7c2003-09-26 21:18:46 +0000142#TARGETS+=ed flex bison file gawk tar grep
143
144#If you want a development system, you probably want gcc built
145# with uClibc so it can run within your dev system...
146#TARGETS+=gcc2_95_target
Eric Andersenbc9faa32003-10-22 06:44:40 +0000147#TARGETS+=gcc3_3_target
Eric Andersencad58102002-11-14 12:16:04 +0000148
Eric Andersen75640332003-01-08 18:22:25 +0000149# Of course, if you are installing a development system, you
150# may want some header files so you can compile stuff....
151#TARGETS+=ncurses-headers zlib-headers openssl-headers
152
Eric Andersenb7d4f492003-01-09 02:34:10 +0000153# More development system stuff for those that want it
154#TARGETS+=m4 autoconf automake libtool
155
Eric Andersen13694742003-06-28 02:02:47 +0000156# Perl
157#TARGETS+=perl
158
Eric Andersencad58102002-11-14 12:16:04 +0000159# Some nice debugging tools
160#TARGETS+=gdb strace
161
Eric Andersen382187f2003-01-17 04:45:35 +0000162# The Valgrind debugger (x86 only)
Eric Andersencad58102002-11-14 12:16:04 +0000163#TARGETS+=valgrind
Eric Andersenffde94b2001-12-22 00:56:11 +0000164
Eric Andersen9741a492003-01-19 07:49:24 +0000165# Some stuff for access points and firewalls
Eric Andersenc8eea312003-02-19 07:07:53 +0000166#TARGETS+=iptables hostap wtools dhcp_relay bridge
Eric Andersen26da8032003-06-04 20:49:24 +0000167#TARGETS+=iproute2 netsnmp
Eric Andersen9741a492003-01-19 07:49:24 +0000168
Eric Andersen54e098e2003-01-18 21:52:46 +0000169# Run customize.mk at the very end to add your own special config.
170# This is useful for making your own distro within the buildroot
171# process.
172# TARGETS+=customize
173
174#############################################################
175#
Eric Andersen08782ae2002-04-26 11:45:55 +0000176# Pick your root filesystem type.
Eric Andersen54e098e2003-01-18 21:52:46 +0000177#
178#############################################################
Eric Andersen08782ae2002-04-26 11:45:55 +0000179TARGETS+=ext2root
Eric Andersenffde94b2001-12-22 00:56:11 +0000180
Eric Andersen27bc59d2003-01-17 04:31:36 +0000181# Must mount cramfs with 'ramdisk_blocksize=4096'
182#TARGETS+=cramfsroot
183
184# You may need to edit make/jffs2root.mk to change target
185# endian-ness or similar, but this is sufficient for most
186# things as-is...
187#TARGETS+=jffs2root
188
Eric Andersen08782ae2002-04-26 11:45:55 +0000189#############################################################
190#
191# You should probably leave this stuff alone unless you know
192# what you are doing.
193#
194#############################################################
Manuel Novoa III d632d422003-11-01 05:34:41 +0000195ifeq ("$(strip $(TARGET_SOFT_FLOAT))","")
196ARCH_FPU_SUFFIX:=
197else
198ARCH_FPU_SUFFIX:=_nofpu
199endif
200
201
Eric Andersen08782ae2002-04-26 11:45:55 +0000202HOSTCC:=gcc
Eric Andersen9741a492003-01-19 07:49:24 +0000203BASE_DIR:=${shell pwd}
Eric Andersen08782ae2002-04-26 11:45:55 +0000204SOURCE_DIR:=$(BASE_DIR)/sources
205DL_DIR:=$(SOURCE_DIR)/dl
206PATCH_DIR=$(SOURCE_DIR)/patches
Manuel Novoa III d632d422003-11-01 05:34:41 +0000207BUILD_DIR:=$(BASE_DIR)/build_$(ARCH)$(ARCH_FPU_SUFFIX)
Eric Andersen08782ae2002-04-26 11:45:55 +0000208TARGET_DIR:=$(BUILD_DIR)/root
Eric Andersen370fb2a2003-02-12 19:49:55 +0000209STAGING_DIR=$(BUILD_DIR)/staging_dir
Manuel Novoa III d632d422003-11-01 05:34:41 +0000210TOOL_BUILD_DIR=$(BASE_DIR)/toolchain_build_$(ARCH)$(ARCH_FPU_SUFFIX)
Eric Andersen370fb2a2003-02-12 19:49:55 +0000211TARGET_PATH=$(STAGING_DIR)/bin:/bin:/sbin:/usr/bin:/usr/sbin
Manuel Novoa III d632d422003-11-01 05:34:41 +0000212#TARGET_CROSS=$(STAGING_DIR)/bin/$(ARCH)-uclibc-
213TARGET_CROSS=$(STAGING_DIR)/bin/$(ARCH)-linux-
214TARGET_CC=$(TARGET_CROSS)gcc$(TARGET_SOFT_FLOAT)
Eric Andersen370fb2a2003-02-12 19:49:55 +0000215STRIP=$(TARGET_CROSS)strip --remove-section=.comment --remove-section=.note
Eric Andersencad58102002-11-14 12:16:04 +0000216#STRIP:=/bin/true
Manuel Novoa III d632d422003-11-01 05:34:41 +0000217IMAGE:=$(BASE_DIR)/root_fs_$(ARCH)$(ARCH_FPU_SUFFIX)
Eric Andersen370fb2a2003-02-12 19:49:55 +0000218GNU_TARGET_NAME=$(OPTIMIZE_FOR_CPU)-linux
Manuel Novoa III d632d422003-11-01 05:34:41 +0000219#KERNEL_CROSS=$(STAGING_DIR)/bin/$(ARCH)-uclibc-
220KERNEL_CROSS=$(STAGING_DIR)/bin/$(ARCH)-linux-
Eric Andersen36830ba2003-03-04 07:56:11 +0000221HOST_ARCH:=$(shell $(HOSTCC) -dumpmachine | sed -e s'/-.*//' \
222 -e 's/sparc.*/sparc/' \
223 -e 's/arm.*/arm/g' \
224 -e 's/m68k.*/m68k/' \
225 -e 's/ppc/powerpc/g' \
226 -e 's/v850.*/v850/g' \
227 -e 's/sh[234]/sh/' \
228 -e 's/mips-.*/mips/' \
229 -e 's/mipsel-.*/mipsel/' \
230 -e 's/cris.*/cris/' \
Eric Andersen0554f622003-09-30 20:59:17 +0000231 -e 's/i[3-9]86/i386/' \
Eric Andersen36830ba2003-03-04 07:56:11 +0000232 )
233GNU_HOST_NAME:=$(HOST_ARCH)-pc-linux-gnu
Eric Andersen1fc3f2f2003-03-04 19:16:19 +0000234TARGET_CONFIGURE_OPTS=PATH=$(TARGET_PATH) \
235 AR=$(TARGET_CROSS)ar \
236 AS=$(TARGET_CROSS)as \
237 LD=$(TARGET_CROSS)ld \
238 NM=$(TARGET_CROSS)nm \
Manuel Novoa III d632d422003-11-01 05:34:41 +0000239 CC=$(TARGET_CROSS)gcc$(TARGET_SOFT_FLOAT) \
240 GCC=$(TARGET_CROSS)gcc$(TARGET_SOFT_FLOAT) \
241 CXX=$(TARGET_CROSS)g++$(TARGET_SOFT_FLOAT) \
Eric Andersen1fc3f2f2003-03-04 19:16:19 +0000242 RANLIB=$(TARGET_CROSS)ranlib
Eric Andersencb7d5b82003-09-14 11:38:35 +0000243ifeq ($(ENABLE_LOCALE),true)
244DISABLE_NLS:=
245else
246DISABLE_NLS:=--disable-nls
247endif
248
Eric Andersenffde94b2001-12-22 00:56:11 +0000249
250all: world
251
Eric Andersen08782ae2002-04-26 11:45:55 +0000252TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS))
Eric Andersena5c23542003-02-19 08:56:04 +0000253TARGETS_SOURCE:=$(patsubst %,%-source,$(TARGETS))
Eric Andersen08782ae2002-04-26 11:45:55 +0000254TARGETS_DIRCLEAN:=$(patsubst %,%-dirclean,$(TARGETS))
Eric Andersenffde94b2001-12-22 00:56:11 +0000255
Eric Andersen08782ae2002-04-26 11:45:55 +0000256world: $(DL_DIR) $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) $(TARGETS)
Eric Andersenffde94b2001-12-22 00:56:11 +0000257
Eric Andersena5c23542003-02-19 08:56:04 +0000258.PHONY: all world clean dirclean distclean source $(TARGETS) \
259 $(TARGETS_CLEAN) $(TARGETS_DIRCLEAN) $(TARGETS_SOURCE)
Jon Nelsonc79e9982002-01-05 20:26:15 +0000260
Eric Andersen08782ae2002-04-26 11:45:55 +0000261include make/*.mk
Eric Andersenffde94b2001-12-22 00:56:11 +0000262
Eric Andersen08782ae2002-04-26 11:45:55 +0000263#############################################################
264#
265# staging and target directories do NOT list these as
266# dependancies anywhere else
267#
268#############################################################
269$(DL_DIR):
270 mkdir $(DL_DIR)
271
272$(BUILD_DIR):
273 mkdir $(BUILD_DIR)
274
275$(STAGING_DIR):
276 rm -rf $(STAGING_DIR)
Eric Andersende2ae8d2003-02-12 09:59:22 +0000277 mkdir -p $(STAGING_DIR)/lib
278 mkdir -p $(STAGING_DIR)/usr/lib
279 mkdir -p $(STAGING_DIR)/include
Eric Andersen08782ae2002-04-26 11:45:55 +0000280
281$(TARGET_DIR):
Eric Andersenffde94b2001-12-22 00:56:11 +0000282 rm -rf $(TARGET_DIR)
Eric Andersen08782ae2002-04-26 11:45:55 +0000283 zcat $(SOURCE_DIR)/skel.tar.gz | tar -C $(BUILD_DIR) -xf -
284 cp -a $(SOURCE_DIR)/target_skeleton/* $(TARGET_DIR)/
Eric Andersen339f2f42001-12-22 01:17:09 +0000285 -find $(TARGET_DIR) -type d -name CVS -exec rm -rf {} \; > /dev/null 2>&1
Eric Andersenffde94b2001-12-22 00:56:11 +0000286
Eric Andersena5c23542003-02-19 08:56:04 +0000287source: $(TARGETS_SOURCE)
Eric Andersenffde94b2001-12-22 00:56:11 +0000288
Eric Andersen08782ae2002-04-26 11:45:55 +0000289#############################################################
290#
291# Cleanup and misc junk
292#
293#############################################################
294clean: $(TARGETS_CLEAN)
295 rm -rf $(TARGET_DIR) $(STAGING_DIR) $(IMAGE)
Eric Andersenffde94b2001-12-22 00:56:11 +0000296
Eric Andersen08782ae2002-04-26 11:45:55 +0000297dirclean: $(TARGETS_DIRCLEAN)
298 rm -rf $(TARGET_DIR) $(STAGING_DIR) $(IMAGE)
Eric Andersenffde94b2001-12-22 00:56:11 +0000299
Eric Andersen08782ae2002-04-26 11:45:55 +0000300distclean:
301 rm -rf $(DL_DIR) $(BUILD_DIR) $(LINUX_KERNEL) $(IMAGE)
Eric Andersenffde94b2001-12-22 00:56:11 +0000302
Eric Andersen08782ae2002-04-26 11:45:55 +0000303sourceball:
304 rm -rf $(BUILD_DIR)
305 set -e; \
306 cd ..; \
307 rm -f buildroot.tar.bz2; \
308 tar -cvf buildroot.tar buildroot; \
309 bzip2 -9 buildroot.tar; \