source: buchla-emu/Makefile

0.1
Last change on this file was 3153af3, checked in by Thomas Lopatic <thomas@…>, 6 years ago

Added packaging script.

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