1 | OS := $(shell uname)
|
---|
2 |
|
---|
3 | ifndef WIN
|
---|
4 | GCC := gcc
|
---|
5 | GPP := g++
|
---|
6 | SDL2 := /opt/sdl2
|
---|
7 | RTMIDI := /opt/rtmidi
|
---|
8 | EXT :=
|
---|
9 | else
|
---|
10 | GCC := x86_64-w64-mingw32-gcc
|
---|
11 | GPP := x86_64-w64-mingw32-g++
|
---|
12 | SDL2 := /opt/sdl2-win
|
---|
13 | RTMIDI := /opt/rtmidi-win
|
---|
14 | EXT := .exe
|
---|
15 | endif
|
---|
16 |
|
---|
17 | SDL2_INC := $(SDL2)/include
|
---|
18 | SDL2_LIB := $(SDL2)/lib
|
---|
19 |
|
---|
20 | RTMIDI_INC := $(RTMIDI)/include
|
---|
21 | RTMIDI_LIB := $(RTMIDI)/lib
|
---|
22 |
|
---|
23 | FLAGS := -std=c99 -O2 -gdwarf-4
|
---|
24 |
|
---|
25 | FLAGS_CPU := $(FLAGS) -pthread -I cpu -I build
|
---|
26 |
|
---|
27 | FLAGS_EMU := $(FLAGS) -pthread \
|
---|
28 | -fno-strict-aliasing -fno-inline -fno-omit-frame-pointer \
|
---|
29 | -Wall -Wextra \
|
---|
30 | -Wpedantic -Wconversion -Wsign-conversion -Wshadow \
|
---|
31 | -Wstrict-prototypes -Wmissing-declarations -Wredundant-decls \
|
---|
32 | -I cpu -I emu -I build -I $(SDL2_INC) -I $(RTMIDI_INC)
|
---|
33 |
|
---|
34 | FLAGS_AUX := $(FLAGS) -Wall -Wextra \
|
---|
35 | -Wpedantic -Wconversion -Wsign-conversion -Wshadow \
|
---|
36 | -Wstrict-prototypes -Wmissing-declarations -Wredundant-decls
|
---|
37 |
|
---|
38 | ifndef WIN
|
---|
39 | ifeq ($(OS), Linux)
|
---|
40 | FLAGS_EMU += -D EMU_LINUX
|
---|
41 | FLAGS_LNK := $(FLAGS) -pthread -Wall -Wextra
|
---|
42 | LIBS := $(SDL2_LIB)/libSDL2.a \
|
---|
43 | $(SDL2_LIB)/libSDL2_net.a \
|
---|
44 | $(SDL2_LIB)/libSDL2_ttf.a \
|
---|
45 | $(SDL2_LIB)/libfreetype.a \
|
---|
46 | $(RTMIDI_LIB)/librtmidi.a \
|
---|
47 | -ldl -lm -lasound
|
---|
48 | endif
|
---|
49 |
|
---|
50 | ifeq ($(OS), Darwin)
|
---|
51 | FLAGS_EMU += -D EMU_OS_X
|
---|
52 | FLAGS_LNK := $(FLAGS) -Wall -Wextra
|
---|
53 | LIBS := $(SDL2_LIB)/libSDL2.a \
|
---|
54 | $(SDL2_LIB)/libSDL2_net.a \
|
---|
55 | $(SDL2_LIB)/libSDL2_ttf.a \
|
---|
56 | $(SDL2_LIB)/libfreetype.a \
|
---|
57 | $(RTMIDI_LIB)/librtmidi.a \
|
---|
58 | -framework AppKit \
|
---|
59 | -framework AudioToolbox \
|
---|
60 | -framework Carbon \
|
---|
61 | -framework CoreMIDI \
|
---|
62 | -framework CoreAudio \
|
---|
63 | -framework CoreFoundation \
|
---|
64 | -framework CoreGraphics \
|
---|
65 | -framework CoreVideo \
|
---|
66 | -framework ForceFeedback \
|
---|
67 | -framework IOKit \
|
---|
68 | -l iconv
|
---|
69 | endif
|
---|
70 | else
|
---|
71 | FLAGS_EMU += -D EMU_WIN
|
---|
72 | FLAGS_LNK := $(FLAGS) -Wall -Wextra -static -static-libstdc++
|
---|
73 | LIBS := -l mingw32 \
|
---|
74 | $(SDL2_LIB)/libSDL2.a \
|
---|
75 | $(SDL2_LIB)/libSDL2main.a \
|
---|
76 | $(SDL2_LIB)/libSDL2_net.a \
|
---|
77 | $(SDL2_LIB)/libSDL2_ttf.a \
|
---|
78 | $(SDL2_LIB)/libfreetype.a \
|
---|
79 | $(RTMIDI_LIB)/librtmidi.a \
|
---|
80 | -l gdi32 \
|
---|
81 | -l imm32 \
|
---|
82 | -l iphlpapi \
|
---|
83 | -l ole32 \
|
---|
84 | -l oleaut32 \
|
---|
85 | -l version \
|
---|
86 | -l winmm \
|
---|
87 | -l ws2_32
|
---|
88 | endif
|
---|
89 |
|
---|
90 | HEADERS := $(wildcard cpu/*.h) $(wildcard emu/*.h)
|
---|
91 |
|
---|
92 | all: buchla$(EXT) buchla.disk
|
---|
93 |
|
---|
94 | build/gen:
|
---|
95 | gcc $(FLAGS) -o build/gen cpu/m68kmake.c
|
---|
96 |
|
---|
97 | GEN_C := m68kopac.c m68kopdm.c m68kopnz.c m68kops.c
|
---|
98 | GEN_H := m68kops.h
|
---|
99 |
|
---|
100 | GEN_CP := $(GEN_C:%=build/%)
|
---|
101 | GEN_HP := $(GEN_H:%=build/%)
|
---|
102 |
|
---|
103 | GEN_O := $(GEN_C:.c=.o)
|
---|
104 | GEN_OP := $(GEN_O:%=build/%)
|
---|
105 |
|
---|
106 | $(GEN_CP) $(GEN_HP): \
|
---|
107 | build/gen
|
---|
108 | cd cpu; ../build/gen ../build
|
---|
109 |
|
---|
110 | build/%.o: build/%.c $(HEADERS)
|
---|
111 | $(GCC) $(FLAGS_CPU) -c -o $@ $<
|
---|
112 |
|
---|
113 | CPU_C := m68kcpu.c m68kdasm.c
|
---|
114 | CPU_O := $(CPU_C:.c=.o)
|
---|
115 | CPU_OP := $(CPU_O:%=build/%)
|
---|
116 |
|
---|
117 | build/%.o: cpu/%.c $(HEADERS) $(GEN_HP)
|
---|
118 | $(GCC) $(FLAGS_CPU) -c -o $@ $<
|
---|
119 |
|
---|
120 | EMU_C := main.c cpu.c vid.c fpu.c tim.c lcd.c ser.c mid.c fdd.c snd.c \
|
---|
121 | led.c kbd.c sdl.c gdb.c
|
---|
122 | EMU_O := $(EMU_C:.c=.o)
|
---|
123 | EMU_OP := $(EMU_O:%=build/%)
|
---|
124 |
|
---|
125 | build/%.o: emu/%.c $(HEADERS)
|
---|
126 | $(GCC) $(FLAGS_EMU) -c -o $@ $<
|
---|
127 |
|
---|
128 | buchla$(EXT): $(CPU_OP) $(GEN_OP) $(EMU_OP)
|
---|
129 | $(GPP) $(FLAGS_LNK) -o buchla$(EXT) \
|
---|
130 | $(CPU_OP) $(GEN_OP) $(EMU_OP) \
|
---|
131 | $(LIBS)
|
---|
132 |
|
---|
133 | mkdisk$(EXT): emu/mkdisk.c
|
---|
134 | $(GCC) $(FLAGS_AUX) -o mkdisk$(EXT) emu/mkdisk.c
|
---|
135 |
|
---|
136 | buchla.disk: mkdisk$(EXT) midas.abs
|
---|
137 | ./mkdisk$(EXT)
|
---|
138 |
|
---|
139 | run: buchla$(EXT) buchla.disk
|
---|
140 | ./buchla$(EXT) ${EMU_OPTS}
|
---|
141 |
|
---|
142 | val: buchla$(EXT) buchla.disk
|
---|
143 | valgrind --leak-resolution=high --track-fds=yes --leak-check=full \
|
---|
144 | --show-reachable=yes --suppressions=misc/buchla.supp \
|
---|
145 | ./buchla$(EXT) ${EMU_OPTS}
|
---|
146 |
|
---|
147 | clean:
|
---|
148 | rm -f build/gen build/*.c build/*.h build/*.o
|
---|
149 | rm -f buchla$(EXT)
|
---|
150 | rm -f mkdisk$(EXT)
|
---|
151 | rm -f buchla.disk
|
---|