diff options
author | Christian C <cc@localhost> | 2025-03-07 21:55:05 -0800 |
---|---|---|
committer | Christian C <cc@localhost> | 2025-03-07 21:55:05 -0800 |
commit | 12a1b2269c64bfbe61490a9a2a8eaa84ec3b41de (patch) | |
tree | 6ebced146b7d441ef3c9b963f30007ff80c197e5 | |
parent | c1f7a624aad8b548b5d95da0d4a587ce49f353c7 (diff) |
Source File Building
-rw-r--r-- | Makefile | 29 |
1 files changed, 19 insertions, 10 deletions
@@ -2,14 +2,23 @@ PKGS=libtiff-4 libpng DEFINES= EXE=prog BUILD_DIR=build/ -OBJ_DIR=$(BUILD_DIR)obj/ -SRC_DIR=src/ INC_DIR=include/ -SRCS=$(shell find $(SRC_DIR) -iname \*.c) -OBJS_sub=$(subst $(SRC_DIR),$(OBJ_DIR),$(SRCS)) -OBJS=$(OBJS_sub:.c=.o) -OBJ_DIRS_sub=$(shell find $(SRC_DIR) -type d) -OBJ_DIRS=$(subst $(SRC_DIR),$(OBJ_DIR),$(OBJ_DIRS_sub)) + +# Source files +SRC_DIR=src/ +SRC_OBJ_DIR=$(BUILD_DIR)obj/src/ +SRC_SRCS=$(shell find $(SRC_DIR) -iname \*.c) +SRC_OBJS_sub=$(subst $(SRC_DIR),$(SRC_OBJ_DIR),$(SRC_SRCS)) +SRC_OBJS=$(SRC_OBJS_sub:.c=.o) +SRC_OBJ_DIRS_sub=$(shell find $(SRC_DIR) -type d) +SRC_OBJ_DIRS=$(subst $(SRC_DIR),$(SRC_OBJ_DIR),$(SRC_OBJ_DIRS_sub)) + +$(info $(SRC_SRCS)) +$(info $(SRC_OBJ_DIR)) +$(info $(SRC_OBJ_DIRS)) +$(info $(SRC_OBJS)) + +# Library files # Include raylib if we want a visual experience ifdef RAYLIB @@ -46,18 +55,18 @@ default: clean build build: $(BUILD_DIR)$(EXE) -$(BUILD_DIR)$(EXE): $(OBJS) +$(BUILD_DIR)$(EXE): $(SRC_OBJS) @echo LD --\> $@ @gcc -o $@ $(LDFLAGS) $^ -$(OBJ_DIR)%.o: $(SRC_DIR)%.c +$(SRC_OBJ_DIR)%.o: $(SRC_DIR)%.c @echo CC $< --\> $@ @gcc -o $@ $(CFLAGS) -c $< clean: @echo Cleaning build files... @-rm -rf $(OBJ_DIR) $(BUILD_DIR) - @mkdir -p $(OBJ_DIR) $(BUILD_DIR) $(OBJ_DIRS) + @mkdir -p $(BUILD_DIR) $(SRC_OBJ_DIRS) run: $(BUILD_DIR)$(EXE) @echo Executing... |