Makefile 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. # Makefile for a simple busybox/uClibc root filesystem
  2. #
  3. # Copyright (C) 2001-2004 Erik Andersen <andersen@codepoet.org>
  4. # Copyright (C) 2002 by Tim Riker <Tim@Rikers.org>
  5. # Copyright (C) 2004 Manuel Novoa III <mjn3@uclibc.org>
  6. #
  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.
  11. #
  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.
  16. #
  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
  20. # USA
  21. #############################################################
  22. #
  23. # EDIT this stuff to suit your system and preferences
  24. #
  25. # Use := when possible to get precomputation, thereby
  26. # speeding up the build process.
  27. #
  28. #############################################################
  29. # What sort of target system shall we compile this for?
  30. #
  31. ARCH:=i386
  32. #ARCH:=arm
  33. #ARCH:=armeb
  34. #ARCH:=mips
  35. #ARCH:=mipsel
  36. #ARCH:=powerpc
  37. #ARCH:=sh4
  38. #ARCH:=cris
  39. #ARCH:=sh64
  40. #ARCH:=m68k
  41. #ARCH:=v850
  42. #ARCH:=sparc
  43. #ARCH:=whatever
  44. # Choose the kernel headers to use for kernel-headers target. This is
  45. # ignored if you are building your own kernel or using the system kernel.
  46. #
  47. #DEFAULT_KERNEL_HEADERS:=2.4.25
  48. DEFAULT_KERNEL_HEADERS:=2.4.27
  49. #DEFAULT_KERNEL_HEADERS:=2.6.7
  50. #DEFAULT_KERNEL_HEADERS:=2.6.8
  51. # Choose gcc version.
  52. # WARNING -- 2.95 currently only builds for i386, arm, mips*, and powerpc.
  53. # WARNING -- 2.95 does not currently build natively for the target.
  54. #
  55. #GCC_VERSION:=2.95
  56. #GCC_VERSION:=3.3.3
  57. #GCC_VERSION:=3.3.4
  58. #GCC_VERSION:=3.4.0
  59. #GCC_VERSION:=3.4.1
  60. GCC_VERSION:=3.4.2
  61. # Choose binutils version.
  62. #
  63. #BINUTILS_VERSION:=2.14.90.0.6
  64. #BINUTILS_VERSION:=2.14.90.0.7
  65. #BINUTILS_VERSION:=2.14.90.0.8
  66. #BINUTILS_VERSION:=2.15
  67. #BINUTILS_VERSION:=2.15.90.0.1
  68. #BINUTILS_VERSION:=2.15.90.0.1.1
  69. #BINUTILS_VERSION:=2.15.90.0.2
  70. #BINUTILS_VERSION:=2.15.90.0.3
  71. #BINUTILS_VERSION:=2.15.91.0.1
  72. BINUTILS_VERSION:=2.15.91.0.2
  73. # Choose gdb version.
  74. #
  75. #GDB_VERSION:=5.3
  76. GDB_VERSION:=6.1.1
  77. #GDB_VERSION:=6.2
  78. # Enable this to use the uClibc daily snapshot instead of a released
  79. # version. Daily snapshots may contain new features and bugfixes. Or
  80. # they may not even compile at all, depending on what Erik is doing.
  81. # Do you wish to use the latest release (), latest snapshot (snapshot),
  82. # or the snapshot from a specific date (yyyymmdd)? Note that snapshots
  83. # may contain new features and bugfixes. Or they may not even compile
  84. # at all, depending on what Erik and Manuel are doing.
  85. #
  86. #USE_UCLIBC_SNAPSHOT:=
  87. USE_UCLIBC_SNAPSHOT:=snapshot
  88. #USE_UCLIBC_SNAPSHOT:=20040807
  89. # Do you wish to use the latest release (), latest snapshot (snapshot),
  90. # or the snapshot from a specific date (yyyymmdd)? Note that snapshots
  91. # may contain new features and bugfixes. Or they may not even compile
  92. # at all...
  93. #
  94. #USE_BUSYBOX_SNAPSHOT:=
  95. USE_BUSYBOX_SNAPSHOT:=snapshot
  96. #USE_BUSYBOX_SNAPSHOT:=20040807
  97. # Enable large file (files > 2 GB) support
  98. BUILD_WITH_LARGEFILE:=true
  99. # Command used to download source code
  100. WGET:=wget --passive-ftp
  101. # Optimize toolchain for which type of CPU?
  102. OPTIMIZE_FOR_CPU=$(ARCH)
  103. #OPTIMIZE_FOR_CPU=i686
  104. # Note... gcc 2.95 does not seem to like anything higher than i586.
  105. #OPTIMIZE_FOR_CPU=i586
  106. #OPTIMIZE_FOR_CPU=whatever
  107. # Might be worth experimenting with for gcc 3.4.x.
  108. GCC_WITH_CPU:=
  109. GCC_WITH_ARCH:=
  110. GCC_WITH_TUNE:=
  111. #GCC_WITH_CPU:=--with-cpu=
  112. #GCC_WITH_ARCH:=--with-arch=
  113. #GCC_WITH_TUNE:=--with-tune=
  114. # Soft floating point options.
  115. # Notes:
  116. # Builds for gcc 3.4.x.
  117. # Can build for gcc 3.3.x for mips, mipsel, powerpc, and arm (special)
  118. # by using custom specs files (currently for 3.3.4 only).
  119. # NOTE!!! The libfloat stuff is currently removed from uClibc. The
  120. # arm soft float for 3.3.x will require reenabling it.
  121. # (i386 support will be added back in at some point.)
  122. # Only tested with multilib enabled.
  123. # For i386, long double is the same as double (64 bits). While this
  124. # is unusual for x86, it seemed the best approach considering the
  125. # limitations in the gcc floating point emulation library.
  126. # For arm, soft float uses the usual libfloat routines.
  127. # (Un)comment the appropriate line below.
  128. #SOFT_FLOAT:=true
  129. SOFT_FLOAT:=false
  130. TARGET_OPTIMIZATION=-Os
  131. TARGET_DEBUGGING= #-g
  132. # Currently the unwind stuff seems to work for staticly linked apps but
  133. # not dynamic. So use setjmp/longjmp exceptions by default.
  134. GCC_USE_SJLJ_EXCEPTIONS:=--enable-sjlj-exceptions
  135. #GCC_USE_SJLJ_EXCEPTIONS:=
  136. # Any additional gcc options you may want to include....
  137. EXTRA_GCC_CONFIG_OPTIONS:=
  138. # Enable the following if you want locale/gettext/i18n support.
  139. # NOTE! Currently the pregnerated locale stuff only works for x86!
  140. #ENABLE_LOCALE:=true
  141. ENABLE_LOCALE:=false
  142. # If you want multilib enabled, enable this...
  143. MULTILIB:=--enable-multilib
  144. # Build/install c++ compiler and libstdc++?
  145. INSTALL_LIBSTDCPP:=true
  146. # Build/install java compiler and libgcj? (requires c++)
  147. # WARNING!!! DOES NOT BUILD FOR TARGET WITHOUT INTERVENTION!!! mjn3
  148. #INSTALL_LIBGCJ:=true
  149. INSTALL_LIBGCJ:=false
  150. # For SMP machines some stuff can be run in parallel
  151. #JLEVEL=-j3
  152. #############################################################
  153. #
  154. # The list of stuff to build for the target filesystem
  155. #
  156. #############################################################
  157. TARGETS:=host-sed
  158. TARGETS+=uclibc-configured binutils gcc ccache
  159. # Are you building your own kernel? Perhaps you have a kernel
  160. # you have already configured and you want to use that? The
  161. # default is to just use a set of known working kernel headers.
  162. # Unless you want to build a kernel, I recommend just using
  163. # that...
  164. TARGETS+=kernel-headers
  165. #TARGETS+=linux
  166. #TARGETS+=system-linux
  167. # The default minimal set
  168. TARGETS+=busybox #tinylogin
  169. # Openssh...
  170. #TARGETS+=zlib openssl openssh
  171. # Dropbear sshd is much smaller than openssl + openssh
  172. #TARGETS+=dropbear_sshd
  173. # Everything needed to build a full uClibc development system!
  174. #TARGETS+=coreutils findutils bash make diffutils patch sed
  175. #TARGETS+=ed flex bison file gawk tar grep bzip2
  176. #If you want a development system, you probably want gcc built
  177. # with uClibc so it can run within your dev system...
  178. #TARGETS+=gcc_target ccache_target
  179. # Of course, if you are installing a development system, you
  180. # may want some header files so you can compile stuff....
  181. #TARGETS+=ncurses-headers zlib-headers openssl-headers
  182. # More development system stuff for those that want it
  183. #TARGETS+=m4 autoconf automake libtool
  184. # Some nice debugging tools for the host
  185. #TARGETS+=gdbclient
  186. # Some nice debugging tools for the target
  187. #TARGETS+=gdbserver gdb_target
  188. #TARGETS+=strace ltrace
  189. # The Valgrind debugger (x86 only)
  190. #TARGETS+=valgrind
  191. # Some stuff for access points and firewalls
  192. #TARGETS+=iptables hostap wtools dhcp_relay bridge
  193. #TARGETS+=iproute2 netsnmp
  194. # Run customize.mk at the very end to add your own special config.
  195. # This is useful for making your own distro within the buildroot
  196. # process.
  197. # TARGETS+=customize
  198. #############################################################
  199. #
  200. # Pick your root filesystem type.
  201. #
  202. #############################################################
  203. #TARGETS+=ext2root
  204. # Must mount cramfs with 'ramdisk_blocksize=4096'
  205. #TARGETS+=cramfsroot
  206. # You may need to edit make/jffs2root.mk to change target
  207. # endian-ness or similar, but this is sufficient for most
  208. # things as-is...
  209. #TARGETS+=jffs2root
  210. #############################################################
  211. #
  212. # You should probably leave this stuff alone unless you know
  213. # what you are doing.
  214. #
  215. #############################################################
  216. ifeq ($(SOFT_FLOAT),true)
  217. # gcc 3.4.x soft float configuration is different than previous versions.
  218. ifeq ($(findstring 3.4.,$(GCC_VERSION)),3.4.)
  219. SOFT_FLOAT_CONFIG_OPTION:=--with-float=soft
  220. else
  221. SOFT_FLOAT_CONFIG_OPTION:=--without-float
  222. endif
  223. TARGET_SOFT_FLOAT:=-msoft-float
  224. ARCH_FPU_SUFFIX:=_nofpu
  225. else
  226. SOFT_FLOAT_CONFIG_OPTION:=
  227. TARGET_SOFT_FLOAT:=
  228. ARCH_FPU_SUFFIX:=
  229. endif
  230. ifeq ($(INSTALL_LIBGCJ),true)
  231. INSTALL_LIBSTDCPP:=true
  232. endif
  233. # WARNING -- uClibc currently disables large file support on cris.
  234. ifeq ("$(strip $(ARCH))","cris")
  235. BUILD_WITH_LARGEFILE:=false
  236. endif
  237. ifneq ($(BUILD_WITH_LARGEFILE),true)
  238. DISABLE_LARGEFILE= --disable-largefile
  239. endif
  240. TARGET_CFLAGS=$(TARGET_OPTIMIZATION) $(TARGET_DEBUGGING)
  241. HOSTCC:=gcc
  242. BASE_DIR:=${shell pwd}
  243. SOURCE_DIR:=$(BASE_DIR)/sources
  244. DL_DIR:=$(SOURCE_DIR)/dl
  245. PATCH_DIR=$(SOURCE_DIR)/patches
  246. BUILD_DIR:=$(BASE_DIR)/build_$(ARCH)$(ARCH_FPU_SUFFIX)
  247. TARGET_DIR:=$(BUILD_DIR)/root
  248. STAGING_DIR=$(BUILD_DIR)/staging_dir
  249. TOOL_BUILD_DIR=$(BASE_DIR)/toolchain_build_$(ARCH)$(ARCH_FPU_SUFFIX)
  250. TARGET_PATH=$(STAGING_DIR)/bin:/bin:/sbin:/usr/bin:/usr/sbin
  251. IMAGE:=$(BASE_DIR)/root_fs_$(ARCH)$(ARCH_FPU_SUFFIX)
  252. REAL_GNU_TARGET_NAME=$(OPTIMIZE_FOR_CPU)-linux-uclibc
  253. GNU_TARGET_NAME=$(OPTIMIZE_FOR_CPU)-linux
  254. KERNEL_CROSS=$(STAGING_DIR)/bin/$(OPTIMIZE_FOR_CPU)-linux-uclibc-
  255. TARGET_CROSS=$(STAGING_DIR)/bin/$(OPTIMIZE_FOR_CPU)-linux-uclibc-
  256. TARGET_CC=$(TARGET_CROSS)gcc
  257. STRIP=$(TARGET_CROSS)strip --remove-section=.comment --remove-section=.note
  258. HOST_ARCH:=$(shell $(HOSTCC) -dumpmachine | sed -e s'/-.*//' \
  259. -e 's/sparc.*/sparc/' \
  260. -e 's/arm.*/arm/g' \
  261. -e 's/m68k.*/m68k/' \
  262. -e 's/ppc/powerpc/g' \
  263. -e 's/v850.*/v850/g' \
  264. -e 's/sh[234]/sh/' \
  265. -e 's/mips-.*/mips/' \
  266. -e 's/mipsel-.*/mipsel/' \
  267. -e 's/cris.*/cris/' \
  268. -e 's/i[3-9]86/i386/' \
  269. )
  270. GNU_HOST_NAME:=$(HOST_ARCH)-pc-linux-gnu
  271. TARGET_CONFIGURE_OPTS=PATH=$(TARGET_PATH) \
  272. AR=$(TARGET_CROSS)ar \
  273. AS=$(TARGET_CROSS)as \
  274. LD=$(TARGET_CROSS)ld \
  275. NM=$(TARGET_CROSS)nm \
  276. CC=$(TARGET_CROSS)gcc \
  277. GCC=$(TARGET_CROSS)gcc \
  278. CXX=$(TARGET_CROSS)g++ \
  279. RANLIB=$(TARGET_CROSS)ranlib
  280. ifeq ($(ENABLE_LOCALE),true)
  281. DISABLE_NLS:=
  282. else
  283. DISABLE_NLS:=--disable-nls
  284. endif
  285. all: world
  286. TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS))
  287. TARGETS_SOURCE:=$(patsubst %,%-source,$(TARGETS))
  288. TARGETS_DIRCLEAN:=$(patsubst %,%-dirclean,$(TARGETS))
  289. world: $(DL_DIR) $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) $(TARGETS)
  290. .PHONY: all world clean dirclean distclean source $(TARGETS) \
  291. $(TARGETS_CLEAN) $(TARGETS_DIRCLEAN) $(TARGETS_SOURCE)
  292. include make/*.mk
  293. #############################################################
  294. #
  295. # staging and target directories do NOT list these as
  296. # dependancies anywhere else
  297. #
  298. #############################################################
  299. $(DL_DIR):
  300. mkdir $(DL_DIR)
  301. $(BUILD_DIR):
  302. mkdir $(BUILD_DIR)
  303. $(TOOL_BUILD_DIR):
  304. mkdir $(TOOL_BUILD_DIR)
  305. $(STAGING_DIR):
  306. rm -rf $(STAGING_DIR)
  307. mkdir -p $(STAGING_DIR)/lib
  308. mkdir -p $(STAGING_DIR)/include
  309. mkdir -p $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)
  310. ln -sf ../lib $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/lib
  311. $(TARGET_DIR):
  312. rm -rf $(TARGET_DIR)
  313. zcat $(SOURCE_DIR)/skel.tar.gz | tar -C $(BUILD_DIR) -xf -
  314. cp -a $(SOURCE_DIR)/target_skeleton/* $(TARGET_DIR)/
  315. -find $(TARGET_DIR) -type d -name CVS -exec rm -rf {} \; > /dev/null 2>&1
  316. source: $(TARGETS_SOURCE)
  317. #############################################################
  318. #
  319. # Cleanup and misc junk
  320. #
  321. #############################################################
  322. clean: $(TARGETS_CLEAN)
  323. rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE)
  324. dirclean: $(TARGETS_DIRCLEAN)
  325. rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE)
  326. distclean:
  327. rm -rf $(DL_DIR) $(BUILD_DIR) $(LINUX_KERNEL) $(IMAGE)
  328. sourceball:
  329. rm -rf $(BUILD_DIR)
  330. set -e; \
  331. cd ..; \
  332. rm -f buildroot.tar.bz2; \
  333. tar -cvf buildroot.tar buildroot; \
  334. bzip2 -9 buildroot.tar; \