diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..0002590 --- /dev/null +++ b/Makefile @@ -0,0 +1,31 @@ +.DEFAULT_GOAL := all + +include config.mk + +# === BUILD ENVIRONMENT === +BIN := bin +BUILD := build +LIB := lib +PATHS := $(BUILD) $(BIN) $(LIB) + +# Macro definitions +define mkbin +$(addprefix $(BIN)/,$1) +endef +define mkbuild +$(addprefix $(BUILD)/,$1) +endef +define mklib +$(addprefix $(LIB)/,$1) +endef + +all: $(PATHS) $(BIN)/pw-test +$(BIN)/pw-test: $(call mklib, main.c) + $(CC) $(CFLAGS) -o $(BUILD)/pw-test.o -c $^ + $(LD) -o $@ $(BUILD)/pw-test.o + +$(PATHS): + mkdir -p $@ +.PHONY: clean +clean: + rm -rf $(PATHS) diff --git a/config.mk b/config.mk new file mode 100644 index 0000000..3591f5d --- /dev/null +++ b/config.mk @@ -0,0 +1,4 @@ +# === C Compiler+Linker === +LD = ld +CC = gcc +CFLAGS =