From 0e9a7d6bd8c7c9d4e44ae2cb73737ea1f92c926e Mon Sep 17 00:00:00 2001 From: jacekpoz Date: Sun, 11 Feb 2024 17:44:35 +0100 Subject: [PATCH] "clean up" makefile will need to rework it again later --- Makefile | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 031b8e7..83a59b4 100644 --- a/Makefile +++ b/Makefile @@ -8,34 +8,36 @@ CFLAGS += -Wconversion -Wunreachable-code CFLAGS += -D_GNU_SOURCE LDFLAGS = -SRC = modfetch.c semver.c -OBJ = $(SRC:.c=.o) +NAME = modfetch + +PROG = modfetch.c +LIB = semver.c +OBJ = $(PROG:.c=.o) $(LIB:.c=.o) BIN = target TEMPMOD = $(wildcard modules/*.c) MOD = $(TEMPMOD:modules/%=%) -PROGRAM = modfetch .PHONY: all clean -all: dirs modules $(PROGRAM) +all: dirs modules $(NAME) modules: dirs $(MOD:.c=.so) dirs: - mkdir -p ./$(BIN) + mkdir -p $(BIN) -$(PROGRAM): $(addprefix $(BIN)/, $(OBJ)) - $(CC) -o $(BIN)/$(PROGRAM) $^ $(LDFLAGS) +$(NAME): $(OBJ) + $(CC) -o $(BIN)/$(NAME) $(addprefix $(BIN)/, $^) $(LDFLAGS) + +%.so: modules/%.c $(LIB) + $(CC) -o $(BIN)/$@ $^ -shared -fPIC $(CFLAGS) $(LDFLAGS) %.o: %.c $(CC) -o $(BIN)/$@ -c $< $(CFLAGS) -%.so: modules/%.c - $(CC) -o $(BIN)/$@ $^ -shared -fPIC $(CFLAGS) - clean: clean_modules - rm -rf $(OBJ) - rm -rf $(PROGRAM) + rm -rf $(addprefix $(BIN)/, $(OBJ)) + rm -rf $(BIN)/$(NAME) clean_modules: rm -rf $(wildcard $(BIN)/*.so)