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
RevLine 
[566ebca]1OS := $(shell uname)
2
[4f3fe48]3ifndef WIN
4GCC := gcc
[ff8d800]5SDL2 := /opt/sdl2
[4f3fe48]6else
7GCC := x86_64-w64-mingw32-gcc
8SDL2 := /opt/sdl2-win
9endif
10
[ff8d800]11SDL2_INC := $(SDL2)/include
12SDL2_LIB := $(SDL2)/lib
13
[566ebca]14FLAGS := -std=c99 -O2 -gdwarf-4
[d54045b]15
[566ebca]16FLAGS_CPU := $(FLAGS) -pthread -I cpu -I build
[d54045b]17
[566ebca]18FLAGS_EMU := $(FLAGS) -pthread \
[d54045b]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 \
[ff8d800]23 -I cpu -I emu -I build -I $(SDL2_INC)
[d54045b]24
[4f3fe48]25ifndef WIN
[566ebca]26ifeq ($(OS), Linux)
[7eb8971]27FLAGS_EMU += -D EMU_LINUX
[566ebca]28FLAGS_LNK := $(FLAGS) -pthread -Wall -Wextra
[2f9f352]29LIBS := $(SDL2_LIB)/libSDL2.a \
30 $(SDL2_LIB)/libSDL2_ttf.a \
31 $(SDL2_LIB)/libfreetype.a \
32 -ldl -lm
[566ebca]33endif
34
35ifeq ($(OS), Darwin)
[7eb8971]36FLAGS_EMU += -D EMU_OS_X
[d54045b]37FLAGS_LNK := $(FLAGS) -Wall -Wextra
[566ebca]38LIBS := $(SDL2_LIB)/libSDL2.a \
[2f9f352]39 $(SDL2_LIB)/libSDL2_ttf.a \
40 $(SDL2_LIB)/libfreetype.a \
[566ebca]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
[4f3fe48]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
[d54045b]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)
[4f3fe48]92 $(GCC) $(FLAGS_CPU) -c -o $@ $<
[d54045b]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
[4f3fe48]99 $(GCC) $(FLAGS_CPU) -c -o $@ $<
[d54045b]100
[a06aa8b]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
[d54045b]103EMU_O := $(EMU_C:.c=.o)
104EMU_OP := $(EMU_O:%=build/%)
105
106build/%.o: emu/%.c $(HEADERS) | build
[4f3fe48]107 $(GCC) $(FLAGS_EMU) -c -o $@ $<
[d54045b]108
109buchla: $(CPU_OP) $(GEN_OP) $(EMU_OP)
[4f3fe48]110 $(GCC) $(FLAGS_LNK) -o buchla \
[ff8d800]111 $(CPU_OP) $(GEN_OP) $(EMU_OP) \
[566ebca]112 $(LIBS)
[ff8d800]113
114run: buchla
115 ./buchla
[d54045b]116
[4edbd1c]117val: buchla
118 valgrind --leak-resolution=high --track-fds=yes --leak-check=full \
[9373f5e]119 --show-reachable=yes --suppressions=misc/buchla.supp ./buchla
[4edbd1c]120
[d54045b]121clean:
122 rm -rf build
123 rm -f buchla
Note: See TracBrowser for help on using the repository browser.