-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmakefile
More file actions
79 lines (57 loc) · 1.72 KB
/
Copy pathmakefile
File metadata and controls
79 lines (57 loc) · 1.72 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
SCRIPT_FILE =
PROJECT_NAME = large_pixel_collider
FLAGS = -Wall -Wextra -Wunreachable-code -I ./
LIBS = -lm $(shell sdl-config --libs) -lncurses -lX11
C_COMPILER = gcc $(FLAGS)
CC = @echo "\tcc $@" && $(C_COMPILER)
SHELL_TERMINAL = gnome-terminal --title="Graphics Engine: Shell" \
--geometry=78x49+1000 --profile=Default -e
EXT_DEP = libsdl1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev \
libsdl-ttf2.0-dev libncurses5-dev bison flex
PARSER_DEP = bin/y.tab.o bin/lex.yy.o
SRC = $(shell find src lib -name "*.c" -printf "%p ")
HEADERS = $(shell find src lib -name "*.h" -printf "%p ")
OBJ = $(patsubst %.c, bin/%.o, $(foreach srcFile, $(SRC), $(notdir $(srcFile))))
debug: FLAGS += -O0 -g3
all: FLAGS += -Ofast
.PHONY: all debug run test kill clean install
all: bin $(PROJECT_NAME)
debug: bin $(PROJECT_NAME)
bin:
@mkdir $@
$(PROJECT_NAME): $(PARSER_DEP) $(OBJ)
$(CC) -o $@ $^ $(LIBS)
bin/%.o: src/%.c
$(CC) -o $@ -c $^
bin/%.o: src/graphics/%.c
$(CC) -o $@ -c $^
bin/%.o: src/interpreter/%.c
$(CC) -o $@ -c $^
bin/%.o: src/interpreter/stack/%.c
$(CC) -o $@ -c $^
bin/lex.yy.c: lib/mdl.l
@flex --outfile=$@ -I lib/mdl.l
bin/y.tab.c: lib/mdl.y
@bison --output-file=$@ -d -y lib/mdl.y
bin/%.o: lib/%.c
$(CC) -I bin -w -o $@ -c $^
bin/%.o: bin/%.c
$(CC) -I bin -I lib -w -o $@ -c $^
bin/screen.o: src/graphics/screen.c
$(CC) -o $@ -c $^ $(shell sdl-config --cflags)
run: all kill
@if [ "$(SCRIPT_FILE)" != "" ]; then \
./$(PROJECT_NAME) --script $(SCRIPT_FILE); \
else \
./$(PROJECT_NAME); \
fi
test: all
@./$(PROJECT_NAME) --test
kill:
@if [ "$(shell pgrep $(PROJECT_NAME))" != "" ]; then \
killall -9 $(PROJECT_NAME); \
fi
clean:
@rm -rf bin $(PROJECT_NAME)
install:
@echo "y" | sudo apt-get install $(EXT_DEP)