]> git.lizzy.rs Git - shadowclad.git/blob - Makefile
668f3770558579304e301f5e57abaf4c1e921c26
[shadowclad.git] / Makefile
1 CFLAGS ::= -g -Wall -Wextra -Wpedantic $(CFLAGS)
2 LDFLAGS ::= $(LDFLAGS)
3 LDLIBS ::= -L/usr/local/lib -lGL -lGLEW -lglut -lassimp $(LDLIBS)
4
5 # Prefix all object file names with the compilation directory
6 objects ::= $(addprefix out/, \
7               main.o debugutil.o level.o logger.o \
8               performance.o render.o tga.o ui.o)
9
10 # Set executable extension for the platform
11 ifeq ($(OS),Windows_NT)
12         binext ::= .exe
13 else
14         binext ::=
15 endif
16 binary ::= out/shadowclad$(binext)
17
18 # Default target: build executable
19 $(binary) : $(objects) | out
20         @echo "###### Linking executable..."
21         $(CC) $(LDFLAGS) -o $(binary) $(objects) $(LOADLIBES) $(LDLIBS)
22
23 # Alias for default target
24 shadowclad : $(binary)
25 .PHONY : shadowclad
26
27 # Build and run
28 run : $(binary)
29         @echo
30         LD_LIBRARY_PATH=/usr/local/lib $(binary)
31 .PHONY : run
32
33 # Create compilation directory
34 out :
35         mkdir out/
36
37 # Alias for 'out'
38 init : out
39 .PHONY : init
40
41 # Generate dependencies
42 out/%.make : %.c Makefile | out
43         $(CPP) -MM -MT out/$*.o -MF $@ $(CPPFLAGS) $<
44
45 # Include generated rules
46 -include $(addsuffix .make, $(basename $(objects)))
47
48 # Build compilation units
49 out/%.o : %.c out/%.make | out
50         $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
51
52 # Delete build output
53 clean : out
54         rm -f $(binary) out/*.o out/*.make
55         rm -d out/
56 .PHONY : clean