diff options
author | Christian C <cc@localhost> | 2025-03-07 22:07:25 -0800 |
---|---|---|
committer | Christian C <cc@localhost> | 2025-03-07 22:07:25 -0800 |
commit | 7ed69a0373ea170a164bf0557d61096100a7bba0 (patch) | |
tree | 70e27a991289e8f67df5ed765fda847d6cf14eeb | |
parent | 0d1f5979dd1d6062af118fae3a1aa1863ea596f2 (diff) |
Modularize programs
-rw-r--r-- | Makefile | 20 | ||||
-rw-r--r-- | src/prog.c (renamed from src/main.c) | 0 |
2 files changed, 9 insertions, 11 deletions
@@ -1,6 +1,5 @@ PKGS=libtiff-4 libpng DEFINES= -EXE=prog BUILD_DIR=build/ INC_DIR=include/ @@ -22,10 +21,13 @@ LIB_OBJS=$(LIB_OBJS_sub:.c=.o) LIB_OBJ_DIRS_sub=$(shell find $(LIB_DIR) -type d) LIB_OBJ_DIRS=$(subst $(LIB_DIR),$(LIB_OBJ_DIR),$(LIB_OBJ_DIRS_sub)) -$(info $(LIB_SRCS)) -$(info $(LIB_OBJ_DIR)) -$(info $(LIB_OBJ_DIRS)) -$(info $(LIB_OBJS)) +# Programs +PROG_DIR= +PROG_OUT_DIR=$(BUILD_DIR)$(PROG_DIR) +PROG_SRCS=$(shell find $(SRC_DIR) -iname \*.c) +PROG_OBJS=$(PROG_SRCS:.c=.o) +PROG_DIRS_sub=$(subst $(SRC_DIR),$(PROG_OUT_DIR),$(PROG_SRCS)) +PROGS=$(PROG_DIRS_sub:.c=) # Include raylib if we want a visual experience ifdef RAYLIB @@ -60,9 +62,9 @@ default: clean build .PHONY: clean build run -build: $(BUILD_DIR)$(EXE) +build: $(PROGS) -$(BUILD_DIR)$(EXE): $(SRC_OBJS) $(LIB_OBJS) +$(BUILD_DIR)$(PROG_DIR)%: $(SRC_OBJ_DIR)%.o $(LIB_OBJS) @echo LD --\> $@ @gcc -o $@ $(LDFLAGS) $^ @@ -78,7 +80,3 @@ clean: @echo Cleaning build files... @-rm -rf $(OBJ_DIR) $(BUILD_DIR) @mkdir -p $(BUILD_DIR) $(SRC_OBJ_DIRS) $(LIB_OBJ_DIRS) - -run: $(BUILD_DIR)$(EXE) - @echo Executing... - @./$(BUILD_DIR)$(EXE) |