Eric Andersen | 85208e2 | 2002-04-12 12:05:57 +0000 | [diff] [blame] | 1 | # Rules.make for busybox |
Eric Andersen | 4bcdd72 | 2001-10-24 05:26:42 +0000 | [diff] [blame] | 2 | # |
Mike Frysinger | 5a5d0fa | 2005-11-29 02:53:52 +0000 | [diff] [blame] | 3 | # Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org> |
Eric Andersen | 85208e2 | 2002-04-12 12:05:57 +0000 | [diff] [blame] | 4 | # |
Mike Frysinger | 5a5d0fa | 2005-11-29 02:53:52 +0000 | [diff] [blame] | 5 | # Licensed under GPLv2, see the file LICENSE in this tarball for details. |
Eric Andersen | 4bcdd72 | 2001-10-24 05:26:42 +0000 | [diff] [blame] | 6 | # |
| 7 | |
Mike Frysinger | 004ad11 | 2005-11-29 02:52:25 +0000 | [diff] [blame] | 8 | # Pull in the user's busybox configuration |
| 9 | ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),) |
| 10 | -include $(top_builddir)/.config |
| 11 | endif |
| 12 | |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 13 | #-------------------------------------------------------- |
Eric Andersen | 85208e2 | 2002-04-12 12:05:57 +0000 | [diff] [blame] | 14 | PROG := busybox |
Bernhard Reutner-Fischer | 8c7a7e6 | 2005-10-13 10:40:18 +0000 | [diff] [blame] | 15 | MAJOR_VERSION :=1 |
Bernhard Reutner-Fischer | 6018225 | 2006-03-29 22:22:37 +0000 | [diff] [blame] | 16 | MINOR_VERSION :=2 |
| 17 | SUBLEVEL_VERSION:=0 |
| 18 | EXTRAVERSION :=-pre0 |
Bernhard Reutner-Fischer | 8c7a7e6 | 2005-10-13 10:40:18 +0000 | [diff] [blame] | 19 | VERSION :=$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL_VERSION)$(EXTRAVERSION) |
Eric Andersen | 85208e2 | 2002-04-12 12:05:57 +0000 | [diff] [blame] | 20 | BUILDTIME := $(shell TZ=UTC date -u "+%Y.%m.%d-%H:%M%z") |
Eric Andersen | 4bcdd72 | 2001-10-24 05:26:42 +0000 | [diff] [blame] | 21 | |
| 22 | |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 23 | #-------------------------------------------------------- |
Eric Andersen | 85208e2 | 2002-04-12 12:05:57 +0000 | [diff] [blame] | 24 | # With a modern GNU make(1) (highly recommended, that's what all the |
| 25 | # developers use), all of the following configuration values can be |
| 26 | # overridden at the command line. For example: |
Bernhard Reutner-Fischer | 5c071bc | 2005-10-05 07:40:46 +0000 | [diff] [blame] | 27 | # make CROSS=powerpc-linux- top_srcdir="$HOME/busybox" PREFIX=/mnt/app |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 28 | #-------------------------------------------------------- |
Eric Andersen | 4bcdd72 | 2001-10-24 05:26:42 +0000 | [diff] [blame] | 29 | |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 30 | # If you are running a cross compiler, you will want to set 'CROSS' |
| 31 | # to something more interesting... Target architecture is determined |
| 32 | # by asking the CC compiler what arch it compiles things for, so unless |
Bernhard Reutner-Fischer | df10094 | 2006-03-13 19:04:00 +0000 | [diff] [blame] | 33 | # your compiler is broken, you should not need to specify TARGET_ARCH |
Bernhard Reutner-Fischer | e28d1d6 | 2006-05-26 13:22:57 +0000 | [diff] [blame] | 34 | CROSS =$(strip $(subst ",, $(strip $(CROSS_COMPILER_PREFIX)))) |
| 35 | # be gentle to vi coloring.. ")) |
Eric Andersen | 5912acb | 2003-11-05 11:34:26 +0000 | [diff] [blame] | 36 | CC = $(CROSS)gcc |
| 37 | AR = $(CROSS)ar |
| 38 | AS = $(CROSS)as |
| 39 | LD = $(CROSS)ld |
| 40 | NM = $(CROSS)nm |
| 41 | STRIP = $(CROSS)strip |
Mike Frysinger | 586ea61 | 2006-04-21 01:18:07 +0000 | [diff] [blame] | 42 | ELF2FLT = $(CROSS)elf2flt |
Eric Andersen | 5912acb | 2003-11-05 11:34:26 +0000 | [diff] [blame] | 43 | CPP = $(CC) -E |
Bernhard Reutner-Fischer | 5d26126 | 2006-03-01 22:54:48 +0000 | [diff] [blame] | 44 | SED ?= sed |
Bernhard Reutner-Fischer | e28d1d6 | 2006-05-26 13:22:57 +0000 | [diff] [blame] | 45 | BZIP2 ?= bzip2 |
Bernhard Reutner-Fischer | 8c7a7e6 | 2005-10-13 10:40:18 +0000 | [diff] [blame] | 46 | |
Eric Andersen | 85208e2 | 2002-04-12 12:05:57 +0000 | [diff] [blame] | 47 | |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 48 | # What OS are you compiling busybox for? This allows you to include |
| 49 | # OS specific things, syscall overrides, etc. |
Eric Andersen | 5912acb | 2003-11-05 11:34:26 +0000 | [diff] [blame] | 50 | TARGET_OS=linux |
Eric Andersen | 85208e2 | 2002-04-12 12:05:57 +0000 | [diff] [blame] | 51 | |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 52 | # Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc. |
Eric Andersen | 85d9d80 | 2003-01-14 09:12:39 +0000 | [diff] [blame] | 53 | LC_ALL:= C |
| 54 | |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 55 | # If you want to add some simple compiler switches (like -march=i686), |
| 56 | # especially from the command line, use this instead of CFLAGS directly. |
Bernhard Reutner-Fischer | df10094 | 2006-03-13 19:04:00 +0000 | [diff] [blame] | 57 | # For optimization overrides, it's better still to set OPTIMIZATION. |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 58 | CFLAGS_EXTRA=$(subst ",, $(strip $(EXTRA_CFLAGS_OPTIONS))) |
Bernhard Reutner-Fischer | e5de384 | 2006-06-10 14:58:33 +0000 | [diff] [blame] | 59 | # be gentle to vi coloring.. ") |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 60 | |
Eric Andersen | 85208e2 | 2002-04-12 12:05:57 +0000 | [diff] [blame] | 61 | # To compile vs some other alternative libc, you may need to use/adjust |
| 62 | # the following lines to meet your needs... |
| 63 | # |
| 64 | # If you are using Red Hat 6.x with the compatible RPMs (for developing under |
| 65 | # Red Hat 5.x and glibc 2.0) uncomment the following. Be sure to read about |
| 66 | # using the compatible RPMs (compat-*) at http://www.redhat.com ! |
| 67 | #LIBCDIR:=/usr/i386-glibc20-linux |
| 68 | # |
Eric Andersen | 0a14c9f | 2003-07-22 08:56:01 +0000 | [diff] [blame] | 69 | # For other libraries, you are on your own. But these may (or may not) help... |
Eric Andersen | 85208e2 | 2002-04-12 12:05:57 +0000 | [diff] [blame] | 70 | #LDFLAGS+=-nostdlib |
| 71 | #LIBRARIES:=$(LIBCDIR)/lib/libc.a -lgcc |
Rob Landley | 4a070d1 | 2005-12-01 17:01:43 +0000 | [diff] [blame] | 72 | #CROSS_CFLAGS+=-nostdinc -I$(LIBCDIR)/include -I$(GCCINCDIR) -funsigned-char |
Bernhard Reutner-Fischer | e28d1d6 | 2006-05-26 13:22:57 +0000 | [diff] [blame] | 73 | #GCCINCDIR:=$(shell gcc -print-search-dirs | $(SED) -ne "s/install: \(.*\)/\1include/gp") |
Eric Andersen | 85208e2 | 2002-04-12 12:05:57 +0000 | [diff] [blame] | 74 | |
Rob Landley | 5076eb4 | 2006-04-19 20:32:27 +0000 | [diff] [blame] | 75 | # This must bind late because srcdir is reset for every source subdirectory. |
Bernhard Reutner-Fischer | 45d5458 | 2006-05-08 20:20:32 +0000 | [diff] [blame] | 76 | INCS:=-I$(top_builddir)/include -I$(top_srcdir)/include |
Rob Landley | c503df5 | 2006-05-09 22:08:56 +0000 | [diff] [blame] | 77 | CFLAGS=$(INCS) -I$(srcdir) -D_GNU_SOURCE |
Rob Landley | 5076eb4 | 2006-04-19 20:32:27 +0000 | [diff] [blame] | 78 | CFLAGS+=$(CHECKED_CFLAGS) |
Bernhard Reutner-Fischer | 07a79e7 | 2006-03-09 09:03:37 +0000 | [diff] [blame] | 79 | ARFLAGS=cru |
Eric Andersen | 85208e2 | 2002-04-12 12:05:57 +0000 | [diff] [blame] | 80 | |
Bernhard Reutner-Fischer | e0b8778 | 2005-12-13 11:52:46 +0000 | [diff] [blame] | 81 | # gcc centric. Perhaps fiddle with findstring gcc,$(CC) for the rest |
Bernhard Reutner-Fischer | df10094 | 2006-03-13 19:04:00 +0000 | [diff] [blame] | 82 | # get the CC MAJOR/MINOR version |
Bernhard Reutner-Fischer | e0b8778 | 2005-12-13 11:52:46 +0000 | [diff] [blame] | 83 | CC_MAJOR:=$(shell printf "%02d" $(shell echo __GNUC__ | $(CC) -E -xc - | tail -n 1)) |
| 84 | CC_MINOR:=$(shell printf "%02d" $(shell echo __GNUC_MINOR__ | $(CC) -E -xc - | tail -n 1)) |
| 85 | |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 86 | #-------------------------------------------------------- |
Bernhard Reutner-Fischer | 1c943eb | 2005-09-26 16:01:43 +0000 | [diff] [blame] | 87 | export VERSION BUILDTIME HOSTCC HOSTCFLAGS CROSS CC AR AS LD NM STRIP CPP |
Bernhard Reutner-Fischer | df10094 | 2006-03-13 19:04:00 +0000 | [diff] [blame] | 88 | ifeq ($(strip $(TARGET_ARCH)),) |
Bernhard Reutner-Fischer | e28d1d6 | 2006-05-26 13:22:57 +0000 | [diff] [blame] | 89 | TARGET_ARCH:=$(shell $(CC) -dumpmachine | $(SED) -e s'/-.*//' \ |
Eric Andersen | 5b0f9e4 | 2002-06-23 04:50:49 +0000 | [diff] [blame] | 90 | -e 's/i.86/i386/' \ |
| 91 | -e 's/sparc.*/sparc/' \ |
| 92 | -e 's/arm.*/arm/g' \ |
| 93 | -e 's/m68k.*/m68k/' \ |
| 94 | -e 's/ppc/powerpc/g' \ |
| 95 | -e 's/v850.*/v850/g' \ |
| 96 | -e 's/sh[234]/sh/' \ |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 97 | -e 's/mips-.*/mips/' \ |
| 98 | -e 's/mipsel-.*/mipsel/' \ |
| 99 | -e 's/cris.*/cris/' \ |
| 100 | ) |
Eric Andersen | 5912acb | 2003-11-05 11:34:26 +0000 | [diff] [blame] | 101 | endif |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 102 | |
Rob Landley | 5076eb4 | 2006-04-19 20:32:27 +0000 | [diff] [blame] | 103 | # A nifty macro to make testing gcc features easier, but note that everything |
Bernhard Reutner-Fischer | e28d1d6 | 2006-05-26 13:22:57 +0000 | [diff] [blame] | 104 | # that uses this _must_ use := or it will be re-evaluated everytime it is |
| 105 | # referenced. |
Bernhard Reutner-Fischer | 7b8ff22 | 2006-06-13 14:20:17 +0000 | [diff] [blame] | 106 | ifeq ($(strip $(BUILD_VERBOSE)),2) |
Bernhard Reutner-Fischer | e28d1d6 | 2006-05-26 13:22:57 +0000 | [diff] [blame] | 107 | VERBOSE_CHECK_CC=echo CC=\"$(1)\" check_cc $(2) >&2; |
Rob Landley | 5076eb4 | 2006-04-19 20:32:27 +0000 | [diff] [blame] | 108 | endif |
Bernhard Reutner-Fischer | e28d1d6 | 2006-05-26 13:22:57 +0000 | [diff] [blame] | 109 | check_cc=$(shell \ |
| 110 | $(VERBOSE_CHECK_CC) \ |
| 111 | if [ "x$(1)" != "x" ] && [ "x$(2)" != "x" ]; then \ |
| 112 | echo "int i;" > ./conftest.c; \ |
| 113 | if $(1) $(2) -c -o conftest.o conftest.c > /dev/null 2>&1; \ |
| 114 | then echo "$(2)"; else echo "$(3)"; fi ; \ |
| 115 | rm -f conftest.c conftest.o; \ |
Bernhard Reutner-Fischer | df10094 | 2006-03-13 19:04:00 +0000 | [diff] [blame] | 116 | fi) |
| 117 | |
Bernhard Reutner-Fischer | 081b1ac | 2006-06-11 16:41:10 +0000 | [diff] [blame] | 118 | ifneq ($(filter $(nocheck_targets),$(MAKECMDGOALS)),) |
Bernhard Reutner-Fischer | e5de384 | 2006-06-10 14:58:33 +0000 | [diff] [blame] | 119 | check_cc:= |
| 120 | endif |
| 121 | |
Bernhard Reutner-Fischer | df10094 | 2006-03-13 19:04:00 +0000 | [diff] [blame] | 122 | # A not very robust macro to check for available ld flags |
Bernhard Reutner-Fischer | 7b8ff22 | 2006-06-13 14:20:17 +0000 | [diff] [blame] | 123 | ifeq ($(strip $(BUILD_VERBOSE)),2) |
Bernhard Reutner-Fischer | e28d1d6 | 2006-05-26 13:22:57 +0000 | [diff] [blame] | 124 | VERBOSE_CHECK_LD=echo LD=\"$(1)\" check_ld $(2) >&2; |
| 125 | endif |
Bernhard Reutner-Fischer | df10094 | 2006-03-13 19:04:00 +0000 | [diff] [blame] | 126 | check_ld=$(shell \ |
Bernhard Reutner-Fischer | e28d1d6 | 2006-05-26 13:22:57 +0000 | [diff] [blame] | 127 | $(VERBOSE_CHECK_LD) \ |
| 128 | if [ "x$(1)" != "x" ] && [ "x$(2)" != "x" ]; then \ |
| 129 | $(1) -o /dev/null -b binary /dev/null > /dev/null 2>&1 && \ |
| 130 | echo "-Wl,$(2)" ; \ |
Bernhard Reutner-Fischer | df10094 | 2006-03-13 19:04:00 +0000 | [diff] [blame] | 131 | fi) |
| 132 | |
Bernhard Reutner-Fischer | 081b1ac | 2006-06-11 16:41:10 +0000 | [diff] [blame] | 133 | ifneq ($(filter $(nocheck_targets),$(MAKECMDGOALS)),) |
Bernhard Reutner-Fischer | e5de384 | 2006-06-10 14:58:33 +0000 | [diff] [blame] | 134 | check_ld:= |
| 135 | endif |
| 136 | |
Bernhard Reutner-Fischer | e28d1d6 | 2006-05-26 13:22:57 +0000 | [diff] [blame] | 137 | # A not very robust macro to check for available strip flags |
Bernhard Reutner-Fischer | 7b8ff22 | 2006-06-13 14:20:17 +0000 | [diff] [blame] | 138 | ifeq ($(strip $(BUILD_VERBOSE)),2) |
Bernhard Reutner-Fischer | e28d1d6 | 2006-05-26 13:22:57 +0000 | [diff] [blame] | 139 | VERBOSE_CHECK_STRIP=echo STRIPCMD=\"$(1)\" check_strip $(2) >&2; |
| 140 | endif |
| 141 | check_strip=$(shell \ |
| 142 | $(VERBOSE_CHECK_STRIP) \ |
| 143 | if [ "x$(1)" != "x" ] && [ "x$(2)" != "x" ]; then \ |
| 144 | echo "int i;" > ./conftest.c ; \ |
| 145 | $(CC) -c -o conftest.o conftest.c > /dev/null 2>&1 ; \ |
| 146 | $(1) $(2) conftest.o > /dev/null 2>&1 && \ |
| 147 | echo "$(1) $(2)" || echo "$(3)"; \ |
| 148 | rm -f conftest.c conftest.o > /dev/null 2>&1 ; \ |
| 149 | fi) |
| 150 | |
Bernhard Reutner-Fischer | 081b1ac | 2006-06-11 16:41:10 +0000 | [diff] [blame] | 151 | ifneq ($(filter $(nocheck_targets),$(MAKECMDGOALS)),) |
Bernhard Reutner-Fischer | e5de384 | 2006-06-10 14:58:33 +0000 | [diff] [blame] | 152 | check_strip:= |
| 153 | endif |
Bernhard Reutner-Fischer | e28d1d6 | 2006-05-26 13:22:57 +0000 | [diff] [blame] | 154 | |
| 155 | |
| 156 | # Select the compiler needed to build binaries for your development system |
| 157 | HOSTCC = gcc |
| 158 | HOSTCFLAGS:=$(call check_cc,$(HOSTCC),-Wall,) |
| 159 | HOSTCFLAGS+=$(call check_cc,$(HOSTCC),-Wstrict-prototypes,) |
| 160 | HOSTCFLAGS+=$(call check_cc,$(HOSTCC),-O2,) |
| 161 | HOSTCFLAGS+=$(call check_cc,$(HOSTCC),-fomit-frame-pointer,) |
| 162 | |
| 163 | LD_WHOLE_ARCHIVE:=$(shell echo "int i;" > conftest.c ; \ |
| 164 | $(CC) -c -o conftest.o conftest.c ; \ |
| 165 | echo "int main(void){return 0;}" > conftest_main.c ; \ |
| 166 | $(CC) -c -o conftest_main.o conftest_main.c ; \ |
| 167 | $(AR) $(ARFLAGS) conftest.a conftest.o ; \ |
| 168 | $(CC) -Wl,--whole-archive conftest.a -Wl,--no-whole-archive \ |
| 169 | conftest_main.o -o conftest > /dev/null 2>&1 \ |
| 170 | && echo "-Wl,--whole-archive" ; \ |
| 171 | rm conftest_main.o conftest_main.c conftest.o conftest.c \ |
| 172 | conftest.a conftest > /dev/null 2>&1 ; ) |
| 173 | ifneq ($(findstring whole-archive,$(LD_WHOLE_ARCHIVE)),) |
| 174 | LD_NO_WHOLE_ARCHIVE:= -Wl,--no-whole-archive |
| 175 | endif |
| 176 | |
| 177 | LD_START_GROUP:=$(shell echo "int bar(void){return 0;}" > conftest.c ; \ |
| 178 | $(CC) -c -o conftest.o conftest.c ; \ |
| 179 | echo "int main(void){return bar();}" > conftest_main.c ; \ |
| 180 | $(CC) -c -o conftest_main.o conftest_main.c ; \ |
| 181 | $(AR) $(ARFLAGS) conftest.a conftest.o ; \ |
| 182 | $(CC) -Wl,--start-group conftest.a conftest_main.o -Wl,--end-group \ |
| 183 | -o conftest > /dev/null 2>&1 && echo "-Wl,--start-group" ; \ |
Bernhard Reutner-Fischer | 0773681 | 2006-05-29 20:01:52 +0000 | [diff] [blame] | 184 | rm conftest_main.o conftest_main.c conftest.o conftest.c \ |
Bernhard Reutner-Fischer | e28d1d6 | 2006-05-26 13:22:57 +0000 | [diff] [blame] | 185 | conftest.a conftest > /dev/null 2>&1 ; ) |
| 186 | ifneq ($(findstring start-group,$(LD_START_GROUP)),) |
| 187 | LD_END_GROUP:= -Wl,--end-group |
| 188 | endif |
| 189 | |
| 190 | CHECKED_LDFLAGS := $(call check_ld,$(LD),--warn-common,) |
| 191 | |
Rob Landley | 5076eb4 | 2006-04-19 20:32:27 +0000 | [diff] [blame] | 192 | # Pin CHECKED_CFLAGS with := so it's only evaluated once. |
Bernhard Reutner-Fischer | e28d1d6 | 2006-05-26 13:22:57 +0000 | [diff] [blame] | 193 | CHECKED_CFLAGS:=$(call check_cc,$(CC),-Wall,) |
| 194 | CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wstrict-prototypes,) |
| 195 | CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wshadow,) |
| 196 | CHECKED_CFLAGS+=$(call check_cc,$(CC),-funsigned-char,) |
| 197 | CHECKED_CFLAGS+=$(call check_cc,$(CC),-mmax-stack-frame=256,) |
| 198 | CHECKED_CFLAGS+=$(call check_cc,$(CC),-fno-builtin-strlen) |
Bernhard Reutner-Fischer | df10094 | 2006-03-13 19:04:00 +0000 | [diff] [blame] | 199 | |
Rob Landley | 5076eb4 | 2006-04-19 20:32:27 +0000 | [diff] [blame] | 200 | # Preemptively pin this too. |
| 201 | PROG_CFLAGS:= |
| 202 | |
Bernhard Reutner-Fischer | 7ca61b6 | 2006-01-15 14:04:57 +0000 | [diff] [blame] | 203 | |
Eric Andersen | 5b0f9e4 | 2002-06-23 04:50:49 +0000 | [diff] [blame] | 204 | #-------------------------------------------------------- |
| 205 | # Arch specific compiler optimization stuff should go here. |
| 206 | # Unless you want to override the defaults, do not set anything |
Bernhard Reutner-Fischer | df10094 | 2006-03-13 19:04:00 +0000 | [diff] [blame] | 207 | # for OPTIMIZATION... |
Eric Andersen | 5b0f9e4 | 2002-06-23 04:50:49 +0000 | [diff] [blame] | 208 | |
| 209 | # use '-Os' optimization if available, else use -O2 |
Bernhard Reutner-Fischer | e28d1d6 | 2006-05-26 13:22:57 +0000 | [diff] [blame] | 210 | OPTIMIZATION:=$(call check_cc,$(CC),-Os,-O2) |
Eric Andersen | 5b0f9e4 | 2002-06-23 04:50:49 +0000 | [diff] [blame] | 211 | |
Bernhard Reutner-Fischer | df10094 | 2006-03-13 19:04:00 +0000 | [diff] [blame] | 212 | ifeq ($(CONFIG_BUILD_AT_ONCE),y) |
Bernhard Reutner-Fischer | 7ca61b6 | 2006-01-15 14:04:57 +0000 | [diff] [blame] | 213 | # gcc 2.95 exits with 0 for "unrecognized option" |
Bernhard Reutner-Fischer | df10094 | 2006-03-13 19:04:00 +0000 | [diff] [blame] | 214 | ifeq ($(strip $(shell [ $(CC_MAJOR) -ge 3 ] ; echo $$?)),0) |
Bernhard Reutner-Fischer | e28d1d6 | 2006-05-26 13:22:57 +0000 | [diff] [blame] | 215 | CFLAGS_COMBINE:=$(call check_cc,$(CC),--combine,) |
Bernhard Reutner-Fischer | df10094 | 2006-03-13 19:04:00 +0000 | [diff] [blame] | 216 | endif |
Bernhard Reutner-Fischer | e28d1d6 | 2006-05-26 13:22:57 +0000 | [diff] [blame] | 217 | OPTIMIZATION+=$(call check_cc,$(CC),-funit-at-a-time,) |
| 218 | OPTIMIZATION+=$(call check_cc,$(CC),-fgcse-after-reload,) |
Bernhard Reutner-Fischer | 3737c03 | 2006-04-28 20:02:29 +0000 | [diff] [blame] | 219 | ifneq ($(CONFIG_BUILD_LIBBUSYBOX),y) |
Bernhard Reutner-Fischer | d1ba916 | 2006-03-21 11:06:43 +0000 | [diff] [blame] | 220 | # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25795 |
Bernhard Reutner-Fischer | 3737c03 | 2006-04-28 20:02:29 +0000 | [diff] [blame] | 221 | # This prevents us from using -fwhole-program when we build the lib |
Bernhard Reutner-Fischer | e28d1d6 | 2006-05-26 13:22:57 +0000 | [diff] [blame] | 222 | PROG_CFLAGS+=$(call check_cc,$(CC),-fwhole-program,) |
Bernhard Reutner-Fischer | 3737c03 | 2006-04-28 20:02:29 +0000 | [diff] [blame] | 223 | endif # CONFIG_BUILD_LIBBUSYBOX |
Bernhard Reutner-Fischer | df10094 | 2006-03-13 19:04:00 +0000 | [diff] [blame] | 224 | endif # CONFIG_BUILD_AT_ONCE |
Bernhard Reutner-Fischer | 7ca61b6 | 2006-01-15 14:04:57 +0000 | [diff] [blame] | 225 | |
Bernhard Reutner-Fischer | e28d1d6 | 2006-05-26 13:22:57 +0000 | [diff] [blame] | 226 | LIB_LDFLAGS:=$(call check_ld,$(LD),--enable-new-dtags,) |
| 227 | #LIB_LDFLAGS+=$(call check_ld,$(LD),--reduce-memory-overheads,) |
| 228 | #LIB_LDFLAGS+=$(call check_ld,$(LD),--as-needed,) |
| 229 | #LIB_LDFLAGS+=$(call check_ld,$(LD),--warn-shared-textrel,) |
Bernhard Reutner-Fischer | 08a1b50 | 2006-01-27 15:45:56 +0000 | [diff] [blame] | 230 | |
| 231 | |
Eric Andersen | 5b0f9e4 | 2002-06-23 04:50:49 +0000 | [diff] [blame] | 232 | # Some nice architecture specific optimizations |
Bernhard Reutner-Fischer | df10094 | 2006-03-13 19:04:00 +0000 | [diff] [blame] | 233 | ifeq ($(strip $(TARGET_ARCH)),arm) |
| 234 | OPTIMIZATION+=-fstrict-aliasing |
| 235 | endif |
| 236 | ifeq ($(strip $(TARGET_ARCH)),i386) |
Bernhard Reutner-Fischer | e28d1d6 | 2006-05-26 13:22:57 +0000 | [diff] [blame] | 237 | OPTIMIZATION+=$(call check_cc,$(CC),-march=i386,) |
Bernhard Reutner-Fischer | d9969ea | 2006-03-03 20:31:33 +0000 | [diff] [blame] | 238 | # gcc-4.0 and older seem to benefit from these |
Bernhard Reutner-Fischer | df10094 | 2006-03-13 19:04:00 +0000 | [diff] [blame] | 239 | #ifneq ($(strip $(shell [ $(CC_MAJOR) -ge 4 -a $(CC_MINOR) -ge 1 ] ; echo $$?)),0) |
Bernhard Reutner-Fischer | e28d1d6 | 2006-05-26 13:22:57 +0000 | [diff] [blame] | 240 | OPTIMIZATION+=$(call check_cc,$(CC),-mpreferred-stack-boundary=2,) |
| 241 | OPTIMIZATION+=$(call check_cc,$(CC),-falign-functions=1 -falign-jumps=1 -falign-loops=1,\ |
Bernhard Reutner-Fischer | df10094 | 2006-03-13 19:04:00 +0000 | [diff] [blame] | 242 | -malign-functions=0 -malign-jumps=0 -malign-loops=0) |
| 243 | #endif # gcc-4.0 and older |
Bernhard Reutner-Fischer | 7ca61b6 | 2006-01-15 14:04:57 +0000 | [diff] [blame] | 244 | |
| 245 | # gcc-4.1 and beyond seem to benefit from these |
Bernhard Reutner-Fischer | df10094 | 2006-03-13 19:04:00 +0000 | [diff] [blame] | 246 | ifeq ($(strip $(shell [ $(CC_MAJOR) -ge 4 -a $(CC_MINOR) -ge 1 ] ; echo $$?)),0) |
| 247 | # turn off flags which hurt -Os |
Bernhard Reutner-Fischer | e28d1d6 | 2006-05-26 13:22:57 +0000 | [diff] [blame] | 248 | OPTIMIZATION+=$(call check_cc,$(CC),-fno-tree-loop-optimize,) |
| 249 | OPTIMIZATION+=$(call check_cc,$(CC),-fno-tree-dominator-opts,) |
| 250 | OPTIMIZATION+=$(call check_cc,$(CC),-fno-strength-reduce,) |
Bernhard Reutner-Fischer | 7ca61b6 | 2006-01-15 14:04:57 +0000 | [diff] [blame] | 251 | |
Bernhard Reutner-Fischer | e28d1d6 | 2006-05-26 13:22:57 +0000 | [diff] [blame] | 252 | OPTIMIZATION+=$(call check_cc,$(CC),-fno-branch-count-reg,) |
Bernhard Reutner-Fischer | df10094 | 2006-03-13 19:04:00 +0000 | [diff] [blame] | 253 | endif # gcc-4.1 and beyond |
| 254 | endif |
Bernhard Reutner-Fischer | e28d1d6 | 2006-05-26 13:22:57 +0000 | [diff] [blame] | 255 | OPTIMIZATION+=$(call check_cc,$(CC),-fomit-frame-pointer,) |
Rob Landley | 7900b7b | 2006-06-13 16:17:16 +0000 | [diff] [blame] | 256 | OPTIMIZATION+=$(call check_cc,$(CC),-ffunction-sections -fdata-sections,) |
Eric Andersen | 5b0f9e4 | 2002-06-23 04:50:49 +0000 | [diff] [blame] | 257 | |
Eric Andersen | 85208e2 | 2002-04-12 12:05:57 +0000 | [diff] [blame] | 258 | # |
| 259 | #-------------------------------------------------------- |
| 260 | # If you're going to do a lot of builds with a non-vanilla configuration, |
| 261 | # it makes sense to adjust parameters above, so you can type "make" |
| 262 | # by itself, instead of following it by the same half-dozen overrides |
| 263 | # every time. The stuff below, on the other hand, is probably less |
| 264 | # prone to casual user adjustment. |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 265 | # |
Eric Andersen | 85208e2 | 2002-04-12 12:05:57 +0000 | [diff] [blame] | 266 | |
Bernhard Reutner-Fischer | df10094 | 2006-03-13 19:04:00 +0000 | [diff] [blame] | 267 | ifeq ($(strip $(CONFIG_LFS)),y) |
Eric Andersen | 85208e2 | 2002-04-12 12:05:57 +0000 | [diff] [blame] | 268 | # For large file summit support |
Eric Andersen | ecfa290 | 2002-09-22 12:09:44 +0000 | [diff] [blame] | 269 | CFLAGS+=-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 |
Eric Andersen | 85208e2 | 2002-04-12 12:05:57 +0000 | [diff] [blame] | 270 | endif |
Bernhard Reutner-Fischer | df10094 | 2006-03-13 19:04:00 +0000 | [diff] [blame] | 271 | ifeq ($(strip $(CONFIG_DMALLOC)),y) |
Eric Andersen | 85208e2 | 2002-04-12 12:05:57 +0000 | [diff] [blame] | 272 | # For testing mem leaks with dmalloc |
| 273 | CFLAGS+=-DDMALLOC |
| 274 | LIBRARIES:=-ldmalloc |
Eric Andersen | 85208e2 | 2002-04-12 12:05:57 +0000 | [diff] [blame] | 275 | else |
Bernhard Reutner-Fischer | df10094 | 2006-03-13 19:04:00 +0000 | [diff] [blame] | 276 | ifeq ($(strip $(CONFIG_EFENCE)),y) |
Eric Andersen | 85208e2 | 2002-04-12 12:05:57 +0000 | [diff] [blame] | 277 | LIBRARIES:=-lefence |
Eric Andersen | 85208e2 | 2002-04-12 12:05:57 +0000 | [diff] [blame] | 278 | endif |
| 279 | endif |
Rob Landley | c503df5 | 2006-05-09 22:08:56 +0000 | [diff] [blame] | 280 | |
| 281 | # Debugging info |
| 282 | |
Bernhard Reutner-Fischer | df10094 | 2006-03-13 19:04:00 +0000 | [diff] [blame] | 283 | ifeq ($(strip $(CONFIG_DEBUG)),y) |
Rob Landley | c503df5 | 2006-05-09 22:08:56 +0000 | [diff] [blame] | 284 | CFLAGS +=-g |
Eric Andersen | 85208e2 | 2002-04-12 12:05:57 +0000 | [diff] [blame] | 285 | else |
Rob Landley | c503df5 | 2006-05-09 22:08:56 +0000 | [diff] [blame] | 286 | CFLAGS +=-DNDEBUG |
Bernhard Reutner-Fischer | e28d1d6 | 2006-05-26 13:22:57 +0000 | [diff] [blame] | 287 | CHECKED_LDFLAGS += $(call check_ld,$(LD),--sort-common,) |
Rob Landley | 7900b7b | 2006-06-13 16:17:16 +0000 | [diff] [blame] | 288 | CHECKED_LDFLAGS += $(call check_ld,--gc-sections,) |
Mike Frysinger | c70240c | 2006-03-10 23:20:48 +0000 | [diff] [blame] | 289 | endif |
Rob Landley | c503df5 | 2006-05-09 22:08:56 +0000 | [diff] [blame] | 290 | |
| 291 | ifneq ($(strip $(CONFIG_DEBUG_PESSIMIZE)),y) |
Rob Landley | c503df5 | 2006-05-09 22:08:56 +0000 | [diff] [blame] | 292 | CFLAGS += $(OPTIMIZATION) |
| 293 | endif |
| 294 | |
Bernhard Reutner-Fischer | abaef65 | 2006-03-29 22:28:27 +0000 | [diff] [blame] | 295 | # warn a bit more verbosely for non-release versions |
| 296 | ifneq ($(EXTRAVERSION),) |
Bernhard Reutner-Fischer | e28d1d6 | 2006-05-26 13:22:57 +0000 | [diff] [blame] | 297 | CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wstrict-prototypes,) |
| 298 | CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wmissing-prototypes,) |
| 299 | CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wmissing-declarations,) |
| 300 | CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wunused,) |
| 301 | CHECKED_CFLAGS+=$(call check_cc,$(CC),-Winit-self,) |
| 302 | CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wshadow,) |
| 303 | CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wcast-align,) |
Bernhard Reutner-Fischer | abaef65 | 2006-03-29 22:28:27 +0000 | [diff] [blame] | 304 | endif |
Bernhard Reutner-Fischer | e28d1d6 | 2006-05-26 13:22:57 +0000 | [diff] [blame] | 305 | STRIPCMD:=$(call check_strip,$(STRIP),-s --remove-section=.note --remove-section=.comment,$(STRIP)) |
Bernhard Reutner-Fischer | df10094 | 2006-03-13 19:04:00 +0000 | [diff] [blame] | 306 | ifeq ($(strip $(CONFIG_STATIC)),y) |
Bernhard Reutner-Fischer | e28d1d6 | 2006-05-26 13:22:57 +0000 | [diff] [blame] | 307 | PROG_CFLAGS += $(call check_cc,$(CC),-static,) |
Bernhard Reutner-Fischer | df10094 | 2006-03-13 19:04:00 +0000 | [diff] [blame] | 308 | endif |
Bernhard Reutner-Fischer | e28d1d6 | 2006-05-26 13:22:57 +0000 | [diff] [blame] | 309 | CFLAGS_SHARED := $(call check_cc,$(CC),-shared,) |
Bernhard Reutner-Fischer | 81b9496 | 2006-01-31 11:29:22 +0000 | [diff] [blame] | 310 | LIB_CFLAGS+=$(CFLAGS_SHARED) |
Bernhard Reutner-Fischer | 7ca61b6 | 2006-01-15 14:04:57 +0000 | [diff] [blame] | 311 | |
Bernhard Reutner-Fischer | df10094 | 2006-03-13 19:04:00 +0000 | [diff] [blame] | 312 | ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y) |
Bernhard Reutner-Fischer | e28d1d6 | 2006-05-26 13:22:57 +0000 | [diff] [blame] | 313 | CFLAGS_PIC:= $(call check_cc,$(CC),-fPIC,) |
Bernhard Reutner-Fischer | df10094 | 2006-03-13 19:04:00 +0000 | [diff] [blame] | 314 | LIB_CFLAGS+=$(CFLAGS_PIC) |
| 315 | endif |
Eric Andersen | 85208e2 | 2002-04-12 12:05:57 +0000 | [diff] [blame] | 316 | |
Bernhard Reutner-Fischer | df10094 | 2006-03-13 19:04:00 +0000 | [diff] [blame] | 317 | ifeq ($(strip $(CONFIG_SELINUX)),y) |
Rob Landley | dbd91af | 2006-03-28 19:40:15 +0000 | [diff] [blame] | 318 | LIBRARIES += -lselinux |
Bernhard Reutner-Fischer | 5c071bc | 2005-10-05 07:40:46 +0000 | [diff] [blame] | 319 | endif |
| 320 | |
Eric Andersen | 12f834c | 2002-10-26 10:17:24 +0000 | [diff] [blame] | 321 | ifeq ($(strip $(PREFIX)),) |
Eric Andersen | 85208e2 | 2002-04-12 12:05:57 +0000 | [diff] [blame] | 322 | PREFIX:=`pwd`/_install |
| 323 | endif |
| 324 | |
Bernhard Reutner-Fischer | 01d23ad | 2006-05-26 20:19:22 +0000 | [diff] [blame] | 325 | ifneq ($(strip $(CONFIG_GETOPT_LONG)),y) |
| 326 | CFLAGS += -D__need_getopt |
| 327 | endif |
Bernhard Reutner-Fischer | e28d1d6 | 2006-05-26 13:22:57 +0000 | [diff] [blame] | 328 | |
Bernhard Reutner-Fischer | df10094 | 2006-03-13 19:04:00 +0000 | [diff] [blame] | 329 | # Additional complications due to support for pristine source dir. |
| 330 | # Include files in the build directory should take precedence over |
| 331 | # the copy in top_srcdir, both during the compilation phase and the |
| 332 | # shell script that finds the list of object files. |
| 333 | # Work in progress by <ldoolitt@recycle.lbl.gov>. |
| 334 | |
| 335 | |
| 336 | OBJECTS:=$(APPLET_SOURCES:.c=.o) busybox.o usage.o applets.o |
Bernhard Reutner-Fischer | e28d1d6 | 2006-05-26 13:22:57 +0000 | [diff] [blame] | 337 | CFLAGS += $(CHECKED_CFLAGS) $(CROSS_CFLAGS) |
| 338 | LDFLAGS += $(CHECKED_LDFLAGS) |
| 339 | |
Eric Andersen | 85208e2 | 2002-04-12 12:05:57 +0000 | [diff] [blame] | 340 | ifdef BB_INIT_SCRIPT |
| 341 | CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"' |
| 342 | endif |
| 343 | |
| 344 | # Put user-supplied flags at the end, where they |
| 345 | # have a chance of winning. |
| 346 | CFLAGS += $(CFLAGS_EXTRA) |
Eric Andersen | 4bcdd72 | 2001-10-24 05:26:42 +0000 | [diff] [blame] | 347 | |
Rob Landley | e0c418e | 2005-12-15 07:25:54 +0000 | [diff] [blame] | 348 | #------------------------------------------------------------ |
| 349 | # Installation options |
| 350 | ifeq ($(strip $(CONFIG_INSTALL_APPLET_HARDLINKS)),y) |
| 351 | INSTALL_OPTS=--hardlinks |
| 352 | endif |
| 353 | ifeq ($(strip $(CONFIG_INSTALL_APPLET_SYMLINKS)),y) |
| 354 | INSTALL_OPTS=--symlinks |
| 355 | endif |
| 356 | ifeq ($(strip $(CONFIG_INSTALL_APPLET_DONT)),y) |
| 357 | INSTALL_OPTS= |
| 358 | endif |
| 359 | |
Mike Frysinger | b38673f | 2006-02-02 01:41:53 +0000 | [diff] [blame] | 360 | #------------------------------------------------------------ |
| 361 | # Make the output nice and tight |
Bernhard Reutner-Fischer | df10094 | 2006-03-13 19:04:00 +0000 | [diff] [blame] | 362 | MAKEFLAGS += --no-print-directory |
Mike Frysinger | b38673f | 2006-02-02 01:41:53 +0000 | [diff] [blame] | 363 | export MAKE_IS_SILENT=n |
| 364 | ifneq ($(findstring s,$(MAKEFLAGS)),) |
| 365 | export MAKE_IS_SILENT=y |
Bernhard Reutner-Fischer | df10094 | 2006-03-13 19:04:00 +0000 | [diff] [blame] | 366 | SECHO := @-false |
Mike Frysinger | b38673f | 2006-02-02 01:41:53 +0000 | [diff] [blame] | 367 | DISP := sil |
| 368 | Q := @ |
| 369 | else |
Bernhard Reutner-Fischer | 7b8ff22 | 2006-06-13 14:20:17 +0000 | [diff] [blame] | 370 | ifneq ($(BUILD_VERBOSE),) |
Bernhard Reutner-Fischer | df10094 | 2006-03-13 19:04:00 +0000 | [diff] [blame] | 371 | SECHO := @-false |
Mike Frysinger | b38673f | 2006-02-02 01:41:53 +0000 | [diff] [blame] | 372 | DISP := ver |
| 373 | Q := |
| 374 | else |
Bernhard Reutner-Fischer | df10094 | 2006-03-13 19:04:00 +0000 | [diff] [blame] | 375 | SECHO := @echo |
Mike Frysinger | b38673f | 2006-02-02 01:41:53 +0000 | [diff] [blame] | 376 | DISP := pur |
| 377 | Q := @ |
| 378 | endif |
| 379 | endif |
| 380 | |
Bernhard Reutner-Fischer | df10094 | 2006-03-13 19:04:00 +0000 | [diff] [blame] | 381 | show_objs = $(subst $(top_builddir)/,,$(subst ../,,$@)) |
| 382 | pur_disp_compile.c = echo " "CC $(show_objs) |
| 383 | pur_disp_compile.h = echo " "HOSTCC $(show_objs) |
| 384 | pur_disp_strip = echo " "STRIP $(show_objs) |
| 385 | pur_disp_link = echo " "LINK $(show_objs) |
Bernhard Reutner-Fischer | 45d5458 | 2006-05-08 20:20:32 +0000 | [diff] [blame] | 386 | pur_disp_link.h = echo " "HOSTLINK $(show_objs) |
Bernhard Reutner-Fischer | df10094 | 2006-03-13 19:04:00 +0000 | [diff] [blame] | 387 | pur_disp_ar = echo " "AR $(ARFLAGS) $(show_objs) |
Mike Frysinger | 586ea61 | 2006-04-21 01:18:07 +0000 | [diff] [blame] | 388 | pur_disp_elf2flt = echo " "ELF2FLT $(ELF2FLTFLAGS) $(show_objs) |
Bernhard Reutner-Fischer | df10094 | 2006-03-13 19:04:00 +0000 | [diff] [blame] | 389 | sil_disp_compile.c = true |
| 390 | sil_disp_compile.h = true |
| 391 | sil_disp_strip = true |
| 392 | sil_disp_link = true |
Bernhard Reutner-Fischer | 45d5458 | 2006-05-08 20:20:32 +0000 | [diff] [blame] | 393 | sil_disp_link.h = true |
Bernhard Reutner-Fischer | df10094 | 2006-03-13 19:04:00 +0000 | [diff] [blame] | 394 | sil_disp_ar = true |
Mike Frysinger | 586ea61 | 2006-04-21 01:18:07 +0000 | [diff] [blame] | 395 | sil_disp_elf2flt = true |
Bernhard Reutner-Fischer | df10094 | 2006-03-13 19:04:00 +0000 | [diff] [blame] | 396 | ver_disp_compile.c = echo $(cmd_compile.c) |
| 397 | ver_disp_compile.h = echo $(cmd_compile.h) |
| 398 | ver_disp_strip = echo $(cmd_strip) |
| 399 | ver_disp_link = echo $(cmd_link) |
Bernhard Reutner-Fischer | 45d5458 | 2006-05-08 20:20:32 +0000 | [diff] [blame] | 400 | ver_disp_link.h = echo $(cmd_link.h) |
Bernhard Reutner-Fischer | df10094 | 2006-03-13 19:04:00 +0000 | [diff] [blame] | 401 | ver_disp_ar = echo $(cmd_ar) |
Mike Frysinger | 586ea61 | 2006-04-21 01:18:07 +0000 | [diff] [blame] | 402 | ver_disp_elf2flt = echo $(cmd_elf2flt) |
Mike Frysinger | b38673f | 2006-02-02 01:41:53 +0000 | [diff] [blame] | 403 | disp_compile.c = $($(DISP)_disp_compile.c) |
| 404 | disp_compile.h = $($(DISP)_disp_compile.h) |
| 405 | disp_strip = $($(DISP)_disp_strip) |
| 406 | disp_link = $($(DISP)_disp_link) |
Bernhard Reutner-Fischer | 45d5458 | 2006-05-08 20:20:32 +0000 | [diff] [blame] | 407 | disp_link.h = $($(DISP)_disp_link.h) |
Mike Frysinger | b38673f | 2006-02-02 01:41:53 +0000 | [diff] [blame] | 408 | disp_ar = $($(DISP)_disp_ar) |
Bernhard Reutner-Fischer | df10094 | 2006-03-13 19:04:00 +0000 | [diff] [blame] | 409 | disp_gen = $(SECHO) " "GEN $@ ; true |
| 410 | disp_doc = $(SECHO) " "DOC $(subst docs/,,$@) ; true |
Mike Frysinger | 586ea61 | 2006-04-21 01:18:07 +0000 | [diff] [blame] | 411 | disp_elf2flt = $($(DISP)_disp_elf2flt) |
Bernhard Reutner-Fischer | df10094 | 2006-03-13 19:04:00 +0000 | [diff] [blame] | 412 | cmd_compile.c = $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $< |
Bernhard Reutner-Fischer | 45d5458 | 2006-05-08 20:20:32 +0000 | [diff] [blame] | 413 | cmd_compile.h = $(HOSTCC) $(HOSTCFLAGS) $(INCS) -c -o $@ $< |
Mike Frysinger | b38673f | 2006-02-02 01:41:53 +0000 | [diff] [blame] | 414 | cmd_strip = $(STRIPCMD) $@ |
Bernhard Reutner-Fischer | 7b8ff22 | 2006-06-13 14:20:17 +0000 | [diff] [blame] | 415 | cmd_link = $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS) \ |
| 416 | $(PROG_CFLAGS) $(PROG_LDFLAGS) $(CFLAGS_COMBINE) \ |
| 417 | -o $@ $(LD_START_GROUP) \ |
| 418 | $(APPLETS_DEFINE) $(APPLET_SRC) \ |
| 419 | $(BUSYBOX_DEFINE) $(BUSYBOX_SRC) $(libraries-y) \ |
| 420 | $(LDBUSYBOX) $(LIBRARIES) \ |
| 421 | $(LD_END_GROUP) |
| 422 | cmd_link.so = $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS) \ |
| 423 | $(LIB_CFLAGS) $(CFLAGS_COMBINE) $(LIB_LDFLAGS) \ |
| 424 | -o $(@) $(LD_START_GROUP) $(LD_WHOLE_ARCHIVE) \ |
| 425 | $(LIBRARY_DEFINE) $(^) \ |
| 426 | $(LD_NO_WHOLE_ARCHIVE) $(LD_END_GROUP) |
Bernhard Reutner-Fischer | 45d5458 | 2006-05-08 20:20:32 +0000 | [diff] [blame] | 427 | cmd_link.h = $(HOSTCC) $(HOSTCFLAGS) $(INCS) $< -o $@ |
Mike Frysinger | b38673f | 2006-02-02 01:41:53 +0000 | [diff] [blame] | 428 | cmd_ar = $(AR) $(ARFLAGS) $@ $^ |
Mike Frysinger | 586ea61 | 2006-04-21 01:18:07 +0000 | [diff] [blame] | 429 | cmd_elf2flt = $(ELF2FLT) $(ELF2FLTFLAGS) $< -o $@ |
Bernhard Reutner-Fischer | df10094 | 2006-03-13 19:04:00 +0000 | [diff] [blame] | 430 | compile.c = @$(disp_compile.c) ; $(cmd_compile.c) |
| 431 | compile.h = @$(disp_compile.h) ; $(cmd_compile.h) |
| 432 | do_strip = @$(disp_strip) ; $(cmd_strip) |
| 433 | do_link = @$(disp_link) ; $(cmd_link) |
Bernhard Reutner-Fischer | 7b8ff22 | 2006-06-13 14:20:17 +0000 | [diff] [blame] | 434 | do_link.so = @$(disp_link) ; $(cmd_link.so) |
Bernhard Reutner-Fischer | 45d5458 | 2006-05-08 20:20:32 +0000 | [diff] [blame] | 435 | do_link.h = @$(disp_link.h) ; $(cmd_link.h) |
Bernhard Reutner-Fischer | df10094 | 2006-03-13 19:04:00 +0000 | [diff] [blame] | 436 | do_ar = @$(disp_ar) ; $(cmd_ar) |
Mike Frysinger | 586ea61 | 2006-04-21 01:18:07 +0000 | [diff] [blame] | 437 | do_elf2flt = @$(disp_elf2flt) ; $(cmd_elf2flt) |
Mike Frysinger | b38673f | 2006-02-02 01:41:53 +0000 | [diff] [blame] | 438 | |
Bernhard Reutner-Fischer | e5de384 | 2006-06-10 14:58:33 +0000 | [diff] [blame] | 439 | uppercase = $(shell echo $1 | $(SED) -e "y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/") |
Mike Frysinger | 6143c07 | 2006-05-10 18:12:16 +0000 | [diff] [blame] | 440 | %.a: |
| 441 | @if test -z "$($(call uppercase,$*)_DIR)" ; then \ |
| 442 | echo "Invalid target $@" ; \ |
| 443 | exit 1 ; \ |
| 444 | fi |
| 445 | $(Q)$(MAKE) $($(call uppercase,$*)_DIR)$@ |
| 446 | |
Eric Andersen | 85208e2 | 2002-04-12 12:05:57 +0000 | [diff] [blame] | 447 | .PHONY: dummy |