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