---- /Users/alfredh/src/re-0.3.0/mk/re.mk 2011-08-30 13:07:12.000000000 +0200
-+++ re/mk/re.mk 2011-10-07 21:27:53.000000000 +0200
-@@ -5,34 +5,37 @@
- #
- # Imported variables:
- #
--# PROJECT Project name
--# VERSION Version number
--# CC Compiler
--# GCOV If non-empty, enable GNU Coverage testing
--# GPROF If non-empty, enable GNU Profiling
--# OPT_SPEED If non-empty, optimize for speed
--# OPT_SIZE If non-empty, optimize for size
--# USE_OPENSSL If non-empty, link to libssl library
--# USE_ZLIB If non-empty, link to libz library
--# SYSROOT System root of library and include files
--# SYSROOT_ALT Alternative system root of library and include files
--# EXTRA_CFLAGS Extra compiler flags appended to CFLAGS
--# EXTRA_LFLAGS Extra linker flags appended to LFLAGS
-+# ARCH Target architecture
-+# CC Compiler
-+# CROSS_COMPILE Cross-compiler prefix (optional)
-+# EXTRA_CFLAGS Extra compiler flags appended to CFLAGS
-+# EXTRA_LFLAGS Extra linker flags appended to LFLAGS
-+# GCOV If non-empty, enable GNU Coverage testing
-+# GPROF If non-empty, enable GNU Profiling
-+# OPT_SIZE If non-empty, optimize for size
-+# OPT_SPEED If non-empty, optimize for speed
-+# PROJECT Project name
-+# RELEASE Release build
-+# SYSROOT System root of library and include files
-+# SYSROOT_ALT Alternative system root of library and include files
-+# USE_OPENSSL If non-empty, link to libssl library
-+# USE_ZLIB If non-empty, link to libz library
-+# VERSION Version number
- #
- # Exported variables:
- #
--# CC Compiler
--# CCACHE Compiler ccache tool
--# CFLAGS Compiler flags
--# DFLAGS Dependency generator flags
--# LFLAGS Common linker flags
--# SH_LFLAGS Linker flags for shared libraries
--# MOD_LFLAGS Linker flags for dynamic modules
--# APP_LFLAGS Linker flags for applications using modules
--# LIBS Libraries to link against
--# LIB_SUFFIX Suffix for shared libraries
--# MOD_SUFFIX Suffix for dynamic modules
--# BIN_SUFFIX Suffix for binary executables
-+# APP_LFLAGS Linker flags for applications using modules
-+# BIN_SUFFIX Suffix for binary executables
-+# CC Compiler
-+# CCACHE Compiler ccache tool
-+# CFLAGS Compiler flags
-+# DFLAGS Dependency generator flags
-+# LFLAGS Common linker flags
-+# LIBS Libraries to link against
-+# LIB_SUFFIX Suffix for shared libraries
-+# MOD_LFLAGS Linker flags for dynamic modules
-+# MOD_SUFFIX Suffix for dynamic modules
-+# SH_LFLAGS Linker flags for shared libraries
- #
-
-
-@@ -177,65 +180,27 @@
- #
- # OS section
- #
-+
- MACHINE := $(shell $(CC) -dumpmachine)
--OS := $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")
--#ARCH := $(shell echo $(MACHINE) | sed -e 's/\([^-]*\)-.*/\1/')
-
--# TODO get ARCH from first tuple in CC -dumpmachine which is more future proof
--ifeq ($(MACHINE), i386-mingw32)
-- OS := win32
-- ARCH := i386
--endif
--ifeq ($(MACHINE), i486-mingw32)
-- OS := win32
-- ARCH := i486
-+ifeq ($(CROSS_COMPILE),)
-+OS := $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")
- endif
--ifeq ($(MACHINE), i586-mingw32msvc)
-+
-+
-+#
-+# Try to guess the OS
-+#
-+
-+ifneq ($(strip $(filter i386-mingw32 i486-mingw32 i586-mingw32msvc mingw32, \
-+ $(MACHINE))),)
- OS := win32
-- ARCH := i586
--endif
- ifeq ($(MACHINE), mingw32)
-- OS := win32
-- ARCH := i386
- CROSS_COMPILE :=
- endif
--ifeq ($(MACHINE), i686-pc-cygwin)
-- OS := cygwin
-- ARCH := i686
--endif
--ifeq ($(MACHINE), mipsel-linux-uclibc)
-- OS := linux
-- ARCH := mipsel
--endif
--ifeq ($(MACHINE), bfin-linux-uclibc)
-- OS := linux
-- ARCH := bfin
--endif
--ifeq ($(MACHINE), bfin-uclinux)
-- OS := linux
-- ARCH := bfin
--endif
--ifeq ($(MACHINE), arm-apple-darwin)
-- OS := darwin
-- ARCH := arm
-- CROSS_COMPILE ?= $(MACHINE)-
-- CFLAGS += -F/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks
--endif
--ifeq ($(MACHINE), arm-apple-darwin9)
-- OS := darwin
-- ARCH := arm
-- CROSS_COMPILE ?= $(MACHINE)-
-- ROOT := /Developer//Platforms/iPhoneOS.platform/Developer
-- SDK := $(ROOT)/SDKs/iPhoneOS3.0.sdk
-- CFLAGS += -F$(SDK)/System/Library/Frameworks/
-- CFLAGS += -I$(SDK)/usr/include
-- CFLAGS += -I$(SDK)/usr/lib/gcc/arm-apple-darwin9/4.2.1/include
-- CFLAGS += -isysroot $(SDK)
-- LFLAGS += -F$(SDK)/System/Library/Frameworks
-- LFLAGS += -L$(SDK)/usr/lib
-- LFLAGS += -L$(SDK)/usr/lib/gcc/arm-apple-darwin9/4.2.1/
- endif
-
-+
- # default
- LIB_SUFFIX := .so
- MOD_SUFFIX := .so
-@@ -276,8 +241,6 @@
- AR := ar
- AFLAGS := cru
- LIB_SUFFIX := .dylib
-- ARCH := $(shell echo $(MACHINE) | \
-- sed -e 's/\([^-]*\)-.*/\1/')
- endif
- ifeq ($(OS),netbsd)
- CFLAGS += -fPIC -DNETBSD
-@@ -347,30 +310,121 @@
- endif
-
-
-+ifeq ($(OS),)
-+$(warning Could not detect OS)
-+endif
-+
-+
- ##############################################################################
- #
- # Architecture section
- #
-+# detect $(HOST_ARCH) -- Host architecture
-+# detect $(ARCH) -- Target architecture
-+#
-+
-+
-+#
-+# detect $(HOST_ARCH)
-+#
-
- ifeq ($(OS),solaris)
-+ GETARCH=isainfo -n
-+ifeq ($(GETARCH),)
- GETARCH=uname -p
-+endif
- else
- GETARCH=uname -m
- endif
-
-+HOST_ARCH := $(shell $(GETARCH) |sed -e s/i.86/i386/ -e s/sun4[uv]/sparc64/ \
-+ -e s/armv[3-5].*/arm/ -e s/armv6.*/arm6/ \
-+ -e "s/Power Macintosh/ppc/" \
-+ -e "s/cobalt/mips2/" \
-+ -e s/amd64/x86_64/ -e s/sparcv9/sparc64/ )
-+
-+ifeq ($(HOST_ARCH),sparc)
-+ifeq ($(shell uname -m),sun4u)
-+ HOST_ARCH := sparc64
-+endif
-+ifeq ($(shell uname -m),sun4v)
-+ HOST_ARCH := sparc64
-+endif
-+endif
-+
-+
-+#
-+# detect $(ARCH)
-+#
-+
- ifeq ($(ARCH),)
--ARCH := $(shell $(GETARCH) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
-- -e s/armv4l/arm/ -e "s/Power Macintosh/ppc/" \
-- -e "s/cobalt/mips2/" \
-- -e s/amd64/x86_64/ )
--endif
--# fix sparc -> sparc64
--ifeq ($(ARCH),sparc)
-- ifeq ($(shell uname -m),sun4u)
-- ARCH := sparc64
-- endif
-+ifeq ($(CC_NAME),gcc)
-+PREDEF := $(shell $(CC) -dM -E -x c $(EXTRA_CFLAGS) $(CFLAGS) /dev/null)
-+
-+ifneq ($(strip $(filter i386 __i386__ __i386 _M_IX86 __X86__ _X86_, \
-+ $(PREDEF))),)
-+ARCH := i386
- endif
-
-+ifneq ($(strip $(filter __i486__,$(PREDEF))),)
-+ARCH := i486
-+endif
-+
-+ifneq ($(strip $(filter __i586__,$(PREDEF))),)
-+ARCH := i586
-+endif
-+
-+ifneq ($(strip $(filter __i686__ ,$(PREDEF))),)
-+ARCH := i686
-+endif
-+
-+ifneq ($(strip $(filter __amd64__ __amd64 __x86_64__ __x86_64, \
-+ $(PREDEF))),)
-+ARCH := x86_64
-+endif
-+
-+ifneq ($(strip $(filter __arm__ __thumb__,$(PREDEF))),)
-+
-+ifneq ($(strip $(filter __ARM_ARCH_6__,$(PREDEF))),)
-+ARCH := arm6
-+else
-+ARCH := arm
-+endif
-+
-+endif
-+
-+ifneq ($(strip $(filter __mips__ __mips, $(PREDEF))),)
-+ARCH := mips
-+endif
-+
-+ifneq ($(strip $(filter __powerpc __powerpc__ __POWERPC__ __ppc__ \
-+ _ARCH_PPC, $(PREDEF))),)
-+ARCH := ppc
-+endif
-+
-+ifneq ($(strip $(filter __ppc64__ _ARCH_PPC64 , $(PREDEF))),)
-+ARCH := ppc64
-+endif
-+
-+ifneq ($(strip $(filter __sparc__ __sparc __sparcv8 , $(PREDEF))),)
-+
-+ifneq ($(strip $(filter __sparcv9 __sparc_v9__ , $(PREDEF))),)
-+ARCH := sparc64
-+else
-+ARCH := sparc
-+endif
-+
-+endif
-+
-+endif
-+endif
-+
-+
-+ifeq ($(ARCH),)
-+$(warning Could not detect ARCH)
-+endif
-+
-+
- CFLAGS += -DARCH=\"$(ARCH)\"
-
- ifeq ($(ARCH),mipsel)
-@@ -549,6 +603,7 @@
- @echo " MODULES: $(MODULES)"
- # @echo " SRCS: $(SRCS)"
- @echo " MACHINE: $(MACHINE)"
-+ @echo " HOST_ARCH: $(HOST_ARCH)"
- @echo " ARCH: $(ARCH)"
- @echo " OS: $(OS)"
- @echo " BUILD: $(BUILD)"