Makefile 10 KB

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