mirror of
https://github.com/thepigeongenerator/sdl_template.git
synced 2025-12-17 05:55:47 +01:00
make some makefile changes, to make things more consise
This commit is contained in:
21
makefile
21
makefile
@@ -1,12 +1,15 @@
|
|||||||
NAME = sdl_template
|
NAME = sdl_template
|
||||||
CFLAGS = -Wall -g -march=x86-64 -lm
|
|
||||||
|
|
||||||
DIR_BIN = bin
|
# compiler settings
|
||||||
DIR_OBJ = obj
|
CC := clang
|
||||||
|
CFLAGS := -Wall -g
|
||||||
|
LDFLAGS = $(shell sdl2-config --cflags --libs) -lm
|
||||||
|
|
||||||
|
# file locations
|
||||||
|
DIR_BIN := bin
|
||||||
|
DIR_OBJ := obj
|
||||||
SRC = $(wildcard src/*.c) $(wildcard src/**/*.c) $(wildcard src/**/**/*.c) $(wildcard src/**/**/**/*.c) $(wildcard src/**/**/**/**/*.c)
|
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))
|
OBJ = $(patsubst src/%,$(DIR_OBJ)/$(ARCH)/%,$(SRC:.c=.o))
|
||||||
|
|
||||||
TARGET = $(DIR_BIN)/$(ARCH)/$(NAME)$(EXT)
|
TARGET = $(DIR_BIN)/$(ARCH)/$(NAME)$(EXT)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@@ -14,22 +17,22 @@ clean:
|
|||||||
|
|
||||||
# sets the variables for the different targets
|
# sets the variables for the different targets
|
||||||
linux-x86_64:
|
linux-x86_64:
|
||||||
$(MAKE) build ARCH=linux-x86_64 CC=clang PCFLAGS="-target x86_64-pc-linux-gnu -lSDL2"
|
$(MAKE) build ARCH=linux-x86_64 CFLAGS="$(CFLAGS) -target x86_64-pc-linux-gnu"
|
||||||
win-x86_64:
|
win-x86_64:
|
||||||
$(MAKE) build ARCH=win-x86-64 CC=clang PCFLAGS="-target x86_64-pc-windows-gnu -lmingw32 -lSDL2main -lSDL2 -mwindows" EXT=".exe"
|
$(MAKE) build ARCH=win-x86-64 CFLAGS="$(CFLAGS) -target x86_64-pc-windows-gnu" EXT=".exe"
|
||||||
web:
|
web:
|
||||||
$(MAKE) build ARCH=web CC=emcc PCFLAGS="-s USE_SDL=2" EXT=".html"
|
$(MAKE) build ARCH=web CC=emcc EXT=".html"
|
||||||
|
|
||||||
build: dirs binary
|
build: dirs binary
|
||||||
|
|
||||||
# creates the binary
|
# creates the binary
|
||||||
binary: $(OBJ)
|
binary: $(OBJ)
|
||||||
$(CC) -o $(TARGET) $^ $(CFLAGS) $(PCFLAGS)
|
$(CC) -o $(TARGET) $^ $(CFLAGS) $(LDFLAGS)
|
||||||
|
|
||||||
# creates the object files, include a flag for no unused command line arguments, because in this context it's unneeded
|
# creates the object files, include a flag for no unused command line arguments, because in this context it's unneeded
|
||||||
$(DIR_OBJ)/$(ARCH)/%.o: src/%.c
|
$(DIR_OBJ)/$(ARCH)/%.o: src/%.c
|
||||||
mkdir -p $(dir $@)
|
mkdir -p $(dir $@)
|
||||||
$(CC) -o $@ -c $< $(CFLAGS) $(PCFLAGS) -Wno-unused-command-line-argument
|
$(CC) -o $@ -c $< $(CFLAGS) $(LDFLAGS) -Wno-unused-command-line-argument
|
||||||
|
|
||||||
dirs:
|
dirs:
|
||||||
mkdir -p $(DIR_BIN)/$(ARCH)
|
mkdir -p $(DIR_BIN)/$(ARCH)
|
||||||
|
|||||||
Reference in New Issue
Block a user