From: Bernhard Reutner-Fischer Date: Mon, 13 Mar 2006 19:04:00 +0000 (-0000) Subject: - revert back to r14406 X-Git-Tag: 1_1_0~87 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=df10094870c28cc0c6c5577c9aa03b8ede9cb8a6;p=oweals%2Fbusybox.git - revert back to r14406 --- diff --git a/Makefile b/Makefile index 879c4d6e5..fe346b0d4 100644 --- a/Makefile +++ b/Makefile @@ -15,18 +15,11 @@ noconfig_targets := menuconfig config oldconfig randconfig \ # the toplevel sourcedir ifndef top_srcdir -# make-3.79.1 didn't support MAKEFILE_LIST -# for building out-of-tree, users of make-3.79.1 still have to pass top_srcdir= -# to make: make -f /srcs/busybox/Makefile top_srcdir=/srcs/busybox -ifdef MAKEFILE_LIST -top_srcdir:=$(shell cd $(dir $(firstword $(MAKEFILE_LIST))) && pwd) -else -top_srcdir:=$(CURDIR) -endif +top_srcdir=$(CURDIR) endif # toplevel directory of the object-tree ifndef top_builddir -top_builddir:=$(CURDIR) +top_builddir=$(CURDIR) endif export srctree=$(top_srcdir) @@ -41,86 +34,79 @@ SRC_DIRS:=$(patsubst %,$(top_srcdir)/%,$(DIRS)) # That's our default target when none is given on the command line .PHONY: _all +_all: -_all: all +CONFIG_CONFIG_IN = $(top_srcdir)/Config.in -# see if we are in verbose mode -ifdef VERBOSE - CHECK_VERBOSE := -v - PACKAGE_BE_VERBOSE := $(VERBOSE) -endif -ifdef V - CHECK_VERBOSE := -v - PACKAGE_BE_VERBOSE := $(V) -endif +ifeq ($(KBUILD_SRC),) ifdef O ifeq ("$(origin O)", "command line") - PACKAGE_OUTPUTDIR := $(shell cd $(O) && pwd) - top_builddir := $(PACKAGE_OUTPUTDIR) + KBUILD_OUTPUT := $(O) + top_builddir := $(O) endif else # If no alternate output-dir was specified, we build in cwd - PACKAGE_OUTPUTDIR := $(top_builddir) +# We are using KBUILD_OUTPUT nevertheless to make sure that we create +# Rules.mak and the toplevel Makefile, in case they don't exist. + KBUILD_OUTPUT := $(top_builddir) endif -define check_gcc -$(if $(2),$(if $(shell $(CC) $(2) -S -o /dev/null -xc /dev/null > /dev/null 2>&1 && echo y),$(2),$(if $(3),$(3))),$(if $(3),$(3))) -endef - -define check_ld -$(if $(2),$(if $(shell $(LD) $(2) -o /dev/null -b binary /dev/null > /dev/null 2>&1 && echo y),$(shell echo \-Wl,$(2)),$(if $(3),$(3))),$(if $(3),$(3))) -endef - -####################################################################### -# make-3.79.1 doesn't support order-only prerequisites.. -ifeq ($(MAKE_VERSION),3.79.1) -|: $(^) ; +ifneq ($(strip $(HAVE_DOT_CONFIG)),y) +# pull in OS specific commands like cp, mkdir, etc. early +-include $(top_srcdir)/Rules.mak endif -####################################################################### - - -# Handle building out of tree -ifneq ($(top_builddir),$(top_srcdir)) -all_tree := $(patsubst %,$(top_builddir)/%,$(DIRS) scripts scripts/config include include/config) +# All object directories. +OBJ_DIRS := $(DIRS) +all_tree := $(patsubst %,$(top_builddir)/%,$(OBJ_DIRS) scripts scripts/config include) +all_tree: $(all_tree) $(all_tree): @mkdir -p "$@" -saved-output := $(PACKAGE_OUTPUTDIR) - -$(if $(wildcard $(PACKAGE_OUTPUTDIR)),, \ +ifneq ($(KBUILD_OUTPUT),) +# Invoke a second make in the output directory, passing relevant variables +# Check that the output directory actually exists +saved-output := $(KBUILD_OUTPUT) +KBUILD_OUTPUT := $(shell cd $(KBUILD_OUTPUT) && /bin/pwd) +$(if $(wildcard $(KBUILD_OUTPUT)),, \ $(error output directory "$(saved-output)" does not exist)) -.PHONY: $(filter $(noconfig_targets),$(MAKECMDGOALS)) +.PHONY: $(MAKECMDGOALS) + +$(filter-out _all,$(MAKECMDGOALS)) _all: $(KBUILD_OUTPUT)/Rules.mak $(KBUILD_OUTPUT)/Makefile all_tree + $(Q)$(MAKE) -C $(KBUILD_OUTPUT) \ + top_srcdir=$(top_srcdir) \ + top_builddir=$(top_builddir) \ + KBUILD_SRC=$(top_srcdir) \ + -f $(CURDIR)/Makefile $@ -$(PACKAGE_OUTPUTDIR)/Rules.mak: +$(KBUILD_OUTPUT)/Rules.mak: @echo > $@ @echo top_srcdir=$(top_srcdir) >> $@ - @echo top_builddir=$(PACKAGE_OUTPUTDIR) >> $@ - @echo include $$\(top_srcdir\)/Rules.mak >> $@ + @echo top_builddir=$(KBUILD_OUTPUT) >> $@ + @echo include $(top_srcdir)/Rules.mak >> $@ -$(PACKAGE_OUTPUTDIR)/Makefile: +$(KBUILD_OUTPUT)/Makefile: @echo > $@ @echo top_srcdir=$(top_srcdir) >> $@ - @echo top_builddir=$(PACKAGE_OUTPUTDIR) >> $@ - @echo PACKAGE_SOURCEDIR='$$(top_srcdir)' >> $@ - @echo include '$$(PACKAGE_SOURCEDIR)'/Makefile >> $@ + @echo top_builddir=$(KBUILD_OUTPUT) >> $@ + @echo KBUILD_SRC='$$(top_srcdir)' >> $@ + @echo include '$$(KBUILD_SRC)'/Makefile >> $@ +# Leave processing to above invocation of make +skip-makefile := 1 +endif # ifneq ($(KBUILD_OUTPUT),) +endif # ifeq ($(KBUILD_SRC),) -buildtree := $(all_tree) $(PACKAGE_OUTPUTDIR)/Rules.mak $(PACKAGE_OUTPUTDIR)/Makefile +ifeq ($(skip-makefile),) # We only need a copy of the Makefile for the config targets and reuse # the rest from the source directory, i.e. we do not cp ALL_MAKEFILES. -scripts/config/Makefile: $(top_srcdir)/scripts/config/Makefile | $(buildtree) - @cp $(top_srcdir)/scripts/config/Makefile $@ +scripts/config/Makefile: $(top_srcdir)/scripts/config/Makefile + cp $< $@ -else -all_tree := include/config -$(all_tree): - @mkdir -p "$@" -buildtree := $(all_tree) -endif # ifneq ($(PACKAGE_OUTPUTDIR),$(top_srcdir)) +_all: all help: @echo 'Cleaning:' @@ -151,44 +137,37 @@ help: @echo ' release - create a distribution tarball' @echo ' sizes - show size of all enabled busybox symbols' @echo - @echo 'Make flags:' - @echo ' V= - print verbose make output (default: unset)' - @echo ' 0 print CC invocations' - @echo ' 1' - @echo ' 2 also print when make enters a directory' - @echo ' 3 also verbosely print shell invocations' --include $(top_srcdir)/Rules.mak + +include $(top_srcdir)/Rules.mak ifneq ($(strip $(HAVE_DOT_CONFIG)),y) + # Default target if none was requested explicitly -all: menuconfig ; +all: defconfig menuconfig -ifneq ($(filter-out $(noconfig_targets),$(MAKECMDGOALS)),) # warn if no configuration exists and we are asked to build a non-config target .config: @echo "" @echo "No $(top_builddir)/$@ found!" - @echo "Please refer to 'make help', section Configuration." + @echo "Please refer to 'make help', section Configuration." @echo "" @exit 1 -else -# Avoid implicit rule to kick in by using an empty command -.config: $(buildtree) ; -endif -endif # ifneq ($(strip $(HAVE_DOT_CONFIG)),y) - # configuration # --------------------------------------------------------------------------- -CONFIG_CONFIG_IN = $(top_srcdir)/Config.in - scripts/config/conf: scripts/config/Makefile $(Q)$(MAKE) -C scripts/config conf + -@if [ ! -f .config ] ; then \ + touch .config; \ + fi scripts/config/mconf: scripts/config/Makefile $(Q)$(MAKE) -C scripts/config ncurses conf mconf + -@if [ ! -f .config ] ; then \ + touch .config; \ + fi menuconfig: scripts/config/mconf @[ -f .config ] || make $(MAKEFLAGS) defconfig @@ -220,6 +199,7 @@ defconfig: scripts/config/conf @$(SED) -i -r -e "s/^(USING_CROSS_COMPILER|CONFIG_(DEBUG.*|STATIC|SELINUX|BUILD_(AT_ONCE|LIBBUSYBOX)|FEATURE_(DEVFS|FULL_LIBBUSYBOX|SHARED_BUSYBOX|MTAB_SUPPORT|CLEAN_UP|UDHCP_DEBUG)|INSTALL_NO_USR))=.*/# \1 is not set/" .config @./scripts/config/conf -o $(CONFIG_CONFIG_IN) + allbareconfig: scripts/config/conf @./scripts/config/conf -y $(CONFIG_CONFIG_IN) @$(SED) -i -r -e "s/^(USING_CROSS_COMPILER|CONFIG_(DEBUG|STATIC|SELINUX|DEVFSD|NC_GAPING_SECURITY_HOLE|BUILD_AT_ONCE)).*/# \1 is not set/" .config @@ -227,28 +207,19 @@ allbareconfig: scripts/config/conf @echo "CONFIG_FEATURE_BUFFERS_GO_ON_STACK=y" >> .config @./scripts/config/conf -o $(CONFIG_CONFIG_IN) -ifeq ($(strip $(HAVE_DOT_CONFIG)),y) +else # ifneq ($(strip $(HAVE_DOT_CONFIG)),y) -# Load all Config.in --include $(top_builddir)/.config.cmd +all: busybox busybox.links doc -endif # ifeq ($(strip $(HAVE_DOT_CONFIG)),y) +# In this section, we need .config +-include $(top_builddir)/.config.cmd +include $(patsubst %,%/Makefile.in, $(SRC_DIRS)) -include $(patsubst %,%/Makefile.in,$(SRC_DIRS)) +endif # ifneq ($(strip $(HAVE_DOT_CONFIG)),y) -ifeq ($(strip $(HAVE_DOT_CONFIG)),y) -# Finally pull in the dependencies (headers and other includes) of the -# individual object files +-include $(top_builddir)/.config -include $(top_builddir)/.depend -$(top_builddir)/applets/applets.o: $(top_builddir)/.config -# Everything is set. - -all: busybox busybox.links doc ; - -# Two modes of operation: legacy and IMA -# Legacy mode builds each object through an individual invocation of CC -# IMA compiles all sources at once (aka IPO aka IPA etc.) ifeq ($(strip $(CONFIG_BUILD_AT_ONCE)),y) libraries-y:= @@ -269,16 +240,18 @@ else # CONFIG_BUILD_AT_ONCE # This was the old way the binary was built. libbusybox-obj:=archival/libunarchive/libunarchive.a \ networking/libiproute/libiproute.a \ - libpwdgrp/libpwdgrp.a coreutils/libcoreutils/libcoreutils.a \ + libpwdgrp/libpwdgrp.a \ + coreutils/libcoreutils/libcoreutils.a \ libbb/libbb.a libbusybox-obj:=$(patsubst %,$(top_builddir)/%,$(libbusybox-obj)) + ifeq ($(strip $(CONFIG_FEATURE_SHARED_BUSYBOX)),y) # linking against libbusybox, so don't build the .a already contained in the .so libraries-y:=$(filter-out $(libbusybox-obj),$(libraries-y)) endif # CONFIG_FEATURE_SHARED_BUSYBOX - endif # CONFIG_BUILD_AT_ONCE + ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y) LD_LIBBUSYBOX:=libbusybox.so LIBBUSYBOX_SONAME:=$(LD_LIBBUSYBOX).$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL_VERSION) @@ -286,21 +259,17 @@ DO_INSTALL_LIBS:=$(LD_LIBBUSYBOX) \ $(LD_LIBBUSYBOX).$(MAJOR_VERSION) \ $(LD_LIBBUSYBOX).$(MAJOR_VERSION).$(MINOR_VERSION) -endif # CONFIG_BUILD_LIBBUSYBOX - ifeq ($(strip $(CONFIG_BUILD_AT_ONCE)),y) ifneq ($(strip $(CONFIG_FEATURE_SHARED_BUSYBOX)),y) -# --combine but not linking against libbusybox, so compile lib*.c +# --combine but not linking against libbusybox, so compile all BUSYBOX_SRC := $(LIBRARY_SRC) BUSYBOX_DEFINE:= $(LIBRARY_DEFINE) endif # !CONFIG_FEATURE_SHARED_BUSYBOX $(LIBBUSYBOX_SONAME): $(LIBRARY_SRC) else # CONFIG_BUILD_AT_ONCE $(LIBBUSYBOX_SONAME): $(libbusybox-obj) -AR_INTRO:=-Wl,--whole-archive -AR_EXTRO:=-Wl,--no-whole-archive endif # CONFIG_BUILD_AT_ONCE - +endif # CONFIG_BUILD_LIBBUSYBOX ifeq ($(strip $(CONFIG_FEATURE_SHARED_BUSYBOX)),y) LDBUSYBOX:=-L$(top_builddir) -lbusybox @@ -315,23 +284,20 @@ endif -Wl,-soname=$(LD_LIBBUSYBOX).$(MAJOR_VERSION) \ -Wl,-z,combreloc $(LIB_LDFLAGS) \ -o $(@) \ - -Wl,--start-group \ - $(LIBRARY_DEFINE) $(AR_INTRO) $(^) $(AR_EXTRO) \ - -Wl,--end-group + -Wl,--start-group -Wl,--whole-archive \ + $(LIBRARY_DEFINE) $(^) \ + -Wl,--no-whole-archive -Wl,--end-group @rm -f $(DO_INSTALL_LIBS) @for i in $(DO_INSTALL_LIBS); do ln -s $(@) $$i ; done $(do_strip) endif # ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y) -busybox_unstripped: $(top_builddir)/.depend $(LIBBUSYBOX_SONAME) $(BUSYBOX_SRC) $(APPLET_SRC) $(libraries-y) +busybox_unstripped: .depend $(LIBBUSYBOX_SONAME) $(BUSYBOX_SRC) $(libraries-y) $(do_link) $(PROG_CFLAGS) $(PROG_LDFLAGS) $(CFLAGS_COMBINE) \ - $(foreach f,$(^:.o=.c),$(CFLAGS-$(notdir $(patsubst %/$,%,$(dir $(f))))-$(notdir $(f)))) \ - $(CFLAGS-$(@)) \ - -o $@ -Wl,--start-group \ + -o $@ -Wl,--start-group \ $(APPLETS_DEFINE) $(APPLET_SRC) \ - $(BUSYBOX_DEFINE) $(BUSYBOX_SRC) \ - $(libraries-y) \ + $(BUSYBOX_DEFINE) $(BUSYBOX_SRC) $(libraries-y) \ $(LDBUSYBOX) $(LIBRARIES) \ -Wl,--end-group @@ -365,6 +331,17 @@ ifneq ($(strip $(DO_INSTALL_LIBS)),n) done endif +# see if we are in verbose mode +KBUILD_VERBOSE := +ifdef V + ifeq ("$(origin V)", "command line") + KBUILD_VERBOSE := $(V) + endif +endif +ifneq ($(strip $(KBUILD_VERBOSE)),) + CHECK_VERBOSE := -v +# ARFLAGS+=v +endif check test: busybox bindir=$(top_builddir) srcdir=$(top_srcdir)/testsuite \ $(top_srcdir)/testsuite/runtest $(CHECK_VERBOSE) @@ -373,7 +350,7 @@ sizes: busybox_unstripped $(NM) --size-sort $(<) # Documentation Targets -doc: docs/busybox.pod docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html ; +doc: docs/busybox.pod docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html docs/busybox.pod : $(top_srcdir)/docs/busybox_header.pod $(top_srcdir)/include/usage.h $(top_srcdir)/docs/busybox_footer.pod $(top_srcdir)/docs/autodocifier.pl $(disp_doc) @@ -407,7 +384,7 @@ docs/busybox.net/BusyBox.html: docs/busybox.pod # The nifty new dependency stuff scripts/bb_mkdep: $(top_srcdir)/scripts/bb_mkdep.c - $(do_link.h) + $(Q)$(HOSTCC) $(HOSTCFLAGS) -o $@ $< DEP_INCLUDES := include/bb_config.h @@ -419,21 +396,22 @@ include/bbconfigopts.h: .config $(Q)$(top_srcdir)/scripts/config/mkconfigs > $@ endif -depend dep: $(top_builddir)/.depend ; -$(top_builddir)/.depend: $(buildtree) scripts/bb_mkdep $(DEP_INCLUDES) +depend dep: .depend +.depend: scripts/bb_mkdep $(DEP_INCLUDES) $(disp_gen) $(Q)rm -f .depend - $(Q)scripts/bb_mkdep $(MKDEP_ARGS) \ - -I $(top_srcdir)/include $(top_srcdir) > $@.tmp + $(Q)mkdir -p include/config + $(Q)scripts/bb_mkdep -I $(top_srcdir)/include $(top_srcdir) > $@.tmp $(Q)mv $@.tmp $@ include/bb_config.h: .config - $(disp_gen) + @if [ ! -x $(top_builddir)/scripts/config/conf ] ; then \ + $(MAKE) -C scripts/config conf; \ + fi; @$(top_builddir)/scripts/config/conf -o $(CONFIG_CONFIG_IN) -endif # ifeq ($(strip $(HAVE_DOT_CONFIG)),y) - clean: + - $(MAKE) -C scripts/config $@ - rm -f docs/busybox.dvi docs/busybox.ps \ docs/busybox.pod docs/busybox.net/busybox.html \ docs/busybox pod2htm* *.gdb *.elf *~ core .*config.log \ @@ -446,10 +424,9 @@ clean: -o -name \*.os -o -name \*.osm -o -name \*.a | xargs rm -f distclean: clean - - $(MAKE) -C scripts/config clean - rm -f scripts/bb_mkdep - rm -r -f include/config $(DEP_INCLUDES) - - find . -name .depend'*' | xargs rm -f + - find . -name .depend'*' | xargs rm -f rm -f .config .config.old .config.cmd release: distclean #doc @@ -472,10 +449,8 @@ release: distclean #doc tags: ctags -R . -# keep these in sync with noconfig_targets above! -.PHONY: dummy subdirs check test depend dep buildtree \ - menuconfig config oldconfig randconfig \ - defconfig allyesconfig allnoconfig allbareconfig \ - clean distclean \ - release tags +endif # ifeq ($(skip-makefile),) + +.PHONY: dummy subdirs release distclean clean config oldconfig \ + menuconfig tags check test depend dep buildtree diff --git a/Rules.mak b/Rules.mak index 031b41ee5..34c9be69e 100644 --- a/Rules.mak +++ b/Rules.mak @@ -10,10 +10,6 @@ ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),) -include $(top_builddir)/.config endif -ifeq ($(HAVE_DOT_CONFIG),y) -rules-mak-rules:=0 -endif - #-------------------------------------------------------- PROG := busybox MAJOR_VERSION :=1 @@ -34,9 +30,8 @@ BUILDTIME := $(shell TZ=UTC date -u "+%Y.%m.%d-%H:%M%z") # If you are running a cross compiler, you will want to set 'CROSS' # 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 +# your compiler is broken, you should not need to specify TARGET_ARCH CROSS =$(subst ",, $(strip $(CROSS_COMPILER_PREFIX))) -#") CC = $(CROSS)gcc AR = $(CROSS)ar AS = $(CROSS)as @@ -45,18 +40,7 @@ NM = $(CROSS)nm STRIP = $(CROSS)strip CPP = $(CC) -E SED ?= sed -AWK ?= awk - -ifdef PACKAGE_BE_VERBOSE -PACKAGE_BE_VERBOSE := $(shell echo $(PACKAGE_BE_VERBOSE) | $(SED) "s/[[:alpha:]]*//g") -endif - -# for make V=3 and above make $(shell) invocations verbose -ifeq ($(if $(strip $(PACKAGE_BE_VERBOSE)),$(shell test $(PACKAGE_BE_VERBOSE) -gt 2 ; echo $$?),1),0) - SHELL+=-x - MKDEP_ARGS:=-w -endif # What OS are you compiling busybox for? This allows you to include # OS specific things, syscall overrides, etc. @@ -69,21 +53,10 @@ HOSTCFLAGS= -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer # Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc. LC_ALL:= C -# initialize flags here -CFLAGS:= -CFLAGS_COMBINE:= -CFLAGS_PIC:= -LD_FLAGS:= -LIB_LDFLAGS:= -PROG_LDFLAGS:= -PROG_CFLAGS:= -OPTIMIZATIONS:= - # 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 OPTIMIZATIONS. +# 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... @@ -100,50 +73,20 @@ CFLAGS_EXTRA=$(subst ",, $(strip $(EXTRA_CFLAGS_OPTIONS))) #GCCINCDIR:=$(shell gcc -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp") WARNINGS=-Wall -Wstrict-prototypes -Wshadow -CFLAGS+=-I$(top_builddir)/include -I$(top_srcdir)/include +CFLAGS+=-I$(top_builddir)/include -I$(top_srcdir)/include -I$(srcdir) ARFLAGS=cru - -# Get the CC MAJOR/MINOR version # gcc centric. Perhaps fiddle with findstring gcc,$(CC) for the rest +# get the CC MAJOR/MINOR version CC_MAJOR:=$(shell printf "%02d" $(shell echo __GNUC__ | $(CC) -E -xc - | tail -n 1)) CC_MINOR:=$(shell printf "%02d" $(shell echo __GNUC_MINOR__ | $(CC) -E -xc - | tail -n 1)) -# Note: spaces are significant here! -# Check if CC version is equal to given MAJOR,MINOR. Returns empty if false. -define cc_eq -$(shell [ $(CC_MAJOR) -eq $(1) -a $(CC_MINOR) -eq $(2) ] && echo y) -endef -# Check if CC version is greater or equal than given MAJOR,MINOR -define cc_ge -$(shell [ $(CC_MAJOR) -ge $(1) -a $(CC_MINOR) -ge $(2) ] && echo y) -endef -# Check if CC version is less or equal than given MAJOR,MINOR -define cc_le -$(shell [ $(CC_MAJOR) -le $(1) -a $(CC_MINOR) -le $(2) ] && echo y) -endef - -# Workaround bugs in make-3.80 for eval in conditionals -define is_eq -$(shell [ $(1) = $(2) ] 2> /dev/null && echo y) -endef -define is_neq -$(shell [ $(1) != $(2) ] 2> /dev/null && echo y) -endef - #-------------------------------------------------------- export VERSION BUILDTIME HOSTCC HOSTCFLAGS CROSS CC AR AS LD NM STRIP CPP - -# TARGET_ARCH and TARGET_MACH will be passed verbatim to CC with recent -# versions of make, so we use __TARGET_ARCH here. -# Current builtin rules looks like that: -# COMPILE.s = $(AS) $(ASFLAGS) $(TARGET_MACH) -# COMPILE.c = $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c - -ifeq ($(strip $(__TARGET_ARCH)),) -__TARGET_ARCH:=$(shell $(CC) -dumpmachine | sed -e s'/-.*//' \ +ifeq ($(strip $(TARGET_ARCH)),) +TARGET_ARCH:=$(shell $(CC) -dumpmachine | sed -e s'/-.*//' \ -e 's/i.86/i386/' \ -e 's/sparc.*/sparc/' \ -e 's/arm.*/arm/g' \ @@ -157,60 +100,70 @@ __TARGET_ARCH:=$(shell $(CC) -dumpmachine | sed -e s'/-.*//' \ ) endif -CFLAGS+=$(call check_gcc,CFLAGS,-funsigned-char,) -CFLAGS+=$(call check_gcc,CFLAGS,-mmax-stack-frame=256,) +# A nifty macro to make testing gcc features easier +check_gcc=$(shell \ + if [ "$(1)" != "" ]; then \ + if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \ + then echo "$(1)"; else echo "$(2)"; fi \ + fi) + +# A not very robust macro to check for available ld flags +check_ld=$(shell \ + if [ "x$(1)" != "x" ]; then \ + $(LD) --help | grep -q "\$(1)" && echo "-Wl,$(1)" ; \ + fi) + +CFLAGS+=$(call check_gcc,-funsigned-char,) + +CFLAGS+=$(call check_gcc,-mmax-stack-frame=256,) #-------------------------------------------------------- # Arch specific compiler optimization stuff should go here. # Unless you want to override the defaults, do not set anything -# for OPTIMIZATIONS... +# for OPTIMIZATION... # use '-Os' optimization if available, else use -O2 -OPTIMIZATIONS+=$(call check_gcc,OPTIMIZATIONS,-Os,-O2) +OPTIMIZATION:=$(call check_gcc,-Os,-O2) +ifeq ($(CONFIG_BUILD_AT_ONCE),y) # gcc 2.95 exits with 0 for "unrecognized option" -CFLAGS_COMBINE+=$(if $(call is_eq,$(CONFIG_BUILD_AT_ONCE),y),\ - $(if $(call cc_ge,3,0),\ - $(call check_gcc,CFLAGS_COMBINE,--combine,))) - -OPTIMIZATIONS+=$(if $(call is_eq,$(CONFIG_BUILD_AT_ONCE),y),\ - $(call check_gcc,OPTIMIZATIONS,-funit-at-a-time,)) - -# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25795 -#PROG_CFLAGS+=$(if $(call is_eq,$(CONFIG_BUILD_AT_ONCE),y),\ -# $(call check_gcc,PROG_CFLAGS,-fwhole-program,)) +ifeq ($(strip $(shell [ $(CC_MAJOR) -ge 3 ] ; echo $$?)),0) + CFLAGS_COMBINE:=$(call check_gcc,--combine,) +endif +OPTIMIZATION+=$(call check_gcc,-funit-at-a-time,) +PROG_CFLAGS+=$(call check_gcc,-fwhole-program,) +endif # CONFIG_BUILD_AT_ONCE -LIB_LDFLAGS+=$(call check_ld,LIB_LDFLAGS,--enable-new-dtags,) -#LIB_LDFLAGS+=$(call check_ld,LIB_LDFLAGS,--reduce-memory-overheads,) -#LIB_LDFLAGS+=$(call check_ld,LIB_LDFLAGS,--as-needed,) -#LIB_LDFLAGS+=$(call check_ld,LIB_LDFLAGS,--warn-shared-textrel,) +LIB_LDFLAGS:=$(call check_ld,--enable-new-dtags,) +#LIB_LDFLAGS+=$(call check_ld,--reduce-memory-overheads,) +#LIB_LDFLAGS+=$(call check_ld,--as-needed,) +#LIB_LDFLAGS+=$(call check_ld,--warn-shared-textrel,) -PROG_LDFLAGS+=$(call check_ld,PROG_LDFLAGS,--gc-sections,) # Some nice architecture specific optimizations -ifeq ($(__TARGET_ARCH),arm) - OPTIMIZATIONS+=-fstrict-aliasing -endif # arm - -OPTIMIZATIONS+=$(if $(call is_eq,$(__TARGET_ARCH),i386),\ - $(call check_gcc,OPTIMIZATIONS,-march=i386,)) - +ifeq ($(strip $(TARGET_ARCH)),arm) + OPTIMIZATION+=-fstrict-aliasing +endif +ifeq ($(strip $(TARGET_ARCH)),i386) + OPTIMIZATION+=$(call check_gcc,-march=i386,) # gcc-4.0 and older seem to benefit from these -OPTIMIZATIONS+=$(if $(call cc_le,4,0),\ - $(call check_gcc,OPTIMIZATIONS,-mpreferred-stack-boundary=2,)\ - $(call check_gcc,OPTIMIZATIONS,-falign-functions=1 -falign-jumps=1 -falign-loops=1,\ - -malign-functions=0 -malign-jumps=0 -malign-loops=0)) +#ifneq ($(strip $(shell [ $(CC_MAJOR) -ge 4 -a $(CC_MINOR) -ge 1 ] ; echo $$?)),0) + OPTIMIZATION+=$(call check_gcc,-mpreferred-stack-boundary=2,) + OPTIMIZATION+=$(call check_gcc,-falign-functions=1 -falign-jumps=1 -falign-loops=1,\ + -malign-functions=0 -malign-jumps=0 -malign-loops=0) +#endif # gcc-4.0 and older # gcc-4.1 and beyond seem to benefit from these -# turn off flags which hurt -Os -OPTIMIZATIONS+=$(if $(call cc_ge,4,1),\ - $(call check_gcc,OPTIMIZATIONS,-fno-tree-loop-optimize,)\ - $(call check_gcc,OPTIMIZATIONS,-fno-tree-dominator-opts,)\ - $(call check_gcc,OPTIMIZATIONS,-fno-strength-reduce,)\ -\ - $(call check_gcc,OPTIMIZATIONS,-fno-branch-count-reg,)) - -OPTIMIZATIONS+=$(call check_gcc,OPTIMIZATIONS,-fomit-frame-pointer,) +ifeq ($(strip $(shell [ $(CC_MAJOR) -ge 4 -a $(CC_MINOR) -ge 1 ] ; echo $$?)),0) + # turn off flags which hurt -Os + OPTIMIZATION+=$(call check_gcc,-fno-tree-loop-optimize,) + OPTIMIZATION+=$(call check_gcc,-fno-tree-dominator-opts,) + OPTIMIZATION+=$(call check_gcc,-fno-strength-reduce,) + + OPTIMIZATION+=$(call check_gcc,-fno-branch-count-reg,) +endif # gcc-4.1 and beyond +endif +OPTIMIZATIONS:=$(OPTIMIZATION) $(call check_gcc,-fomit-frame-pointer,) # #-------------------------------------------------------- @@ -221,42 +174,45 @@ OPTIMIZATIONS+=$(call check_gcc,OPTIMIZATIONS,-fomit-frame-pointer,) # prone to casual user adjustment. # -ifeq ($(CONFIG_LFS),y) +ifeq ($(strip $(CONFIG_LFS)),y) # For large file summit support CFLAGS+=-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 endif -ifeq ($(CONFIG_DMALLOC),y) +ifeq ($(strip $(CONFIG_DMALLOC)),y) # For testing mem leaks with dmalloc CFLAGS+=-DDMALLOC LIBRARIES:=-ldmalloc else - ifeq ($(CONFIG_EFENCE),y) + ifeq ($(strip $(CONFIG_EFENCE)),y) LIBRARIES:=-lefence endif endif - -LDFLAGS+=$(if $(call is_eq,$(CONFIG_DEBUG),y),$(call check_ld,LDFLAGS,--warn-common,)$(call check_ld,LDFLAGS,--sort-common,)) -ifeq ($(CONFIG_DEBUG),y) +ifeq ($(strip $(CONFIG_DEBUG)),y) CFLAGS +=$(WARNINGS) -g -D_GNU_SOURCE + LDFLAGS += $(call check_ld,--warn-common,) else CFLAGS+=$(WARNINGS) $(OPTIMIZATIONS) -D_GNU_SOURCE -DNDEBUG + LDFLAGS += $(call check_ld,--warn-common,) + LDFLAGS += $(call check_ld,--sort-common,) endif ifeq ($(CONFIG_STRIP_BINARIES),y) STRIPCMD:=$(STRIP) -s --remove-section=.note --remove-section=.comment else STRIPCMD:=/bin/true -Not_stripping_since_we_are_debugging endif -PROG_CFLAGS+=$(if $(call is_eq,$(CONFIG_STATIC),y),\ - $(call check_gcc,PROG_CFLAGS,-static,)) - -CFLAGS_SHARED+=$(call check_gcc,CFLAGS_SHARED,-shared,) +ifeq ($(strip $(CONFIG_STATIC)),y) + PROG_CFLAGS += $(call check_gcc,-static,) +endif +CFLAGS_SHARED += $(call check_gcc,-shared,) LIB_CFLAGS+=$(CFLAGS_SHARED) -CFLAGS_PIC+=$(if $(call is_eq,$(CONFIG_BUILD_LIBBUSYBOX),y),\ - $(call check_gcc,CFLAGS_PIC,-fPIC,)) -LIB_CFLAGS+=$(CFLAGS_PIC) +ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y) + CFLAGS_PIC:= $(call check_gcc,-fPIC,) + LIB_CFLAGS+=$(CFLAGS_PIC) +endif + -ifeq ($(CONFIG_SELINUX),y) +ifeq ($(strip $(CONFIG_SELINUX)),y) LIBRARIES += -lselinux endif @@ -264,6 +220,14 @@ ifeq ($(strip $(PREFIX)),) PREFIX:=`pwd`/_install endif +# Additional complications due to support for pristine source dir. +# Include files in the build directory should take precedence over +# the copy in top_srcdir, both during the compilation phase and the +# shell script that finds the list of object files. +# Work in progress by . + + +OBJECTS:=$(APPLET_SOURCES:.c=.o) busybox.o usage.o applets.o CFLAGS += $(CROSS_CFLAGS) ifdef BB_INIT_SCRIPT CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"' @@ -285,117 +249,59 @@ ifeq ($(strip $(CONFIG_INSTALL_APPLET_DONT)),y) INSTALL_OPTS= endif - -#------------------------------------------------------------ -# object extensions - -# object potentially used in shared object -ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y) -# single-object extension -os:=.os -# multi-object extension -om:=.osm -else -os:=.o -om:=.om -endif - #------------------------------------------------------------ # Make the output nice and tight - -# for make V=2 and above, do print directory -ifneq ($(shell test -n "$(strip $(PACKAGE_BE_VERBOSE))" && test $(PACKAGE_BE_VERBOSE) -gt 1 ; echo $$?),0) - MAKEFLAGS += --no-print-directory -endif - -export MAKEOVERRIDES +MAKEFLAGS += --no-print-directory export MAKE_IS_SILENT=n ifneq ($(findstring s,$(MAKEFLAGS)),) export MAKE_IS_SILENT=y +SECHO := @-false DISP := sil Q := @ else ifneq ($(V)$(VERBOSE),) +SECHO := @-false DISP := ver Q := else +SECHO := @echo DISP := pur Q := @ endif endif -define show_objs - $(subst $(top_builddir)/,,$(subst ../,,$@)) -endef -pur_disp_compile.c = @echo " "CC $(show_objs) ; -pur_disp_compile.h = @echo " "HOSTCC $(show_objs) ; -pur_disp_strip = @echo " "STRIP $(show_objs) ; -pur_disp_link = @echo " "LINK $(show_objs) ; -pur_disp_link.h = @echo " "HOSTLINK $(show_objs) ; -pur_disp_ar = @echo " "AR $(ARFLAGS) $(show_objs) ; -pur_disp_gen = @echo " "GEN $@ ; -pur_disp_doc = @echo " "DOC $(subst docs/,,$@) ; -pur_disp_bin = @echo " "BIN $(show_objs) ; -sil_disp_compile.c = @ -sil_disp_compile.h = @ -sil_disp_strip = @ -sil_disp_link = @ -sil_disp_link.h = @ -sil_disp_ar = @ -sil_disp_gen = @ -sil_disp_doc = @ -sil_disp_bin = @ -ver_disp_compile.c = -ver_disp_compile.h = -ver_disp_strip = -ver_disp_link = -ver_disp_link.h = -ver_disp_ar = -ver_disp_gen = -ver_disp_doc = -ver_disp_bin = +show_objs = $(subst $(top_builddir)/,,$(subst ../,,$@)) +pur_disp_compile.c = echo " "CC $(show_objs) +pur_disp_compile.h = echo " "HOSTCC $(show_objs) +pur_disp_strip = echo " "STRIP $(show_objs) +pur_disp_link = echo " "LINK $(show_objs) +pur_disp_ar = echo " "AR $(ARFLAGS) $(show_objs) +sil_disp_compile.c = true +sil_disp_compile.h = true +sil_disp_strip = true +sil_disp_link = true +sil_disp_ar = true +ver_disp_compile.c = echo $(cmd_compile.c) +ver_disp_compile.h = echo $(cmd_compile.h) +ver_disp_strip = echo $(cmd_strip) +ver_disp_link = echo $(cmd_link) +ver_disp_ar = echo $(cmd_ar) disp_compile.c = $($(DISP)_disp_compile.c) disp_compile.h = $($(DISP)_disp_compile.h) disp_strip = $($(DISP)_disp_strip) disp_link = $($(DISP)_disp_link) -disp_link.h = $($(DISP)_disp_link.h) disp_ar = $($(DISP)_disp_ar) -disp_gen = $($(DISP)_disp_gen) -disp_doc = $($(DISP)_disp_doc) -disp_bin = $($(DISP)_disp_bin) -# CFLAGS-dir == $(CFLAGS-$(notdir $(@D))) -# CFLAGS-dir-file.o == $(CFLAGS-$(notdir $(@D))-$(notdir $(@F))) -# CFLAGS-dir-file.c == $(CFLAGS-$(notdir $( # # Licensed under the GPL v2 or later, see the file LICENSE in this tarball. +# -srcdir:=$(top_srcdir)/networking/libiproute -objdir:=$(top_builddir)/networking/libiproute +LIBIPROUTE_AR:=libiproute.a +ifndef $(LIBIPROUTE_DIR) +LIBIPROUTE_DIR:=$(top_builddir)/networking/libiproute +endif +srcdir=$(top_srcdir)/networking/libiproute +LIBIPROUTE-y:= LIBIPROUTE-$(CONFIG_IP) += \ - ip_parse_common_args \ - ipaddress \ - iplink \ - iproute \ - iptunnel \ - libnetlink \ - ll_addr \ - ll_map \ - ll_proto \ - ll_types \ - rt_names \ - rtm_map \ - utils + ip_parse_common_args.o \ + ipaddress.o \ + iplink.o \ + iproute.o \ + iptunnel.o \ + libnetlink.o \ + ll_addr.o \ + ll_map.o \ + ll_proto.o \ + ll_types.o \ + rt_names.o \ + rtm_map.o \ + utils.o LIBIPROUTE-$(CONFIG_IPADDR) += \ - ip_parse_common_args \ - ipaddress \ - libnetlink \ - ll_addr \ - ll_map \ - ll_types \ - rt_names \ - utils + ip_parse_common_args.o \ + ipaddress.o \ + libnetlink.o \ + ll_addr.o \ + ll_map.o \ + ll_types.o \ + rt_names.o \ + utils.o LIBIPROUTE-$(CONFIG_IPLINK) += \ - ip_parse_common_args \ - ipaddress \ - iplink \ - libnetlink \ - ll_addr \ - ll_map \ - ll_types \ - rt_names \ - utils + ip_parse_common_args.o \ + ipaddress.o \ + iplink.o \ + libnetlink.o \ + ll_addr.o \ + ll_map.o \ + ll_types.o \ + rt_names.o \ + utils.o LIBIPROUTE-$(CONFIG_IPROUTE) += \ - ip_parse_common_args \ - iproute \ - libnetlink \ - ll_map \ - rt_names \ - rtm_map \ - utils + ip_parse_common_args.o \ + iproute.o \ + libnetlink.o \ + ll_map.o \ + rt_names.o \ + rtm_map.o \ + utils.o LIBIPROUTE-$(CONFIG_IPTUNNEL) += \ - ip_parse_common_args \ - iptunnel \ - rt_names \ - utils + ip_parse_common_args.o \ + iptunnel.o \ + rt_names.o \ + utils.o LIBIPROUTE-y:=$(sort $(LIBIPROUTE-y)) -LIBIPROUTE_SRC-y:=$(patsubst %,$(srcdir)/%.c,$(LIBIPROUTE-y)) +LIBIPROUTE_SRC-y:=$(patsubst %,$(srcdir)/%,$(subst .o,.c,$(LIBIPROUTE-y))) LIBIPROUTE_SRC-a:=$(wildcard $(srcdir)/*.c) LIBRARY_SRC-y+=$(LIBIPROUTE_SRC-y) LIBRARY_SRC-a+=$(LIBIPROUTE_SRC-a) -networking_libiproute_OBJ$(os):=$(patsubst %,$(objdir)/%$(os),$(LIBIPROUTE-y)) +LIBIPROUTE-obj:=$(LIBIPROUTE_DIR)/$(LIBIPROUTE_AR) + +ifneq ($(strip $(LIBIPROUTE-y)),) +libraries-y+=$(LIBIPROUTE_DIR)/$(LIBIPROUTE_AR) +endif -$(networking_libiproute_OBJ$(os)): $(objdir)/%$(os): $(srcdir)/%.c -$(objdir)/libiproute.a: $(networking_libiproute_OBJ$(os)) -libraries-y:=$(libraries-y) $(objdir)/libiproute.a +$(LIBIPROUTE_DIR)/$(LIBIPROUTE_AR): $(patsubst %,$(LIBIPROUTE_DIR)/%,$(LIBIPROUTE-y)) + $(do_ar) +$(LIBIPROUTE_DIR)/%.o: $(srcdir)/%.c + $(compile.c) diff --git a/networking/udhcp/Makefile.in b/networking/udhcp/Makefile.in index 210939fd6..df32247c6 100644 --- a/networking/udhcp/Makefile.in +++ b/networking/udhcp/Makefile.in @@ -3,9 +3,13 @@ # Copyright (C) 1999-2004 by Erik Andersen # # Licensed under the GPL v2 or later, see the file LICENSE in this tarball. +# -srcdir:=$(top_srcdir)/networking/udhcp -objdir:=$(top_builddir)/networking/udhcp +UDHCP_AR:=udhcp.a +ifndef $(UDHCP_DIR) +UDHCP_DIR:=$(top_builddir)/networking/udhcp/ +endif +srcdir=$(top_srcdir)/networking/udhcp #ok, so I forgot how to do an or, but this is a quick and dirty hack ifeq ($(strip $(CONFIG_UDHCPC)),y) @@ -18,77 +22,32 @@ CONFIG_UDHCP_SHARED=n endif endif -UDHCP__SHARED_FILES:=common.c options.c packet.c pidfile.c signalpipe.c socket.c -UDHCP__UDHCPC_FILES:=dhcpc.c clientpacket.c clientsocket.c script.c -UDHCP__UDHCPD_FILES:=dhcpd.c arpping.c files.c leases.c serverpacket.c \ - static_leases.c -UDHCP__DUMPLEASES_FILES:=dumpleases.c - -UDHCP-$(CONFIG_UDHCP_SHARED) += $(UDHCP__SHARED_FILES) -UDHCP-$(CONFIG_UDHCPC) += $(UDHCP__UDHCPC_FILES) -UDHCP-$(CONFIG_UDHCPD) += $(UDHCP__UDHCPD_FILES) -UDHCP-$(CONFIG_DUMPLEASES) += $(UDHCP__DUMPLEASES_FILES) +UDHCP-y:= +UDHCP-$(CONFIG_UDHCP_SHARED) += common.c options.c packet.c pidfile.c \ + signalpipe.c socket.c +UDHCP-$(CONFIG_UDHCPC) += dhcpc.c clientpacket.c clientsocket.c \ + script.c +UDHCP-$(CONFIG_UDHCPD) += dhcpd.c arpping.c files.c leases.c \ + serverpacket.c static_leases.c +UDHCP-$(CONFIG_DUMPLEASES) += dumpleases.c +UDHCP_OBJS:=$(patsubst %.c,$(UDHCP_DIR)%.o, $(UDHCP-y)) + +ifneq ($(strip $(UDHCP-y)),) +libraries-y+=$(UDHCP_DIR)$(UDHCP_AR) +endif -UDHCP_SRC-y:=$(patsubst %,$(srcdir)/%,$(UDHCP-y)) -UDHCP_SRC-a:=$(wildcard $(srcdir)/*.c) -APPLET_SRC-y+=$(UDHCP_SRC-y) -APPLET_SRC-a+=$(UDHCP_SRC-a) +UDHCP-y:=$(patsubst %,$(srcdir)/%,$(UDHCP-y)) +UDHCP-a:=$(wildcard $(srcdir)/*.c) +APPLET_SRC-y+=$(UDHCP-y) +APPLET_SRC-a+=$(UDHCP-a) UDHCP_INCLUDES:=$(srcdir) -#APPLETS_DEFINE-y+= -I$(UDHCP_INCLUDES) -DIN_BUSYBOX -#APPLETS_DEFINE-a+= -I$(UDHCP_INCLUDES) -DIN_BUSYBOX - -CFLAGS-udhcp:= -I$(UDHCP_INCLUDES) - -# bug in make-3.80 prevents this: -#define udhcp__flags -#CFLAGS-udhcp-$(1):=-DIN_BUSYBOX -#endef -# -#ifeq ($(CONFIG_UDHCP_SHARED),y) -#$(foreach f,$(UDHCP__SHARED_FILES),$(eval $(call udhcp__flags,$(f)))) -#endif -#ifeq ($(CONFIG_UDHCPC),y) -#$(foreach f,$(UDHCP__UDHCPC_FILES),$(eval $(call udhcp__flags,$(f)))) -#endif -#ifeq ($(CONFIG_UDHCPD),y) -#$(foreach f,$(UDHCP__UDHCPD_FILES),$(eval $(call udhcp__flags,$(f)))) -#endif -#ifeq ($(CONFIG_DUMPLEASES),y) -#$(foreach f,$(UDHCP__DUMPLEASES_FILES),$(eval $(call udhcp__flags,$(f)))) -#endif - -ifeq ($(CONFIG_UDHCP_SHARED),y) -CFLAGS-udhcp-common.c:=-DIN_BUSYBOX -CFLAGS-udhcp-options.c:=-DIN_BUSYBOX -CFLAGS-udhcp-packet.c:=-DIN_BUSYBOX -CFLAGS-udhcp-pidfile.c:=-DIN_BUSYBOX -CFLAGS-udhcp-signalpipe.c:=-DIN_BUSYBOX -CFLAGS-udhcp-socket.c:=-DIN_BUSYBOX -endif -ifeq ($(CONFIG_UDHCPC),y) -CFLAGS-udhcp-dhcpc.c:=-DIN_BUSYBOX -CFLAGS-udhcp-clientpacket.c:=-DIN_BUSYBOX -CFLAGS-udhcp-clientsocket.c:=-DIN_BUSYBOX -CFLAGS-udhcp-script.c:=-DIN_BUSYBOX -endif -ifeq ($(CONFIG_UDHCPD),y) -CFLAGS-udhcp-dhcpd.c:=-DIN_BUSYBOX -CFLAGS-udhcp-arpping.c:=-DIN_BUSYBOX -CFLAGS-udhcp-files.c:=-DIN_BUSYBOX -CFLAGS-udhcp-leases.c:=-DIN_BUSYBOX -CFLAGS-udhcp-serverpacket.c:=-DIN_BUSYBOX -CFLAGS-udhcp-static_leases.c:=-DIN_BUSYBOX -endif -ifeq ($(CONFIG_DUMPLEASES),y) -CFLAGS-udhcp-dumpleases.c:=-DIN_BUSYBOX -endif - - -networking_udhcp_OBJ:=$(patsubst %.c,$(objdir)/%.o,$(UDHCP-y)) +APPLETS_DEFINE-y+=-DIN_BUSYBOX -I$(UDHCP_INCLUDES) +APPLETS_DEFINE-a+=-DIN_BUSYBOX -I$(UDHCP_INCLUDES) -$(networking_udhcp_OBJ): $(objdir)/%.o: $(srcdir)/%.c -$(objdir)/udhcp.a: $(networking_udhcp_OBJ) -libraries-y:=$(libraries-y) $(objdir)/udhcp.a +$(UDHCP_DIR)$(UDHCP_AR): $(UDHCP_OBJS) + $(do_ar) +$(UDHCP_OBJS): $(UDHCP_DIR)%.o : $(srcdir)/%.c + $(compile.c) -DIN_BUSYBOX diff --git a/procps/Makefile.in b/procps/Makefile.in index 69455eb26..261c49b02 100644 --- a/procps/Makefile.in +++ b/procps/Makefile.in @@ -4,9 +4,13 @@ # # Licensed under the GPL v2, see the file LICENSE in this tarball. -srcdir:=$(top_srcdir)/procps -objdir:=$(top_builddir)/procps +PROCPS_AR:=procps.a +ifndef $(PROCPS_DIR) +PROCPS_DIR:=$(top_builddir)/procps/ +endif +srcdir=$(top_srcdir)/procps +PROCPS-y:= PROCPS-$(CONFIG_FREE) += free.o PROCPS-$(CONFIG_KILL) += kill.o PROCPS-$(CONFIG_PIDOF) += pidof.o @@ -17,15 +21,17 @@ PROCPS-$(CONFIG_TOP) += top.o PROCPS-$(CONFIG_UPTIME) += uptime.o PROCPS-$(CONFIG_FUSER) += fuser.o +ifneq ($(strip $(PROCPS-y)),) +libraries-y+=$(PROCPS_DIR)$(PROCPS_AR) +endif PROCPS_SRC-y:=$(patsubst %.o,$(srcdir)/%.c,$(PROCPS-y)) PROCPS_SRC-a:=$(wildcard $(srcdir)/*.c) APPLET_SRC-y+=$(PROCPS_SRC-y) APPLET_SRC-a+=$(PROCPS_SRC-a) -procps_OBJ:= $(patsubst %,$(objdir)/%,$(PROCPS-y)) - -$(procps_OBJ): $(objdir)/%.o: $(srcdir)/%.c -$(objdir)/procps.a: $(procps_OBJ) -libraries-y:=$(libraries-y) $(objdir)/procps.a +$(PROCPS_DIR)$(PROCPS_AR): $(patsubst %,$(PROCPS_DIR)%, $(PROCPS-y)) + $(do_ar) +$(PROCPS_DIR)%.o: $(srcdir)/%.c + $(compile.c) diff --git a/scripts/config/Makefile b/scripts/config/Makefile index 716e130da..4c966f7a6 100644 --- a/scripts/config/Makefile +++ b/scripts/config/Makefile @@ -2,12 +2,8 @@ # # Copyright (C) 2002 Erik Andersen -ifndef top_srcdir top_srcdir=../.. -endif -ifndef top_builddir top_builddir=../.. -endif srcdir=$(top_srcdir)/scripts/config include $(top_srcdir)/Rules.mak @@ -54,10 +50,12 @@ MCONF_OBJS = $(patsubst %.c,%.o, $(MCONF_SRC) $(LXD_SRC)) SHARED_OBJS = $(patsubst %.c,%.o, $(SHARED_SRC)) conf: $(CONF_OBJS) $(SHARED_OBJS) - $(do_link.h) + $(SECHO) " "HOSTCC $@ ; true + $(Q)$(HOSTCC) $(NATIVE_LDFLAGS) $^ -o $@ mconf: $(MCONF_OBJS) $(SHARED_OBJS) - $(do_link.h) $(LIBS) + $(SECHO) " "HOSTCC $@ ; true + $(Q)$(HOSTCC) $(NATIVE_LDFLAGS) $^ -o $@ $(LIBS) $(CONF_OBJS): %.o : $(srcdir)/%.c $(SHARED_DEPS) $(compile.h) -I. diff --git a/shell/Makefile.in b/shell/Makefile.in index 94cf729a7..fcd93f345 100644 --- a/shell/Makefile.in +++ b/shell/Makefile.in @@ -4,24 +4,30 @@ # # Licensed under the GPL v2, see the file LICENSE in this tarball. -srcdir:=$(top_srcdir)/shell -objdir:=$(top_builddir)/shell +SHELL_AR:=shell.a +ifndef $(SHELL_DIR) +SHELL_DIR:=$(top_builddir)/shell/ +endif +srcdir=$(top_srcdir)/shell -SHELL-$(CONFIG_ASH) += ash.o -SHELL-$(CONFIG_HUSH) += hush.o -SHELL-$(CONFIG_LASH) += lash.o -SHELL-$(CONFIG_MSH) += msh.o -SHELL-$(CONFIG_FEATURE_COMMAND_EDITING) += cmdedit.o +SHELLT-y:= +SHELLT-$(CONFIG_ASH) += ash.o +SHELLT-$(CONFIG_HUSH) += hush.o +SHELLT-$(CONFIG_LASH) += lash.o +SHELLT-$(CONFIG_MSH) += msh.o +SHELLT-$(CONFIG_FEATURE_COMMAND_EDITING) += cmdedit.o +ifneq ($(strip $(SHELLT-y)),) +libraries-y+=$(SHELL_DIR)$(SHELL_AR) +endif -SHELLT_SRC-y:=$(patsubst %.o,$(srcdir)/%.c,$(SHELL-y)) +SHELLT_SRC-y:=$(patsubst %.o,$(srcdir)/%.c,$(SHELLT-y)) SHELLT_SRC-a:=$(wildcard $(srcdir)/*.c) APPLET_SRC-y+=$(SHELLT_SRC-y) APPLET_SRC-a+=$(SHELLT_SRC-a) -shell_OBJ:= $(patsubst %,$(objdir)/%,$(SHELL-y)) - -$(shell_OBJ): $(objdir)/%.o: $(srcdir)/%.c -$(objdir)/shell.a: $(shell_OBJ) -libraries-y:=$(libraries-y) $(objdir)/shell.a +$(SHELL_DIR)$(SHELL_AR): $(patsubst %,$(SHELL_DIR)%, $(SHELLT-y)) + $(do_ar) +$(SHELL_DIR)%.o: $(srcdir)/%.c + $(compile.c) diff --git a/sysklogd/Makefile.in b/sysklogd/Makefile.in index 412cf5bab..83f77be90 100644 --- a/sysklogd/Makefile.in +++ b/sysklogd/Makefile.in @@ -4,23 +4,29 @@ # # Licensed under the GPL v2, see the file LICENSE in this tarball. -srcdir:=$(top_srcdir)/sysklogd -objdir:=$(top_builddir)/sysklogd +SYSKLOGD_AR:=sysklogd.a +ifndef $(SYSKLOGD_DIR) +SYSKLOGD_DIR:=$(top_builddir)/sysklogd/ +endif +srcdir=$(top_srcdir)/sysklogd +SYSKLOGD-y:= SYSKLOGD-$(CONFIG_KLOGD) += klogd.o SYSKLOGD-$(CONFIG_LOGGER) += logger.o SYSKLOGD-$(CONFIG_LOGREAD) += logread.o SYSKLOGD-$(CONFIG_SYSLOGD) += syslogd.o +ifneq ($(strip $(SYSKLOGD-y)),) +libraries-y+=$(SYSKLOGD_DIR)$(SYSKLOGD_AR) +endif SYSKLOGD_SRC-y:=$(patsubst %.o,$(srcdir)/%.c,$(SYSKLOGD-y)) SYSKLOGD_SRC-a:=$(wildcard $(srcdir)/*.c) APPLET_SRC-y+=$(SYSKLOGD_SRC-y) APPLET_SRC-a+=$(SYSKLOGD_SRC-a) -sysklogd_OBJ:= $(patsubst %,$(objdir)/%,$(SYSKLOGD-y)) - -$(sysklogd_OBJ): $(objdir)/%.o: $(srcdir)/%.c -$(objdir)/sysklogd.a: $(sysklogd_OBJ) -libraries-y:=$(libraries-y) $(objdir)/sysklogd.a +$(SYSKLOGD_DIR)$(SYSKLOGD_AR): $(patsubst %,$(SYSKLOGD_DIR)%, $(SYSKLOGD-y)) + $(do_ar) +$(SYSKLOGD_DIR)%.o: $(srcdir)/%.c + $(compile.c) diff --git a/util-linux/Makefile.in b/util-linux/Makefile.in index b56a7766e..f6a50b7f7 100644 --- a/util-linux/Makefile.in +++ b/util-linux/Makefile.in @@ -4,51 +4,62 @@ # # Licensed under the GPL v2, see the file LICENSE in this tarball. -srcdir:=$(top_srcdir)/util-linux -objdir:=$(top_builddir)/util-linux - -UTIL-LINUX-$(CONFIG_DMESG) +=dmesg.o -UTIL-LINUX-$(CONFIG_FBSET) +=fbset.o -UTIL-LINUX-$(CONFIG_FDFLUSH) +=fdflush.o -UTIL-LINUX-$(CONFIG_FDFORMAT) +=fdformat.o -UTIL-LINUX-$(CONFIG_FDISK) +=fdisk.o -UTIL-LINUX-$(CONFIG_FREERAMDISK) +=freeramdisk.o -UTIL-LINUX-$(CONFIG_FSCK_MINIX) +=fsck_minix.o -UTIL-LINUX-$(CONFIG_GETOPT) +=getopt.o -UTIL-LINUX-$(CONFIG_HEXDUMP) +=hexdump.o -UTIL-LINUX-$(CONFIG_HWCLOCK) +=hwclock.o -UTIL-LINUX-$(CONFIG_IPCRM) +=ipcrm.o -UTIL-LINUX-$(CONFIG_IPCS) +=ipcs.o -UTIL-LINUX-$(CONFIG_LOSETUP) +=losetup.o -UTIL-LINUX-$(CONFIG_MDEV) +=mdev.o -UTIL-LINUX-$(CONFIG_MKFS_MINIX) +=mkfs_minix.o -UTIL-LINUX-$(CONFIG_MKSWAP) +=mkswap.o -UTIL-LINUX-$(CONFIG_MORE) +=more.o -UTIL-LINUX-$(CONFIG_MOUNT) +=mount.o -UTIL-LINUX-$(CONFIG_FEATURE_MOUNT_NFS) +=nfsmount.o -UTIL-LINUX-$(CONFIG_PIVOT_ROOT) +=pivot_root.o -UTIL-LINUX-$(CONFIG_RDATE) +=rdate.o -UTIL-LINUX-$(CONFIG_READPROFILE) +=readprofile.o -UTIL-LINUX-$(CONFIG_SETARCH) +=setarch.o -UTIL-LINUX-$(CONFIG_SWAPONOFF) +=swaponoff.o -UTIL-LINUX-$(CONFIG_SWITCH_ROOT) +=switch_root.o -UTIL-LINUX-$(CONFIG_UMOUNT) +=umount.o - - -UTILLINUX_SRC-y:=$(patsubst %.o,$(srcdir)/%.c,$(UTIL-LINUX-y)) +UTILLINUX_AR:=util-linux.a +ifndef $(UTILLINUX_DIR) +UTILLINUX_DIR:=$(top_builddir)/util-linux/ +endif +srcdir=$(top_srcdir)/util-linux + +UTILLINUX-y:= +UTILLINUX-$(CONFIG_DMESG) +=dmesg.o +UTILLINUX-$(CONFIG_FBSET) +=fbset.o +UTILLINUX-$(CONFIG_FDFLUSH) +=fdflush.o +UTILLINUX-$(CONFIG_FDFORMAT) +=fdformat.o +UTILLINUX-$(CONFIG_FDISK) +=fdisk.o +UTILLINUX-$(CONFIG_FREERAMDISK) +=freeramdisk.o +UTILLINUX-$(CONFIG_FSCK_MINIX) +=fsck_minix.o +UTILLINUX-$(CONFIG_GETOPT) +=getopt.o +UTILLINUX-$(CONFIG_HEXDUMP) +=hexdump.o +UTILLINUX-$(CONFIG_HWCLOCK) +=hwclock.o +UTILLINUX-$(CONFIG_IPCRM) +=ipcrm.o +UTILLINUX-$(CONFIG_IPCS) +=ipcs.o +UTILLINUX-$(CONFIG_LOSETUP) +=losetup.o +UTILLINUX-$(CONFIG_MDEV) +=mdev.o +UTILLINUX-$(CONFIG_MKFS_MINIX) +=mkfs_minix.o +UTILLINUX-$(CONFIG_MKSWAP) +=mkswap.o +UTILLINUX-$(CONFIG_MORE) +=more.o +UTILLINUX-$(CONFIG_MOUNT) +=mount.o +UTILLINUX-$(CONFIG_FEATURE_MOUNT_NFS) +=nfsmount.o +UTILLINUX-$(CONFIG_PIVOT_ROOT) +=pivot_root.o +UTILLINUX-$(CONFIG_RDATE) +=rdate.o +UTILLINUX-$(CONFIG_READPROFILE) +=readprofile.o +UTILLINUX-$(CONFIG_SETARCH) +=setarch.o +UTILLINUX-$(CONFIG_SWAPONOFF) +=swaponoff.o +UTILLINUX-$(CONFIG_SWITCH_ROOT) +=switch_root.o +UTILLINUX-$(CONFIG_UMOUNT) +=umount.o + +ifneq ($(strip $(UTILLINUX-y)),) +libraries-y+=$(UTILLINUX_DIR)$(UTILLINUX_AR) +endif + +UTILLINUX_SRC-y:=$(patsubst %.o,$(srcdir)/%.c,$(UTILLINUX-y)) UTILLINUX_SRC-a:=$(wildcard $(srcdir)/*.c) APPLET_SRC-y+=$(UTILLINUX_SRC-y) APPLET_SRC-a+=$(UTILLINUX_SRC-a) +$(UTILLINUX_DIR)$(UTILLINUX_AR): $(patsubst %,$(UTILLINUX_DIR)%, $(UTILLINUX-y)) + $(do_ar) + +$(UTILLINUX_DIR)%.o: $(srcdir)/%.c + $(compile.c) + ifneq ($(strip $(CONFIG_LFS)),y) ifeq ($(strip $(FDISK_SUPPORT_LARGE_DISKS)),y) -CFLAGS-util-linux-fdisk.c := -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -endif -endif -util-linux_OBJ:= $(patsubst %,$(objdir)/%,$(UTIL-LINUX-y)) - -$(util-linux_OBJ): $(objdir)/%.o: $(srcdir)/%.c -$(objdir)/util-linux.a: $(util-linux_OBJ) -libraries-y:=$(libraries-y) $(objdir)/util-linux.a +$(UTILLINUX_DIR)fdisk.o: $(srcdir)/fdisk.c + $(CC) $(CFLAGS) \ + -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 \ + $(EXTRA_CFLAGS) -c -o $@ $< +endif +endif