source: buchla-emu/Makefile@ 3cd71b9

Last change on this file since 3cd71b9 was 3cd71b9, checked in by Alexander Heinrich <alex.heinrich@…>, 7 years ago

Statically link gcc on windows.

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