cleaned up posix makefile

This commit is contained in:
jeefo 2016-09-13 22:40:06 +03:00
commit 8155d08769
7 changed files with 142 additions and 117 deletions

View file

@ -4,7 +4,7 @@
#
# This software is licensed under the BSD-style license.
# Additional exceptions apply. For full license details, see LICENSE.txt or visit:
# http://yapb.jeefo.net/license
# https://yapb.jeefo.net/license
#
# Based on Makefile written by David "BAILOPAN" Anderson.
#
@ -22,28 +22,30 @@ OBJECTS = $(SRC_DIR)/basecode.cpp \
$(SRC_DIR)/support.cpp \
$(SRC_DIR)/waypoint.cpp \
C_OPT_FLAGS = -O2 -DNDEBUG=1 -fno-exceptions -fno-rtti -funroll-loops -fomit-frame-pointer -pipe -mtune=native
C_OPT_FLAGS = -O2 -DNDEBUG -pipe -fno-strict-aliasing
C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3
C_GCC4_FLAGS = -fvisibility=hidden
CPP_GCC4_FLAGS = -fvisibility-inlines-hidden
C_GCC_FLAGS = -fvisibility=hidden
CPP_GCC_FLAGS = -fvisibility-inlines-hidden
CPP = clang-3.7
CPP_OSX = clang
CPP_MAC = o32-clang
LINK =
INCLUDE = -I../include -I../include/engine
ifeq "$(OSX)" "true"
ifeq "$(MAC)" "true"
OS = Darwin
CPP_OSX = o32-clang
CPP_MAC = o32-clang
else
OS := $(shell uname -s)
endif
ifeq "$(OS)" "Darwin"
CPP = $(CPP_OSX)
CPP = $(CPP_MAC)
LIB_EXT = dylib
CFLAGS += -DOSX -D_OSX -DPOSIX
LINK += -dynamiclib -lstdc++ -mmacosx-version-min=10.5
LINK += -dynamiclib -lstdc++ -mmacosx-version-min=10.5 -arch i386
else
LIB_EXT = so
CFLAGS += -DLINUX -D_LINUX -DPOSIX
@ -52,7 +54,7 @@ endif
LINK += -m32 -lm -ldl
CFLAGS += -msse2 -std=c++11 -DHAVE_STDINT_H -D__extern_always_inline=inline -D_strdup=strdup -Dstricmp=strcasecmp -Dstrcmpi=strcasecmp -fno-strict-aliasing -m32 -Wall -Werror -Wextra
CFLAGS += -msse2 -std=c++11 -m32 -Wall -Werror -Wextra
CPPFLAGS += -fno-exceptions -fno-rtti -fno-builtin
BINARY = $(PROJECT).$(LIB_EXT)
@ -72,8 +74,8 @@ endif
IS_CLANG := $(shell $(CPP) --version | head -1 | grep clang > /dev/null && echo "1" || echo "0")
ifeq "$(IS_CLANG)" "1"
CFLAGS += $(C_GCC4_FLAGS)
CPPFLAGS += $(CPP_GCC4_FLAGS)
CFLAGS += $(C_GCC_FLAGS)
CPPFLAGS += $(CPP_GCC_FLAGS)
endif
# OS is Linux and not using clang
@ -92,6 +94,8 @@ $(BIN_DIR)/%.o: %.cpp
$(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $(subst $(SRC_DIR)/,,$@) -c $<
main:
mkdir -p release
mkdir -p debug
$(MAKE) $(PROJECT)
$(PROJECT): $(OBJ_BIN)
@ -105,19 +109,23 @@ release:
mkdir -p release
$(MAKE) main DEBUG=false
release_osx:
mkdir -p release
$(MAKE) main OSX=true DEBUG=false
release_mac:
$(MAKE) main MAC=true DEBUG=false
debug_osx:
mkdir -p debug
$(MAKE) main OSX=true DEBUG=true
debug_mac:
$(MAKE) main MAC=true DEBUG=true
all_linux: release debug
all_osx: release_osx debug_osx
all: all_linux all_osx
all_linux:
release debug
default: all
all_mac:
release_mac debug_mac
all:
all_linux all_mac
default:
all_linux
clean:
rm -rf release