-
Notifications
You must be signed in to change notification settings - Fork 11
/
Makefile
91 lines (73 loc) · 2.01 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
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
80
81
82
83
84
85
86
87
88
89
90
91
# Makefile for Linux and Windows (MinGW)
CC=gcc
CFLAGS=-c -Wall
LDFLAGS=-lm
# Detect operating system:
# More info: http://stackoverflow.com/q/714100
ifeq ($(OS),Windows_NT)
EXECUTABLES=chip8 chip8-gdi
LDFLAGS+=-mwindows
else
EXECUTABLES=chip8
endif
ifeq ($(BUILD),debug)
# Debug
CFLAGS += -O0 -g
LDFLAGS +=
else
# Release mode
CFLAGS += -O2 -DNDEBUG
LDFLAGS += -s
endif
all: c8asm c8dasm $(EXECUTABLES) docs example
debug:
make BUILD=debug
c8asm: asmmain.o c8asm.o chip8.o
$(CC) $(LDFLAGS) -o $@ $^
c8dasm: dasmmain.o c8dasm.o chip8.o
$(CC) $(LDFLAGS) -o $@ $^
.c.o:
$(CC) $(CFLAGS) $< -o $@
asmmain.o: asmmain.c chip8.h
bmp.o: bmp.c bmp.h
c8asm.o: c8asm.c chip8.h
c8dasm.o: c8dasm.c chip8.h
chip8.o: chip8.c chip8.h
dasmmain.o: dasmmain.c chip8.h
render.o: render.c gdi/gdi.h gdi/../bmp.h gdi/../app.h chip8.h bmp.h
gdi.o: gdi/gdi.c gdi/../bmp.h gdi/gdi.h gdi/../app.h
pocadv.o: sdl/pocadv.c sdl/pocadv.h sdl/../app.h sdl/../bmp.h
# SDL specific:
chip8: pocadv.o render-sdl.o chip8.o bmp.o
$(CC) $^ $(LDFLAGS) `sdl2-config --libs` -o $@
render-sdl.o: render.c chip8.h sdl/pocadv.h app.h bmp.h
$(CC) $(CFLAGS) -DSDL2 `sdl2-config --cflags` $< -o $@
pocadv.o: sdl/pocadv.c sdl/pocadv.h app.h bmp.h
$(CC) $(CFLAGS) -DSDL2 `sdl2-config --cflags` $< -o $@
# Example
example : examples/CUBE8.ch8
examples/CUBE8.ch8 : examples/cube.asm ./c8asm
mkdir -p GAMES
./c8asm -o $@ $<
# Windows GDI-version specific:
chip8-gdi: gdi.o render-gdi.o chip8.o bmp.o
$(CC) $^ -o $@ $(LDFLAGS)
render-gdi.o: render.c chip8.h gdi/gdi.h app.h bmp.h
$(CC) $(CFLAGS) -DGDI $< -o $@
gdi.o: gdi/gdi.c gdi/gdi.h app.h bmp.h
$(CC) $(CFLAGS) -DGDI $< -o $@
# Documentation
docs: chip8-api.html assembler.html README.html
chip8-api.html: chip8.h d.awk
awk -f d.awk $< > $@
assembler.html: c8asm.c d.awk
awk -f d.awk $< > $@
README.html: README.md d.awk
awk -f d.awk -v Clean=1 $< > $@
.PHONY : clean wipe
wipe:
-rm -f *.o sdl/*.o gdi/*.o
clean: wipe
-rm -f c8asm chip8 c8dasm *.exe
-rm -f chip8-api.html README.html
-rm -f *.log *.bak