diff options
-rw-r--r-- | Makefile | 50 | ||||
-rw-r--r-- | common.mk | 55 |
2 files changed, 56 insertions, 49 deletions
@@ -1,20 +1,4 @@ -ifeq ($(SYSTEM),) - SYSTEM := $(shell uname | cut -f 1 -d_) -endif - -TRUESYSTEM := $(shell uname) -MACHINE := $(shell uname -m) -DISTRIB := $(shell cat /etc/issue | cut -f 1 -d\ | head -1) - -CC = gcc -CXX = g++ -LD = g++ -AS = gcc -c -AR = ar rcs - -BINEXT = bin - -CPPFLAGS += -fno-strict-aliasing +include common.mk ifeq ($(DEBUG),) CPPFLAGS += -g -O3 -DNDEBUG @@ -29,50 +13,18 @@ LIBS = z DEFINES = _LARGEFILE64_SOURCE ifeq ($(SYSTEM),Darwin) - CC = clang - CXX = clang++ - CPPFLAGS += -fPIC - LDFLAGS += -fPIC LIBS += pthread iconv CONFIG_H = darwin-config.h - ARCH_FLAGS = - LD = clang++ - STRIP = strip -x endif ifeq ($(SYSTEM),Linux) - CPPFLAGS += -fPIC - LDFLAGS += -fPIC -rdynamic LIBS += pthread dl CONFIG_H = linux-config.h - ARCH_FLAGS = - ASFLAGS = - STRIP = strip --strip-unneeded - - GCC_VERSION := $(shell g++ -dumpversion) - GCC_VERSION_4 := $(shell expr `g++ -dumpversion | cut -f1 -d.` \>= 4) - GCC_VERSION_x_8 := $(shell expr `g++ -dumpversion | cut -f2 -d.` >= 8) - - ifneq ($(GCC_VERSION_4),1) - USE_CLANG = true - else - ifneq ($(GCC_VERSION_x_8),1) - USE_CLANG = true - endif - endif - - ifeq ($(USE_CLANG),true) - CC = clang - CXX = clang++ - LD = clang++ - endif endif CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) -fexceptions -imacros $(CONFIG_H) CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS) $(addprefix -D, $(DEFINES)) -CXXFLAGS += -Wno-deprecated -std=c++11 - LDFLAGS += $(ARCH_FLAGS) LDLIBS = $(addprefix -l, $(LIBS)) diff --git a/common.mk b/common.mk new file mode 100644 index 0000000..e3e084b --- /dev/null +++ b/common.mk @@ -0,0 +1,55 @@ +ifeq ($(SYSTEM),) + SYSTEM := $(shell uname | cut -f 1 -d_) +endif + +TRUESYSTEM := $(shell uname) +MACHINE := $(shell uname -m) +DISTRIB := $(shell cat /etc/issue | cut -f 1 -d\ | head -1) + +CC = gcc +CXX = g++ +LD = g++ +AS = gcc -c +AR = ar rcs + +BINEXT = bin + +CPPFLAGS += -fno-strict-aliasing + +ifeq ($(SYSTEM),Darwin) + CC = clang + CXX = clang++ + CPPFLAGS += -fPIC + LDFLAGS += -fPIC + ARCH_FLAGS = + LD = clang++ + STRIP = strip -x +endif + +ifeq ($(SYSTEM),Linux) + CPPFLAGS += -fPIC + LDFLAGS += -fPIC -rdynamic + ARCH_FLAGS = + ASFLAGS = + STRIP = strip --strip-unneeded + + GCC_VERSION := $(shell g++ -dumpversion) + GCC_VERSION_4 := $(shell expr `g++ -dumpversion | cut -f1 -d.` \>= 4) + GCC_VERSION_x_8 := $(shell expr `g++ -dumpversion | cut -f2 -d.` \>= 8) + + ifneq ($(GCC_VERSION_4),1) + USE_CLANG = true + else + ifneq ($(GCC_VERSION_x_8),1) + USE_CLANG = true + endif + endif + + ifeq ($(USE_CLANG),true) + CC = clang + CXX = clang++ + LD = clang++ + endif +endif + +CXXFLAGS += -Wno-deprecated -std=c++11 |