3
0

Makefile.flags 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. # ==========================================================================
  2. # Build system
  3. # ==========================================================================
  4. BB_VER = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
  5. export BB_VER
  6. SKIP_STRIP = n
  7. # -std=gnu99 needed for [U]LLONG_MAX on some systems
  8. CPPFLAGS += $(call cc-option,-std=gnu99,)
  9. CPPFLAGS += \
  10. -Iinclude -Ilibbb \
  11. $(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include -I$(srctree)/libbb) \
  12. -include include/autoconf.h \
  13. -D_GNU_SOURCE -DNDEBUG \
  14. $(if $(CONFIG_LFS),-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64) \
  15. -D"BB_VER=KBUILD_STR($(BB_VER))" -DBB_BT=AUTOCONF_TIMESTAMP
  16. CFLAGS += $(call cc-option,-Wall,)
  17. CFLAGS += $(call cc-option,-Wshadow,)
  18. CFLAGS += $(call cc-option,-Wwrite-strings,)
  19. CFLAGS += $(call cc-option,-Wundef,)
  20. CFLAGS += $(call cc-option,-Wstrict-prototypes,)
  21. CFLAGS += $(call cc-option,-Wunused -Wunused-parameter,)
  22. CFLAGS += $(call cc-option,-Wmissing-prototypes -Wmissing-declarations,)
  23. # warn about C99 declaration after statement
  24. CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
  25. # If you want to add more -Wsomething above, make sure that it is
  26. # still possible to build bbox without warnings.
  27. ifeq ($(CONFIG_WERROR),y)
  28. CFLAGS += $(call cc-option,-Werror,)
  29. endif
  30. # gcc 3.x emits bogus "old style proto" warning on find.c:alloc_action()
  31. CFLAGS += $(call cc-ifversion, -ge, 0400, -Wold-style-definition)
  32. CFLAGS += $(call cc-option,-fno-builtin-strlen -finline-limit=0 -fomit-frame-pointer -ffunction-sections -fdata-sections,)
  33. # -fno-guess-branch-probability: prohibit pseudo-random guessing
  34. # of branch probabilities (hopefully makes bloatcheck more stable):
  35. CFLAGS += $(call cc-option,-fno-guess-branch-probability,)
  36. CFLAGS += $(call cc-option,-funsigned-char -static-libgcc,)
  37. CFLAGS += $(call cc-option,-falign-functions=1 -falign-jumps=1 -falign-labels=1 -falign-loops=1,)
  38. # FIXME: These warnings are at least partially to be concerned about and should
  39. # be fixed..
  40. #CFLAGS += $(call cc-option,-Wconversion,)
  41. ifneq ($(CONFIG_DEBUG),y)
  42. CFLAGS += $(call cc-option,-Os,)
  43. else
  44. CFLAGS += $(call cc-option,-g,)
  45. #CFLAGS += "-D_FORTIFY_SOURCE=2"
  46. ifeq ($(CONFIG_DEBUG_PESSIMIZE),y)
  47. CFLAGS += $(call cc-option,-O0,)
  48. else
  49. CFLAGS += $(call cc-option,-Os,)
  50. endif
  51. endif
  52. # If arch/$(ARCH)/Makefile did not override it (with, say, -fPIC)...
  53. ARCH_FPIC ?= -fpic
  54. ARCH_FPIE ?= -fpie
  55. ARCH_PIE ?= -pie
  56. ifeq ($(CONFIG_BUILD_LIBBUSYBOX),y)
  57. # on i386: 14% smaller libbusybox.so
  58. # (code itself is 9% bigger, we save on relocs/PLT/GOT)
  59. CFLAGS += $(ARCH_FPIC)
  60. # and another 4% reduction of libbusybox.so:
  61. # (external entry points must be marked EXTERNALLY_VISIBLE)
  62. CFLAGS += $(call cc-option,-fvisibility=hidden)
  63. endif
  64. ifeq ($(CONFIG_STATIC),y)
  65. CFLAGS_busybox += -static
  66. endif
  67. ifeq ($(CONFIG_PIE),y)
  68. CFLAGS_busybox += $(ARCH_PIE)
  69. CFLAGS += $(ARCH_FPIE)
  70. endif
  71. LDLIBS += m crypt
  72. ifeq ($(CONFIG_PAM),y)
  73. LDLIBS += pam pam_misc
  74. endif
  75. ifeq ($(CONFIG_SELINUX),y)
  76. LDLIBS += selinux sepol
  77. endif
  78. ifeq ($(CONFIG_EFENCE),y)
  79. LDLIBS += efence
  80. endif
  81. ifeq ($(CONFIG_DMALLOC),y)
  82. LDLIBS += dmalloc
  83. endif
  84. # If a flat binary should be built, CFLAGS_busybox="-Wl,-elf2flt"
  85. # env var should be set for make invocation.
  86. # Here we check whether CFLAGS_busybox indeed contains that flag.
  87. # (For historical reasons, we also check LDFLAGS, which doesn't
  88. # seem to be entirely correct variable to put "-Wl,-elf2flt" into).
  89. W_ELF2FLT = -Wl,-elf2flt
  90. ifneq (,$(findstring $(W_ELF2FLT),$(LDFLAGS) $(CFLAGS_busybox)))
  91. SKIP_STRIP = y
  92. endif
  93. # Busybox is a stack-fatty so make sure we increase default size
  94. # TODO: use "make stksizes" to find & fix big stack users
  95. # (we stole scripts/checkstack.pl from the kernel... thanks guys!)
  96. # Reduced from 20k to 16k in 1.9.0.
  97. FLTFLAGS += -s 16000