yapb-noob-edition/project/makefile

144 lines
3.5 KiB
Makefile
Raw Normal View History

2014-07-30 14:17:46 +04:00
#
# Yet Another POD-Bot, based on PODBot by Markus Klinge ("CountFloyd").
# Copyright (c) YaPB Development Team.
2014-07-30 14:17:46 +04:00
#
# 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
2014-07-30 14:17:46 +04:00
#
2015-06-06 17:32:59 +03:00
# Based on Makefile written by David "BAILOPAN" Anderson.
#
2014-07-30 14:17:46 +04:00
2015-06-06 17:32:59 +03:00
PROJECT = yapb
SRC_DIR = ../source
OBJECTS = $(SRC_DIR)/basecode.cpp \
$(SRC_DIR)/manager.cpp \
$(SRC_DIR)/chatlib.cpp \
$(SRC_DIR)/combat.cpp \
2015-06-06 17:32:59 +03:00
$(SRC_DIR)/globals.cpp \
$(SRC_DIR)/interface.cpp \
$(SRC_DIR)/navigate.cpp \
$(SRC_DIR)/netmsg.cpp \
2015-06-06 17:32:59 +03:00
$(SRC_DIR)/support.cpp \
$(SRC_DIR)/waypoint.cpp \
2014-07-30 14:17:46 +04:00
C_OPT_FLAGS = -O3 -DNDEBUG=1 -fno-exceptions -fno-rtti -funroll-loops -fomit-frame-pointer -pipe
2015-06-06 17:32:59 +03:00
C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3
C_GCC4_FLAGS = -fvisibility=hidden
CPP_GCC4_FLAGS = -fvisibility-inlines-hidden
CPP = clang
CPP_OSX = clang
2014-07-30 14:17:46 +04:00
2015-06-06 17:32:59 +03:00
LINK =
INCLUDE = -I../include -I../include/engine
2014-07-30 14:17:46 +04:00
ifeq "$(OSX)" "true"
OS = Darwin
CPP_OSX = o32-clang
else
OS := $(shell uname -s)
endif
2014-07-30 14:17:46 +04:00
ifeq "$(OS)" "Darwin"
2015-06-06 17:32:59 +03:00
CPP = $(CPP_OSX)
LIB_EXT = dylib
CFLAGS += -DOSX -D_OSX -DPOSIX
LINK += -dynamiclib -lstdc++ -mmacosx-version-min=10.5
else
LIB_EXT = so
CFLAGS += -DLINUX -D_LINUX -DPOSIX
LINK += -shared
endif
LINK += -m32 -lm -ldl
2015-06-28 20:16:03 +03:00
CFLAGS += -DHAVE_STDINT_H -D__extern_always_inline=inline -D_strdup=strdup -Dstricmp=strcasecmp -Dstrcmpi=strcasecmp -fno-strict-aliasing -m32 -Wall -Werror -Wno-uninitialized -Wno-unused -Wno-switch -Wno-c++11-compat-deprecated-writable-strings
2015-06-06 17:32:59 +03:00
CPPFLAGS += -Wno-invalid-offsetof -fno-exceptions -fno-rtti
BINARY = $(PROJECT).$(LIB_EXT)
ifeq "$(DEBUG)" "true"
BIN_DIR = debug
CFLAGS += $(C_DEBUG_FLAGS)
2014-07-30 14:17:46 +04:00
else
2015-06-06 17:32:59 +03:00
BIN_DIR = release
CFLAGS += $(C_OPT_FLAGS)
2015-11-03 17:42:14 +03:00
ifneq "$(OS)" "Darwin"
LINK += -s
endif
2014-07-30 14:17:46 +04:00
endif
2015-06-06 17:32:59 +03:00
IS_CLANG := $(shell $(CPP) --version | head -1 | grep clang > /dev/null && echo "1" || echo "0")
ifeq "$(IS_CLANG)" "1"
CPP_MAJOR := $(shell $(CPP) --version | grep clang | sed "s/.*version \([0-9]\)*\.[0-9]*.*/\1/")
CPP_MINOR := $(shell $(CPP) --version | grep clang | sed "s/.*version [0-9]*\.\([0-9]\)*.*/\1/")
else
CPP_MAJOR := $(shell $(CPP) -dumpversion >&1 | cut -b1)
CPP_MINOR := $(shell $(CPP) -dumpversion >&1 | cut -b3)
endif
# Clang || GCC >= 4
ifeq "$(shell expr $(IS_CLANG) \| $(CPP_MAJOR) \>= 4)" "1"
CFLAGS += $(C_GCC4_FLAGS)
CPPFLAGS += $(CPP_GCC4_FLAGS)
endif
ifeq "$(IS_CLANG)" "1"
CFLAGS += -Wno-logical-op-parentheses
else
CFLAGS += -Wno-parentheses
endif
# Clang >= 3 || GCC >= 4.7
ifeq "$(shell expr $(IS_CLANG) \& $(CPP_MAJOR) \>= 3 \| $(CPP_MAJOR) \>= 4 \& $(CPP_MINOR) \>= 7)" "1"
CFLAGS += -Wno-delete-non-virtual-dtor
endif
# OS is Linux and not using clang
ifeq "$(shell expr $(OS) \= Linux \& $(IS_CLANG) \= 0)" "1"
LINK += -static-libgcc
endif
# OS is Linux and using clang
ifeq "$(shell expr $(OS) \= Linux \& $(IS_CLANG) \= 1)" "1"
LINK += -lgcc_eh
endif
OBJ_BIN := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o)
$(BIN_DIR)/%.o: %.cpp
$(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $(subst $(SRC_DIR)/,,$@) -c $<
main:
$(MAKE) $(PROJECT)
2015-06-06 17:32:59 +03:00
$(PROJECT): $(OBJ_BIN)
$(CPP) $(INCLUDE) $(subst $(SRC_DIR)/,,$(OBJ_BIN)) $(LINK) -o $(BIN_DIR)/$(BINARY)
debug:
mkdir -p debug
$(MAKE) main DEBUG=true
release:
mkdir -p release
$(MAKE) main DEBUG=false
release_osx:
mkdir -p release
$(MAKE) main OSX=true DEBUG=false
debug_osx:
mkdir -p debug
$(MAKE) main OSX=true DEBUG=true
all_linux: release debug
all_osx: release_osx debug_osx
all: all_linux all_osx
2014-07-30 14:17:46 +04:00
2015-06-06 17:32:59 +03:00
default: all
2014-07-30 14:17:46 +04:00
clean:
2015-06-06 17:32:59 +03:00
rm -rf release
rm -rf debug