From b36c894fe7dc7085d0c9a6d1d2b1b2a1196fe5ac Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Fri, 15 Sep 2017 22:45:23 +0200 Subject: [PATCH] Unix build files. --- standalone/build/unix/Makefile | 12 ++++++++ standalone/build/unix/build.mk | 51 ++++++++++++++++++++++++++++++++ standalone/build/unix/debug.mk | 10 +++++++ standalone/build/unix/release.mk | 10 +++++++ 4 files changed, 83 insertions(+) create mode 100644 standalone/build/unix/Makefile create mode 100644 standalone/build/unix/build.mk create mode 100644 standalone/build/unix/debug.mk create mode 100644 standalone/build/unix/release.mk diff --git a/standalone/build/unix/Makefile b/standalone/build/unix/Makefile new file mode 100644 index 00000000..3b50301c --- /dev/null +++ b/standalone/build/unix/Makefile @@ -0,0 +1,12 @@ +all: debug + +debug: + @+make -f debug.mk all + +release: + @+make -f release.mk all + +clean: + @+make -f build.mk clean + +.PHONY: all clean debug release diff --git a/standalone/build/unix/build.mk b/standalone/build/unix/build.mk new file mode 100644 index 00000000..b47efb54 --- /dev/null +++ b/standalone/build/unix/build.mk @@ -0,0 +1,51 @@ +CFLAGS += +CXXFLAGS := $(CFLAGS) -std=c++14 +DEFINES += +INCLUDES := $(shell pkg-config --cflags glfw3) -I../../../imgui -I../../libs/gl3w +LIBS := $(shell pkg-config --libs glfw3) -lpthread -ldl -lGL +IMAGE := Tracy + +FILTER := + +BASE := $(shell egrep 'ClCompile.*cpp"' ../win32/$(IMAGE).vcxproj | sed -e 's/.*\"\(.*\)\".*/\1/' | sed -e 's@\\@/@g') +BASE2 := $(shell egrep 'ClCompile.*c"' ../win32/$(IMAGE).vcxproj | sed -e 's/.*\"\(.*\)\".*/\1/' | sed -e 's@\\@/@g') + +SRC := $(filter-out $(FILTER),$(BASE)) +SRC2 := $(filter-out $(FILTER),$(BASE2)) + +OBJ := $(SRC:%.cpp=%.o) +OBJ2 := $(SRC2:%.c=%.o) + +all: $(IMAGE) + +%.o: %.cpp + $(CXX) -c $(INCLUDES) $(CXXFLAGS) $(DEFINES) $< -o $@ + +%.d : %.cpp + @echo Resolving dependencies of $< + @mkdir -p $(@D) + @$(CXX) -MM $(INCLUDES) $(CXXFLAGS) $(DEFINES) $< > $@.$$$$; \ + sed 's,.*\.o[ :]*,$(<:.cpp=.o) $@ : ,g' < $@.$$$$ > $@; \ + rm -f $@.$$$$ + +%.o: %.c + $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + +%.d : %.c + @echo Resolving dependencies of $< + @mkdir -p $(@D) + @$(CC) -MM $(INCLUDES) $(CFLAGS) $(DEFINES) $< > $@.$$$$; \ + sed 's,.*\.o[ :]*,$(<:.c=.o) $@ : ,g' < $@.$$$$ > $@; \ + rm -f $@.$$$$ + +$(IMAGE): $(OBJ) $(OBJ2) + $(CXX) $(CXXFLAGS) $(DEFINES) $(OBJ) $(OBJ2) $(LIBS) -o $@ + +ifneq "$(MAKECMDGOALS)" "clean" +-include $(SRC:.cpp=.d) $(SRC2:.c=.d) +endif + +clean: + rm -f $(OBJ) $(OBJ2) $(SRC:.cpp=.d) $(SRC2:.c=.d) $(IMAGE) + +.PHONY: clean all diff --git a/standalone/build/unix/debug.mk b/standalone/build/unix/debug.mk new file mode 100644 index 00000000..5a4e17b3 --- /dev/null +++ b/standalone/build/unix/debug.mk @@ -0,0 +1,10 @@ +ARCH := $(shell uname -m) + +CFLAGS := -g3 -Wall +DEFINES := -DDEBUG + +ifeq ($(ARCH),x86_64) +CFLAGS += -msse4.1 +endif + +include build.mk diff --git a/standalone/build/unix/release.mk b/standalone/build/unix/release.mk new file mode 100644 index 00000000..1c820a6e --- /dev/null +++ b/standalone/build/unix/release.mk @@ -0,0 +1,10 @@ +ARCH := $(shell uname -m) + +CFLAGS := -O3 -s -fomit-frame-pointer +DEFINES := -DNDEBUG + +ifeq ($(ARCH),x86_64) +CFLAGS += -msse4.1 +endif + +include build.mk