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