init gmake
This commit is contained in:
parent
9d31afc224
commit
474b232b3a
2 changed files with 72 additions and 0 deletions
49
Makefile
Normal file
49
Makefile
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
.DEFAULT_GOAL := all
|
||||
|
||||
include config.mk
|
||||
|
||||
# === BUILD ENVIRONMENT ===
|
||||
SRC := src
|
||||
BIN := bin
|
||||
BUILD := build
|
||||
|
||||
# === MACRO DEFINITIONS ===
|
||||
define objpath
|
||||
$(addprefix $(BUILD)/,
|
||||
$(addsuffix .o,
|
||||
$(basename $(1))))
|
||||
endef
|
||||
define mkobj
|
||||
$(foreach DEP, $?,
|
||||
mkdir -p $(dir $(call objpath, $(DEP)))
|
||||
$(CC) $(CFLAGS) $1 -o $(call objpath, $(DEP)) -c $(DEP))
|
||||
|
||||
$(LD) -r $(LDFLAGS) -o $@ $(call objpath, $?)
|
||||
endef
|
||||
|
||||
# === BUILD TARGETS ===
|
||||
all: tests
|
||||
|
||||
.PHONY: tests
|
||||
tests: $(BIN) $(BIN)/ct_test
|
||||
|
||||
$(BIN)/ct_test: $(BUILD) $(addprefix $(BUILD)/, ct_test.o term.o surface.o)
|
||||
$(LD) -o $@ $(filter %.o, $^)
|
||||
|
||||
$(BUILD)/%.o: $(SRC)/%.c
|
||||
$(CC) $(CFLAGS) -o $@ -c $^
|
||||
|
||||
$(BUILD) $(BIN):
|
||||
mkdir -p $@
|
||||
|
||||
# === DEVELOPMENT TARGETS ===
|
||||
.PHONY: debug
|
||||
debug:
|
||||
$(MAKE) all \
|
||||
CFLAGS="$(CFLAGS) $(CDEBUG)" \
|
||||
CLDFLAGS="$(LDFLAGS) $(LDDEBUG)"
|
||||
|
||||
# === UTILITY TARGETS ===
|
||||
.PHONY: clean
|
||||
clean:
|
||||
- rm -rf $(BUILD) $(BIN) vgcore.* 2>/dev/null
|
||||
Loading…
Add table
Add a link
Reference in a new issue