From 9a9efefdb2ec7af52ca6946b78cb8610d8391ecf Mon Sep 17 00:00:00 2001 From: Dominik Riebeling Date: Sat, 11 May 2013 17:31:34 +0200 Subject: [PATCH] ucl: Replace use of uname by checking the compiler output. Similar as done for libtools.make ask the compiler for the binary it creates instead of using uname to figure the target to avoid special handling when cross compiling. Change-Id: Icb4654616e4339bf9e6e3be5177b35e0bb313bcd --- tools/ucl/src/Makefile | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/tools/ucl/src/Makefile b/tools/ucl/src/Makefile index 2d6f18f102..1f3207f426 100644 --- a/tools/ucl/src/Makefile +++ b/tools/ucl/src/Makefile @@ -22,20 +22,32 @@ ifdef RBARCH CFLAGS += -arch $(RBARCH) endif +CPPDEFINES := $(shell echo foo | $(CROSS)$(CC) -dM -E -) +#build standalone win32 executables on cygwin +ifeq ($(findstring CYGWIN,$(CPPDEFINES)),CYGWIN) +COMPILETARGET = cygwin +else +ifeq ($(findstring MINGW,$(CPPDEFINES)),MINGW) +COMPILETARGET = mingw +else # OS X specifics. Needs to consider cross compiling for Windows. -ifeq ($(findstring Darwin,$(shell uname)),Darwin) -ifneq ($(findstring mingw,$(CROSS)$(CC)),mingw) +ifeq ($(findstring APPLE,$(CPPDEFINES)),APPLE) # when building libs for OS X build for both i386 and ppc at the same time. # This creates fat objects, and ar can only create the archive but not operate # on it. As a result the ar call must NOT use the u (update) flag. -CFLAGS += -arch ppc -arch i386 +ARCHFLAGS = -arch ppc -arch i386 # building against SDK 10.4 is not compatible with gcc-4.2 (default on newer Xcode) # might need adjustment for older Xcode. CC ?= gcc-4.0 CFLAGS += -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4 NATIVECC ?= gcc-4.0 +COMPILETARGET = darwin +else +COMPILETARGET = posix endif endif +endif +$(info Compiler creates $(COMPILETARGET) binaries) TARGET_DIR ?= $(shell pwd)/ OBJDIR = $(TARGET_DIR)build$(RBARCH) @@ -60,13 +72,12 @@ $(TARGET_DIR)ucl.dll: $(OBJS) $(TARGET_DIR)libucl$(RBARCH).a: $(OBJS) @echo AR $(notdir $@) - $(SILENT)rm -f $@ $(SILENT)$(CROSS)$(AR) rcs $@ $(OBJS) >/dev/null 2>&1 $(OBJDIR)/%.o: %.c @echo CC $< $(SILENT)$(call mkdir, $(dir $@)) - $(SILENT)$(CROSS)$(CC) $(CFLAGS) -c $< -o $@ + $(SILENT)$(CROSS)$(CC) $(CFLAGS) $(ARCHFLAGS) -c $< -o $@ clean: rm -f $(TARGET_DIR)libucl*.a