[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 \
|
---|
| 34 | $(SDL2_LIB)/libSDL2_ttf.a \
|
---|
| 35 | $(SDL2_LIB)/libfreetype.a \
|
---|
| 36 | -ldl -lm
|
---|
[566ebca] | 37 | endif
|
---|
| 38 |
|
---|
| 39 | ifeq ($(OS), Darwin)
|
---|
[7eb8971] | 40 | FLAGS_EMU += -D EMU_OS_X
|
---|
[d54045b] | 41 | FLAGS_LNK := $(FLAGS) -Wall -Wextra
|
---|
[566ebca] | 42 | LIBS := $(SDL2_LIB)/libSDL2.a \
|
---|
[2f9f352] | 43 | $(SDL2_LIB)/libSDL2_ttf.a \
|
---|
| 44 | $(SDL2_LIB)/libfreetype.a \
|
---|
[566ebca] | 45 | -framework AppKit \
|
---|
| 46 | -framework AudioToolbox \
|
---|
| 47 | -framework Carbon \
|
---|
| 48 | -framework CoreAudio \
|
---|
| 49 | -framework CoreFoundation \
|
---|
| 50 | -framework CoreGraphics \
|
---|
| 51 | -framework CoreVideo \
|
---|
| 52 | -framework ForceFeedback \
|
---|
| 53 | -framework IOKit \
|
---|
| 54 | -l iconv
|
---|
| 55 | endif
|
---|
[4f3fe48] | 56 | else
|
---|
| 57 | FLAGS_EMU += -D EMU_WIN
|
---|
| 58 | FLAGS_LNK := $(FLAGS) -Wall -Wextra
|
---|
| 59 | LIBS := -l mingw32 \
|
---|
| 60 | $(SDL2_LIB)/libSDL2.a \
|
---|
| 61 | $(SDL2_LIB)/libSDL2main.a \
|
---|
| 62 | $(SDL2_LIB)/libSDL2_ttf.a \
|
---|
| 63 | $(SDL2_LIB)/libfreetype.a \
|
---|
| 64 | -l gdi32 \
|
---|
| 65 | -l imm32 \
|
---|
| 66 | -l ole32 \
|
---|
| 67 | -l oleaut32 \
|
---|
| 68 | -l version \
|
---|
| 69 | -l winmm
|
---|
| 70 | endif
|
---|
[d54045b] | 71 |
|
---|
| 72 | HEADERS := $(wildcard cpu/*.h) $(wildcard emu/*.h)
|
---|
| 73 |
|
---|
[a6da9fb] | 74 | all: buchla buchla.disk
|
---|
[d54045b] | 75 |
|
---|
| 76 | build:
|
---|
| 77 | mkdir build
|
---|
| 78 |
|
---|
| 79 | build/gen: | build
|
---|
| 80 | gcc $(FLAGS) -o build/gen cpu/m68kmake.c
|
---|
| 81 |
|
---|
| 82 | GEN_C := m68kopac.c m68kopdm.c m68kopnz.c m68kops.c
|
---|
| 83 | GEN_H := m68kops.h
|
---|
| 84 |
|
---|
| 85 | GEN_CP := $(GEN_C:%=build/%)
|
---|
| 86 | GEN_HP := $(GEN_H:%=build/%)
|
---|
| 87 |
|
---|
| 88 | GEN_O := $(GEN_C:.c=.o)
|
---|
| 89 | GEN_OP := $(GEN_O:%=build/%)
|
---|
| 90 |
|
---|
| 91 | $(GEN_CP) $(GEN_HP): \
|
---|
| 92 | build/gen | build
|
---|
| 93 | cd cpu; ../build/gen ../build
|
---|
| 94 |
|
---|
| 95 | build/%.o: build/%.c $(HEADERS)
|
---|
[4f3fe48] | 96 | $(GCC) $(FLAGS_CPU) -c -o $@ $<
|
---|
[d54045b] | 97 |
|
---|
| 98 | CPU_C := m68kcpu.c m68kdasm.c
|
---|
| 99 | CPU_O := $(CPU_C:.c=.o)
|
---|
| 100 | CPU_OP := $(CPU_O:%=build/%)
|
---|
| 101 |
|
---|
| 102 | build/%.o: cpu/%.c $(HEADERS) $(GEN_HP) | build
|
---|
[4f3fe48] | 103 | $(GCC) $(FLAGS_CPU) -c -o $@ $<
|
---|
[d54045b] | 104 |
|
---|
[a06aa8b] | 105 | EMU_C := main.c cpu.c vid.c fpu.c tim.c lcd.c ser.c mid.c fdd.c snd.c \
|
---|
| 106 | led.c kbd.c sdl.c
|
---|
[d54045b] | 107 | EMU_O := $(EMU_C:.c=.o)
|
---|
| 108 | EMU_OP := $(EMU_O:%=build/%)
|
---|
| 109 |
|
---|
| 110 | build/%.o: emu/%.c $(HEADERS) | build
|
---|
[4f3fe48] | 111 | $(GCC) $(FLAGS_EMU) -c -o $@ $<
|
---|
[d54045b] | 112 |
|
---|
| 113 | buchla: $(CPU_OP) $(GEN_OP) $(EMU_OP)
|
---|
[4f3fe48] | 114 | $(GCC) $(FLAGS_LNK) -o buchla \
|
---|
[ff8d800] | 115 | $(CPU_OP) $(GEN_OP) $(EMU_OP) \
|
---|
[566ebca] | 116 | $(LIBS)
|
---|
[ff8d800] | 117 |
|
---|
[a6da9fb] | 118 | mkdisk: emu/mkdisk.c
|
---|
| 119 | $(GCC) $(FLAGS_AUX) -o mkdisk emu/mkdisk.c
|
---|
| 120 |
|
---|
| 121 | buchla.disk: mkdisk midas.abs
|
---|
| 122 | ./mkdisk
|
---|
| 123 |
|
---|
[ff8d800] | 124 | run: buchla
|
---|
| 125 | ./buchla
|
---|
[d54045b] | 126 |
|
---|
[4edbd1c] | 127 | val: buchla
|
---|
| 128 | valgrind --leak-resolution=high --track-fds=yes --leak-check=full \
|
---|
[9373f5e] | 129 | --show-reachable=yes --suppressions=misc/buchla.supp ./buchla
|
---|
[4edbd1c] | 130 |
|
---|
[d54045b] | 131 | clean:
|
---|
| 132 | rm -rf build
|
---|
| 133 | rm -f buchla
|
---|
[a6da9fb] | 134 | rm -f mkdisk
|
---|
| 135 | rm -f buchla.disk
|
---|