mirror of
https://github.com/thepigeongenerator/sdl_template.git
synced 2025-12-17 05:55:47 +01:00
switch to a makefile build system
This commit is contained in:
36
makefile
Normal file
36
makefile
Normal file
@@ -0,0 +1,36 @@
|
||||
NAME = sdl_template
|
||||
CFLAGS = -Wall -g -march=x86-64 -lm
|
||||
|
||||
DIR_BIN = bin
|
||||
DIR_OBJ = obj
|
||||
|
||||
SRC = $(wildcard src/*.c) $(wildcard src/**/*.c) $(wildcard src/**/**/*.c) $(wildcard src/**/**/**/*.c) $(wildcard src/**/**/**/**/*.c)
|
||||
OBJ = $(patsubst src/%,$(DIR_OBJ)/$(ARCH)/%,$(SRC:.c=.o))
|
||||
|
||||
TARGET = $(DIR_BIN)/$(ARCH)/$(NAME)$(EXT)
|
||||
|
||||
clean:
|
||||
rm -rf $(DIR_BIN) $(DIR_OBJ)
|
||||
|
||||
# sets the variables for the different targets
|
||||
linux-x86_64:
|
||||
$(MAKE) build ARCH=linux-x86_64 CC=gcc PCFLAGS="-lSDL2"
|
||||
win86-64:
|
||||
$(MAKE) build ARCH=win-x86-64 CC=x86_64-w64-mingw32-gcc PCFLAGS="-lmingw32 -lSDL2main -lSDL2 -mwindows" EXT=".exe"
|
||||
web:
|
||||
$(MAKE) build ARCH=web CC=emcc PCFLAGS="-s USE_SDL=2" EXT=".html"
|
||||
|
||||
build: dirs binary
|
||||
|
||||
# creates the binary
|
||||
binary: $(OBJ)
|
||||
$(CC) -o $(TARGET) $^ $(CFLAGS) $(PCFLAGS)
|
||||
|
||||
# creates the object files
|
||||
$(DIR_OBJ)/$(ARCH)/%.o: src/%.c
|
||||
mkdir -p $(dir $@)
|
||||
$(CC) -o $@ -c $< $(CFLAGS) $(PCFLAGS)
|
||||
|
||||
dirs:
|
||||
mkdir -p $(DIR_BIN)/$(ARCH)
|
||||
mkdir -p $(DIR_OBJ)/$(ARCH)
|
||||
Reference in New Issue
Block a user