Hello World

- determine project structure
- add makefile and main function
This commit is contained in:
var
2026-03-29 20:09:56 -05:00
parent aeb0d9d9fb
commit 72d68ffa91
3 changed files with 43 additions and 54 deletions

35
makefile Executable file
View File

@@ -0,0 +1,35 @@
INC = include
OBJ = obj
SRC = src
EXE = Game
CC = gcc
CFLAGS = -w -ggdb -I$(INC)
LIBS = -lGLEW -lGLU -lGL -lSDL2 -lcglm -lz -lm
OBJFILES := $(patsubst $(SRC)/%.c, $(OBJ)/%.o, $(shell find $(SRC) -name '*.c'))
OBJDIRS := $(patsubst $(SRC)%, $(OBJ)%, $(shell find $(SRC) -type d))
CLEANDIRS := $(addsuffix /.clean, $(OBJDIRS));
# Explicit targets
.PHONY: all clean
.DEFAULT_GOAL := all
# Build executable
all: $(EXE)
$(EXE): $(OBJFILES) | $(OBJDIRS)
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
# Compile object files
$(OBJ)/%.o: $(SRC)/%.c | $(OBJDIRS)
$(CC) -c -o $@ $(SRC)/$*.c $(CFLAGS)
# Create obj directory tree if it doesn't exist
$(OBJDIRS):
mkdir -p $@
# Delete previously built files
clean: $(CLEANDIRS)
rm -f $(EXE)
%.clean:
rm -f $**.o