1 | SDL2 := /opt/sdl2
|
---|
2 | SDL2_INC := $(SDL2)/include
|
---|
3 | SDL2_LIB := $(SDL2)/lib
|
---|
4 |
|
---|
5 | FLAGS := -std=c99 -pthread -O2 -gdwarf-4
|
---|
6 |
|
---|
7 | FLAGS_CPU := $(FLAGS) -I cpu -I build
|
---|
8 |
|
---|
9 | FLAGS_EMU := $(FLAGS) \
|
---|
10 | -fno-strict-aliasing -fno-inline -fno-omit-frame-pointer \
|
---|
11 | -Wall -Wextra \
|
---|
12 | -Wpedantic -Wconversion -Wsign-conversion -Wshadow \
|
---|
13 | -Wstrict-prototypes -Wmissing-declarations -Wredundant-decls \
|
---|
14 | -I cpu -I emu -I build -I $(SDL2_INC)
|
---|
15 |
|
---|
16 | FLAGS_LNK := $(FLAGS) -Wall -Wextra
|
---|
17 |
|
---|
18 | HEADERS := $(wildcard cpu/*.h) $(wildcard emu/*.h)
|
---|
19 |
|
---|
20 | all: buchla
|
---|
21 |
|
---|
22 | build:
|
---|
23 | mkdir build
|
---|
24 |
|
---|
25 | build/gen: | build
|
---|
26 | gcc $(FLAGS) -o build/gen cpu/m68kmake.c
|
---|
27 |
|
---|
28 | GEN_C := m68kopac.c m68kopdm.c m68kopnz.c m68kops.c
|
---|
29 | GEN_H := m68kops.h
|
---|
30 |
|
---|
31 | GEN_CP := $(GEN_C:%=build/%)
|
---|
32 | GEN_HP := $(GEN_H:%=build/%)
|
---|
33 |
|
---|
34 | GEN_O := $(GEN_C:.c=.o)
|
---|
35 | GEN_OP := $(GEN_O:%=build/%)
|
---|
36 |
|
---|
37 | $(GEN_CP) $(GEN_HP): \
|
---|
38 | build/gen | build
|
---|
39 | cd cpu; ../build/gen ../build
|
---|
40 |
|
---|
41 | build/%.o: build/%.c $(HEADERS)
|
---|
42 | gcc $(FLAGS_CPU) -c -o $@ $<
|
---|
43 |
|
---|
44 | CPU_C := m68kcpu.c m68kdasm.c
|
---|
45 | CPU_O := $(CPU_C:.c=.o)
|
---|
46 | CPU_OP := $(CPU_O:%=build/%)
|
---|
47 |
|
---|
48 | build/%.o: cpu/%.c $(HEADERS) $(GEN_HP) | build
|
---|
49 | gcc $(FLAGS_CPU) -c -o $@ $<
|
---|
50 |
|
---|
51 | EMU_C := main.c cpu.c sdl.c
|
---|
52 | EMU_O := $(EMU_C:.c=.o)
|
---|
53 | EMU_OP := $(EMU_O:%=build/%)
|
---|
54 |
|
---|
55 | build/%.o: emu/%.c $(HEADERS) | build
|
---|
56 | gcc $(FLAGS_EMU) -c -o $@ $<
|
---|
57 |
|
---|
58 | buchla: $(CPU_OP) $(GEN_OP) $(EMU_OP)
|
---|
59 | gcc $(FLAGS_LNK) -o buchla \
|
---|
60 | $(CPU_OP) $(GEN_OP) $(EMU_OP) \
|
---|
61 | $(SDL2_LIB)/libSDL2.a -ldl -lm
|
---|
62 |
|
---|
63 | run: buchla
|
---|
64 | ./buchla
|
---|
65 |
|
---|
66 | val: buchla
|
---|
67 | valgrind --leak-resolution=high --track-fds=yes --leak-check=full \
|
---|
68 | --show-reachable=yes --suppressions=misc/buchla.supp ./buchla
|
---|
69 |
|
---|
70 | clean:
|
---|
71 | rm -rf build
|
---|
72 | rm -f buchla
|
---|