From 72d68ffa918e9cd0b42c7712a197b3291406e199 Mon Sep 17 00:00:00 2001 From: var Date: Sun, 29 Mar 2026 20:09:56 -0500 Subject: [PATCH] Hello World - determine project structure - add makefile and main function --- .gitignore | 56 ++---------------------------------------------------- makefile | 35 ++++++++++++++++++++++++++++++++++ src/main.c | 6 ++++++ 3 files changed, 43 insertions(+), 54 deletions(-) create mode 100755 makefile create mode 100644 src/main.c diff --git a/.gitignore b/.gitignore index cd531cf..678b679 100644 --- a/.gitignore +++ b/.gitignore @@ -1,54 +1,2 @@ -# ---> C -# Prerequisites -*.d - -# Object files -*.o -*.ko -*.obj -*.elf - -# Linker output -*.ilk -*.map -*.exp - -# Precompiled Headers -*.gch -*.pch - -# Libraries -*.lib -*.a -*.la -*.lo - -# Shared objects (inc. Windows DLLs) -*.dll -*.so -*.so.* -*.dylib - -# Executables -*.exe -*.out -*.app -*.i*86 -*.x86_64 -*.hex - -# Debug files -*.dSYM/ -*.su -*.idb -*.pdb - -# Kernel Module Compile Results -*.mod* -*.cmd -.tmp_versions/ -modules.order -Module.symvers -Mkfile.old -dkms.conf - +obj/* +Game diff --git a/makefile b/makefile new file mode 100755 index 0000000..ce52794 --- /dev/null +++ b/makefile @@ -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 diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..3c6bf72 --- /dev/null +++ b/src/main.c @@ -0,0 +1,6 @@ +#include + +int main(int argc, char* argv[]) +{ + printf("Hello World!\n"); +}