]> Git Repo - buildroot-mgba.git/blob - Makefile
Mention the saveconfig and getconfig targets in make help
[buildroot-mgba.git] / Makefile
1 # Makefile for buildroot2
2 #
3 # Copyright (C) 1999-2005 by Erik Andersen <[email protected]>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 #
19
20 #--------------------------------------------------------------
21 # Just run 'make menuconfig', configure stuff, then run 'make'.
22 # You shouldn't need to mess with anything beyond this point...
23 #--------------------------------------------------------------
24 TOPDIR=./
25 CONFIG_CONFIG_IN=Config.in
26 CONFIG_DEFCONFIG=.defconfig
27 CONFIG=package/config
28 DATE:=$(shell date +%Y%m%d)
29
30 noconfig_targets:=menuconfig config oldconfig randconfig \
31         defconfig allyesconfig allnoconfig release tags \
32         source-check help
33
34
35 # Use shell variables, if defined
36 ifneq ($(BUILDROOT_LOCAL),)
37 BR2_LOCAL:=$(BUILDROOT_LOCAL)
38 else
39 BR2_LOCAL:=$(TOPDIR)/local
40 endif
41
42 # $(shell find . -name *_defconfig |sed 's/.*\///')
43 # Pull in the user's configuration file
44 ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
45 ifeq ($(BOARD),)
46 # if "make BOARD=xyz" command
47 -include .config
48 else
49 # if "make" command
50 -include $(BR2_LOCAL)/$(BOARD)/$(BOARD).config
51 endif
52 endif
53
54 # Override BR2_DL_DIR if shell variable defined
55 ifneq ($(BUILDROOT_DL_DIR),)
56 BR2_DL_DIR:=$(BUILDROOT_DL_DIR)
57 endif
58 LOCAL:=$(BR2_LOCAL)
59
60 # To put more focus on warnings, be less verbose as default
61 # Use 'make V=1' to see the full commands
62 ifdef V
63   ifeq ("$(origin V)", "command line")
64     KBUILD_VERBOSE=$(V)
65   endif
66 endif
67 ifndef KBUILD_VERBOSE
68   KBUILD_VERBOSE=0
69 endif
70
71 ifeq ($(KBUILD_VERBOSE),1)
72   quiet=
73   Q=
74 ifndef VERBOSE
75   VERBOSE=1
76 endif
77 else
78   quiet=quiet_
79   Q=@
80 endif
81
82 # we want bash as shell
83 SHELL:=$(shell if [ -x "$$BASH" ]; then echo $$BASH; \
84         else if [ -x /bin/bash ]; then echo /bin/bash; \
85         else echo sh; fi; fi)
86
87 # kconfig uses CONFIG_SHELL
88 CONFIG_SHELL:=$(SHELL)
89
90 export SHELL CONFIG_SHELL quiet Q KBUILD_VERBOSE VERBOSE
91
92 ifndef HOSTAR
93 HOSTAR:=ar
94 endif
95 ifndef HOSTAS
96 HOSTAS:=as
97 endif
98 ifndef HOSTCC
99 HOSTCC:=gcc
100 else
101 endif
102 ifndef HOSTCXX
103 HOSTCXX:=g++
104 endif
105 ifndef HOSTFC
106 HOSTFC:=gfortran
107 endif
108 ifndef HOSTCPP
109 HOSTCPP:=cpp
110 endif
111 ifndef HOSTLD
112 HOSTLD:=ld
113 endif
114 ifndef HOSTLN
115 HOSTLN:=ln
116 endif
117 ifndef HOSTNM
118 HOSTNM:=nm
119 endif
120 HOSTAR:=$(shell which $(HOSTAR) || type -p $(HOSTAR) || echo ar)
121 HOSTAS:=$(shell which $(HOSTAS) || type -p $(HOSTAS) || echo as)
122 HOSTCC:=$(shell which $(HOSTCC) || type -p $(HOSTCC) || echo gcc)
123 HOSTCXX:=$(shell which $(HOSTCXX) || type -p $(HOSTCXX) || echo g++)
124 HOSTFC:=$(shell which $(HOSTLD) || type -p $(HOSTLD) || echo || which g77 || type -p g77 || echo gfortran)
125 HOSTCPP:=$(shell which $(HOSTCPP) || type -p $(HOSTCPP) || echo cpp)
126 HOSTLD:=$(shell which $(HOSTLD) || type -p $(HOSTLD) || echo ld)
127 HOSTLN:=$(shell which $(HOSTLN) || type -p $(HOSTLN) || echo ln)
128 HOSTNM:=$(shell which $(HOSTNM) || type -p $(HOSTNM) || echo nm)
129 HOST_GLIB_BIN:=`dirname $(shell which glib-genmarshal || echo /usr/bin/glib-genmarshal)`
130 HOST_GLIB:=$(shell dirname $(HOST_GLIB_BIN) || echo /usr)
131
132
133 ifndef CFLAGS_FOR_BUILD
134 CFLAGS_FOR_BUILD:=-g -O2
135 endif
136 ifndef CXXFLAGS_FOR_BUILD
137 CXXFLAGS_FOR_BUILD:=-g -O2
138 endif
139 ifndef FCFLAGS_FOR_BUILD
140 FCFLAGS_FOR_BUILD:=-g -O2
141 endif
142 export HOSTAR HOSTAS HOSTCC HOSTCXX HOSTFC HOSTLD
143
144
145 ifeq ($(BR2_HAVE_DOT_CONFIG),y)
146
147 # cc-option
148 # Usage: cflags-y+=$(call cc-option, -march=winchip-c6, -march=i586)
149 # sets -march=winchip-c6 if supported else falls back to -march=i586
150 # without checking the latter.
151 cc-option=$(shell if $(TARGET_CC) $(TARGET_CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
152         > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
153
154 #############################################################
155 #
156 # Hide troublesome environment variables from sub processes
157 #
158 #############################################################
159 unexport CROSS_COMPILE
160 unexport ARCH
161
162 #############################################################
163 #
164 # Setup the proper filename extensions for the host
165 #
166 ##############################################################
167 ifneq ($(findstring linux,$(BR2_GNU_BUILD_SUFFIX)),)
168 HOST_EXEEXT:=
169 HOST_LIBEXT:=.a
170 HOST_SHREXT:=.so
171 endif
172 ifneq ($(findstring apple,$(BR2_GNU_BUILD_SUFFIX)),)
173 HOST_EXEEXT:=
174 HOST_LIBEXT:=.a
175 HOST_SHREXT:=.dylib
176 endif
177 ifneq ($(findstring cygwin,$(BR2_GNU_BUILD_SUFFIX)),)
178 HOST_EXEEXT:=.exe
179 HOST_LIBEXT:=.lib
180 HOST_SHREXT:=.dll
181 HOST_LOADLIBES="-lcurses -lintl"
182 export HOST_LOADLIBES
183 endif
184 ifneq ($(findstring mingw,$(BR2_GNU_BUILD_SUFFIX)),)
185 HOST_EXEEXT:=.exe
186 HOST_LIBEXT:=.lib
187 HOST_SHREXT:=.dll
188 endif
189
190 # The preferred type of libs we build for the target
191 ifeq ($(BR2_PREFER_STATIC_LIB),y)
192 LIBTGTEXT=.a
193 #PREFERRED_LIB_FLAGS:=--disable-shared --enable-static
194 else
195 LIBTGTEXT=.so
196 #PREFERRED_LIB_FLAGS:=--disable-static --enable-shared
197 endif
198 PREFERRED_LIB_FLAGS:=--enable-static --enable-shared
199
200 ##############################################################
201 #
202 # The list of stuff to build for the target toolchain
203 # along with the packages to build for the target.
204 #
205 ##############################################################
206 ifeq ($(BR2_TOOLCHAIN_SOURCE),y)
207 BASE_TARGETS:=uclibc-configured binutils cross_compiler uclibc-target-utils kernel-headers
208 else
209 BASE_TARGETS:=uclibc
210 endif
211 TARGETS:=
212
213 # setup our pathes
214 include project/Makefile.in
215
216 BR2_DEPENDS_DIR=$(PROJECT_BUILD_DIR)/buildroot-config
217
218 include toolchain/Makefile.in
219 include package/Makefile.in
220
221 #############################################################
222 #
223 # You should probably leave this stuff alone unless you know
224 # what you are doing.
225 #
226 #############################################################
227
228 all: world
229
230 # In this section, we need .config
231 include .config.cmd
232
233 include project/*.mk
234
235 # We also need the various per-package makefiles, which also add
236 # each selected package to TARGETS if that package was selected
237 # in the .config file.
238 ifeq ($(BR2_TOOLCHAIN_SOURCE),y)
239 # avoid pulling in external toolchain which is broken for toplvl parallel builds
240 # Explicit ordering:
241 include toolchain/dependencies/dependencies.mk
242 include toolchain/binutils/binutils.mk
243 include toolchain/ccache/ccache.mk
244 include toolchain/elf2flt/elf2flt.mk
245 include toolchain/gcc/gcc-uclibc-3.x.mk
246 include toolchain/gcc/gcc-uclibc-4.x.mk
247 include toolchain/gdb/gdb.mk
248 include toolchain/kernel-headers/kernel-headers.mk
249 include toolchain/mklibs/mklibs.mk
250 include toolchain/sstrip/sstrip.mk
251 include toolchain/uClibc/uclibc.mk
252 else
253 include toolchain/*/*.mk
254 endif
255
256 ifeq ($(BR2_PACKAGE_LINUX),y)
257 TARGETS+=linux26-modules
258 endif
259
260 include package/*/*.mk
261
262 TARGETS+=target-devfiles
263
264 # target stuff is last so it can override anything else
265 include target/Makefile.in
266
267 TARGETS+=erase-fakeroots
268
269 TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS))
270 TARGETS_SOURCE:=$(patsubst %,%-source,$(TARGETS) $(BASE_TARGETS))
271 TARGETS_DIRCLEAN:=$(patsubst %,%-dirclean,$(TARGETS))
272 TARGETS_ALL:=$(patsubst %,__real_tgt_%,$(TARGETS))
273 # all targets depend on the crosscompiler and it's prerequisites
274 $(TARGETS_ALL): __real_tgt_%: $(BASE_TARGETS) %
275
276 $(BR2_DEPENDS_DIR): .config
277         rm -rf $@
278         mkdir -p $(@D)
279         cp -dpRf $(CONFIG)/buildroot-config $@
280
281 dirs: $(DL_DIR) $(TOOL_BUILD_DIR) $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) \
282         $(BR2_DEPENDS_DIR) $(BINARIES_DIR) $(PROJECT_BUILD_DIR) \
283         $(PROJECT_BUILD_DIR)/autotools-stamps
284
285 $(BASE_TARGETS): dirs
286
287 world: dependencies dirs target-host-info $(BASE_TARGETS) $(TARGETS_ALL)
288
289
290 .PHONY: all world dirs clean dirclean distclean source \
291         $(BASE_TARGETS) $(TARGETS) $(TARGETS_ALL) \
292         $(TARGETS_CLEAN) $(TARGETS_DIRCLEAN) $(TARGETS_SOURCE) \
293         $(DL_DIR) $(TOOL_BUILD_DIR) $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) \
294         $(BR2_DEPENDS_DIR) $(BINARIES_DIR) $(PROJECT_BUILD_DIR) \
295         $(PROJECT_BUILD_DIR)/autotools-stamps
296
297 #############################################################
298 #
299 # staging and target directories do NOT list these as
300 # dependencies anywhere else
301 #
302 #############################################################
303 $(DL_DIR) $(TOOL_BUILD_DIR) $(BUILD_DIR) $(PROJECT_BUILD_DIR) \
304         $(PROJECT_BUILD_DIR)/autotools-stamps $(BINARIES_DIR):
305         @mkdir -p $@
306
307 $(STAGING_DIR):
308         @mkdir -p $(STAGING_DIR)/bin
309         @mkdir -p $(STAGING_DIR)/lib
310 ifeq ($(BR2_TOOLCHAIN_SYSROOT),y)
311         @mkdir -p $(STAGING_DIR)/usr/lib
312 else
313 ifneq ($(BR2_TOOLCHAIN_EXTERNAL),y)
314         @ln -snf . $(STAGING_DIR)/usr
315         @mkdir -p $(STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME)
316         @ln -snf ../lib $(STAGING_DIR)/usr/lib
317         @ln -snf ../lib $(STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME)/lib
318 endif
319 endif
320         @mkdir -p $(STAGING_DIR)/usr/include
321
322 $(PROJECT_BUILD_DIR)/.root:
323         mkdir -p $(TARGET_DIR)
324         if ! [ -d "$(TARGET_DIR)/bin" ]; then \
325                 if [ -d "$(TARGET_SKELETON)" ]; then \
326                         cp -fa $(TARGET_SKELETON)/* $(TARGET_DIR)/; \
327                 fi; \
328                 touch $(STAGING_DIR)/.fakeroot.00000; \
329         fi
330         -find $(TARGET_DIR) -type d -name CVS -o -name .svn | xargs rm -rf
331         -find $(TARGET_DIR) -type f -name .empty | xargs rm -rf 
332         touch $@
333
334 $(TARGET_DIR): $(PROJECT_BUILD_DIR)/.root
335
336 erase-fakeroots:
337         rm -f $(PROJECT_BUILD_DIR)/.fakeroot*
338
339 target-devfiles:
340 ifeq ($(BR2_HAVE_DEVFILES),y)
341         ( scripts/copy.sh $(STAGING_DIR) $(TARGET_DIR) )
342 else
343         rm -rf $(TARGET_DIR)/usr/include $(TARGET_DIR)/usr/lib/pkgconfig
344         find $(TARGET_DIR)/usr/lib -name '*.a' -delete
345         find $(TARGET_DIR)/lib -name '*.a' -delete
346         find $(TARGET_DIR)/usr/lib -name '*.la' -delete
347         find $(TARGET_DIR)/lib -name '*.la' -delete
348 endif
349
350 source: $(TARGETS_SOURCE) $(HOST_SOURCE)
351
352 _source-check:
353         $(MAKE) SPIDER=--spider source
354
355 external-deps:
356         @$(MAKE) -Bs BR2_WGET=$(TOPDIR)/toolchain/wget-show-external-deps.sh \
357                 SPIDER=--spider source
358
359 #############################################################
360 #
361 # Cleanup and misc junk
362 #
363 #############################################################
364 clean: $(TARGETS_CLEAN)
365         rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE) $(PROJECT_BUILD_DIR)/.root $(PROJECT_BUILD_DIR)/autotools-stamps
366
367 dirclean: $(TARGETS_DIRCLEAN)
368         rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE) $(PROJECT_BUILD_DIR)/.root $(PROJECT_BUILD_DIR)/autotools-stamps
369
370 distclean:
371 ifeq ($(DL_DIR),$(BASE_DIR)/dl)
372         rm -rf $(DL_DIR)
373 endif
374         rm -rf $(BUILD_DIR) $(PROJECT_BUILD_DIR) $(BINARIES_DIR) \
375         $(LINUX_KERNEL) $(BASE_DIR)/include \
376                 .config.cmd
377         $(MAKE) -C $(CONFIG) clean
378
379 sourceball:
380         rm -rf $(BUILD_DIR) $(PROJECT_BUILD_DIR) $(BINARIES_DIR)
381         set -e; \
382         cd ..; \
383         rm -f buildroot.tar.bz2; \
384         tar -cvf buildroot.tar buildroot; \
385         bzip2 -9 buildroot.tar; \
386
387
388 else # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
389
390 all: menuconfig
391
392 # configuration
393 # ---------------------------------------------------------------------------
394
395 HOSTCFLAGS=$(CFLAGS_FOR_BUILD)
396 export HOSTCFLAGS
397
398 $(CONFIG)/conf:
399         @mkdir -p $(CONFIG)/buildroot-config
400         $(MAKE) CC="$(HOSTCC)" -C $(CONFIG) conf
401         -@if [ ! -f .config ]; then \
402                 cp $(CONFIG_DEFCONFIG) .config; \
403         fi
404 $(CONFIG)/mconf:
405         @mkdir -p $(CONFIG)/buildroot-config
406         $(MAKE) CC="$(HOSTCC)" -C $(CONFIG) conf mconf
407         -@if [ ! -f .config ]; then \
408                 cp $(CONFIG_DEFCONFIG) .config; \
409         fi
410
411 menuconfig: $(CONFIG)/mconf
412         @mkdir -p $(CONFIG)/buildroot-config
413         @if ! KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
414                 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
415                 $(CONFIG)/mconf $(CONFIG_CONFIG_IN); then \
416                 test -f .config.cmd || rm -f .config; \
417         fi
418
419 config: $(CONFIG)/conf
420         @mkdir -p $(CONFIG)/buildroot-config
421         @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
422                 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
423                 $(CONFIG)/conf $(CONFIG_CONFIG_IN)
424
425 oldconfig: $(CONFIG)/conf
426         @mkdir -p $(CONFIG)/buildroot-config
427         @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
428                 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
429                 $(CONFIG)/conf -o $(CONFIG_CONFIG_IN)
430
431 randconfig: $(CONFIG)/conf
432         @mkdir -p $(CONFIG)/buildroot-config
433         @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
434                 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
435                 $(CONFIG)/conf -r $(CONFIG_CONFIG_IN)
436
437 allyesconfig: $(CONFIG)/conf
438         cat $(CONFIG_DEFCONFIG) > .config
439         @mkdir -p $(CONFIG)/buildroot-config
440         @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
441                 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
442                 $(CONFIG)/conf -y $(CONFIG_CONFIG_IN)
443         #sed -i -e "s/^CONFIG_DEBUG.*/# CONFIG_DEBUG is not set/" .config
444
445 allnoconfig: $(CONFIG)/conf
446         @mkdir -p $(CONFIG)/buildroot-config
447         @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
448                 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
449                 $(CONFIG)/conf -n $(CONFIG_CONFIG_IN)
450
451 defconfig: $(CONFIG)/conf
452         @mkdir -p $(CONFIG)/buildroot-config
453         @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
454                 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
455                 $(CONFIG)/conf -d $(CONFIG_CONFIG_IN)
456
457 # check if download URLs are outdated
458 source-check: allyesconfig
459         $(MAKE) _source-check
460
461 #############################################################
462 #
463 # Cleanup and misc junk
464 #
465 #############################################################
466 clean:
467         rm -f .config .config.old .config.cmd .tmpconfig.h .lognr.*
468         -$(MAKE) -C $(CONFIG) clean
469
470 distclean: clean
471         rm -rf sources/*
472
473 endif # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
474
475 %_defconfig: $(CONFIG)/conf
476         cp $(shell find ./target/ -name $@) .config
477         -@$(MAKE) oldconfig
478
479 update:
480         cp .config $(BOARD_PATH)/$(BOARD_NAME)_defconfig
481
482 configured: dirs host-sed kernel-headers uclibc-config busybox-config linux26-config
483
484 prepatch:       gcc-patched binutils-patched gdb-patched uclibc-patched
485
486 .lognr.$(PROJECT):
487         @echo "0" > .lognr.$(PROJECT)
488
489 log:    .lognr.$(PROJECT)
490         @expr `cat .lognr.$(PROJECT)` + 1 > .lognr.$(PROJECT)   
491         @echo Creating $(PROJECT)-`cat .lognr.$(PROJECT)`.log
492         @$(MAKE) > $(PROJECT)-`cat .lognr.$(PROJECT)`.log 2>&1
493
494
495 cross: $(BASE_TARGETS)
496
497 help:
498         @echo 'Cleaning:'
499         @echo '  clean                  - delete temporary files created by build'
500         @echo '  distclean              - delete all non-source files (including .config)'
501         @echo
502         @echo 'Build:'
503         @echo '  all                    - make world'
504         @echo
505         @echo 'Configuration:'
506         @echo '  menuconfig             - interactive curses-based configurator'
507         @echo '  oldconfig              - resolve any unresolved symbols in .config'
508         @echo '  saveconfig             - save current configuration under local/<project>'
509         @echo '  getconfig              - restore saved configuration from local/<project>'
510         @echo
511         @echo 'Miscellaneous:'
512         @echo '  source                 - download all sources needed for offline-build'
513         @echo '  source-check           - check all packages for valid download URLs'
514         @echo '  external-deps          - list external packages used'
515         @echo
516         @echo 'See docs/README and docs/buildroot.html for further details'
517         @echo
518
519 .PHONY: dummy subdirs release distclean clean config oldconfig \
520         menuconfig tags check test depend defconfig help
521
This page took 0.054642 seconds and 4 git commands to generate.