This repository has been archived by the owner on Mar 1, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathMakefile
46 lines (36 loc) · 1.99 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
WERROR?=-Werror
PKGS=sdl2
CFLAGS=-Wall -Wextra $(WERROR) -pedantic -I.
CXXFLAGS_WITHOUT_PKGS=$(CFLAGS) -std=c++17 -fno-exceptions -Wno-missing-braces -Wswitch-enum
ifdef OS # https://stackoverflow.com/questions/4058840/makefile-that-distincts-between-windows-and-unix-like-systems
CXXFLAGS=$(CXXFLAGS_WITHOUT_PKGS) $(shell pkg-config --cflags $(PKGS))
LIBS=$(shell pkg-config --libs $(PKGS)) -lm
EXESUFF=.exe
else
CXXFLAGS=$(CXXFLAGS_WITHOUT_PKGS) `pkg-config --cflags $(PKGS)`
LIBS=`pkg-config --libs $(PKGS) ` -lm
EXESUFF=
endif
CXXFLAGS_DEBUG=$(CXXFLAGS) -O0 -fno-builtin -ggdb
CXXFLAGS_WITHOUT_PKGS_DEBUG=$(CXXFLAGS_WITHOUT_PKGS) -O0 -fno-builtin -ggdb
CXXFLAGS_RELEASE=$(CXXFLAGS) -DSOMETHING_RELEASE -O3 -ggdb
.PHONY: all
all: something.debug something.release
something.debug: $(wildcard src/something*.cpp) $(wildcard src/something*.hpp) stb_image.o config_types.hpp assets_types.hpp
$(CXX) $(CXXFLAGS_DEBUG) -o $(addsuffix $(EXESUFF),something.debug) src/something.cpp stb_image.o $(LIBS)
something.release: $(wildcard src/something*.cpp) $(wildcard src/something*.hpp) baked_config.hpp assets_types.hpp
$(CXX) $(CXXFLAGS_RELEASE) -o $(addsuffix $(EXESUFF),something.release) src/something.cpp $(LIBS)
stb_image.o: src/stb_image.h
$(CC) $(CFLAGS) -x c -ggdb -DSTBI_ONLY_PNG -DSTB_IMAGE_IMPLEMENTATION -c -o stb_image.o src/stb_image.h
baked_config.hpp: config_baker ./assets/vars.conf
"./config_baker" > baked_config.hpp
config_baker: src/config_baker.cpp src/config_common.cpp config_types.hpp
$(CXX) $(CXXFLAGS_DEBUG) -o config_baker src/config_baker.cpp $(LIBS)
config_types.hpp: config_typer ./assets/vars.conf
"./config_typer" ./assets/vars.conf > config_types.hpp
config_typer: src/config_typer.cpp
$(CXX) $(CXXFLAGS_WITHOUT_PKGS_DEBUG) -o config_typer src/config_typer.cpp
assets_types.hpp: assets_typer ./assets/assets.conf
"./assets_typer" ./assets/assets.conf > assets_types.hpp
assets_typer: src/assets_typer.cpp
$(CXX) $(CXXFLAGS_WITHOUT_PKGS_DEBUG) -o assets_typer src/assets_typer.cpp