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