configure GNU Make for C library

This commit is contained in:
Emile Clark-Boman 2025-09-03 02:32:13 +10:00
parent d25d0a9965
commit 79caa11f84
2 changed files with 35 additions and 0 deletions

31
Makefile Normal file
View file

@ -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)

4
config.mk Normal file
View file

@ -0,0 +1,4 @@
# === C Compiler+Linker ===
LD = ld
CC = gcc
CFLAGS =