diff options
author | mattkae <mattkae@protonmail.com> | 2022-12-23 12:47:10 -0500 |
---|---|---|
committer | mattkae <mattkae@protonmail.com> | 2022-12-23 12:47:10 -0500 |
commit | 7228b2e1a2d0a8399facce3493d71a3569d250d5 (patch) | |
tree | 8eb5e4b686bf68fa12fcbb270ef88dd29aa1d704 /themes/Makefile | |
parent | f63d0af456f76d713e56ca17be114fba0af22f6c (diff) |
Improved the makefile considerably
Diffstat (limited to 'themes/Makefile')
-rw-r--r-- | themes/Makefile | 49 |
1 files changed, 38 insertions, 11 deletions
diff --git a/themes/Makefile b/themes/Makefile index 8bdc04e..bfe42a3 100644 --- a/themes/Makefile +++ b/themes/Makefile @@ -1,17 +1,44 @@ -CXX = emcc -EXE = dist/output.js -SRCS = $(wildcard *.cpp) -OBJS = $(patsubst %.cpp,%.o,$(SRCS)) +TARGET_EXEC ?= output.js + +BUILD_DIR ?= ./dist +SRC_DIRS ?= ./src + +CC := emcc +CXX := emcc +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)) LDFLAGS = -s ALLOW_MEMORY_GROWTH=1 -s USE_WEBGL2=1 -s FULL_ES3=1 -s WASM=1 -s NO_EXIT_RUNTIME=1 -s FETCH -all: build $(EXE) +CPPFLAGS ?= $(INC_FLAGS) -MMD -MP + +$(BUILD_DIR)/$(TARGET_EXEC): $(OBJS) + $(CC) $(OBJS) -o $@ $(LDFLAGS) + +# assembly +$(BUILD_DIR)/%.s.o: %.s + $(MKDIR_P) $(dir $@) + $(AS) $(ASFLAGS) -c $< -o $@ -$(EXE): $(OBJS) - echo $(OBJS) - $(CXX) -o $(EXE) $(OBJS) $(LDFLAGS) +# c source +$(BUILD_DIR)/%.c.o: %.c + $(MKDIR_P) $(dir $@) + $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ -build: - @mkdir -p dist +# c++ source +$(BUILD_DIR)/%.cpp.o: %.cpp + $(MKDIR_P) $(dir $@) + $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@ + + +.PHONY: clean clean: - rm -rf dist && rm *.o
\ No newline at end of file + $(RM) -r $(BUILD_DIR) + +-include $(DEPS) + +MKDIR_P ?= mkdir -p |