summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile45
1 files changed, 45 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..e453aa6
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,45 @@
+TARGET_EXEC ?= html_parser
+
+BUILD_DIR ?= ./build
+SRC_DIRS ?= ./src
+
+CC := g++ -g
+SRCS := $(shell find $(SRC_DIRS) -name *.cpp -or -name *.c -or -name *.s)
+OBJS := $(SRCS:%=$(BUILD_DIR)/%.o)
+DEPS := $(OBJS:.o=.d)
+
+INC_DIRS := $(shell find $(SRC_DIRS) -type d)
+INC_FLAGS := $(addprefix -I,$(INC_DIRS))
+
+CPPFLAGS ?= $(INC_FLAGS) -MMD -MP
+
+$(BUILD_DIR)/$(TARGET_EXEC): $(OBJS)
+ $(CC) $(OBJS) -o $@ -lmatte
+
+# assembly
+$(BUILD_DIR)/%.s.o: %.s
+ $(MKDIR_P) $(dir $@)
+ $(AS) $(ASFLAGS) -c $< -o $@
+
+# c source
+$(BUILD_DIR)/%.c.o: %.c
+ $(MKDIR_P) $(dir $@)
+ $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
+
+# c++ source
+$(BUILD_DIR)/%.cpp.o: %.cpp
+ $(MKDIR_P) $(dir $@)
+ $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
+
+
+.PHONY: clean
+
+clean:
+ $(RM) -r $(BUILD_DIR)
+
+all:
+ $(BUILD_DIR)/$(TARGET_EXEC)
+
+-include $(DEPS)
+
+MKDIR_P ?= mkdir -p