- Fix TARGETOS detection on OS X.

- Do not try to check TARGETOS when cross-compiling
- For non-windows targets, try to auto-detect PTR64
This commit is contained in:
Couriersud 2010-01-15 22:05:00 +00:00
parent 4b257e2c66
commit 25b0e97ca1

View file

@ -64,25 +64,36 @@ ifndef TARGETOS
ifeq ($(OS),Windows_NT) ifeq ($(OS),Windows_NT)
TARGETOS = win32 TARGETOS = win32
else else
ifneq ($(CROSSBUILD),1)
UNAME = $(shell uname -a) UNAME = $(shell uname -a)
ifeq ($(filter Linux,$(UNAME)),Linux) ifeq ($(firstword $(filter Linux,$(UNAME))),Linux)
TARGETOS = unix TARGETOS = unix
endif endif
ifeq ($(filter Solaris,$(UNAME)),Solaris) ifeq ($(firstword $(filter Solaris,$(UNAME))),Solaris)
TARGETOS = solaris TARGETOS = solaris
endif endif
ifeq ($(filter FreeBSD,$(UNAME)),FreeBSD) ifeq ($(firstword $(filter FreeBSD,$(UNAME))),FreeBSD)
TARGETOS = freebsd TARGETOS = freebsd
endif endif
ifeq ($(filter Darwin,$(UNAME)),Darwin) ifeq ($(firstword $(filter Darwin,$(UNAME))),Darwin)
TARGETOS = macosx TARGETOS = macosx
endif endif
ifndef TARGETOS
$(error Unable to detect TARGETOS from uname -a: $(UNAME))
endif
# Autodetect PTR64
ifndef PTR64
ifeq ($(firstword $(filter x86_64,$(UNAME))),x86_64)
PTR64 = 1
endif endif
endif endif
endif # CROSS_BUILD
endif # Windows_NT
endif # TARGET_OS
#------------------------------------------------- #-------------------------------------------------
# configure name of final executable # configure name of final executable
@ -321,11 +332,13 @@ endif
# CCOMFLAGS are common flags # CCOMFLAGS are common flags
# CONLYFLAGS are flags only used when compiling for C # CONLYFLAGS are flags only used when compiling for C
# CPPONLYFLAGS are flags only used when compiling for C++ # CPPONLYFLAGS are flags only used when compiling for C++
# COBJFLAGS are flags only used when compiling for Objective-C(++)
#------------------------------------------------- #-------------------------------------------------
# start with empties for everything # start with empties for everything
CCOMFLAGS = CCOMFLAGS =
CONLYFLAGS = CONLYFLAGS =
COBJFLAGS =
CPPONLYFLAGS = CPPONLYFLAGS =
# CFLAGS is defined based on C or C++ targets # CFLAGS is defined based on C or C++ targets
@ -336,6 +349,7 @@ CFLAGS = $(CCOMFLAGS) $(CPPONLYFLAGS)
# we compile C++ code to C++98 standard with GNU extensions # we compile C++ code to C++98 standard with GNU extensions
CONLYFLAGS += -std=gnu89 CONLYFLAGS += -std=gnu89
CPPONLYFLAGS += -x c++ -std=gnu++98 CPPONLYFLAGS += -x c++ -std=gnu++98
COBJFLAGS += -x objective-c++
# this speeds it up a bit by piping between the preprocessor/compiler/assembler # this speeds it up a bit by piping between the preprocessor/compiler/assembler
CCOMFLAGS += -pipe CCOMFLAGS += -pipe
@ -386,6 +400,9 @@ CONLYFLAGS += \
-Wbad-function-cast \ -Wbad-function-cast \
-Wstrict-prototypes -Wstrict-prototypes
# warnings only applicable to OBJ-C compiles
COBJFLAGS += \
-Wpointer-arith
#------------------------------------------------- #-------------------------------------------------
@ -622,7 +639,5 @@ $(OBJ)/%.a:
ifeq ($(TARGETOS),macosx) ifeq ($(TARGETOS),macosx)
$(OBJ)/%.o: $(SRC)/%.m | $(OSPREBUILD) $(OBJ)/%.o: $(SRC)/%.m | $(OSPREBUILD)
@echo Objective-C compiling $<... @echo Objective-C compiling $<...
#$(CC) -x objective-c++ $(CDEFS) $(CCOMFLAGS) $(CONLYFLAGS) -c $< -o $@ $(CC) $(CDEFS) $(COBJFLAGS) $(CCOMFLAGS) -c $< -o $@
$(CC) -x objective-c++ $(CDEFS) $(CCOMFLAGS) -c $< -o $@
#$(CC) $(CDEFS) $(CFLAGS) -c $< -o $@
endif endif