source: buchla-emu/Makefile@ 375f7fb

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

Support cross-build for Windows.

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