source: buchla-emu/Makefile@ 566ebca

Last change on this file since 566ebca was 566ebca, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Support OS X.

  • Property mode set to 100644
File size: 2.1 KB
Line 
1OS := $(shell uname)
2
3SDL2 := /opt/sdl2
4SDL2_INC := $(SDL2)/include
5SDL2_LIB := $(SDL2)/lib
6
7FLAGS := -std=c99 -O2 -gdwarf-4
8
9FLAGS_CPU := $(FLAGS) -pthread -I cpu -I build
10
11FLAGS_EMU := $(FLAGS) -pthread \
12 -fno-strict-aliasing -fno-inline -fno-omit-frame-pointer \
13 -Wall -Wextra \
14 -Wpedantic -Wconversion -Wsign-conversion -Wshadow \
15 -Wstrict-prototypes -Wmissing-declarations -Wredundant-decls \
16 -I cpu -I emu -I build -I $(SDL2_INC)
17
18ifeq ($(OS), Linux)
19FLAGS_LNK := $(FLAGS) -pthread -Wall -Wextra
20LIBS := $(SDL2_LIB)/libSDL2.a -ldl -lm
21endif
22
23ifeq ($(OS), Darwin)
24FLAGS_LNK := $(FLAGS) -Wall -Wextra
25LIBS := $(SDL2_LIB)/libSDL2.a \
26 -framework AppKit \
27 -framework AudioToolbox \
28 -framework Carbon \
29 -framework CoreAudio \
30 -framework CoreFoundation \
31 -framework CoreGraphics \
32 -framework CoreVideo \
33 -framework ForceFeedback \
34 -framework IOKit \
35 -l iconv
36endif
37
38HEADERS := $(wildcard cpu/*.h) $(wildcard emu/*.h)
39
40all: buchla
41
42build:
43 mkdir build
44
45build/gen: | build
46 gcc $(FLAGS) -o build/gen cpu/m68kmake.c
47
48GEN_C := m68kopac.c m68kopdm.c m68kopnz.c m68kops.c
49GEN_H := m68kops.h
50
51GEN_CP := $(GEN_C:%=build/%)
52GEN_HP := $(GEN_H:%=build/%)
53
54GEN_O := $(GEN_C:.c=.o)
55GEN_OP := $(GEN_O:%=build/%)
56
57$(GEN_CP) $(GEN_HP): \
58 build/gen | build
59 cd cpu; ../build/gen ../build
60
61build/%.o: build/%.c $(HEADERS)
62 gcc $(FLAGS_CPU) -c -o $@ $<
63
64CPU_C := m68kcpu.c m68kdasm.c
65CPU_O := $(CPU_C:.c=.o)
66CPU_OP := $(CPU_O:%=build/%)
67
68build/%.o: cpu/%.c $(HEADERS) $(GEN_HP) | build
69 gcc $(FLAGS_CPU) -c -o $@ $<
70
71EMU_C := main.c cpu.c sdl.c
72EMU_O := $(EMU_C:.c=.o)
73EMU_OP := $(EMU_O:%=build/%)
74
75build/%.o: emu/%.c $(HEADERS) | build
76 gcc $(FLAGS_EMU) -c -o $@ $<
77
78buchla: $(CPU_OP) $(GEN_OP) $(EMU_OP)
79 gcc $(FLAGS_LNK) -o buchla \
80 $(CPU_OP) $(GEN_OP) $(EMU_OP) \
81 $(LIBS)
82
83run: buchla
84 ./buchla
85
86val: buchla
87 valgrind --leak-resolution=high --track-fds=yes --leak-check=full \
88 --show-reachable=yes --suppressions=misc/buchla.supp ./buchla
89
90clean:
91 rm -rf build
92 rm -f buchla
Note: See TracBrowser for help on using the repository browser.