[git commit] buildsys: restructure
Bernhard Reutner-Fischer
rep.dot.nop at gmail.com
Tue Jan 8 20:22:49 UTC 2013
commit: http://git.uclibc.org/uClibc++/commit/?id=03028c2b51ca3bb0f44007800cba931608ddb2a4
branch: http://git.uclibc.org/uClibc++/commit/?id=refs/heads/master
Restructure the buildsys in order to add proper dependencies.
- no superfluous re-linking with 'make;make;'
- proper relinking with 'make CXX=g++-4.8.mine;make CXX=g++-4.7'
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop at gmail.com>
---
.gitignore | 1 +
Makefile | 97 +--------
Makefile.end | 44 ++++
Makefile.in | 125 ++++++++++
Rules.mak | 501 +++++++++++++++++++++++++++++++++++++----
bin/Makefile | 55 +----
bin/Makefile.in | 65 ++++++
extra/Configs/Config.in | 2 +-
extra/Makefile | 32 +---
extra/Makefile.in | 3 +
extra/config/Makefile | 11 +-
extra/config/menu.c | 2 +-
extra/locale/Makefile | 6 +-
include/Makefile | 18 +-
include/Makefile.in | 7 +
src/Makefile | 80 +------
src/Makefile.in | 54 +++++
src/abi/libgcc_eh/Makefile | 29 +--
src/abi/libgcc_eh/Makefile.in | 24 ++
src/abi/libsupc/Makefile | 29 +--
src/abi/libsupc/Makefile.in | 24 ++
tests/Makefile | 69 +-----
tests/Makefile.in | 41 ++++
tests/testoutput/Makefile | 14 --
tests/testoutput/Makefile.in | 7 +
25 files changed, 909 insertions(+), 431 deletions(-)
diff --git a/.gitignore b/.gitignore
index d54adb4..ac2c9c4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,6 +15,7 @@
/*.log
cscope.*
bin/g++-uc
+bin/env_check
libuClibc++*.so
libuClibc++*.so.0
include/system_configuration.h
diff --git a/Makefile b/Makefile
index 8cac4aa..f0c3346 100644
--- a/Makefile
+++ b/Makefile
@@ -1,90 +1,7 @@
-MAKE ?= make
-SUBDIRS = bin include src
-
-# User defines:
-
-noconfig_targets := menuconfig config oldconfig silentoldconfig randconfig \
- defconfig allyesconfig allnoconfig clean distclean \
- release tags TAGS
-
-TOPDIR=./
-include $(TOPDIR)Rules.mak
-
-all: headers
- for dir in $(SUBDIRS) ; do \
- $(MAKE) -C $$dir all; \
- done
-
-tests: all
- $(MAKE) -C tests all
-
-check test: tests
- $(MAKE) -C tests test
-
-clean:
- for dir in $(SUBDIRS) tests ; do \
- $(MAKE) -C $$dir clean; \
- done
- #$(MAKE) -C extra/locale clean
-
-distclean: clean
- $(MAKE) -C extra clean
- $(RM) .config .config.cmd .config.old
- $(RM) include/system_configuration.h
-
-release:
- $(RM) ../uClibc++-$(VERSION).tar
- git archive --format=tar --prefix=uClibc++-$(VERSION)/ HEAD \
- > ../uClibc++-$(VERSION).tar
- cat ../uClibc++-$(VERSION).tar | bzip2 -c9 > ../uClibc++-$(VERSION).tar.bz2
- cat ../uClibc++-$(VERSION).tar | xz -e -c8 > ../uClibc++-$(VERSION).tar.xz
- du -b ../uClibc++-$(VERSION).tar.{bz2,xz}
-
-headers: include/system_configuration.h
-
-install:
- for dir in $(SUBDIRS) ; do \
- $(MAKE) -C $$dir install; \
- done
-
-
-#Menu configuration system
-
-extra/config/conf:
- @$(MAKE) -C extra/config conf
-
-extra/config/mconf:
- @$(MAKE) -C extra/config ncurses mconf
-
-menuconfig: extra/config/mconf
- @$< extra/Configs/Config.in
-
-config: extra/config/conf
- @$< extra/Configs/Config.in
-
-oldconfig: extra/config/conf
- @$< -o extra/Configs/Config.in
-
-silentoldconfig: extra/config/conf
- @$< -s extra/Configs/Config.in
-
-randconfig: extra/config/conf
- @$< -r extra/Configs/Config.in
-
-allyesconfig: extra/config/conf
- @$< -y extra/Configs/Config.in
-
-allnoconfig: extra/config/conf
- @$< -n extra/Configs/Config.in
-
-defconfig: extra/config/conf
- @$< -d extra/Configs/Config.in
-
-include/system_configuration.h: .config
- @if [ ! -x ./extra/config/conf ] ; then \
- $(MAKE) -C extra/config conf; \
- fi;
- @extra/config/conf -o extra/Configs/Config.in
-
-.config:
- $(MAKE) defconfig
+top_srcdir=./
+top_builddir=$(if $(O),$(O),.)/
+export top_builddir
+all:
+include $(top_srcdir)Rules.mak
+include Makefile.in
+include $(top_srcdir)Makefile.end
diff --git a/Makefile.end b/Makefile.end
new file mode 100644
index 0000000..87fc87e
--- /dev/null
+++ b/Makefile.end
@@ -0,0 +1,44 @@
+# Rules.mak
+# vi: ft=make :
+
+# Copyright Garrett Kajmowicz, 2004-2006
+# Copyright (C) 2000 by Lineo, inc.
+# Copyright (C) 2000-2002 Erik Andersen <andersen at uclibc.org>
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Library General Public License as published by the Free
+# Software Foundation; either version 2 of the License, or (at your option) any
+# later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Library General Public License
+# along with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+# This file and most of the menuconfiguration system have been taken wholesale from
+# the uClibc package availalble at www.uclibc.org
+
+ifeq ($(HAVE_DOT_CONFIG),y)
+# dependency tracking
+files.dep := $(libcxx-a-y) $(libcxx-so-y) $(libcxx-nonshared-y) \
+ $(libgcc_eh-y) $(libsupc-y)
+.depends.dep := \
+ $(patsubst %.s,%.s.dep,$(filter %.s,$(files.dep))) \
+ $(patsubst %.o,%.o.dep,$(filter %.o,$(files.dep)))
+# Oh, and prepend a dot to the basename so i don't have to change my habit of
+# calling 'size thefile.o*'
+.depends.dep := $(foreach f,$(.depends.dep),$(dir $(f)).$(notdir $(f)))
+.depends.dep := $(wildcard $(.depends.dep)) $(manual.depends.dep)
+
+ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
+ifneq ($(strip $(.depends.dep)),)
+.NOEXPORT:
+-include $(.depends.dep)
+endif # filter
+endif # any .dep file
+
+endif # ifeq ($(HAVE_DOT_CONFIG),y)
diff --git a/Makefile.in b/Makefile.in
new file mode 100644
index 0000000..2830e8e
--- /dev/null
+++ b/Makefile.in
@@ -0,0 +1,125 @@
+ifeq ($(HAVE_DOT_CONFIG),y)
+all: lib
+else
+all: defconfig
+endif
+
+include $(top_srcdir)bin/Makefile.in
+include $(top_srcdir)include/Makefile.in
+include $(top_srcdir)src/Makefile.in
+include $(top_srcdir)extra/Makefile.in
+
+$(headers-y) $(libcxx-a-y) $(libcxx-so-y): include/system_configuration.h
+
+tests: lib
+ $(Q)$(MAKE) -C tests all
+
+check test: tests
+ $(Q)$(MAKE) -C tests test
+
+release:
+ $(RM) ../uClibc++-$(VERSION).tar
+ git archive --format=tar --prefix=uClibc++-$(VERSION)/ HEAD \
+ > ../uClibc++-$(VERSION).tar
+ cat ../uClibc++-$(VERSION).tar | bzip2 -c9 > ../uClibc++-$(VERSION).tar.bz2
+ cat ../uClibc++-$(VERSION).tar | xz -e -c8 > ../uClibc++-$(VERSION).tar.xz
+ du -b $(addprefix ../uClibc++-$(VERSION).tar.,bz2 xz)
+
+install: install-bin install-include install-lib
+
+clean: CLEAN_bin CLEAN_src
+ #$(MAKE) -C $(top_builddir)extra/locale clean
+
+realclean: clean DISTCLEAN_extra DISTCLEAN_include DISTCLEAN_src
+distclean: realclean DISTCLEAN_.config
+DISTCLEAN_.config:
+ $(do_rm) $(addprefix $(top_builddir),.config .config.cmd .config.old)
+
+#Menu configuration system
+
+extra/config/conf:
+ $(Q)$(MAKE) -C extra/config conf
+
+extra/config/mconf:
+ $(Q)$(MAKE) -C extra/config ncurses mconf
+
+menuconfig: extra/config/mconf
+ $(Q)$< extra/Configs/Config.in
+
+config: extra/config/conf
+ $(Q)$< extra/Configs/Config.in
+
+oldconfig: extra/config/conf
+ $(Q)$< -o extra/Configs/Config.in
+
+silentoldconfig: extra/config/conf
+ $(Q)$< -s extra/Configs/Config.in
+
+randconfig: extra/config/conf
+ $(Q)$< -r extra/Configs/Config.in
+
+allyesconfig: extra/config/conf
+ $(Q)$< -y extra/Configs/Config.in
+
+allnoconfig: extra/config/conf
+ $(Q)$< -n extra/Configs/Config.in
+
+defconfig: extra/config/conf
+ $(Q)$< -d extra/Configs/Config.in
+
+include/system_configuration.h: .config | extra/config/conf
+ $(Q)extra/config/conf -o extra/Configs/Config.in
+
+
+ifeq ($(HAVE_DOT_CONFIG),)
+.config: defconfig
+endif
+
+help:
+ @echo 'Cleaning:'
+ @echo ' clean - delete temporary object files'
+ @echo ' realclean - delete temporary object files, including dependencies'
+ @echo ' distclean - delete all non-source files (including .config)'
+ @echo
+ @echo 'Build:'
+ @echo ' all - libraries'
+ @echo
+ @echo 'Configuration:'
+ @echo ' allnoconfig - disable all symbols in .config'
+ @echo ' allyesconfig - enable all symbols in .config (see defconfig)'
+ @echo ' config - text based configurator (of last resort)'
+ @echo ' defconfig - set .config to arch-specific defaults'
+ @echo ' menuconfig - interactive curses-based configurator'
+ @echo ' oldconfig - resolve any unresolved symbols in .config'
+ @echo ' silentoldconfig - resolve any unresolved symbols in .config, silently'
+ @echo ' randconfig - generate a random .config'
+ @$(if $(arch-defconfigs), \
+ @echo ''; \
+ echo 'Architecture specific configs ($(ARCH))'; \
+ $(foreach c, $(arch-defconfigs), \
+ printf " %-21s - Build for %s\\n" $(c) $(subst _defconfig,,$(c));) \
+ )
+ @echo
+ @echo 'Installation:'
+ @echo ' install - install both the runtime and the headers'
+ @echo
+ @echo 'Development:'
+ @echo ' check - run testsuite'
+ @echo ' tests - compile testsuite binaries'
+ @echo ' release - create a distribution tarball'
+ @echo
+ @echo 'Environment variables:'
+ @echo ' V="" - Quiet build (default)'
+ @echo ' V=1 - Brief build (show defines, ld flags)'
+ @echo ' V=2 - Very verbose build'
+ @echo ' CROSS_COMPILE= - Override CROSS_COMPILER_PREFIX from .config'
+ @echo ' SHELL= - Shell to use for make'
+ @echo ' HOSTCC= - C Compiler for compiling host binaries'
+ @echo ' HOSTCXX= - C++ Compiler for compiling host binaries'
+ @echo ' HOSTCFLAGS= - extra CFLAGS for compiling host binaries'
+ @echo ' HOSTCXXFLAGS= - extra CXXFLAGS for compiling host binaries'
+ @echo ' HOSTLDFLAGS= - extra LDFLAGS for linking host binaries'
+ @echo
+ @echo ' DESTDIR= - Prepended prefix to installation paths'
+ @echo ' CPU_CFLAGS - extra C- and CXX- FLAGS for compiling uClibc++'
+ @echo ' BUILD_EXTRA_LIBRARIES - extra LDFLAGS for linking uClibc++ itself'
diff --git a/Rules.mak b/Rules.mak
index f4b60c5..39e4245 100644
--- a/Rules.mak
+++ b/Rules.mak
@@ -1,4 +1,5 @@
# Rules.mak
+# vi: ft=make :
# Copyright Garrett Kajmowicz, 2004-2006
# Copyright (C) 2000 by Lineo, inc.
@@ -18,26 +19,39 @@
# along with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-# This file and most of the menuconfiguration system have been taken wholesle from
+# This file and most of the menuconfiguration system have been taken wholesale from
# the uClibc package availalble at www.uclibc.org
-ifndef CROSS
-CROSS=
+.SUFFIXES:
+.SUFFIXES: .cpp .c .S .o .so .a .s .i
+PHONY := FORCE
+.PHONY: $(PHONY) all clean realclean distclean install
+FORCE:
+
+ifdef CROSS
+# CROSS is still supported for backward compatibily only
+$(warning CROSS is deprecated, please use CROSS_COMPILE instead)
+ifneq ($(CROSS_COMPILE),)
+$(warning CROSS_COMPILE has precedence over CROSS, ignoring the latter)
+endif
endif
-CC= $(CROSS)gcc
-CXX= $(CROSS)g++
-AR= $(CROSS)ar
-LD= $(CROSS)ld
-NM= $(CROSS)nm
-RANLIB= $(CROSS)ranlib
-STRIPTOOL= $(CROSS)strip
+CROSS_COMPILE ?= $(CROSS)
+CC= $(CROSS_COMPILE)gcc
+CXX= $(CROSS_COMPILE)g++
+AR= $(CROSS_COMPILE)ar
+LD= $(CROSS_COMPILE)ld
+NM= $(CROSS_COMPILE)nm
+RANLIB= $(CROSS_COMPILE)ranlib
+STRIPTOOL= $(CROSS_COMPILE)strip
-INSTALL= install
-LN= ln -s -f
-RM= rm -f
-TAR= tar
+INSTALL = install
+LN = ln
+RM = rm -f
+TAR = tar
+SED = sed
+AWK = awk
-ARFLAGS:= rcs
+ARFLAGS:= cr
# Select the compiler needed to build binaries for your development system
HOSTCC=gcc
@@ -49,39 +63,104 @@ HOSTCXXFLAGS=-O2 -Wall
# Nothing beyond this point should ever be touched by mere mortals.
# Unless you hang out with the gods, you should probably leave all
# this stuff alone.
+
MAJOR_VERSION:=0
MINOR_VERSION:=2
SUBLEVEL:=5-git
VERSION:=$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL)
-# Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc.
-# LC_ALL:= C
-# export MAJOR_VERSION MINOR_VERSION SUBLEVEL VERSION LC_ALL
-export MAJOR_VERSION MINOR_VERSION SUBLEVEL VERSION
+ABI_VERSION:=$(MAJOR_VERSION)
+export MAJOR_VERSION MINOR_VERSION SUBLEVEL VERSION ABI_VERSION
LNAME:=uClibc++
LIBNAME:=libuClibc++
SHARED_FULLNAME:=$(LIBNAME)-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so
-SHARED_MAJORNAME:=$(LIBNAME).so.$(MAJOR_VERSION)
+SHARED_MAJORNAME:=$(LIBNAME).so.$(ABI_VERSION)
# Make sure DESTDIR and PREFIX can be used to install
+ifdef PREFIX
# PREFIX is a uClibcism while DESTDIR is a common GNUism
-PREFIX = $(DESTDIR)
+$(warning PREFIX is deprecated, please use DESTDIR instead)
+ifneq ($(DESTDIR),)
+$(warning DESTDIR has precedence over PREFIX, ignoring the latter)
+endif
+endif
+DESTDIR ?= $(PREFIX)
+
+clean_targets := clean distclean CLEAN_% DISTCLEAN_%
+noconfig_targets := conf mconf \
+ menuconfig config oldconfig silentoldconfig randconfig \
+ defconfig allyesconfig allnoconfig $(clean_targets) \
+ release tags TAGS help
# Pull in the user's uClibc++ configuration
ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
# Prevent make from searching
--include $(abspath $(TOPDIR).config)
+-include $(abspath $(top_builddir).config)
endif
+comma:=,
+space:= #
+
# A nifty macro to make testing gcc features easier
-check_gcc=$(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
- then echo "$(1)"; else echo "$(2)"; fi)
+check_gcc=$(shell \
+ if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
+ then echo "$(1)"; else echo "$(2)"; fi)
+check_as=$(shell \
+ if $(CC) -Wa,$(1) -Wa,-Z -c -o /dev/null -xassembler /dev/null > /dev/null 2>&1; \
+ then echo "-Wa,$(1)"; fi)
+check_ld=$(shell \
+ if $(LD) $(1) -o /dev/null -b binary /dev/null > /dev/null 2>&1; \
+ then echo "$(1)"; fi)
-check_gxx_visibility=$(shell if $(CXX) -fvisibility-inlines-hidden -S -o /dev/null -xc++ /dev/null > /dev/null 2>&1; \
- then echo "-DGCC_HASCLASSVISIBILITY"; fi)
+# Use variable indirection here so that we can have variable
+# names with fun chars in them like equal signs
+define check-tool-var
+ifeq ($(filter $(clean_targets) CLEAN_%,$(MAKECMDGOALS)),)
+_v = $(2)_$(3)
+ifndef $$(_v)
+$$(_v) := $$(call $(1),$(subst %, ,$(3)))
+export $$(_v)
+endif
+endif
+endef
+
+# Usage: check-gcc-var,<flag>
+# Check the C compiler to see if it supports <flag>.
+# Export the variable CFLAG_<flag> if it does.
+define check-gcc-var
+$(call check-tool-var,check_gcc,CFLAG,$(1))
+endef
+# Usage: check-as-var,<flag>
+# Check the assembler to see if it supports <flag>. Export the
+# variable ASFLAG_<flag> if it does (for invoking the assembler),
+# as well CFLAG_-Wa<flag> (for invoking the compiler driver).
+define check-as-var
+$(call check-tool-var,check_as,ASFLAG,$(1))
+_v = CFLAG_-Wa$(1)
+export $$(_v) = $$(if $$(ASFLAG_$(1)),-Wa$$(comma)$$(ASFLAG_$(1)))
+endef
+# Usage: check-ld-var,<flag>
+# Check the linker to see if it supports <flag>. Export the
+# variable LDFLAG_<flag> if it does (for invoking the linker),
+# as well CFLAG_-Wl<flag> (for invoking the compiler driver).
+define check-ld-var
+$(call check-tool-var,check_ld,LDFLAG,$(1))
+_v = CFLAG_-Wl$(1)
+export $$(_v) = $$(if $$(LDFLAG_$(1)),-Wl$$(comma)$$(LDFLAG_$(1)))
+endef
+# Usage: cache-output-var,<variable>,<shell command>
+# Execute <shell command> and cache the output in <variable>.
+define cache-output-var
+ifndef $(1)
+$(1) := $$(shell $(2))
+export $(1)
+endif
+endef
-check_as_needed=$(shell if $(LD) --help | grep -q 'as-needed' ; \
- then echo "-Wl,--as-needed -lgcc_s -Wl,--no-as-needed"; else echo "-lgcc_s"; fi)
+$(eval $(call cache-output-var,GCC_VER,$(CC) -dumpversion))
+GCC_VER := $(subst ., ,$(GCC_VER))
+GCC_MAJOR_VER ?= $(word 1,$(GCC_VER))
+#GCC_MINOR_VER ?= $(word 2,$(GCC_VER))
# strip quotes
qstrip = $(strip $(subst ",,$(1)))
@@ -96,11 +175,20 @@ UCLIBCXX_RUNTIME_BINDIR:=$(strip $(subst //,/, $(subst //,/, $(subst ,/, $(call
UCLIBCXX_RUNTIME_INCLUDEDIR:=$(strip $(subst //,/, $(subst //,/, $(subst ,/, $(call qstrip,$(UCLIBCXX_RUNTIME_PREFIX)$(UCLIBCXX_RUNTIME_INCLUDE_SUBDIR))))))
export UCLIBCXX_RUNTIME_PREFIX UCLIBCXX_RUNTIME_LIBDIR UCLIBCXX_RUNTIME_BINDIR UCLIBCXX_RUNTIME_INCLUDEDIR
+WRAPPER = $(top_builddir)bin/g++-uc
OPTIMIZATION:=
PICFLAG:=-fPIC
# use '-Os' optimization if available, else use -O2, allow Config to override
-OPTIMIZATION+=$(call check_gcc,-Os,-O2)
+$(eval $(call check-gcc-var,-Os))
+ifneq ($(CFLAG_-Os),)
+OPTIMIZATION += $(CFLAG_-Os)
+else
+$(eval $(call check-gcc-var,-O2))
+OPTIMIZATION += $(CFLAG_-O2)
+endif
+
+$(eval $(call check-gcc-var,-fvisibility-inlines-hidden))
# Add a bunch of extra pedantic annoyingly strict checks
XWARNINGS=$(call qstrip,$(UCLIBCXX_WARNINGS)) -Wno-trigraphs -pedantic
@@ -110,10 +198,12 @@ CPU_CFLAGS=$(call qstrip,$(CPU_CFLAGS-y))
GEN_CFLAGS:=-fno-builtin
CFLAGS:=$(XWARNINGS) $(CPU_CFLAGS) -ansi
-LDFLAGS:=-Wl,--warn-common -Wl,--warn-once -Wl,-z,combreloc -Wl,-z,defs
+LDFLAGS-$(LIBNAME).so:=-Wl,--warn-common -Wl,--warn-once -Wl,-z,combreloc -Wl,-z,defs
+STRIP_FLAGS-src := -x -R .note -R .comment
+STRIP_FLAGS-src/abi := -x -R .note -R .comment
ifeq ($(DODEBUG),y)
- CFLAGS += -O0 -g3
+ CFLAGS += -O0 -g3
STRIPTOOL:= true -Since_we_are_debugging
else
CFLAGS += $(OPTIMIZATION)
@@ -129,15 +219,24 @@ ifneq ($(UCLIBCXX_EXCEPTION_SUPPORT),y)
endif
GEN_CXXFLAGS:=-nostdinc++
-GEN_CXXFLAGS+=$(call check_gxx_visibility)
+GEN_CXXFLAGS+=$(if $(CFLAG_-fvisibility-inlines-hidden),-DGCC_HASCLASSVISIBILITY)
CXXFLAGS:=$(CFLAGS)
LIBGCC:=$(shell $(CC) -print-libgcc-file-name)
LIBGCC_DIR:=$(dir $(LIBGCC))
-#GCC_VERSION?=$(shell $(CC) -dumpversion | cut -c1-3)
-GCC_MAJOR_VER?=$(shell $(CC) -dumpversion | cut -c1)
-#GCC_MINOR_VER?=$(shell $(CC) -dumpversion | cut -c3)
+# Let users override these
+ifndef LIBGCC_EH
+$(eval $(call cache-output-var,FILE_LIBGCC_EH,$(CXX) -print-file-name=libgcc_eh.a))
+LIBGCC_EH:=$(strip $(if $(IMPORT_LIBGCC_EH),$(FILE_LIBGCC_EH)))
+endif
+ifndef LIBSUP
+$(eval $(call cache-output-var,FILE_LIBSUP,$(CXX) -print-file-name=libsupc++.a))
+LIBSUP:=$(strip $(if $(IMPORT_LIBSUP),$(FILE_LIBSUP)))
+endif
+
+list-archive-members = $(if $(1),$(shell $(AR) t $(1)))
+variablify = $(strip $(subst /,_,$(subst :,_,$(subst ;,_,$(subst |,_,$(subst >,_,$(subst <,_,$(1))))))))
GEN_LIBS:=
ifneq ($(LIBGCC_DIR),$(UCLIBCXX_RUNTIME_LIBDIR))
@@ -150,16 +249,336 @@ GEN_LIBS += -lc -lgcc
LIBS := $(GEN_LIBS)
STATIC_LIBS := $(GEN_LIBS)
-#ifeq ($(UCLIBCXX_EXCEPTION_SUPPORT),y)
+
+$(eval $(call cache-output-var,LDASNEEDED,$(LD) --help 2>/dev/null | grep -q -- --as-needed && echo y))
+link.asneeded = $(if $1,$(if $(LDASNEEDED),-Wl$(comma)--as-needed $(1) -Wl$(comma)--no-as-needed,$(1)))
+
ifneq ($(GCC_MAJOR_VER),3)
-LIBS += $(call check_as_needed)
+LIBS-ASNEEDED-$(LIBNAME).so = -lgcc_s
endif
ifneq ($(IMPORT_LIBGCC_EH),y)
STATIC_LIBS += -lgcc_eh
-ifeq ($(GCC_MAJOR_VER),3)
- LIBS += -lgcc_eh
+#ifeq ($(GCC_MAJOR_VER),3)
+# LIBS += -lgcc_eh
+#endif
endif
+
+# We do not need built-in implicit rules
+MAKEFLAGS += -r
+
+ifneq ($(findstring s,$(MAKEFLAGS)),)
+export MAKE_IS_SILENT := y
+SECHO := - at false
+DISP := sil
+Q := @
+else
+export MAKE_IS_SILENT := n
+SECHO := @echo
+ifneq ($(V)$(VERBOSE),)
+ifeq ($(V),1)
+DISP := bri# brief, like pur but with defines
+Q := @
+else
+SHELL_SET_X := set -x
+DISP := ver
+Q :=
endif
-#endif
+else
+DISP := pur
+Q := @
+endif
+endif
+
+show_objs = $(subst $(top_builddir),,$(subst ../,,$@))
+define show_defs
+ $(filter -D%,$(1))
+endef
+define show_ldflags
+ $(subst $(comma), ,$(subst -Wl$(comma),,$(filter -Wl%,$(1))))
+endef
+
+pur_disp_compile.cxx = echo " "CXX $(show_objs)
+pur_disp_compile.c = echo " "CC $(show_objs)
+pur_disp_compile.ixx = echo " "CPP $(show_objs)
+pur_disp_compile.i = echo " "CPP $(show_objs)
+pur_disp_compile.sxx = echo " "CXX-S $(show_objs)
+pur_disp_compile.s = echo " "CC-S $(show_objs)
+pur_disp_compile.u = echo " "CC $(show_objs)
+pur_disp_compile.S = echo " "AS $(show_objs)
+pur_disp_compile.uxx = echo " "CXX $(show_objs)
+pur_disp_compile.oxx = echo " "CXX-o $(show_objs)
+pur_disp_hcompile.u = echo " "HOSTCC $(show_objs)
+pur_disp_hcompile.o = echo " "HOSTCC-o $(show_objs)
+pur_disp_hcompile.uxx= echo " "HOSTCXX $(show_objs)
+pur_disp_hcompile.oxx= echo " "HOSTCXX-o $(show_objs)
+pur_disp_strip = echo " "STRIP $(STRIP_FLAGS) $@
+pur_disp_t_strip = echo " "STRIP $(STRIP_FLAGS-$(@D)) $@
+pur_disp_ar = echo " "AR $(ARFLAGS) $@
+pur_disp_ranlib = echo " "RANLIB $(RANLIBFLAGS) $@
+pur_disp_ld = echo " "LD $(call dirify,$(1))
+pur_disp_ln = echo " "LN $(show_objs)
+pur_disp_mkdir = echo " "MKDIR $(show_objs)
+pur_disp_gen = echo " "GEN $(show_objs)
+pur_disp_install = echo " "INSTALL $(1)
+pur_disp_unifdef = echo " "UNIFDEF $(show_objs)
+pur_disp_rm = echo " "CLEAN $(subst CLEAN_,,$(subst DISTCLEAN_,,$@))
+
+sil_disp_compile.cxx = true
+sil_disp_compile.c = true
+sil_disp_compile.ixx = true
+sil_disp_compile.i = true
+sil_disp_compile.sxx = true
+sil_disp_compile.s = true
+sil_disp_compile.u = true
+sil_disp_compile.S = true
+sil_disp_compile.uxx = true
+sil_disp_compile.oxx = true
+sil_disp_hcompile.u = true
+sil_disp_hcompile.o = true
+sil_disp_hcompile.uxx= true
+sil_disp_hcompile.oxx= true
+sil_disp_strip = true
+sil_disp_t_strip = true
+sil_disp_ar = true
+sil_disp_ranlib = true
+sil_disp_ld = true
+sil_disp_ln = true
+sil_disp_mkdir = true
+sil_disp_gen = true
+sil_disp_install = true
+sil_disp_unifdef = true
+sil_disp_rm = true
+
+bri_disp_compile.cxx = $(pur_disp_compile.cxx) $(call show_defs,$(cmd_compile.cxx))
+bri_disp_compile.c = $(pur_disp_compile.c) $(call show_defs,$(cmd_compile.c))
+bri_disp_compile.ixx = $(pur_disp_compile.ixx) $(call show_defs,$(cmd_compile.ixx))
+bri_disp_compile.i = $(pur_disp_compile.i) $(call show_defs,$(cmd_compile.i))
+bri_disp_compile.sxx = $(pur_disp_compile.sxx) $(call show_defs,$(cmd_compile.sxx))
+bri_disp_compile.s = $(pur_disp_compile.s) $(call show_defs,$(cmd_compile.s))
+bri_disp_compile.u = $(pur_disp_compile.u) $(call show_defs,$(cmd_compile.u))
+bri_disp_compile.S = $(pur_disp_compile.S) $(call show_defs,$(cmd_compile.S))
+bri_disp_compile.uxx = $(pur_disp_compile.uxx) $(call show_defs,$(cmd_compile.uxx))
+bri_disp_compile.oxx = $(pur_disp_compile.oxx) $(call show_defs,$(cmd_compile.oxx))
+bri_disp_hcompile.u = $(pur_disp_hcompile.u) $(call show_defs,$(cmd_hcompile.u))
+bri_disp_hcompile.o = $(pur_disp_hcompile.o) $(call show_defs,$(cmd_hcompile.o))
+bri_disp_hcompile.uxx=$(pur_disp_hcompile.uxx) $(call show_defs,$(cmd_hcompile.uxx))
+bri_disp_hcompile.oxx=$(pur_disp_hcompile.oxx) $(call show_defs,$(cmd_hcompile.oxx))
+bri_disp_strip = $(pur_disp_strip)
+bri_disp_t_strip = $(pur_disp_t_strip)
+bri_disp_ar = $(pur_disp_ar)
+bri_disp_ranlib = $(pur_disp_ranlib)
+bri_disp_ld = $(pur_disp_ld) $(call show_ldflags,$(cmd_ld))
+bri_disp_ln = $(pur_disp_ln)
+bri_disp_mkdir = $(pur_disp_mkdir)
+bri_disp_gen = $(pur_disp_gen)
+bri_disp_install = $(pur_disp_install)
+bri_disp_unifdef = $(pur_disp_unifdef)
+bri_disp_rm = $(pur_disp_rm)
+
+esc=$(subst ','\'',$(1))
+# ')
+ver_disp_compile.cxx = echo '$(call esc,$(cmd_compile.cxx))'
+ver_disp_compile.c = echo '$(call esc,$(cmd_compile.c))'
+ver_disp_compile.ixx = echo '$(call esc,$(cmd_compile.ixx))'
+ver_disp_compile.i = echo '$(call esc,$(cmd_compile.i))'
+ver_disp_compile.sxx = echo '$(call esc,$(cmd_compile.sxx))'
+ver_disp_compile.s = echo '$(call esc,$(cmd_compile.s))'
+ver_disp_compile.u = echo '$(call esc,$(cmd_compile.u))'
+ver_disp_compile.S = echo '$(call esc,$(cmd_compile.S))'
+ver_disp_compile.uxx = echo '$(call esc,$(cmd_compile.uxx))'
+ver_disp_compile.oxx = echo '$(call esc,$(cmd_compile.oxx))'
+ver_disp_hcompile.u = echo '$(call esc,$(cmd_hcompile.u))'
+ver_disp_hcompile.o = echo '$(call esc,$(cmd_hcompile.o))'
+ver_disp_hcompile.uxx= echo '$(call esc,$(cmd_hcompile.uxx))'
+ver_disp_hcompile.oxx= echo '$(call esc,$(cmd_hcompile.oxx))'
+ver_disp_strip = echo '$(call esc,$(cmd_strip))'
+ver_disp_t_strip = echo '$(call esc,$(cmd_t_strip))'
+ver_disp_ar = echo '$(call esc,$(cmd_ar))'
+ver_disp_ranlib = echo '$(call esc,$(cmd_ranlib))'
+ver_disp_ld =
+ver_disp_ln =
+ver_disp_mkdir =
+ver_disp_gen =
+ver_disp_install =
+ver_disp_unifdef = echo '$(call esc,$(cmd_unifdef))'
+ver_disp_rm =
+
+disp_compile.cxx = $($(DISP)_disp_compile.cxx)
+disp_compile.c = $($(DISP)_disp_compile.c)
+disp_compile.ixx = $($(DISP)_disp_compile.ixx)
+disp_compile.i = $($(DISP)_disp_compile.i)
+disp_compile.s = $($(DISP)_disp_compile.s)
+disp_compile.sxx = $($(DISP)_disp_compile.sxx)
+disp_compile.u = $($(DISP)_disp_compile.u)
+disp_compile.S = $($(DISP)_disp_compile.S)
+disp_compile.uxx = $($(DISP)_disp_compile.uxx)
+disp_compile.oxx = $($(DISP)_disp_compile.oxx)
+disp_hcompile.u = $($(DISP)_disp_hcompile.u)
+disp_hcompile.o = $($(DISP)_disp_hcompile.o)
+disp_hcompile.uxx= $($(DISP)_disp_hcompile.uxx)
+disp_hcompile.oxx= $($(DISP)_disp_hcompile.oxx)
+disp_strip = $($(DISP)_disp_strip)
+disp_t_strip = $($(DISP)_disp_t_strip)
+disp_ar = $($(DISP)_disp_ar)
+disp_ranlib = $($(DISP)_disp_ranlib)
+disp_ld = $($(DISP)_disp_ld)
+disp_ln = $($(DISP)_disp_ln)
+disp_mkdir = $($(DISP)_disp_mkdir)
+disp_gen = $($(DISP)_disp_gen)
+disp_install = $($(DISP)_disp_install)
+disp_unifdef = $($(DISP)_disp_unifdef)
+disp_rm = $($(DISP)_disp_rm)
+
+any-prereq = $(filter-out $(PHONY),$?) $(filter-out $(PHONY) $(wildcard $^),$^)
+
+# strip the top_builddir off everything to make the *string* idempotent for -C
+dirify = $(subst $(top_builddir),,$(patsubst -L$(top_builddir)%,-L%,$(patsubst -I$(top_builddir)%,-I%,$(1))))
+unwrapper = $(call dirify,$(subst $(call dirify,$(WRAPPER)),$(CXX) $(GEN_CFLAGS) $(GEN_CXXFLAGS) $(EH_CXXFLAGS),$(subst WRAPPER_INCLUDEDIR=,,$(subst WRAPPER_LIBDIR=,,$(1)))))
+# True if not identical. Neither order nor whitespace nor identical flags
+# matter.
+compare_flags = \
+ $(strip $(filter-out $(call unwrapper,$(cmd_$(call variablify,$(call dirify,$(1))))), \
+ $(call unwrapper,$(cmd_$(call variablify,$(call dirify,$(@)))))) \
+ $(filter-out $(call unwrapper,$(cmd_$(call variablify,$(call dirify,$(@))))), \
+ $(call unwrapper,$(cmd_$(call variablify,$(call dirify,$(1)))))))
+
+# Rebuild if any prerequisite, the used CC or flags changed.
+# Previously used flags are stored in the corresponding .%.dep files
+maybe_exec = \
+ $(if $(strip $(compare_flags) $(any-prereq)), \
+ @set -e; \
+ $(disp_$(1)); \
+ $(cmd_$(1)); \
+ echo 'cmd_$(call variablify,$(call dirify,$(@))) := $(call dirify,$(cmd_$(call variablify,$(call dirify,$(1)))))' >> $(dir $@).$(notdir $@).dep)
-.PHONY: all clean distclean install
+CFLAGS_gen.dep = -MT $@ -MD -MP -MF $(dir $@).$(notdir $@).dep
+
+cmd_compile.c = $(CC) $(CFLAGS_gen.dep) \
+ $(CFLAGS-$(suffix $@)) \
+ $(filter-out $(CFLAGS-OMIT-$(notdir $<)),$(CFLAGS-$(notdir $(<D)))) \
+ $(CFLAGS-$(subst $(top_srcdir),,$(dir $<))) \
+ $(CFLAGS-$(notdir $<)) \
+ $(CFLAGS-$(notdir $@)) \
+ $(CFLAGS) \
+ -c $< -o $@
+cmd_compile.i = $(cmd_compile.c:-c=-E -dD) $(UCLIBC_EXTRA_CPPFLAGS)
+cmd_compile.s = $(cmd_compile.c:-c=-S)
+cmd_compile.cxx = $(WR_CXX) $(CFLAGS_gen.dep) \
+ $(CXXFLAGS-$(suffix $@)) \
+ $(filter-out $(CXXFLAGS-OMIT-$(notdir $<)),$(CXXFLAGS-$(notdir $(<D)))) \
+ $(CXXFLAGS-$(subst $(top_srcdir),,$(dir $<))) \
+ $(CXXFLAGS-$(notdir $<)) \
+ $(CXXFLAGS-$(notdir $@)) \
+ $(CXXFLAGS) \
+ -c $< -o $@
+cmd_compile.ixx = $(cmd_compile.cxx:-c=-E -dD) $(CXXCPPFLAGS)
+cmd_compile.sxx = $(cmd_compile.cxx:-c=-S)
+cmd_compile.oxx = $(WR_CXX) $(CFLAGS_gen.dep) \
+ $(CXXFLAGS-$(suffix $@)) \
+ $(filter-out $(CXXFLAGS-OMIT-$(notdir $<)),$(CXXFLAGS-$(notdir $(<D)))) \
+ $(CXXFLAGS-$(subst $(top_srcdir),,$(dir $<))) \
+ $(CXXFLAGS-$(notdir $<)) \
+ $(CXXFLAGS-$(notdir $@)) \
+ $(CXXFLAGS) \
+ -c $< -o $@
+cmd_compile.uxx = $(WR_CXX) $(CFLAGS_gen.dep) \
+ $(filter-out $(CXXFLAGS-OMIT-$(notdir $<)),$(CXXFLAGS-$(notdir $(<D)))) \
+ $(CXXFLAGS-$(subst $(top_srcdir),,$(dir $<))) \
+ $(CXXFLAGS-$(notdir $<)) \
+ $(CXXFLAGS-$(notdir $@)) \
+ $(CXXFLAGS) \
+ $^ $(LDFLAGS) $(DEPS-$(notdir $@)) -o $@
+cmd_compile.u = $(CC) $(CFLAGS_gen.dep) $(CFLAGS) $(CFLAGS-$(notdir $(^D))) $(CFLAGS-$(notdir $@)) $^ $(DEPS-$(notdir $@)) -o $@
+cmd_compile.S = $(filter-out -std=gnu99, $(cmd_compile.c)) -D__ASSEMBLER__ $(ASFLAGS) $(ARCH_ASFLAGS) $(ASFLAGS-$(suffix $@)) $(ASFLAGS-$(notdir $<)) $(ASFLAGS-$(notdir $@))
+cmd_hcompile.uxx = $(HOSTCXX) $(CFLAGS_gen.dep) $(HOSTCXXFLAGS) $(CXXFLAGS-$(notdir $(^D))) $(CXXFLAGS-$(notdir $@)) $^ $(HOSTLDFLAGS) $(DEPS-$(notdir $@)) -o $@
+cmd_hcompile.oxx = $(HOSTCXX) $(CFLAGS_gen.dep) $(HOSTCXXFLAGS) $(HOSTCXXFLAGS-$(notdir $(^D))) $(HOSTCXXFLAGS-$(notdir $@)) -c $< -o $@
+cmd_strip = $(STRIPTOOL) $(STRIP_FLAGS) $^
+cmd_t_strip = $(STRIPTOOL) $(STRIP_FLAGS) $@
+cmd_ar = $(AR) $(ARFLAGS) $@ $^
+cmd_ranlib = $(RANLIB) $(RANLIBFLAGS) $@
+
+define do_ln
+ @$(disp_ln)
+ $(Q)$(LN) -f -s
+endef
+
+define do_mkdir
+ @$(disp_mkdir)
+ $(Q)$(INSTALL) -d $@
+endef
+
+define do_rm
+ @$(disp_rm)
+ $(Q)$(RM)
+endef
+
+define do_awk
+ @$(disp_gen)
+ $(Q)$(AWK) -f
+endef
+
+define do_sed
+ @$(disp_gen)
+ $(Q)$(SED)
+endef
+
+compile.cxx = @$(call maybe_exec,compile.cxx)
+compile.c = @$(call maybe_exec,compile.c)
+compile.ixx = $(call maybe_exec,compile.ixx)
+compile.i = $(call maybe_exec,compile.i)
+compile.sxx = $(call maybe_exec,compile.sxx)
+compile.s = $(call maybe_exec,compile.s)
+compile.S = @$(call maybe_exec,compile.S)
+compile.uxx = @$(call maybe_exec,compile.uxx)
+compile.oxx = @$(call maybe_exec,compile.oxx)
+do_strip = @$(disp_strip) ; $(cmd_strip)
+do_t_strip = @$(disp_t_strip) ; $(cmd_t_strip)
+do_unifdef = @$(disp_unifdef) ; $(cmd_unifdef)
+hcompile.u = @$(disp_hcompile.u); $(cmd_hcompile.u)
+hcompile.o = @$(disp_hcompile.o); $(cmd_hcompile.o)
+hcompile.uxx= @$(call maybe_exec,hcompile.uxx)
+hcompile.oxx= @$(call maybe_exec,hcompile.oxx)
+
+define do_ar
+ @$(disp_ar) ; $(cmd_ar)
+ @$(disp_ranlib) ; $(cmd_ranlib)
+endef
+define compile.u
+ @$(disp_compile.u) ; $(cmd_compile.u)
+ @$(disp_t_strip)
+endef
+cmd_hcompile.u = $(HOSTCC) $(filter-out $(PHONY),$^) $(DEPS-$(notdir $@)) -o $@ $(HOSTLDFLAGS) $(HOSTLDFLAGS-$(notdir $(^D))) $(HOSTLDFLAGS-$(notdir $@)) $(HOSTCFLAGS) $(HOSTCFLAGS-$(notdir $(^D))) $(HOSTCFLAGS-$(notdir $@))
+cmd_hcompile.o = $(HOSTCC) $(filter-out $(PHONY),$<) $(DEPS-$(notdir $@)) -c -o $@ $(HOSTCFLAGS) $(HOSTCFLAGS-$(notdir $(^D))) $(HOSTCFLAGS-$(notdir $@))
+
+define link.so
+ $(Q)$(RM) $@ $@.$(2) $(1)
+ @$(disp_ld)
+ $(Q)$(CXX) $(LDFLAGS-$(@F)) $(LDFLAGS-y-$(@F)) \
+ -Wl,-soname=$(@F).$(2) \
+ -o $(1) $^ \
+ $(START_FILE-$(@F)) \
+ $(LIBS-$(@F)) $(call link.asneeded,$(LIBS-ASNEEDED-$(@F))) \
+ $(END_FILE-$(@F))
+ $(Q)$(LN) -sf $(notdir $(1)) $@.$(2)
+ $(Q)$(LN) -sf $(@F).$(2) $@
+endef
+
+$(top_builddir)%.o: $(top_srcdir)%.cpp FORCE ; $(compile.cxx)
+$(top_builddir)%.o: $(top_srcdir)%.c FORCE ; $(compile.c)
+$(top_builddir)%.o: $(top_srcdir)%.S FORCE ; $(compile.S)
+$(top_builddir)%.o: $(top_srcdir)%.s FORCE ; $(compile.S)
+$(top_builddir)%.i: $(top_srcdir)%.cpp FORCE ; $(compile.ixx)
+$(top_builddir)%.i: $(top_srcdir)%.c FORCE ; $(compile.i)
+$(top_builddir)%.i: $(top_srcdir)%.S FORCE ; $(compile.i)
+$(top_builddir)%.s: $(top_srcdir)%.cpp FORCE ; $(compile.sxx)
+$(top_builddir)%.s: $(top_srcdir)%.c FORCE ; $(compile.s)
+$(top_builddir)%.s: $(top_srcdir)%.S FORCE ; $(compile.s)
+#$(top_builddir)tests/%.o: $(top_srcdir)tests/%.cpp FORCE ; $(hcompile.oxx)
+#$(top_builddir)tests/%: $(top_builddir)tests/%.o FORCE ; $(hcompile.uxx)
+$(top_builddir)%.dep:
+FORCE: ;
+
+ifeq ($(HAVE_DOT_CONFIG),y)
+$(DESTDIR)$(UCLIBCXX_RUNTIME_LIBDIR) $(DESTDIR)$(UCLIBCXX_RUNTIME_BINDIR) $(DESTDIR)$(UCLIBCXX_RUNTIME_INCLUDEDIR):
+ $(do_mkdir)
+endif
diff --git a/bin/Makefile b/bin/Makefile
index acf3b95..ee320d8 100644
--- a/bin/Makefile
+++ b/bin/Makefile
@@ -1,49 +1,6 @@
-TOPDIR=../
-include $(TOPDIR)Rules.mak
-
-WRAPPER = g++-uc
-
-all: $(WRAPPER)
-
-clean:
- $(RM) $(WRAPPER)
-
-install:
- $(INSTALL) -d $(PREFIX)$(UCLIBCXX_RUNTIME_BINDIR)
- $(INSTALL) -m 755 $(WRAPPER) $(PREFIX)$(UCLIBCXX_RUNTIME_BINDIR)
-
-$(WRAPPER): Makefile
- echo '#!/bin/sh' > $@
- echo '' >> $@
- echo 'WRAPPER_INCLUDEDIR="$${WRAPPER_INCLUDEDIR:=-I$(UCLIBCXX_RUNTIME_INCLUDEDIR)}"' >> $@
- echo 'WRAPPER_LIBDIR="$${WRAPPER_LIBDIR:=-L$(UCLIBCXX_RUNTIME_LIBDIR)}"' >> $@
- echo '' >> $@
- echo 'WRAPPER_OPTIONS=""' >> $@
- echo 'WRAPPER_LIBS="$(LIBS)"' >> $@
- echo '' >> $@
- echo 'WRAPPER_INCLIB="Y"' >> $@
- echo 'while [ -n "$$1" ]' >> $@
- echo 'do' >> $@
- echo ' WRAPPER_OPTIONS="$$WRAPPER_OPTIONS $$1"' >> $@
- echo ' if [ "$$1" = "-c" -o "$$1" = "-E" -o "$$1" = "-S" -o "$$1" = "-MF" ]' >> $@
- echo ' then' >> $@
- echo ' WRAPPER_INCLIB="N"' >> $@
- echo ' fi' >> $@
-ifneq ($(strip $(LIBS)),$(strip $(STATIC_LIBS)))
- echo ' if [ "$$1" = "-static" ]' >> $@
- echo ' then' >> $@
- echo ' WRAPPER_LIBS="$(STATIC_LIBS)"' >> $@
- echo ' fi' >> $@
-endif
- echo ' shift' >> $@
- echo 'done' >> $@
- echo 'if [ "$$WRAPPER_INCLIB" = "Y" ]' >> $@
- echo 'then' >> $@
- echo ' WRAPPER_OPTIONS="$$WRAPPER_OPTIONS -nodefaultlibs $$WRAPPER_LIBDIR -l$(LNAME) $$WRAPPER_LIBS"' >> $@
- echo 'fi' >> $@
- echo '' >> $@
-ifeq ($(DODEBUG),y)
- echo 'echo $(CXX) $(GEN_CFLAGS) $(GEN_CXXFLAGS) $(EH_CXXFLAGS) $$WRAPPER_INCLUDEDIR $$WRAPPER_OPTIONS' >> $@
-endif
- echo 'exec $(CXX) $(GEN_CFLAGS) $(GEN_CXXFLAGS) $(EH_CXXFLAGS) $$WRAPPER_INCLUDEDIR $$WRAPPER_OPTIONS' >> $@
- chmod 755 $@
+top_srcdir=../
+top_builddir=../
+all:
+include $(top_srcdir)Rules.mak
+include Makefile.in
+include $(top_srcdir)Makefile.end
diff --git a/bin/Makefile.in b/bin/Makefile.in
new file mode 100644
index 0000000..80b45bf
--- /dev/null
+++ b/bin/Makefile.in
@@ -0,0 +1,65 @@
+BIN_DIR := $(top_builddir)bin/
+CLEAN_bin:
+ $(do_rm) $(WRAPPER) $(BIN_DIR)env_check
+
+install-bin: $(WRAPPER) | $(DESTDIR)$(UCLIBCXX_RUNTIME_BINDIR)
+ @$(disp_install) $(call dirify,$(WRAPPER))
+ $(Q)$(INSTALL) -m 0755 $(WRAPPER) $(DESTDIR)$(UCLIBCXX_RUNTIME_BINDIR)
+
+# Rebuild wrapper whenever any of these vars change
+# Hardcoding these in the wrapper is arguably bad design but handy
+cmd_bin_env_check = CXX="$(CXX)" GEN_CFLAGS="$(GEN_CFLAGS)" GEN_CXXFLAGS="$(GEN_CXXFLAGS)" EH_CXXFLAGS="$(EH_CXXFLAGS)" UCLIBCXX_RUNTIME_INCLUDEDIR="$(UCLIBCXX_RUNTIME_INCLUDEDIR)" UCLIBCXX_RUNTIME_LIBDIR="$(UCLIBCXX_RUNTIME_LIBDIR)"
+
+.PHONY: $(BIN_DIR)env_check
+manual.depends.dep += $(BIN_DIR)env_check
+$(BIN_DIR)env_check:
+ @echo 'cmd_$(call variablify,$(call dirify,$(WRAPPER))) := $(cmd_bin_env_check)' > $@.new
+ @echo '' >> $@.new
+ @echo "\$$(if \$$(Q),,\$$(info read $@))" >> $@.new
+ @if cmp -s $@ $@.new ; then \
+ $(RM) $@.new ; \
+ else \
+ mv $@.new $@ ; \
+ $(RM) $(WRAPPER) ; \
+ fi
+
+define do_wrapper
+ @$(disp_gen)
+ $(Q)echo '#!/bin/sh' > $@.tmp
+ $(Q)echo '' >> $@.tmp
+ $(Q)echo 'WRAPPER_INCLUDEDIR="$${WRAPPER_INCLUDEDIR:=-I$(UCLIBCXX_RUNTIME_INCLUDEDIR)}"' >> $@.tmp
+ $(Q)echo 'WRAPPER_LIBDIR="$${WRAPPER_LIBDIR:=-L$(UCLIBCXX_RUNTIME_LIBDIR)}"' >> $@.tmp
+ $(Q)echo '' >> $@.tmp
+ $(Q)echo 'WRAPPER_OPTIONS=""' >> $@.tmp
+ $(Q)echo 'WRAPPER_LIBS="$(strip $(LIBS))"' >> $@.tmp
+ $(Q)echo '' >> $@.tmp
+ $(Q)echo 'WRAPPER_INCLIB="Y"' >> $@.tmp
+ $(Q)echo 'while [ -n "$$1" ]' >> $@.tmp
+ $(Q)echo 'do' >> $@.tmp
+ $(Q)echo ' WRAPPER_OPTIONS="$$WRAPPER_OPTIONS $$1"' >> $@.tmp
+ $(Q)echo ' if [ "$$1" = "-c" -o "$$1" = "-E" -o "$$1" = "-S" ]' >> $@.tmp
+ $(Q)echo ' then' >> $@.tmp
+ $(Q)echo ' WRAPPER_INCLIB="N"' >> $@.tmp
+ $(Q)echo ' fi' >> $@.tmp
+ $(Q)echo ' if [ "$$1" = "-static" -a "$$WRAPPER_LIBS" != "$(strip $(STATIC_LIBS))" ]' >> $@.tmp
+ $(Q)echo ' then' >> $@.tmp
+ $(Q)echo ' WRAPPER_LIBS="$(strip $(STATIC_LIBS))"' >> $@.tmp
+ $(Q)echo ' fi' >> $@.tmp
+ $(Q)echo ' shift' >> $@.tmp
+ $(Q)echo 'done' >> $@.tmp
+ $(Q)echo 'if [ "$$WRAPPER_INCLIB" = "Y" ]' >> $@.tmp
+ $(Q)echo 'then' >> $@.tmp
+ $(Q)echo ' WRAPPER_OPTIONS="$$WRAPPER_OPTIONS -nodefaultlibs $$WRAPPER_LIBDIR -l$(LNAME) $$WRAPPER_LIBS"' >> $@.tmp
+ $(Q)echo 'fi' >> $@.tmp
+ $(Q)echo '' >> $@.tmp
+ $(Q)echo '[ -n "$$V" ] && [ $$V -eq 1 ] && echo $(CXX) $(GEN_CFLAGS) $(GEN_CXXFLAGS) $(EH_CXXFLAGS) $$WRAPPER_INCLUDEDIR $$WRAPPER_OPTIONS' >> $@.tmp
+ $(Q)echo 'exec $(CXX) $(GEN_CFLAGS) $(GEN_CXXFLAGS) $(EH_CXXFLAGS) $$WRAPPER_INCLUDEDIR $$WRAPPER_OPTIONS' >> $@.tmp
+ $(Q)echo '' >> $@.tmp
+ $(Q)chmod 0755 $@.tmp
+ $(Q)mv $@.tmp $@
+endef
+
+$(WRAPPER) $(BIN_DIR)env_check: $(BIN_DIR)Makefile.in
+$(WRAPPER): $(BIN_DIR)env_check
+ $(if $(strip $(call compare_flags,$<) $?),$(do_wrapper))
+
diff --git a/extra/Configs/Config.in b/extra/Configs/Config.in
index 09c6fac..afc358a 100644
--- a/extra/Configs/Config.in
+++ b/extra/Configs/Config.in
@@ -257,7 +257,7 @@ config UCLIBCXX_RUNTIME_PREFIX
string "uClibc++ runtime prefix directory"
default "/usr/uClibc++"
help
- UCLIBCXX_ RUNTIME_PREFIX is the directory into which the uClibc++
+ UCLIBCXX_RUNTIME_PREFIX is the directory into which the uClibc++
runtime libraries will be installed.
For a typical target system this should be set to "/usr", so
diff --git a/extra/Makefile b/extra/Makefile
index 2371a81..90f9311 100644
--- a/extra/Makefile
+++ b/extra/Makefile
@@ -21,30 +21,8 @@
# other sundry sources. Files within this library are copyright by their
# respective copyright holders.
-TOPDIR=../
-include $(TOPDIR)Rules.mak
-LIBC=$(TOPDIR)libc.a
-
-
-DIRS =
-EXTRA_DIRS_TO_CLEAN = config
-
-all: subdirs
-
-tags:
- ctags -R
-
-clean: subdirs_clean
- $(RM) *.[oa] *~ core
-
-subdirs: $(patsubst %, _dir_%, $(DIRS))
-subdirs_clean: $(patsubst %, _dirclean_%, $(DIRS) $(EXTRA_DIRS_TO_CLEAN))
-
-$(patsubst %, _dir_%, $(DIRS)) : dummy
- $(MAKE) -C $(patsubst _dir_%, %, $@)
-
-$(patsubst %, _dirclean_%, $(DIRS) $(EXTRA_DIRS_TO_CLEAN)) : dummy
- $(MAKE) -C $(patsubst _dirclean_%, %, $@) clean
-
-.PHONY: dummy
-
+top_srcdir=../
+top_builddir=../
+all:
+include $(top_srcdir)Rules.mak
+include Makefile.in
diff --git a/extra/Makefile.in b/extra/Makefile.in
new file mode 100644
index 0000000..4d05d52
--- /dev/null
+++ b/extra/Makefile.in
@@ -0,0 +1,3 @@
+EXTRA_DIR := $(top_srcdir)extra/
+DISTCLEAN_extra: $(PHONY)
+ $(Q)$(MAKE) -C $(EXTRA_DIR)config CLEAN_extra/config
diff --git a/extra/config/Makefile b/extra/config/Makefile
index d642f2d..d5fe112 100644
--- a/extra/config/Makefile
+++ b/extra/config/Makefile
@@ -16,8 +16,8 @@
# along with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-TOPDIR=../../
-include $(TOPDIR)Rules.mak
+top_srcdir=../../
+include $(top_srcdir)Rules.mak
all: ncurses conf mconf
@@ -57,7 +57,7 @@ CONF_OBJS =$(patsubst %.c,%.o, $(CONF_SRC))
MCONF_OBJS=$(patsubst %.c,%.o, $(MCONF_SRC))
SHARED_OBJS=$(patsubst %.c,%.o, $(SHARED_SRC))
-conf: $(CONF_OBJS) $(SHARED_OBJS)
+conf: $(CONF_OBJS) $(SHARED_OBJS)
$(HOSTCC) $(NATIVE_LDFLAGS) $^ -o $@
mconf: $(MCONF_OBJS) $(SHARED_OBJS)
@@ -123,7 +123,6 @@ ncurses:
exit 1 ;\
fi
-clean:
- $(RM) *.o *~ core $(TARGETS) $(MCONF_OBJS) $(CONF_OBJS) \
+CLEAN_extra/config:
+ $(do_rm) *.o *~ core $(TARGETS) $(MCONF_OBJS) $(CONF_OBJS) \
conf mconf zconf.tab.c zconf.tab.h lex.zconf.c lkc_defs.h
-
diff --git a/extra/config/menu.c b/extra/config/menu.c
index ba5c6a6..07d4cb2 100644
--- a/extra/config/menu.c
+++ b/extra/config/menu.c
@@ -388,7 +388,7 @@ int file_write_dep(const char *name)
else
fprintf(out, "\t%s\n", file->name);
}
- fprintf(out, "\n.config include/bits/uClibc_config.h: $(deps_config)\n\n$(deps_config):\n");
+ fprintf(out, "\n.config include/system_configuration.h: $(deps_config)\n\n$(deps_config):\n");
fclose(out);
rename(".config.tmp", name);
return 0;
diff --git a/extra/locale/Makefile b/extra/locale/Makefile
index 2d8a147..1118524 100644
--- a/extra/locale/Makefile
+++ b/extra/locale/Makefile
@@ -1,7 +1,7 @@
-TOPDIR = ../../
-EXTRA_LOCALE_DIR:=${shell cd $(TOPDIR)/extra/locale && pwd}
-include $(TOPDIR)Rules.mak
+top_srcdir = ../../
+EXTRA_LOCALE_DIR:=${shell cd $(top_srcdir)/extra/locale && pwd}
+include $(top_srcdir)Rules.mak
CFLAGS_wc8bit=-DCTYPE_PACKED=1
CFLAGS_mmap=
diff --git a/include/Makefile b/include/Makefile
index b5c2694..6590b44 100644
--- a/include/Makefile
+++ b/include/Makefile
@@ -1,13 +1,5 @@
-TOPDIR=../
-include $(TOPDIR)Rules.mak
-
-all:
-
-clean:
-
-distclean:
-
-HEADERS = $(filter-out .svn CVS Makefile,$(wildcard *))
-install:
- $(INSTALL) -d $(PREFIX)$(UCLIBCXX_RUNTIME_INCLUDEDIR)
- $(INSTALL) -m 644 $(HEADERS) $(PREFIX)$(UCLIBCXX_RUNTIME_INCLUDEDIR)
+top_srcdir=../
+top_builddir=../
+include $(top_srcdir)Rules.mak
+include Makefile.in
+include $(top_srcdir)Makefile.end
diff --git a/include/Makefile.in b/include/Makefile.in
new file mode 100644
index 0000000..45b66c5
--- /dev/null
+++ b/include/Makefile.in
@@ -0,0 +1,7 @@
+DISTCLEAN_include:
+ $(do_rm) $(top_builddir)include/system_configuration.h
+
+headers-y = $(filter-out .svn bits CVS Makefile Makefile.in,$(notdir $(wildcard $(top_srcdir)include/*)))
+install-include: | $(DESTDIR)$(UCLIBCXX_RUNTIME_INCLUDEDIR)
+ @$(disp_install) include/
+ $(Q)$(INSTALL) -m 0644 $(addprefix $(top_srcdir)include/, $(headers-y)) $(DESTDIR)$(UCLIBCXX_RUNTIME_INCLUDEDIR)
diff --git a/src/Makefile b/src/Makefile
index 5717ab1..370f700 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,74 +1,6 @@
-TOPDIR=../
-include $(TOPDIR)Rules.mak
-
-WR_CXX := WRAPPER_INCLUDEDIR=-I$(TOPDIR)include $(TOPDIR)bin/g++-uc
-
-LDFLAGS += -nodefaultlibs -shared -Wl,-soname,$(SHARED_MAJORNAME) $(BUILD_EXTRA_LIBRARIES)
-ifneq ($(DODEBUG),y)
-LDFLAGS += -Wl,-s
-endif
-
-SRCS = $(wildcard *.cpp)
-SRCS += abi/abi.cpp
-SRCS := $(filter-out support.cpp,$(SRCS))
-SRCS := $(filter-out typeinfo.cpp,$(SRCS))
-
-EXOBJS := $(patsubst %.cpp,%.o, $(SRCS))
-
-ALLBIN :=
-ifeq ($(BUILD_STATIC_LIB),y)
-ALLBIN += $(LIBNAME).a
-endif
-ifneq ($(BUILD_ONLY_STATIC_LIB),y)
-ALLBIN += $(SHARED_FULLNAME)
-endif
-
-all: libgcc_eh libsupc $(EXOBJS) $(ALLBIN)
-
-install:
- $(INSTALL) -d $(PREFIX)$(UCLIBCXX_RUNTIME_LIBDIR)
- ($(TAR) -cf - \
- $(if $(BUILD_STATIC_LIB),$(LIBNAME).a,) \
- $(if $(BUILD_ONLY_STATIC_LIB),, \
- $(SHARED_FULLNAME) \
- $(SHARED_MAJORNAME) $(LIBNAME).so \
- ) \
- ) | $(TAR) -xf - -C $(PREFIX)$(UCLIBCXX_RUNTIME_LIBDIR)
-
-libgcc_eh:
-ifeq ($(IMPORT_LIBGCC_EH),y)
- $(MAKE) -C abi/libgcc_eh all
-#ifeq ($(GCC_MAJOR_VER),3)
-GCCOBJS = $(wildcard abi/libgcc_eh/*.o)
-#else
-#GCCOBJS =
-#endif
-else
-GCCOBJS =
-endif
-
-libsupc:
-ifeq ($(IMPORT_LIBSUP),y)
- $(MAKE) -C abi/libsupc all
-SUPOBJS = $(wildcard abi/libsupc/*.o)
-else
-SUPOBJS =
-endif
-
-$(LIBNAME).a: libgcc_eh libsupc $(EXOBJS)
- $(AR) $(ARFLAGS) $@ $(EXOBJS) $(GCCOBJS) $(SUPOBJS)
- $(RANLIB) $@
-
-$(SHARED_FULLNAME): libgcc_eh libsupc $(EXOBJS)
- $(CC) $(LDFLAGS) -o $@ $(EXOBJS) $(SUPOBJS) $(GCCOBJS) $(LIBS)
- $(LN) $@ $(SHARED_MAJORNAME)
- $(LN) $(SHARED_MAJORNAME) $(LIBNAME).so
-
-clean:
- $(MAKE) -C abi/libgcc_eh clean
- $(MAKE) -C abi/libsupc clean
- $(RM) *.o abi/*.o libuClibc++* core
-
-%.o: %.cpp $(TOPDIR)bin/g++-uc
- $(WR_CXX) $(CXXFLAGS) -o $@ -c $<
- $(STRIPTOOL) -x -R .note -R .comment $@
+top_srcdir=../
+top_builddir=../
+lib:
+include $(top_srcdir)Rules.mak
+include Makefile.in
+include $(top_srcdir)Makefile.end
diff --git a/src/Makefile.in b/src/Makefile.in
new file mode 100644
index 0000000..d12343d
--- /dev/null
+++ b/src/Makefile.in
@@ -0,0 +1,54 @@
+WR_CXX := WRAPPER_INCLUDEDIR=-I$(top_srcdir)include $(WRAPPER)
+
+LDFLAGS-$(DODEBUG)-$(LIBNAME).so += -Wl,-s
+LDFLAGS-$(LIBNAME).so += -nodefaultlibs -shared
+LIBS-$(LIBNAME).so += $(BUILD_EXTRA_LIBRARIES) $(LIBS)
+
+SRC_DIR := $(top_srcdir)src/
+SRC_OUT := $(top_builddir)src/
+
+SRCS = $(notdir $(wildcard $(SRC_DIR)*.cpp))
+SRCS := $(filter-out support.cpp,$(SRCS))
+SRCS := $(filter-out typeinfo.cpp,$(SRCS))
+SRCS += abi/abi.cpp
+EXOBJS := $(patsubst %.cpp,$(SRC_OUT)%.o, $(SRCS))
+
+libs-y :=
+libs-$(BUILD_STATIC_LIB) += $(SRC_OUT)$(LIBNAME).a
+libs-$(if $(BUILD_ONLY_STATIC_LIB),,y) += $(SRC_OUT)$(LIBNAME).so
+
+lib: $(libs-y)
+
+include $(top_srcdir)src/abi/libgcc_eh/Makefile.in
+include $(top_srcdir)src/abi/libsupc/Makefile.in
+
+install-lib: lib | $(DESTDIR)$(UCLIBCXX_RUNTIME_LIBDIR)
+ @$(if $(BUILD_STATIC_LIB),$(disp_install) $(LIBNAME).a)
+ @$(if $(BUILD_ONLY_STATIC_LIB),,$(disp_install) \
+ $(SHARED_FULLNAME) $(SHARED_MAJORNAME) $(LIBNAME).so)
+ $(Q)(cd $(SRC_OUT); \
+ $(TAR) -cf - \
+ $(if $(BUILD_STATIC_LIB),$(LIBNAME).a,) \
+ $(if $(BUILD_ONLY_STATIC_LIB),, \
+ $(SHARED_FULLNAME) \
+ $(SHARED_MAJORNAME) $(LIBNAME).so \
+ ) \
+ ) | $(TAR) -xf - -C $(DESTDIR)$(UCLIBCXX_RUNTIME_LIBDIR)
+
+libcxx-a-y = $(EXOBJS) $(libgcc_eh-y) $(libsupc-y)
+libcxx-so-y = $(EXOBJS) $(libgcc_eh-y) $(libsupc-y)
+
+$(EXOBJS) $(libgcc_eh-y) $(libsupc-y) : $(WRAPPER)
+
+$(top_builddir)src/$(LIBNAME).a: $(libcxx-a-y)
+ $(Q)$(RM) $@
+ $(do_ar)
+ $(do_ranlib)
+
+$(top_builddir)src/$(LIBNAME).so: $(libcxx-so-y)
+ $(call link.so,$(SRC_OUT)$(SHARED_FULLNAME),$(ABI_VERSION))
+
+CLEAN_src:
+ $(do_rm) $(addprefix $(SRC_OUT), *.o abi/*.o libuClibc++* core)
+DISTCLEAN_src: DISTCLEAN_libgcc_eh DISTCLEAN_libsupc
+
diff --git a/src/abi/libgcc_eh/Makefile b/src/abi/libgcc_eh/Makefile
index fe2eb01..dede061 100644
--- a/src/abi/libgcc_eh/Makefile
+++ b/src/abi/libgcc_eh/Makefile
@@ -1,25 +1,4 @@
-TOPDIR=../../..
-include $(TOPDIR)/Rules.mak
-
-all: libgcc_eh
-
-libgcc_eh: unwind-c.o
-
-unwind-c.o:
-#ifeq ($(GCC_VERSION),3.3)
-# echo Version 3.3
-# $(CC) -c $(CFLAGS) -o unwind-c.o GCC_3.3/unwind-c.c
-#
-#else
-#ifeq ($(GCC_VERSION),3.4)
-# echo Version 3.4
-#
-#else
-# echo Binary
- $(AR) x $(shell CC="$(CC)" $(TOPDIR)/scripts/find_libgcc_eh.sh)
-#endif
-#endif
-
-clean:
- $(RM) *.o
-
+top_srcdir=../../../
+top_builddir=../../../
+include $(top_srcdir)Rules.mak
+include Makefile.in
diff --git a/src/abi/libgcc_eh/Makefile.in b/src/abi/libgcc_eh/Makefile.in
new file mode 100644
index 0000000..56ef68f
--- /dev/null
+++ b/src/abi/libgcc_eh/Makefile.in
@@ -0,0 +1,24 @@
+LIBGCC_EH_OUT := $(top_builddir)src/abi/libgcc_eh/
+
+OBJS = $(call list-archive-members,$(LIBGCC_EH))
+libgcc_eh-$(IMPORT_LIBGCC_EH) := $(OBJS)
+
+LIBGCC_EH_VAR := $(call variablify,$(LIBGCC_EH))
+LIBGCC_EH_DEP := $(LIBGCC_EH_OUT).$(LIBGCC_EH_VAR).dep
+
+ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
+-include $(LIBGCC_EH_DEP)
+endif
+
+
+ifneq ($(libgcc_eh-y),)
+$(libgcc_eh-y): $(LIBGCC_EH)
+endif
+$(LIBGCC_EH_DEP): $(LIBGCC_EH)
+ $(Q)$(RM) $(LIBGCC_EH_OUT).*dep $(LIBGCC_EH_OUT)*.o
+ $(Q)$(if $(LIBGCC_EH),(cd $(LIBGCC_EH_OUT) && $(AR) x $(LIBGCC_EH)))
+ $(Q)echo "libgcc_eh-y := \$$(addprefix \$$(LIBGCC_EH_OUT),$(libgcc_eh-y))" > $@
+
+CLEAN_libgcc_eh: ;
+DISTCLEAN_libgcc_eh:
+ $(do_rm) $(addprefix $(LIBGCC_EH_OUT),.*dep *.o)
diff --git a/src/abi/libsupc/Makefile b/src/abi/libsupc/Makefile
index 63f626f..dede061 100644
--- a/src/abi/libsupc/Makefile
+++ b/src/abi/libsupc/Makefile
@@ -1,25 +1,4 @@
-TOPDIR=../../..
-include $(TOPDIR)/Rules.mak
-
-all: libsupc
-
-libsupc:
-#ifeq ($(GCC_VERSION),3.3)
-# echo Version 3.3
-# $(WR_CXX) -c $(CXXFLAGS) -o eh_allocQ.o GCC_3.3/eh_alloc.cc
-#
-#else
-#ifeq ($(GCC_VERSION),3.4)
-# echo Version 3.4
-#
-#else
-# echo Binary
- $(AR) x $(shell CC="$(CC)" $(TOPDIR)/scripts/find_libsupc.sh)
- $(RM) -f new_op*.o del_op*.o pure.o new_handler.o eh_alloc.o eh_globals.o
-#
-#endif
-#endif
-
-clean:
- $(RM) *.o
-
+top_srcdir=../../../
+top_builddir=../../../
+include $(top_srcdir)Rules.mak
+include Makefile.in
diff --git a/src/abi/libsupc/Makefile.in b/src/abi/libsupc/Makefile.in
new file mode 100644
index 0000000..9e01d3b
--- /dev/null
+++ b/src/abi/libsupc/Makefile.in
@@ -0,0 +1,24 @@
+LIBSUPC_OUT := $(top_builddir)src/abi/libsupc/
+
+OBJS = $(call list-archive-members,$(LIBSUP))
+OBJS-OMIT = $(filter new_op%.o del_op%.o pure.o new_handler.o eh_alloc.o eh_globals.o,$(OBJS))
+libsupc-$(IMPORT_LIBSUP) := $(filter-out $(OBJS-OMIT),$(OBJS))
+
+LIBSUP_VAR := $(call variablify,$(LIBSUP))
+LIBSUP_DEP :=$(LIBSUPC_OUT).$(LIBSUP_VAR).dep
+
+ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
+-include $(LIBSUP_DEP)
+endif
+
+ifneq ($(libsupc-y),)
+$(libsupc-y): $(LIBSUP)
+endif
+$(LIBSUP_DEP): $(LIBSUP)
+ $(Q)$(RM) $(LIBSUPC_OUT).*dep $(LIBSUPC_OUT)*.o
+ $(Q)$(if $(LIBSUP),(cd $(LIBSUPC_OUT) && $(AR) x $(LIBSUP) && $(RM) $(OBJS-OMIT)))
+ $(Q)echo "libsupc-y := \$$(addprefix \$$(LIBSUPC_OUT),$(libsupc-y))" > $@
+
+CLEAN_libsupc: ;
+DISTCLEAN_libsupc:
+ $(do_rm) $(addprefix $(LIBSUPC_OUT), .*dep *.o)
diff --git a/tests/Makefile b/tests/Makefile
index 3ed8a26..afd83ef 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -1,62 +1,7 @@
-TOPDIR=../
-include $(TOPDIR)Rules.mak
-
-WR_CXX := WRAPPER_INCLUDEDIR=-I$(TOPDIR)include WRAPPER_LIBDIR=-L$(TOPDIR)src $(TOPDIR)bin/g++-uc
-
-CXXOFLAGS := -Wall -pedantic -Os -g3 -ansi $(EH_CXXFLAGS)
-
-TEST_SRCS := $(wildcard *test.cpp)
-UTILITY_SRCS := testframework.cpp
-
-ifneq ($(UCLIBCXX_HAS_WCHAR),y)
-TEST_SRCS := $(filter-out wchartest.cpp,$(TEST_SRCS))
-endif
-
-ifneq ($(UCLIBCXX_EXCEPTION_SUPPORT),y)
-TEST_SRCS := $(filter-out excepttest.cpp,$(TEST_SRCS))
-endif
-
-UTILITY_OBJS := $(patsubst %.cpp,%.o, $(UTILITY_SRCS))
-OLDUTILITY_OBJS := $(patsubst %.cpp,%-old.o, $(UTILITY_SRCS))
-
-EXOBJS := $(patsubst %.cpp,%.o, $(TEST_SRCS))
-OLDOBJS := $(patsubst %.cpp,%-old.o, $(TEST_SRCS))
-
-ALLBIN := $(patsubst %.cpp,%, $(TEST_SRCS))
-
-OLDBIN := $(patsubst %.cpp,%-old, $(TEST_SRCS))
-
-LDFLAGS-valarraytest := -lm
-
-ifeq ($(DODEBUG),y)
-all: $(ALLBIN) $(OLDBIN)
-else
-all: $(ALLBIN)
-endif
-
-clean:
- $(RM) $(ALLBIN) $(OLDBIN)
- $(RM) *.o *.o-old core
- $(MAKE) -C testoutput clean
-
-test: all
- $(MAKE) -C testoutput test
-
-$(ALLBIN): $(EXOBJS) $(UTILITY_OBJS)
- $(WR_CXX) $(LDFLAGS) $(UTILITY_OBJS) -o $@ $@.o $(LDFLAGS-$(notdir $(@)))
-
-$(OLDBIN): $(OLDOBJS) $(OLDUTILITY_OBJS)
- $(HOSTCXX) $(LDFLAGS) $(UTILITY_OBJS) -o $@ $@.o $(LDFLAGS-$(notdir $(@)))
-
-$(EXOBJS): %.o : %.cpp
- $(WR_CXX) $(CXXFLAGS) $(CXXFLAGS-$(notdir $(*))) -o $@ -c $<
-
-$(OLDOBJS): %-old.o : %.cpp
- $(HOSTCXX) $(CXXFLAGS) $(CXXFLAGS-$(notdir $(*))) -o $@ -c $<
-
-$(UTILITY_OBJS): %.o : %.cpp
- $(WR_CXX) $(CXXFLAGS) -o $@ -c $<
-
-$(OLDUTILITY_OBJS): %-old.o : %.cpp
- $(HOSTCXX) $(CXXFLAGS) -o $@ -c $<
-
+top_srcdir=../
+top_builddir=../
+all:
+include $(top_srcdir)Rules.mak
+include Makefile.in
+include $(top_srcdir)bin/Makefile.in
+include $(top_srcdir)Makefile.end
diff --git a/tests/Makefile.in b/tests/Makefile.in
new file mode 100644
index 0000000..2b29e4c
--- /dev/null
+++ b/tests/Makefile.in
@@ -0,0 +1,41 @@
+TESTS_DIR := $(top_srcdir)tests/
+TESTS_OUT := $(top_builddir)tests/
+
+WR_CXX := WRAPPER_INCLUDEDIR=-I$(top_srcdir)include WRAPPER_LIBDIR=-L$(top_builddir)src $(WRAPPER)
+
+LDFLAGS := $(LDFLAGS-$(LIBNAME).so) $(call link.asneeded,-lgcc_s)
+
+TESTS_SRCS-y := $(wildcard *test.cpp)
+UTILITY_SRCS := testframework.cpp
+
+TESTS_OMIT-$(UCLIBCXX_HAS_WCHAR) := wchartest.cpp
+TESTS_OMIT-$(UCLIBCXX_EXCEPTION_SUPPORT) := excepttest.cpp
+
+TESTS_SRCS-y := $(filter-out $(TESTS_OMIT-),$(TESTS_SRCS-y))
+
+EXOBJS := $(patsubst %.cpp,%.o, $(TESTS_SRCS-y))
+UTILITY_OBJS := $(patsubst %.cpp,%.o, $(UTILITY_SRCS))
+ALLBIN := $(patsubst %.cpp,%, $(TESTS_SRCS-y))
+HOST_OBJS := $(patsubst %.cpp,%-old.o, $(TESTS_SRCS-y))
+HOST_UTILITY_OBJS := $(patsubst %.cpp,%-old.o, $(UTILITY_SRCS))
+HOST_BIN := $(patsubst %.cpp,%-old, $(TESTS_SRCS-y))
+
+all: $(ALLBIN) $(if $(DODEBUG),$(HOST_BIN))
+include $(TESTS_DIR)testoutput/Makefile.in
+
+DEPS-valarraytest := -lm
+
+$(EXOBJS) $(UTILITY_OBJS): $(WRAPPER)
+%.o: %.cpp ; $(compile.oxx)
+%: %.o ; $(compile.uxx)
+
+%-old.o: %.cpp ; $(hcompile.oxx)
+%-old: %-old.o ; $(hcompile.uxx)
+
+$(ALLBIN): % : %.o $(UTILITY_OBJS)
+$(HOST_BIN): % : %.o $(HOST_UTILITY_OBJS)
+
+CLEAN_tests:
+ $(do_rm) $(addprefix $(TESTS_OUT),$(ALLBIN) $(HOST_BIN) *.o core)
+
+clean: CLEAN_testoutput CLEAN_tests
diff --git a/tests/testoutput/Makefile b/tests/testoutput/Makefile
deleted file mode 100644
index 97ae470..0000000
--- a/tests/testoutput/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-TOPDIR=../../
-include $(TOPDIR)Rules.mak
-
-all:
-
-clean:
- $(RM) *.test *.out
-
-test:
-ifeq ($(DODEBUG),y)
- V="$(V)" ./runtests.sh DODEBUG
-else
- V="$(V)" ./runtests.sh
-endif
diff --git a/tests/testoutput/Makefile.in b/tests/testoutput/Makefile.in
new file mode 100644
index 0000000..a197328
--- /dev/null
+++ b/tests/testoutput/Makefile.in
@@ -0,0 +1,7 @@
+TESTOUTPUT_DIR := $(TESTS_DIR)testoutput/
+TESTOUTPUT_OUT := $(TESTS_OUT)testoutput/
+test: all
+ cd $(TESTOUTPUT_DIR) && V="$(V)" ./runtests.sh $(if $(DODEBUG),DODEBUG)
+
+CLEAN_testoutput:
+ $(do_rm) $(addprefix $(TESTOUTPUT_OUT),*.test *.out)
More information about the uClibc-cvs
mailing list