Use a rule to make the build directories
This commit is contained in:
parent
509be1b1bf
commit
83ce82708e
1 changed files with 11 additions and 8 deletions
19
Makefile
19
Makefile
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
# Make sure that the build directory exists.
|
# Make sure that the build directory exists.
|
||||||
# We can't check the build directory into git because it is empty.
|
# 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
|
RELEASE_OPTIMIZE_FLAGS ?= -g -O3
|
||||||
DEBUG_OPTIMIZE_FLAGS ?= -g -O0
|
DEBUG_OPTIMIZE_FLAGS ?= -g -O0
|
||||||
JS_OPTIMIZE_FLAGS ?= -O3
|
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_PRE := $(wildcard javascript/*pre.js)
|
||||||
JS_POST := $(wildcard javascript/*post.js)
|
JS_POST := $(wildcard javascript/*post.js)
|
||||||
|
|
||||||
|
|
||||||
CPPFLAGS += -Iinclude -Ilib
|
CPPFLAGS += -Iinclude -Ilib
|
||||||
CFLAGS += -Wall -std=c89 -fPIC
|
CFLAGS += -Wall -std=c89 -fPIC
|
||||||
CXXFLAGS += -Wall -std=c++11 -fPIC
|
CXXFLAGS += -Wall -std=c++11 -fPIC
|
||||||
|
@ -65,6 +64,10 @@ $(JS_TARGET): LDFLAGS += $(JS_OPTIMIZE_FLAGS)
|
||||||
lib: $(RELEASE_TARGET)
|
lib: $(RELEASE_TARGET)
|
||||||
.PHONY: lib
|
.PHONY: lib
|
||||||
|
|
||||||
|
makedirs:
|
||||||
|
mkdir -p $(BUILD_DIR)/release $(BUILD_DIR)/debug $(BUILD_DIR)/javascript $(BUILD_DIR)/tests
|
||||||
|
.PHONY: makedirs
|
||||||
|
|
||||||
$(RELEASE_TARGET): $(RELEASE_OBJECTS)
|
$(RELEASE_TARGET): $(RELEASE_OBJECTS)
|
||||||
$(CXX) $(LDFLAGS) --shared -fPIC \
|
$(CXX) $(LDFLAGS) --shared -fPIC \
|
||||||
-Wl,--version-script,version_script.ver \
|
-Wl,--version-script,version_script.ver \
|
||||||
|
@ -112,22 +115,22 @@ all: test js lib debug
|
||||||
.PHONY: lib
|
.PHONY: lib
|
||||||
|
|
||||||
### rules for building objects
|
### rules for building objects
|
||||||
$(BUILD_DIR)/release/%.o: src/%.c
|
$(BUILD_DIR)/release/%.o: src/%.c | makedirs
|
||||||
$(COMPILE.c) $(OUTPUT_OPTION) $<
|
$(COMPILE.c) $(OUTPUT_OPTION) $<
|
||||||
|
|
||||||
$(BUILD_DIR)/release/%.o: src/%.cpp
|
$(BUILD_DIR)/release/%.o: src/%.cpp | makedirs
|
||||||
$(COMPILE.cc) $(OUTPUT_OPTION) $<
|
$(COMPILE.cc) $(OUTPUT_OPTION) $<
|
||||||
|
|
||||||
$(BUILD_DIR)/debug/%.o: src/%.c
|
$(BUILD_DIR)/debug/%.o: src/%.c | makedirs
|
||||||
$(COMPILE.c) $(OUTPUT_OPTION) $<
|
$(COMPILE.c) $(OUTPUT_OPTION) $<
|
||||||
|
|
||||||
$(BUILD_DIR)/debug/%.o: src/%.cpp
|
$(BUILD_DIR)/debug/%.o: src/%.cpp | makedirs
|
||||||
$(COMPILE.cc) $(OUTPUT_OPTION) $<
|
$(COMPILE.cc) $(OUTPUT_OPTION) $<
|
||||||
|
|
||||||
$(BUILD_DIR)/javascript/%.js.bc: src/%.c
|
$(BUILD_DIR)/javascript/%.js.bc: src/%.c | makedirs
|
||||||
$(EMCC.c) $(OUTPUT_OPTION) $<
|
$(EMCC.c) $(OUTPUT_OPTION) $<
|
||||||
|
|
||||||
$(BUILD_DIR)/javascript/%.js.bc: src/%.cpp
|
$(BUILD_DIR)/javascript/%.js.bc: src/%.cpp | makedirs
|
||||||
$(EMCC.cc) $(OUTPUT_OPTION) $<
|
$(EMCC.cc) $(OUTPUT_OPTION) $<
|
||||||
|
|
||||||
$(BUILD_DIR)/tests/%: tests/%.c $(DEBUG_OBJECTS)
|
$(BUILD_DIR)/tests/%: tests/%.c $(DEBUG_OBJECTS)
|
||||||
|
|
Loading…
Reference in a new issue