Denis Vlasenko | 7d219aa | 2006-10-05 10:17:08 +0000 | [diff] [blame] | 1 | # ========================================================================== |
Denis Vlasenko | da8f43f | 2006-10-09 19:47:38 +0000 | [diff] [blame] | 2 | # Build system |
Denis Vlasenko | 7d219aa | 2006-10-05 10:17:08 +0000 | [diff] [blame] | 3 | # ========================================================================== |
| 4 | |
| 5 | BB_VER = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) |
Mike Frysinger | 5b5bcf2 | 2007-06-19 15:58:02 +0000 | [diff] [blame] | 6 | SKIP_STRIP = n |
Denis Vlasenko | 7d219aa | 2006-10-05 10:17:08 +0000 | [diff] [blame] | 7 | |
Denis Vlasenko | bf11e89 | 2006-11-26 22:17:46 +0000 | [diff] [blame] | 8 | # -std=gnu99 needed for [U]LLONG_MAX on some systems |
Bernhard Reutner-Fischer | 82f8788 | 2007-01-23 11:39:13 +0000 | [diff] [blame] | 9 | CPPFLAGS += $(call cc-option,-std=gnu99,) |
Denis Vlasenko | 9dca07d | 2007-01-27 14:03:15 +0000 | [diff] [blame] | 10 | |
Denis Vlasenko | 7039a66 | 2006-10-08 17:54:47 +0000 | [diff] [blame] | 11 | CPPFLAGS += \ |
| 12 | -Iinclude -Ilibbb \ |
| 13 | $(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include) -I$(srctree)/libbb \ |
| 14 | -include include/autoconf.h \ |
| 15 | -D_GNU_SOURCE -DNDEBUG \ |
| 16 | $(if $(CONFIG_LFS),-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64) \ |
Bernhard Reutner-Fischer | feea1b9 | 2006-12-06 21:51:59 +0000 | [diff] [blame] | 17 | -D"BB_VER=KBUILD_STR($(BB_VER))" -DBB_BT=AUTOCONF_TIMESTAMP |
| 18 | |
Bernhard Reutner-Fischer | 82f8788 | 2007-01-23 11:39:13 +0000 | [diff] [blame] | 19 | # flag checks are grouped together to speed the checks up a bit.. |
Denis Vlasenko | 4bb3189 | 2007-02-01 01:51:36 +0000 | [diff] [blame] | 20 | CFLAGS += $(call cc-option,-Wall -Wshadow -Wwrite-strings,) |
Denis Vlasenko | c562bb7 | 2007-01-29 17:08:51 +0000 | [diff] [blame] | 21 | CFLAGS += $(call cc-option,-Wundef -Wstrict-prototypes,) |
Denis Vlasenko | 9dca07d | 2007-01-27 14:03:15 +0000 | [diff] [blame] | 22 | # If you want to add "-Wmissing-prototypes -Wmissing-declarations" above |
| 23 | # (or anything else for that matter) make sure that it is still possible |
| 24 | # to build bbox without warnings. Current offender: find.c:alloc_action(). |
| 25 | # Looks more like gcc bug: gcc will warn on it with or without prototype. |
| 26 | # But still, warning-free compile is a must, or else we will drown |
| 27 | # in warnings pretty soon. |
Denis Vlasenko | c562bb7 | 2007-01-29 17:08:51 +0000 | [diff] [blame] | 28 | |
Denis Vlasenko | 4bb3189 | 2007-02-01 01:51:36 +0000 | [diff] [blame] | 29 | ifeq ($(CONFIG_WERROR),y) |
| 30 | CFLAGS += $(call cc-option,-Werror,) |
Bernhard Reutner-Fischer | b7e6148 | 2007-06-21 10:28:11 +0000 | [diff] [blame] | 31 | else |
| 32 | # for development, warn a little bit about unused results.. |
| 33 | CPPFLAGS += -D_FORTIFY_SOURCE=2 |
Denis Vlasenko | 4bb3189 | 2007-02-01 01:51:36 +0000 | [diff] [blame] | 34 | endif |
Denis Vlasenko | c562bb7 | 2007-01-29 17:08:51 +0000 | [diff] [blame] | 35 | # gcc 3.x emits bogus "old style proto" warning on find.c:alloc_action() |
| 36 | CFLAGS += $(call cc-ifversion, -ge, 0400, -Wold-style-definition) |
| 37 | |
| 38 | # gcc emits bogus "no prev proto" warning on find.c:alloc_action() |
Denis Vlasenko | 9dca07d | 2007-01-27 14:03:15 +0000 | [diff] [blame] | 39 | ifneq ($(CONFIG_WERROR),y) |
| 40 | CFLAGS += $(call cc-option,-Wmissing-prototypes -Wmissing-declarations,) |
| 41 | endif |
Denis Vlasenko | c562bb7 | 2007-01-29 17:08:51 +0000 | [diff] [blame] | 42 | |
Bernhard Reutner-Fischer | 82f8788 | 2007-01-23 11:39:13 +0000 | [diff] [blame] | 43 | CFLAGS += $(call cc-option,-Os -fno-builtin-strlen -finline-limit=0 -fomit-frame-pointer -ffunction-sections -fdata-sections,) |
Denis Vlasenko | e0eebc1 | 2007-01-27 13:44:53 +0000 | [diff] [blame] | 44 | # -fno-guess-branch-probability: prohibit pseudo-random guessing |
Denis Vlasenko | 9dca07d | 2007-01-27 14:03:15 +0000 | [diff] [blame] | 45 | # of branch probabilities (hopefully makes bloatcheck more stable): |
| 46 | CFLAGS += $(call cc-option,-fno-guess-branch-probability,) |
| 47 | CFLAGS += $(call cc-option,-funsigned-char -static-libgcc,) |
Denis Vlasenko | e0eebc1 | 2007-01-27 13:44:53 +0000 | [diff] [blame] | 48 | CFLAGS += $(call cc-option,-falign-functions=1 -falign-jumps=1 -falign-labels=1 -falign-loops=1,) |
Bernhard Reutner-Fischer | 82f8788 | 2007-01-23 11:39:13 +0000 | [diff] [blame] | 49 | |
Bernhard Reutner-Fischer | fdcd7c4 | 2007-01-22 17:50:21 +0000 | [diff] [blame] | 50 | # FIXME: These warnings are at least partially to be concerned about and should |
| 51 | # be fixed.. |
Bernhard Reutner-Fischer | 82f8788 | 2007-01-23 11:39:13 +0000 | [diff] [blame] | 52 | #CFLAGS+=$(call cc-option,-Wconversion,) |
Bernhard Reutner-Fischer | 9729e65 | 2006-12-13 17:44:24 +0000 | [diff] [blame] | 53 | |
| 54 | ifeq ($(CONFIG_DEBUG),y) |
Bernhard Reutner-Fischer | 82f8788 | 2007-01-23 11:39:13 +0000 | [diff] [blame] | 55 | CFLAGS += $(call cc-option,-g) |
Bernhard Reutner-Fischer | 9729e65 | 2006-12-13 17:44:24 +0000 | [diff] [blame] | 56 | endif |
| 57 | |
Bernhard Reutner-Fischer | c1feac6 | 2007-01-08 16:29:15 +0000 | [diff] [blame] | 58 | ifeq ($(CONFIG_STATIC),y) |
| 59 | LDFLAGS += -static |
| 60 | endif |
Denis Vlasenko | d46d3c2 | 2007-02-06 19:28:50 +0000 | [diff] [blame] | 61 | |
Denis Vlasenko | 150d2fa | 2007-07-17 20:39:27 +0000 | [diff] [blame] | 62 | BBOX_LIB_LIST = m crypt |
Denis Vlasenko | d6e81c7 | 2007-08-21 10:58:18 +0000 | [diff] [blame] | 63 | |
| 64 | ifeq ($(CONFIG_PAM),y) |
| 65 | BBOX_LIB_LIST += pam pam_misc |
| 66 | endif |
| 67 | |
Denis Vlasenko | d46d3c2 | 2007-02-06 19:28:50 +0000 | [diff] [blame] | 68 | ifeq ($(CONFIG_SELINUX),y) |
Denis Vlasenko | 150d2fa | 2007-07-17 20:39:27 +0000 | [diff] [blame] | 69 | BBOX_LIB_LIST += selinux sepol |
Denis Vlasenko | d46d3c2 | 2007-02-06 19:28:50 +0000 | [diff] [blame] | 70 | endif |
Bernhard Reutner-Fischer | 58a275b | 2007-03-28 15:00:27 +0000 | [diff] [blame] | 71 | |
| 72 | ifeq ($(CONFIG_EFENCE),y) |
Denis Vlasenko | 150d2fa | 2007-07-17 20:39:27 +0000 | [diff] [blame] | 73 | BBOX_LIB_LIST += efence |
Bernhard Reutner-Fischer | 58a275b | 2007-03-28 15:00:27 +0000 | [diff] [blame] | 74 | endif |
| 75 | |
| 76 | ifeq ($(CONFIG_DMALLOC),y) |
Denis Vlasenko | 150d2fa | 2007-07-17 20:39:27 +0000 | [diff] [blame] | 77 | BBOX_LIB_LIST += dmalloc |
Bernhard Reutner-Fischer | 58a275b | 2007-03-28 15:00:27 +0000 | [diff] [blame] | 78 | endif |
| 79 | |
Denis Vlasenko | 150d2fa | 2007-07-17 20:39:27 +0000 | [diff] [blame] | 80 | # For scripts/trylink |
| 81 | export BBOX_LIB_LIST |
| 82 | |
Bernhard Reutner-Fischer | d6c23ae | 2007-01-08 16:38:33 +0000 | [diff] [blame] | 83 | #LDFLAGS += -nostdlib |
Mike Frysinger | c7b10dc | 2007-04-05 21:10:59 +0000 | [diff] [blame] | 84 | |
Mike Frysinger | 5b5bcf2 | 2007-06-19 15:58:02 +0000 | [diff] [blame] | 85 | LDFLAGS_ELF2FLT = -Wl,-elf2flt |
| 86 | ifneq (,$(findstring $(LDFLAGS_ELF2FLT),$(LDFLAGS))) |
| 87 | SKIP_STRIP = y |
| 88 | endif |
| 89 | |
Mike Frysinger | c7b10dc | 2007-04-05 21:10:59 +0000 | [diff] [blame] | 90 | # Busybox is a stack-fatty so make sure we increase default size |
Denis Vlasenko | 931de89 | 2007-06-21 12:43:45 +0000 | [diff] [blame] | 91 | # TODO: use "make stksizes" to find & fix big stack users |
| 92 | # (we stole scripts/checkstack.pl from the kernel... thanks guys!) |
Mike Frysinger | c7b10dc | 2007-04-05 21:10:59 +0000 | [diff] [blame] | 93 | FLTFLAGS += -s 20000 |