diff options
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 60 |
1 files changed, 43 insertions, 17 deletions
@@ -1,23 +1,49 @@ 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_DIR) +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)) + +# Library files +LIB_DIR=lib/ +LIB_OBJ_DIR=$(BUILD_DIR)obj/$(LIB_DIR) +LIB_SRCS=$(shell find $(LIB_DIR) -iname \*.c) +LIB_OBJS_sub=$(subst $(LIB_DIR),$(LIB_OBJ_DIR),$(LIB_SRCS)) +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)) + +# 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=$(shell find $(SRC_DIR) -type d) +PROG_DIRS=$(subst $(SRC_DIR),$(PROG_OUT_DIR),$(PROG_DIRS_sub)) +PROGS_sub=$(subst $(SRC_DIR),$(PROG_OUT_DIR),$(PROG_SRCS)) +PROGS=$(PROGS_sub:.c=) # Include raylib if we want a visual experience ifdef RAYLIB -$(info "Visual Experience Selected") +$(info Visual Experience Selected) PKGS+=raylib DEFINES+=-DVISUAL endif +# Dump AVL tree info? +ifdef AVL_INFO +$(info Including AVL Dump) +DEFINES+=-DAVL_INFO +endif + ifeq ($(shell uname -s),Linux) PKGCONF=pkgconf endif @@ -38,21 +64,21 @@ default: clean build .PHONY: clean build run -build: $(BUILD_DIR)$(EXE) +build: $(PROGS) -$(BUILD_DIR)$(EXE): $(OBJS) +$(BUILD_DIR)$(PROG_DIR)%: $(SRC_OBJ_DIR)%.o $(LIB_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 $< + +$(LIB_OBJ_DIR)%.o: $(LIB_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) - -run: $(BUILD_DIR)$(EXE) - @echo Executing... - @./$(BUILD_DIR)$(EXE) + @mkdir -p $(BUILD_DIR) $(SRC_OBJ_DIRS) $(LIB_OBJ_DIRS) $(PROG_DIRS) |