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