forked from enigma-dev/enigma-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove some of the duplicate logic in our Makefiles (enigma-dev#1876)
- Loading branch information
1 parent
c6849f6
commit 9eefc9a
Showing
11 changed files
with
154 additions
and
256 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
/ENIGMA/ | ||
/emake | ||
/test-runner | ||
/emake-tests | ||
/gm2egm | ||
/LinuxExtra/ | ||
/android/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
include ../../Config.mk | ||
|
||
TARGET := ../../gm2egm | ||
|
||
CXXFLAGS := -I../../shared/protos/ -I../../shared/protos/.eobjs -I../libEGM/ | ||
LDFLAGS := -Wl,-rpath,. -L../../ -lEGM -lProtocols -lpthread | ||
SOURCES := main.cpp | ||
|
||
include ../../Default.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,25 @@ | ||
include ../Config.mk | ||
|
||
# "Shared" includes. | ||
SHARED_SRC_DIR := ../shared | ||
include $(SHARED_SRC_DIR)/Makefile | ||
include $(SHARED_SRC_DIR)/eyaml/Makefile | ||
include $(SHARED_SRC_DIR)/event_reader/Makefile | ||
include $(SHARED_SRC_DIR)/rectpacker/Makefile | ||
|
||
################# | ||
# configuration # | ||
################# | ||
# TODO: better config process based on features rather than OS | ||
|
||
BASE = compileEGMf | ||
OS := $(shell uname -s) | ||
ifeq ($(OS), Linux) | ||
TARGET := ../lib$(BASE).so | ||
CXXFLAGS += -fPIC | ||
MKDIR := mkdir | ||
else ifeq ($(OS), Darwin) | ||
TARGET := ../lib$(BASE).dylib | ||
CXXFLAGS += -fPIC | ||
MKDIR := mkdir | ||
else | ||
TARGET := ../$(BASE).dll | ||
LDFLAGS += -static-libgcc | ||
MKDIR := mkdir.exe | ||
endif | ||
|
||
########### | ||
# options # | ||
########### | ||
|
||
CXX := g++ | ||
CXXFLAGS += -std=c++11 -Wall -O3 -g -I./JDI/src | ||
LDFLAGS += -shared -O3 -g -L../ -Wl,-rpath,./ | ||
LDLIBS += -lProtocols -lprotobuf -lz -L$(SHARED_SRC_DIR)/libpng-util -lpng-util -lpng | ||
|
||
# This implements a recursive wildcard allowing us to iterate in subdirs | ||
rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2)) | ||
|
||
SOURCES := $(filter-out ./standalone_main.cpp, $(call rwildcard,./,*.cpp)) | ||
OBJECTS := $(addprefix .eobjs/,$(SOURCES:.cpp=.o)) | ||
DEPENDS := $(OBJECTS:.o=.d) | ||
PROTO_DIR := $(SHARED_SRC_DIR)/protos | ||
CXXFLAGS += -fPIC -I./JDI/src -I$(SHARED_SRC_DIR) -I$(SHARED_SRC_DIR)/libpng-util -I$(PROTO_DIR)/.eobjs $(addprefix -I$(SHARED_SRC_DIR)/, $(SHARED_INCLUDES)) | ||
LDFLAGS += -shared -g -L../ -Wl,-rpath,./ -lProtocols -lprotobuf -lz -L$(SHARED_SRC_DIR)/libpng-util -lpng-util -lpng | ||
SOURCES := $(filter-out ./standalone_main.cpp, $(call rwildcard,.,*.cpp)) | ||
|
||
CXXFLAGS += -I$(SHARED_SRC_DIR) -I$(SHARED_SRC_DIR)/libpng-util -I$(PROTO_DIR)/.eobjs $(addprefix -I$(SHARED_SRC_DIR)/, $(SHARED_INCLUDES)) | ||
SOURCES += $(addprefix $(SHARED_SRC_DIR),$(SHARED_SOURCES)) | ||
OBJECTS += $(addprefix .eobjs/shared/,$(SHARED_SOURCES:.cpp=.o)) | ||
DEPENDS += $(addprefix .eobjs/shared/,$(SHARED_SOURCES:.cpp=.d)) | ||
|
||
# sort has the nice side effect of removing duplicates. this may or may not be faster. | ||
OBJDIRS := $(sort $(dir $(OBJECTS))) | ||
override CPPFLAGS += -I. | ||
|
||
############ | ||
# building # | ||
############ | ||
|
||
.PHONY: all clean | ||
|
||
all: $(TARGET) | ||
|
||
clean: | ||
$(RM) $(TARGET) $(OBJECTS) $(DEPENDS) | ||
|
||
$(TARGET): $(OBJECTS) | ||
$(CXX) $(LDFLAGS) -o $@ $(OBJECTS) $(LDLIBS) | ||
|
||
# GCC will figure out dependencies and write out makefile rules in %.d when they change | ||
# -MMD outputs dependencies to %.d as a side effect of compilation, ignoring system headers | ||
# -MP gives phony rules for non-target files, avoiding problems with missing files | ||
.eobjs/%.o .eobjs/%.d: %.cpp | $(OBJDIRS) | ||
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -MMD -MP -c -o .eobjs/$*.o $< | ||
.eobjs/shared/%.o .eobjs/shared/%.d: $(SHARED_SRC_DIR)/%.cpp | $(OBJDIRS) | ||
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -MMD -MP -c -o .eobjs/shared/$*.o $< | ||
|
||
$(OBJDIRS): | ||
$(MKDIR) -p $@ | ||
|
||
ifneq ($(MAKECMDGOALS),clean) | ||
-include $(DEPENDS) | ||
endif | ||
include ../Default.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
GCCVER := $(shell gcc -dumpversion | cut -c 1) | ||
|
||
OS := $(shell uname -s) | ||
ifeq ($(OS), Linux) | ||
LIB_EXT := .so | ||
BIN_EXT := | ||
else ifeq ($(OS), Darwin) | ||
LIB_EXT := .dylib | ||
BIN_EXT := | ||
else | ||
LIB_EXT := .dll | ||
BIN_EXT := .exe | ||
endif | ||
|
||
# Global g++ flags | ||
CXXFLAGS := -Wall -Wextra -Wpedantic -g -I. | ||
LDFLAGS := -g | ||
|
||
# For older travis instances | ||
ifeq ($(shell expr $(GCCVER) \<= 6), 1) | ||
CXXFLAGS += -std=c++11 | ||
endif | ||
|
||
# These will be relative to the file that includes this Makefile | ||
SRC_DIR := . | ||
OBJ_DIR := .eobjs | ||
|
||
# This implements a recursive wildcard allowing us to iterate in subdirs | ||
rwildcard=$(wildcard $1/$2) $(foreach d,$(wildcard $1/*),$(call rwildcard,$d,$2)) |
Oops, something went wrong.