Replace current verbose GPL stuff in libbb/*.c with one-line GPL boilerplate.
[oweals/busybox.git] / Rules.mak
index cce41dcb9f54efd9fb048d1abc49428090dde91a..6df828c7c658a03fb75114b2a2eab871ee62081f 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,25 +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)))
-
-# 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
@@ -83,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/' \
@@ -102,7 +81,7 @@ endif
 # A nifty macro to make testing gcc features easier, but note that everything
 # that uses this _must_ use := or it will be re-evaluated everytime it is
 # referenced.
-ifeq ($(strip $(V)),2)
+ifeq ($(strip $(BUILD_VERBOSE)),2)
 VERBOSE_CHECK_CC=echo CC=\"$(1)\" check_cc $(2) >&2;
 endif
 check_cc=$(shell \
@@ -114,8 +93,12 @@ check_cc=$(shell \
                rm -f conftest.c conftest.o; \
        fi)
 
+ifneq ($(filter $(nocheck_targets),$(MAKECMDGOALS)),)
+check_cc:=
+endif
+
 # A not very robust macro to check for available ld flags
-ifeq ($(strip $(V)),2)
+ifeq ($(strip $(BUILD_VERBOSE)),2)
 VERBOSE_CHECK_LD=echo LD=\"$(1)\" check_ld $(2) >&2;
 endif
 check_ld=$(shell \
@@ -125,8 +108,12 @@ check_ld=$(shell \
                echo "-Wl,$(2)" ; \
        fi)
 
+ifneq ($(filter $(nocheck_targets),$(MAKECMDGOALS)),)
+check_ld:=
+endif
+
 # A not very robust macro to check for available strip flags
-ifeq ($(strip $(V)),2)
+ifeq ($(strip $(BUILD_VERBOSE)),2)
 VERBOSE_CHECK_STRIP=echo STRIPCMD=\"$(1)\" check_strip $(2) >&2;
 endif
 check_strip=$(shell \
@@ -139,6 +126,9 @@ check_strip=$(shell \
                rm -f conftest.c conftest.o > /dev/null 2>&1 ; \
        fi)
 
+ifneq ($(filter $(nocheck_targets),$(MAKECMDGOALS)),)
+check_strip:=
+endif
 
 
 # Select the compiler needed to build binaries for your development system
@@ -169,7 +159,7 @@ LD_START_GROUP:=$(shell echo "int bar(void){return 0;}" > conftest.c ; \
        $(AR) $(ARFLAGS) conftest.a conftest.o ; \
        $(CC) -Wl,--start-group conftest.a conftest_main.o -Wl,--end-group \
         -o conftest > /dev/null 2>&1 && echo "-Wl,--start-group" ; \
-       echo rm conftest_main.o conftest_main.c conftest.o conftest.c \
+       rm conftest_main.o conftest_main.c conftest.o conftest.c \
         conftest.a conftest > /dev/null 2>&1 ; )
 ifneq ($(findstring start-group,$(LD_START_GROUP)),)
 LD_END_GROUP:= -Wl,--end-group
@@ -184,6 +174,7 @@ 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),-finline-limit=0)
 
 # Preemptively pin this too.
 PROG_CFLAGS:=
@@ -241,6 +232,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,)
 
 #
 #--------------------------------------------------------
@@ -272,6 +264,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)
@@ -308,9 +301,9 @@ ifeq ($(strip $(PREFIX)),)
     PREFIX:=`pwd`/_install
 endif
 
-#ifneq ($(strip $(CONFIG_GETOPT_LONG)),y)
-#    CFLAGS += -D__need_getopt
-#endif
+ifneq ($(strip $(CONFIG_GETOPT_LONG)),y)
+    CFLAGS += -D__need_getopt
+endif
 
 # Additional complications due to support for pristine source dir.
 # Include files in the build directory should take precedence over
@@ -329,7 +322,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
@@ -353,7 +346,7 @@ SECHO := @-false
 DISP  := sil
 Q     := @
 else
-ifneq ($(V)$(VERBOSE),)
+ifneq ($(BUILD_VERBOSE),)
 SECHO := @-false
 DISP  := ver
 Q     := 
@@ -398,7 +391,18 @@ disp_elf2flt       = $($(DISP)_disp_elf2flt)
 cmd_compile.c      = $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
 cmd_compile.h      = $(HOSTCC) $(HOSTCFLAGS) $(INCS) -c -o $@ $<
 cmd_strip          = $(STRIPCMD) $@
-cmd_link           = $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS)
+cmd_link           = $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS) \
+                       $(PROG_CFLAGS) $(PROG_LDFLAGS) $(CFLAGS_COMBINE) \
+                       -o $@ $(LD_START_GROUP)  \
+                       $(APPLETS_DEFINE) $(APPLET_SRC) \
+                       $(BUSYBOX_DEFINE) $(BUSYBOX_SRC) $(libraries-y) \
+                       $(LDBUSYBOX) $(LIBRARIES) \
+                       $(LD_END_GROUP)
+cmd_link.so        = $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS) \
+                       $(LIB_CFLAGS) $(CFLAGS_COMBINE) $(LIB_LDFLAGS) \
+                       -o $(@) $(LD_START_GROUP) $(LD_WHOLE_ARCHIVE) \
+                       $(LIBRARY_DEFINE) $(^) \
+                       $(LD_NO_WHOLE_ARCHIVE) $(LD_END_GROUP)
 cmd_link.h         = $(HOSTCC) $(HOSTCFLAGS) $(INCS) $< -o $@
 cmd_ar             = $(AR) $(ARFLAGS) $@ $^
 cmd_elf2flt        = $(ELF2FLT) $(ELF2FLTFLAGS) $< -o $@
@@ -406,11 +410,12 @@ compile.c          = @$(disp_compile.c) ; $(cmd_compile.c)
 compile.h          = @$(disp_compile.h) ; $(cmd_compile.h)
 do_strip           = @$(disp_strip)     ; $(cmd_strip)
 do_link            = @$(disp_link)      ; $(cmd_link)
+do_link.so         = @$(disp_link)      ; $(cmd_link.so)
 do_link.h          = @$(disp_link.h)    ; $(cmd_link.h)
 do_ar              = @$(disp_ar)        ; $(cmd_ar)
 do_elf2flt         = @$(disp_elf2flt)   ; $(cmd_elf2flt)
 
-uppercase = $(shell echo $1 | tr '[:lower:]' '[:upper:]')
+uppercase = $(shell echo $1 | $(SED) -e "y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/")
 %.a:
        @if test -z "$($(call uppercase,$*)_DIR)" ; then \
                echo "Invalid target $@" ; \