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