]> git.lizzy.rs Git - shadowclad.git/blob - Makefile
Refactor handling of imported assets a bit
[shadowclad.git] / Makefile
1 compileargs ::= -g -Wall -Wextra -Wpedantic
2 linkargs ::=
3 libraries ::= -L/usr/local/lib -lGL -lglut -lassimp
4 # Prefix all object file names with the compilation directory
5 objects ::= $(addprefix out/, \
6               main.o debugutil.o glut_janitor.o render.o \
7               tga.o level.o performance.o)
8
9 # Set executable extension for the platform
10 ifeq ($(OS),Windows_NT)
11         binext ::= .exe
12 else
13         binext ::=
14 endif
15 binary ::= out/shadowclad$(binext)
16
17 # Default target: build executable
18 $(binary) : $(objects) | out
19         @echo "###### Linking executable..."
20         $(CC) $(linkargs) -o $(binary) $(objects) $(libraries)
21
22 # Alias for default target
23 shadowclad : $(binary)
24 .PHONY : shadowclad
25
26 # Build and run
27 run : $(binary)
28         @echo
29         LD_LIBRARY_PATH=/usr/local/lib $(binary)
30 .PHONY : run
31
32 # Create compilation directory
33 out :
34         mkdir out/
35
36 # Alias for 'out'
37 init : out
38 .PHONY : init
39
40 # Build each compilation unit
41
42 out/main.o : main.c debugutil.h glut_janitor.h render.h level.h | out
43         $(CC) $(compileargs) -c -o out/main.o main.c
44
45 out/debugutil.o : debugutil.c | out
46         $(CC) $(compileargs) -c -o out/debugutil.o debugutil.c
47
48 out/glut_janitor.o : glut_janitor.c | out
49         $(CC) $(compileargs) -c -o out/glut_janitor.o glut_janitor.c
50
51 out/render.o : render.c render.h typedefs.h | out
52         $(CC) $(compileargs) -c -o out/render.o render.c
53
54 out/tga.o : tga.c tga.h | out
55         $(CC) $(compileargs) -c -o out/tga.o tga.c
56
57 out/level.o : level.c level.h tga.h | out
58         $(CC) $(compileargs) -c -o out/level.o level.c
59
60 out/performance.o : performance.c | out
61         $(CC) $(compileargs) -c -o out/performance.o performance.c