source: buchla-emu/Makefile@ 149c3e0

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

Successfully attached GDB.

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