source: buchla-emu/Makefile@ 7eb8971

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

Don't use Linux fix on OS X.

  • Property mode set to 100644
File size: 2.3 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_EMU += -D EMU_LINUX
20FLAGS_LNK := $(FLAGS) -pthread -Wall -Wextra
21LIBS := $(SDL2_LIB)/libSDL2.a \
22 $(SDL2_LIB)/libSDL2_ttf.a \
23 $(SDL2_LIB)/libfreetype.a \
24 -ldl -lm
25endif
26
27ifeq ($(OS), Darwin)
28FLAGS_EMU += -D EMU_OS_X
29FLAGS_LNK := $(FLAGS) -Wall -Wextra
30LIBS := $(SDL2_LIB)/libSDL2.a \
31 $(SDL2_LIB)/libSDL2_ttf.a \
32 $(SDL2_LIB)/libfreetype.a \
33 -framework AppKit \
34 -framework AudioToolbox \
35 -framework Carbon \
36 -framework CoreAudio \
37 -framework CoreFoundation \
38 -framework CoreGraphics \
39 -framework CoreVideo \
40 -framework ForceFeedback \
41 -framework IOKit \
42 -l iconv
43endif
44
45HEADERS := $(wildcard cpu/*.h) $(wildcard emu/*.h)
46
47all: buchla
48
49build:
50 mkdir build
51
52build/gen: | build
53 gcc $(FLAGS) -o build/gen cpu/m68kmake.c
54
55GEN_C := m68kopac.c m68kopdm.c m68kopnz.c m68kops.c
56GEN_H := m68kops.h
57
58GEN_CP := $(GEN_C:%=build/%)
59GEN_HP := $(GEN_H:%=build/%)
60
61GEN_O := $(GEN_C:.c=.o)
62GEN_OP := $(GEN_O:%=build/%)
63
64$(GEN_CP) $(GEN_HP): \
65 build/gen | build
66 cd cpu; ../build/gen ../build
67
68build/%.o: build/%.c $(HEADERS)
69 gcc $(FLAGS_CPU) -c -o $@ $<
70
71CPU_C := m68kcpu.c m68kdasm.c
72CPU_O := $(CPU_C:.c=.o)
73CPU_OP := $(CPU_O:%=build/%)
74
75build/%.o: cpu/%.c $(HEADERS) $(GEN_HP) | build
76 gcc $(FLAGS_CPU) -c -o $@ $<
77
78EMU_C := main.c cpu.c vid.c fpu.c tim.c lcd.c ser.c mid.c fdd.c snd.c \
79 led.c kbd.c sdl.c
80EMU_O := $(EMU_C:.c=.o)
81EMU_OP := $(EMU_O:%=build/%)
82
83build/%.o: emu/%.c $(HEADERS) | build
84 gcc $(FLAGS_EMU) -c -o $@ $<
85
86buchla: $(CPU_OP) $(GEN_OP) $(EMU_OP)
87 gcc $(FLAGS_LNK) -o buchla \
88 $(CPU_OP) $(GEN_OP) $(EMU_OP) \
89 $(LIBS)
90
91run: buchla
92 ./buchla
93
94val: buchla
95 valgrind --leak-resolution=high --track-fds=yes --leak-check=full \
96 --show-reachable=yes --suppressions=misc/buchla.supp ./buchla
97
98clean:
99 rm -rf build
100 rm -f buchla
Note: See TracBrowser for help on using the repository browser.