Try to make a "type-punned pointer" warning go away for somebody on the
[oweals/busybox.git] / Rules.mak
index 550fe19bf54353a7f9cdc7bd135ef29898b9fbd4..866e555ebde0e8eabdf82676a39a19c42e5535f3 100644 (file)
--- a/Rules.mak
+++ b/Rules.mak
@@ -15,7 +15,7 @@ PROG      := busybox
 MAJOR_VERSION   :=1
 MINOR_VERSION   :=2
 SUBLEVEL_VERSION:=0
-EXTRAVERSION    :=-pre0
+EXTRAVERSION    :=
 VERSION   :=$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL_VERSION)$(EXTRAVERSION)
 BUILDTIME := $(shell TZ=UTC date -u "+%Y.%m.%d-%H:%M%z")
 
@@ -24,22 +24,20 @@ BUILDTIME := $(shell TZ=UTC date -u "+%Y.%m.%d-%H:%M%z")
 # With a modern GNU make(1) (highly recommended, that's what all the
 # developers use), all of the following configuration values can be
 # overridden at the command line.  For example:
-#   make CROSS=powerpc-linux- top_srcdir="$HOME/busybox" PREFIX=/mnt/app
+#   make CROSS_COMPILE=powerpc-linux- top_srcdir="$HOME/busybox" PREFIX=/mnt/app
 #--------------------------------------------------------
 
-# If you are running a cross compiler, you will want to set 'CROSS'
+# If you are running a cross compiler, you will want to set CROSS_COMPILE
 # to something more interesting...  Target architecture is determined
 # by asking the CC compiler what arch it compiles things for, so unless
 # your compiler is broken, you should not need to specify TARGET_ARCH
-CROSS          =$(strip $(subst ",, $(strip $(CROSS_COMPILER_PREFIX))))
-# be gentle to vi coloring.. "))
-CC             = $(CROSS)gcc
-AR             = $(CROSS)ar
-AS             = $(CROSS)as
-LD             = $(CROSS)ld
-NM             = $(CROSS)nm
-STRIP          = $(CROSS)strip
-ELF2FLT        = $(CROSS)elf2flt
+CC             = $(CROSS_COMPILE)gcc
+AR             = $(CROSS_COMPILE)ar
+AS             = $(CROSS_COMPILE)as
+LD             = $(CROSS_COMPILE)ld
+NM             = $(CROSS_COMPILE)nm
+STRIP          = $(CROSS_COMPILE)strip
+ELF2FLT        = $(CROSS_COMPILE)elf2flt
 CPP            = $(CC) -E
 SED           ?= sed
 BZIP2         ?= bzip2
@@ -52,26 +50,6 @@ TARGET_OS=linux
 # Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc.
 LC_ALL:= C
 
-# If you want to add some simple compiler switches (like -march=i686),
-# especially from the command line, use this instead of CFLAGS directly.
-# For optimization overrides, it's better still to set OPTIMIZATION.
-CFLAGS_EXTRA=$(subst ",, $(strip $(EXTRA_CFLAGS_OPTIONS)))
-# be gentle to vi coloring.. ")
-
-# To compile vs some other alternative libc, you may need to use/adjust
-# the following lines to meet your needs...
-#
-# If you are using Red Hat 6.x with the compatible RPMs (for developing under
-# Red Hat 5.x and glibc 2.0) uncomment the following.  Be sure to read about
-# using the compatible RPMs (compat-*) at http://www.redhat.com !
-#LIBCDIR:=/usr/i386-glibc20-linux
-#
-# For other libraries, you are on your own.  But these may (or may not) help...
-#LDFLAGS+=-nostdlib
-#LIBRARIES:=$(LIBCDIR)/lib/libc.a -lgcc
-#CROSS_CFLAGS+=-nostdinc -I$(LIBCDIR)/include -I$(GCCINCDIR) -funsigned-char
-#GCCINCDIR:=$(shell gcc -print-search-dirs | $(SED) -ne "s/install: \(.*\)/\1include/gp")
-
 # This must bind late because srcdir is reset for every source subdirectory.
 INCS:=-I$(top_builddir)/include -I$(top_srcdir)/include
 CFLAGS=$(INCS) -I$(srcdir) -D_GNU_SOURCE
@@ -84,7 +62,7 @@ CC_MAJOR:=$(shell printf "%02d" $(shell echo __GNUC__ | $(CC) -E -xc - | tail -n
 CC_MINOR:=$(shell printf "%02d" $(shell echo __GNUC_MINOR__ | $(CC) -E -xc - | tail -n 1))
 
 #--------------------------------------------------------
-export VERSION BUILDTIME HOSTCC HOSTCFLAGS CROSS CC AR AS LD NM STRIP CPP
+export VERSION BUILDTIME HOSTCC HOSTCFLAGS CROSS_COMPILE CC AR AS LD NM STRIP CPP
 ifeq ($(strip $(TARGET_ARCH)),)
 TARGET_ARCH:=$(shell $(CC) -dumpmachine | $(SED) -e s'/-.*//' \
                -e 's/i.86/i386/' \
@@ -188,6 +166,7 @@ LD_END_GROUP:= -Wl,--end-group
 endif
 
 CHECKED_LDFLAGS := $(call check_ld,$(LD),--warn-common,)
+#CHECKED_LDFLAGS := $(call check_ld,$(LD),-static-libgcc,)
 
 # Pin CHECKED_CFLAGS with := so it's only evaluated once.
 CHECKED_CFLAGS:=$(call check_cc,$(CC),-Wall,)
@@ -195,7 +174,9 @@ CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wstrict-prototypes,)
 CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wshadow,)
 CHECKED_CFLAGS+=$(call check_cc,$(CC),-funsigned-char,)
 CHECKED_CFLAGS+=$(call check_cc,$(CC),-mmax-stack-frame=256,)
-CHECKED_CFLAGS+=$(call check_cc,$(CC),-fno-builtin-strlen)
+CHECKED_CFLAGS+=$(call check_cc,$(CC),-fno-builtin-strlen,)
+CHECKED_CFLAGS+=$(call check_cc,$(CC),-finline-limit=0,)
+CHECKED_CFLAGS+=$(call check_cc,$(CC),-static-libgcc,)
 
 # Preemptively pin this too.
 PROG_CFLAGS:=
@@ -236,11 +217,13 @@ endif
 ifeq ($(strip $(TARGET_ARCH)),i386)
        OPTIMIZATION+=$(call check_cc,$(CC),-march=i386,)
 # gcc-4.0 and older seem to benefit from these
-#ifneq ($(strip $(shell [ $(CC_MAJOR) -ge 4 -a $(CC_MINOR) -ge 1 ] ; echo $$?)),0)
+ifneq ($(strip $(shell [ $(CC_MAJOR) -ge 4 -a $(CC_MINOR) -ge 1 ] ; echo $$?)),0)
        OPTIMIZATION+=$(call check_cc,$(CC),-mpreferred-stack-boundary=2,)
-       OPTIMIZATION+=$(call check_cc,$(CC),-falign-functions=1 -falign-jumps=1 -falign-loops=1,\
-               -malign-functions=0 -malign-jumps=0 -malign-loops=0)
-#endif # gcc-4.0 and older
+       OPTIMIZATION+=$(call check_cc,$(CC),-falign-functions=1 -falign-jumps=1 -falign-loops=1, -malign-functions=0 -malign-jumps=0 -malign-loops=0,)
+
+       # gcc 4.1 produces many broken, totally invalid warnings
+       CHECKED_CFLAGS+=$(call check_cc,$(CC),-Werror,)
+endif # gcc-4.0 and older
 
 # gcc-4.1 and beyond seem to benefit from these
 ifeq ($(strip $(shell [ $(CC_MAJOR) -ge 4 -a $(CC_MINOR) -ge 1 ] ; echo $$?)),0)
@@ -253,6 +236,7 @@ ifeq ($(strip $(shell [ $(CC_MAJOR) -ge 4 -a $(CC_MINOR) -ge 1 ] ; echo $$?)),0)
 endif # gcc-4.1 and beyond
 endif
 OPTIMIZATION+=$(call check_cc,$(CC),-fomit-frame-pointer,)
+OPTIMIZATION+=$(call check_cc,$(CC),-ffunction-sections -fdata-sections,)
 
 #
 #--------------------------------------------------------
@@ -284,6 +268,7 @@ ifeq ($(strip $(CONFIG_DEBUG)),y)
 else
     CFLAGS +=-DNDEBUG
     CHECKED_LDFLAGS += $(call check_ld,$(LD),--sort-common,)
+    CHECKED_LDFLAGS += $(call check_ld,--gc-sections,)
 endif
 
 ifneq ($(strip $(CONFIG_DEBUG_PESSIMIZE)),y)
@@ -341,7 +326,7 @@ endif
 
 # Put user-supplied flags at the end, where they
 # have a chance of winning.
-CFLAGS += $(CFLAGS_EXTRA)
+-include $(top_builddir)/.config.mak
 
 #------------------------------------------------------------
 # Installation options