-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
34 lines (28 loc) · 1.23 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
CC=gcc
CFLAGS=-Wall -g -D_POSIX_SOURCE -D_BSD_SOURCE -D_DEFAULT_SOURCE -std=c99 -Werror -pedantic
RCFLAGS= -Wall -g -D_POSIX_SOURCE -D_BSD_SOURCE -D_DEFAULT_SOURCE \
-std=c99 -Werror -pedantic
RCLINKERFLAGS=`sdl2-config --libs --cflags` -lSDL2_image -lm -lSDL2_ttf
RENDERER_BUILD_DIR=./renderer_build_dir
RENDERER_FILES=$(addprefix src/,renderer_main.c $(addprefix game/,sprite.c utils.c game.c) \
utils/linked_list/linked_list.c) lib/io_lib.c
RENDERER_OBJECTS=$(RENDERER_FILES:%.c=$(RENDERER_BUILD_DIR)/%.o)
RENDERER_HEADERS=$(addprefix src/game/,utils.h game.h) lib/io_lib.h src/utils/linked_list/linked_list.h
RACER_EXECUTABLE=racergame
TANKS_EXECUTABLE=tanksgame
all: racer tanks
racer: $(RACER_EXECUTABLE)
tanks: $(TANKS_EXECUTABLE)
$(RACER_EXECUTABLE): $(RENDERER_OBJECTS) $(RENDERER_BUILD_DIR)/examples/racer.o
@mkdir -p $(@D)
$(CC) $(RCFLAGS) $^ -o $(RACER_EXECUTABLE) $(RCLINKERFLAGS)
$(TANKS_EXECUTABLE): $(RENDERER_OBJECTS) $(RENDERER_BUILD_DIR)/examples/tanks.o
@mkdir -p $(@D)
$(CC) $(RCFLAGS) $^ -o $(TANKS_EXECUTABLE) $(RCLINKERFLAGS)
$(RENDERER_BUILD_DIR)/%.o: %.c $(RENDERER_HEADERS)
@mkdir -p $(@D)
$(CC) $(RCFLAGS) -c $< -o $@
clean:
rm -rf $(RENDERER_BUILD_DIR)
rm -f $(RACER_EXECUTABLE)
rm -f $(TANKS_EXECUTABLE)