summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile40
1 files changed, 40 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..eddd4f2
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,40 @@
+config=debug
+defines=standard
+
+BUILD=build/make-$(CXX)-$(config)-$(defines)
+
+SOURCES=src/pugixml.cpp $(wildcard tests/*.cpp)
+EXECUTABLE=$(BUILD)/test
+
+CXXFLAGS=-c -g -Wall -Wextra -Werror -pedantic
+LDFLAGS=
+
+ifeq ($(config),release)
+ CXXFLAGS+=-O3 -DNDEBUG
+endif
+
+ifneq ($(defines),standard)
+ COMMA=,
+ CXXFLAGS+=-D $(subst $(COMMA), -D ,$(defines))
+endif
+
+OBJECTS=$(SOURCES:%=$(BUILD)/%.o)
+
+all: $(EXECUTABLE)
+
+test: $(EXECUTABLE)
+ ./$(EXECUTABLE)
+
+clean:
+ rm -rf $(BUILD)
+
+$(EXECUTABLE): $(OBJECTS)
+ $(CXX) $(OBJECTS) $(LDFLAGS) -o $@
+
+$(BUILD)/%.o: %
+ @mkdir -p $(dir $@)
+ $(CXX) $< $(CXXFLAGS) -MMD -MP -o $@
+
+-include $(OBJECTS:.o=.d)
+
+.PHONY: all test clean \ No newline at end of file