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

56
.gitignore vendored
View File

@@ -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

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

6
src/main.c Normal file
View File

@@ -0,0 +1,6 @@
#include <stdio.h>
int main(int argc, char* argv[])
{
printf("Hello World!\n");
}