-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmakefile
More file actions
42 lines (35 loc) · 877 Bytes
/
makefile
File metadata and controls
42 lines (35 loc) · 877 Bytes
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
# config
SOURCES := main.c src/*
# auto
OS := $(shell uname -s)
LUA_DEP := $(patsubst api_repo/tactics/%.lua,build/%.lua,$(wildcard api_repo/tactics/*.lua api_repo/tactics/logic/*.lua))
# detect os
ifeq ($(OS), Linux)
CC=gcc
LIBS=-lm -ldl -lGL -lglfw -llua
FLAGS=-L/usr/lib -I/usr/include -Iinclude
else ifeq ($(OS), Darwin)
CC=clang
LIBS=-framework OpenGL -lglfw -llua
FLAGS=-L/opt/homebrew/lib -I/opt/homebrew/include -Iinclude
else
$(error Unsupported OS)
endif
# main
build/sim: $(SOURCES) include/* $(LUA_DEP)
@mkdir -p $(dir $@)
$(CC) $(SOURCES) $(FLAGS) $(LIBS) -o build/sim
cp -R ./api_repo/tactics/* ./build
@echo "Built Simulator"
# copy lua files
build/%.lua: api_repo/tactics/%.lua
@mkdir -p $(dir $@)
cp $< $@
# run target
run: build/sim
cd build && ./sim
# misc
clean:
rm -r build
@echo "Clean Finished"
.PHONY: clean