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