Skip to content

Commit

Permalink
Rewrite emake makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshDreamland committed Jan 13, 2018
1 parent 8aa78ad commit 872297f
Showing 1 changed file with 40 additions and 29 deletions.
69 changes: 40 additions & 29 deletions CommandLine/emake/Makefile
@@ -1,35 +1,46 @@
CXX=g++
CXXFLAGS=-g -std=c++11 -c -Wall -I. -I../../CompilerSource
BINARY := ../../emake
SRC_DIR := .
OBJ_DIR := .eobjs

ifeq ($(OS),Windows_NT)
LDFLAGS=-lboost_system-mt -Wl,--no-as-needed -Wl,-rpath=./ -lboost_program_options-mt -lboost_iostreams-mt -lboost_filesystem-mt -lboost_system-mt -lpthread
OS_LIBS=-lboost_system-mt -Wl,--no-as-needed -Wl,-rpath=./ -lboost_program_options-mt -lboost_iostreams-mt -lboost_filesystem-mt -lboost_system-mt -lpthread
else
LDFLAGS=-lboost_system -Wl,--no-as-needed -Wl,-rpath=./ -lboost_program_options -lboost_iostreams -lboost_filesystem -lboost_system -lpthread -ldl
OS_LIBS=-lboost_system -Wl,--no-as-needed -Wl,-rpath=./ -lboost_program_options -lboost_iostreams -lboost_filesystem -lboost_system -lpthread -ldl
endif

SOURCES=$(shell find . -name "*.cpp")
OBJECTS=$(addprefix .eobjs/,$(SOURCES:.cpp=.o))
EXECUTABLE=../../emake

all: $(SOURCES) $(EXECUTABLE)

$(EXECUTABLE): $(OBJECTS) eyaml eventsres
$(CXX) $(OBJECTS) $(LDFLAGS) .eobjs/eyaml.o .eobjs/event_parser.o -o $@

.eobjs/%.o : %.cpp .eobjs
$(CXX) $(CXXFLAGS) $< -o $@

.PHONY: eyaml, eventsres, clean

#I'm To lazy to write my own yaml parser or fix plugin to do shit I need
eyaml:
$(CXX) $(CXXFLAGS) ../../CompilerSource/settings-parse/eyaml.cpp -o .eobjs/eyaml.o
eventsres:
$(CXX) $(CXXFLAGS) ../../CompilerSource/compiler/event_reader/event_parser.cpp -o .eobjs/event_parser.o

.eobjs:
mkdir -p .eobjs/

EXTRA_SOURCES := ../../CompilerSource/settings-parse/eyaml.cpp ../../CompilerSource/compiler/event_reader/event_parser.cpp
EXTRA_SRC_DIR := ../../CompilerSource

CXXFLAGS := -I$(SRC_DIR) -I$(EXTRA_SRC_DIR) `wx-config --cxxflags` -Wall -Wextra -Wpedantic -g
LDFLAGS := $(OS_LIBS)
TEST_LIBS := -lgtest_main

EXTRA_OBJS := $(patsubst $(EXTRA_SRC_DIR)/%, $(OBJ_DIR)/Extra/%, $(patsubst %.cpp, %.o, $(EXTRA_SOURCES)))

SOURCES := $(shell find $(SRC_DIR) -name '*.cpp')
OBJECTS := $(patsubst $(SRC_DIR)/%, $(OBJ_DIR)/%, $(patsubst %.cpp, %.o, $(SOURCES)))
OBJDIRS := $(sort $(OBJ_DIR) $(dir $(OBJECTS)) $(dir $(EXTRA_OBJS)))
DEPENDS := $(OBJECTS:.o=.d) $(EXTRA_OBJS:.o=.d)

$(BINARY): $(OBJECTS) $(EXTRA_OBJS)
g++ $(LDFLAGS) $^ -o $@

.PHONY: all clean

all: $(BINARY)
clean:
rm -f .eobjs/*.o
rm -f ../../emake
rm -rf $(BINARY) $(OBJ_DIR)

# Create the object directories
$(OBJDIRS):
mkdir -p $@

# Generate rules for new (unbuilt) files
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp | $(OBJDIRS)
$(CXX) $(CXXFLAGS) -MMD -c -o $@ $<
$(OBJ_DIR)/Extra/%.o: $(EXTRA_SRC_DIR)/%.cpp | $(OBJDIRS)
$(CXX) $(CXXFLAGS) -MMD -c -o $@ $<

# Include rules for known (previously-built) files
-include $(DEPENDS)
.SUFFIXES:

0 comments on commit 872297f

Please sign in to comment.