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) |
| 6 | |
Denis Vlasenko | bf11e89 | 2006-11-26 22:17:46 +0000 | [diff] [blame] | 7 | # -std=gnu99 needed for [U]LLONG_MAX on some systems |
Bernhard Reutner-Fischer | 82f8788 | 2007-01-23 11:39:13 +0000 | [diff] [blame] | 8 | CPPFLAGS += $(call cc-option,-std=gnu99,) |
Denis Vlasenko | 9dca07d | 2007-01-27 14:03:15 +0000 | [diff] [blame] | 9 | |
Denis Vlasenko | 7039a66 | 2006-10-08 17:54:47 +0000 | [diff] [blame] | 10 | CPPFLAGS += \ |
| 11 | -Iinclude -Ilibbb \ |
| 12 | $(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include) -I$(srctree)/libbb \ |
| 13 | -include include/autoconf.h \ |
| 14 | -D_GNU_SOURCE -DNDEBUG \ |
| 15 | $(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] | 16 | -D"BB_VER=KBUILD_STR($(BB_VER))" -DBB_BT=AUTOCONF_TIMESTAMP |
| 17 | |
Bernhard Reutner-Fischer | 82f8788 | 2007-01-23 11:39:13 +0000 | [diff] [blame] | 18 | # flag checks are grouped together to speed the checks up a bit.. |
Denis Vlasenko | 4bb3189 | 2007-02-01 01:51:36 +0000 | [diff] [blame] | 19 | CFLAGS += $(call cc-option,-Wall -Wshadow -Wwrite-strings,) |
Denis Vlasenko | c562bb7 | 2007-01-29 17:08:51 +0000 | [diff] [blame] | 20 | CFLAGS += $(call cc-option,-Wundef -Wstrict-prototypes,) |
Denis Vlasenko | 9dca07d | 2007-01-27 14:03:15 +0000 | [diff] [blame] | 21 | # If you want to add "-Wmissing-prototypes -Wmissing-declarations" above |
| 22 | # (or anything else for that matter) make sure that it is still possible |
| 23 | # to build bbox without warnings. Current offender: find.c:alloc_action(). |
| 24 | # Looks more like gcc bug: gcc will warn on it with or without prototype. |
| 25 | # But still, warning-free compile is a must, or else we will drown |
| 26 | # in warnings pretty soon. |
Denis Vlasenko | c562bb7 | 2007-01-29 17:08:51 +0000 | [diff] [blame] | 27 | |
Denis Vlasenko | 4bb3189 | 2007-02-01 01:51:36 +0000 | [diff] [blame] | 28 | ifeq ($(CONFIG_WERROR),y) |
| 29 | CFLAGS += $(call cc-option,-Werror,) |
| 30 | endif |
Denis Vlasenko | c562bb7 | 2007-01-29 17:08:51 +0000 | [diff] [blame] | 31 | # gcc 3.x emits bogus "old style proto" warning on find.c:alloc_action() |
| 32 | CFLAGS += $(call cc-ifversion, -ge, 0400, -Wold-style-definition) |
| 33 | |
| 34 | # gcc emits bogus "no prev proto" warning on find.c:alloc_action() |
Denis Vlasenko | 9dca07d | 2007-01-27 14:03:15 +0000 | [diff] [blame] | 35 | ifneq ($(CONFIG_WERROR),y) |
| 36 | CFLAGS += $(call cc-option,-Wmissing-prototypes -Wmissing-declarations,) |
| 37 | endif |
Denis Vlasenko | c562bb7 | 2007-01-29 17:08:51 +0000 | [diff] [blame] | 38 | |
Bernhard Reutner-Fischer | 82f8788 | 2007-01-23 11:39:13 +0000 | [diff] [blame] | 39 | 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] | 40 | # -fno-guess-branch-probability: prohibit pseudo-random guessing |
Denis Vlasenko | 9dca07d | 2007-01-27 14:03:15 +0000 | [diff] [blame] | 41 | # of branch probabilities (hopefully makes bloatcheck more stable): |
| 42 | CFLAGS += $(call cc-option,-fno-guess-branch-probability,) |
| 43 | CFLAGS += $(call cc-option,-funsigned-char -static-libgcc,) |
Denis Vlasenko | e0eebc1 | 2007-01-27 13:44:53 +0000 | [diff] [blame] | 44 | 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] | 45 | |
Bernhard Reutner-Fischer | fdcd7c4 | 2007-01-22 17:50:21 +0000 | [diff] [blame] | 46 | # FIXME: These warnings are at least partially to be concerned about and should |
| 47 | # be fixed.. |
Bernhard Reutner-Fischer | 82f8788 | 2007-01-23 11:39:13 +0000 | [diff] [blame] | 48 | #CFLAGS+=$(call cc-option,-Wconversion,) |
Bernhard Reutner-Fischer | 9729e65 | 2006-12-13 17:44:24 +0000 | [diff] [blame] | 49 | |
| 50 | ifeq ($(CONFIG_DEBUG),y) |
Bernhard Reutner-Fischer | 82f8788 | 2007-01-23 11:39:13 +0000 | [diff] [blame] | 51 | CFLAGS += $(call cc-option,-g) |
Bernhard Reutner-Fischer | 9729e65 | 2006-12-13 17:44:24 +0000 | [diff] [blame] | 52 | endif |
| 53 | |
Bernhard Reutner-Fischer | c1feac6 | 2007-01-08 16:29:15 +0000 | [diff] [blame] | 54 | ifeq ($(CONFIG_STATIC),y) |
| 55 | LDFLAGS += -static |
| 56 | endif |
Denis Vlasenko | d46d3c2 | 2007-02-06 19:28:50 +0000 | [diff] [blame] | 57 | |
| 58 | ifeq ($(CONFIG_SELINUX),y) |
| 59 | LDFLAGS += -lselinux -lsepol |
| 60 | endif |
Bernhard Reutner-Fischer | d6c23ae | 2007-01-08 16:38:33 +0000 | [diff] [blame] | 61 | #LDFLAGS += -nostdlib |