source: buchla-emu/Makefile@ a6da9fb

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

Create buchla.disk, a 1.44M FAT12 floppy disk image.

  • Property mode set to 100644
File size: 3.0 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_ttf.a \
35 $(SDL2_LIB)/libfreetype.a \
36 -ldl -lm
37endif
38
39ifeq ($(OS), Darwin)
40FLAGS_EMU += -D EMU_OS_X
41FLAGS_LNK := $(FLAGS) -Wall -Wextra
42LIBS := $(SDL2_LIB)/libSDL2.a \
43 $(SDL2_LIB)/libSDL2_ttf.a \
44 $(SDL2_LIB)/libfreetype.a \
45 -framework AppKit \
46 -framework AudioToolbox \
47 -framework Carbon \
48 -framework CoreAudio \
49 -framework CoreFoundation \
50 -framework CoreGraphics \
51 -framework CoreVideo \
52 -framework ForceFeedback \
53 -framework IOKit \
54 -l iconv
55endif
56else
57FLAGS_EMU += -D EMU_WIN
58FLAGS_LNK := $(FLAGS) -Wall -Wextra
59LIBS := -l mingw32 \
60 $(SDL2_LIB)/libSDL2.a \
61 $(SDL2_LIB)/libSDL2main.a \
62 $(SDL2_LIB)/libSDL2_ttf.a \
63 $(SDL2_LIB)/libfreetype.a \
64 -l gdi32 \
65 -l imm32 \
66 -l ole32 \
67 -l oleaut32 \
68 -l version \
69 -l winmm
70endif
71
72HEADERS := $(wildcard cpu/*.h) $(wildcard emu/*.h)
73
74all: buchla buchla.disk
75
76build:
77 mkdir build
78
79build/gen: | build
80 gcc $(FLAGS) -o build/gen cpu/m68kmake.c
81
82GEN_C := m68kopac.c m68kopdm.c m68kopnz.c m68kops.c
83GEN_H := m68kops.h
84
85GEN_CP := $(GEN_C:%=build/%)
86GEN_HP := $(GEN_H:%=build/%)
87
88GEN_O := $(GEN_C:.c=.o)
89GEN_OP := $(GEN_O:%=build/%)
90
91$(GEN_CP) $(GEN_HP): \
92 build/gen | build
93 cd cpu; ../build/gen ../build
94
95build/%.o: build/%.c $(HEADERS)
96 $(GCC) $(FLAGS_CPU) -c -o $@ $<
97
98CPU_C := m68kcpu.c m68kdasm.c
99CPU_O := $(CPU_C:.c=.o)
100CPU_OP := $(CPU_O:%=build/%)
101
102build/%.o: cpu/%.c $(HEADERS) $(GEN_HP) | build
103 $(GCC) $(FLAGS_CPU) -c -o $@ $<
104
105EMU_C := main.c cpu.c vid.c fpu.c tim.c lcd.c ser.c mid.c fdd.c snd.c \
106 led.c kbd.c sdl.c
107EMU_O := $(EMU_C:.c=.o)
108EMU_OP := $(EMU_O:%=build/%)
109
110build/%.o: emu/%.c $(HEADERS) | build
111 $(GCC) $(FLAGS_EMU) -c -o $@ $<
112
113buchla: $(CPU_OP) $(GEN_OP) $(EMU_OP)
114 $(GCC) $(FLAGS_LNK) -o buchla \
115 $(CPU_OP) $(GEN_OP) $(EMU_OP) \
116 $(LIBS)
117
118mkdisk: emu/mkdisk.c
119 $(GCC) $(FLAGS_AUX) -o mkdisk emu/mkdisk.c
120
121buchla.disk: mkdisk midas.abs
122 ./mkdisk
123
124run: buchla
125 ./buchla
126
127val: buchla
128 valgrind --leak-resolution=high --track-fds=yes --leak-check=full \
129 --show-reachable=yes --suppressions=misc/buchla.supp ./buchla
130
131clean:
132 rm -rf build
133 rm -f buchla
134 rm -f mkdisk
135 rm -f buchla.disk
Note: See TracBrowser for help on using the repository browser.