diff options
author | Mark Haines <mjark@negativecurvature.net> | 2016-05-23 16:21:37 +0100 |
---|---|---|
committer | Mark Haines <mjark@negativecurvature.net> | 2016-05-23 16:21:37 +0100 |
commit | 83ce82708e6fafc210d0f359fcb9cd767974f1e3 (patch) | |
tree | aac8c096701da02325dcce35182c7ca7f4d10620 /Makefile | |
parent | 509be1b1bf762adb3d5410414eb96176340a5fbc (diff) |
Use a rule to make the build directories
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 19 |
1 files changed, 11 insertions, 8 deletions
@@ -2,7 +2,7 @@ # Make sure that the build directory exists. # We can't check the build directory into git because it is empty. -BUILD_DIR := $(shell mkdir -p build/release build/debug build/javascript build/tests; echo build) +BUILD_DIR := build RELEASE_OPTIMIZE_FLAGS ?= -g -O3 DEBUG_OPTIMIZE_FLAGS ?= -g -O0 JS_OPTIMIZE_FLAGS ?= -O3 @@ -25,7 +25,6 @@ JS_OBJECTS := $(patsubst src/%,$(BUILD_DIR)/javascript/%,$(patsubst %.c,%.js.bc, JS_PRE := $(wildcard javascript/*pre.js) JS_POST := $(wildcard javascript/*post.js) - CPPFLAGS += -Iinclude -Ilib CFLAGS += -Wall -std=c89 -fPIC CXXFLAGS += -Wall -std=c++11 -fPIC @@ -65,6 +64,10 @@ $(JS_TARGET): LDFLAGS += $(JS_OPTIMIZE_FLAGS) lib: $(RELEASE_TARGET) .PHONY: lib +makedirs: + mkdir -p $(BUILD_DIR)/release $(BUILD_DIR)/debug $(BUILD_DIR)/javascript $(BUILD_DIR)/tests +.PHONY: makedirs + $(RELEASE_TARGET): $(RELEASE_OBJECTS) $(CXX) $(LDFLAGS) --shared -fPIC \ -Wl,--version-script,version_script.ver \ @@ -112,22 +115,22 @@ all: test js lib debug .PHONY: lib ### rules for building objects -$(BUILD_DIR)/release/%.o: src/%.c +$(BUILD_DIR)/release/%.o: src/%.c | makedirs $(COMPILE.c) $(OUTPUT_OPTION) $< -$(BUILD_DIR)/release/%.o: src/%.cpp +$(BUILD_DIR)/release/%.o: src/%.cpp | makedirs $(COMPILE.cc) $(OUTPUT_OPTION) $< -$(BUILD_DIR)/debug/%.o: src/%.c +$(BUILD_DIR)/debug/%.o: src/%.c | makedirs $(COMPILE.c) $(OUTPUT_OPTION) $< -$(BUILD_DIR)/debug/%.o: src/%.cpp +$(BUILD_DIR)/debug/%.o: src/%.cpp | makedirs $(COMPILE.cc) $(OUTPUT_OPTION) $< -$(BUILD_DIR)/javascript/%.js.bc: src/%.c +$(BUILD_DIR)/javascript/%.js.bc: src/%.c | makedirs $(EMCC.c) $(OUTPUT_OPTION) $< -$(BUILD_DIR)/javascript/%.js.bc: src/%.cpp +$(BUILD_DIR)/javascript/%.js.bc: src/%.cpp | makedirs $(EMCC.cc) $(OUTPUT_OPTION) $< $(BUILD_DIR)/tests/%: tests/%.c $(DEBUG_OBJECTS) |