Hello World
- determine project structure - add makefile and main function
This commit is contained in:
35
makefile
Executable file
35
makefile
Executable 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
|
||||
Reference in New Issue
Block a user