[566ebca] | 1 | OS := $(shell uname)
|
---|
| 2 |
|
---|
[ff8d800] | 3 | SDL2 := /opt/sdl2
|
---|
| 4 | SDL2_INC := $(SDL2)/include
|
---|
| 5 | SDL2_LIB := $(SDL2)/lib
|
---|
| 6 |
|
---|
[566ebca] | 7 | FLAGS := -std=c99 -O2 -gdwarf-4
|
---|
[d54045b] | 8 |
|
---|
[566ebca] | 9 | FLAGS_CPU := $(FLAGS) -pthread -I cpu -I build
|
---|
[d54045b] | 10 |
|
---|
[566ebca] | 11 | FLAGS_EMU := $(FLAGS) -pthread \
|
---|
[d54045b] | 12 | -fno-strict-aliasing -fno-inline -fno-omit-frame-pointer \
|
---|
| 13 | -Wall -Wextra \
|
---|
| 14 | -Wpedantic -Wconversion -Wsign-conversion -Wshadow \
|
---|
| 15 | -Wstrict-prototypes -Wmissing-declarations -Wredundant-decls \
|
---|
[ff8d800] | 16 | -I cpu -I emu -I build -I $(SDL2_INC)
|
---|
[d54045b] | 17 |
|
---|
[566ebca] | 18 | ifeq ($(OS), Linux)
|
---|
| 19 | FLAGS_LNK := $(FLAGS) -pthread -Wall -Wextra
|
---|
| 20 | LIBS := $(SDL2_LIB)/libSDL2.a -ldl -lm
|
---|
| 21 | endif
|
---|
| 22 |
|
---|
| 23 | ifeq ($(OS), Darwin)
|
---|
[d54045b] | 24 | FLAGS_LNK := $(FLAGS) -Wall -Wextra
|
---|
[566ebca] | 25 | LIBS := $(SDL2_LIB)/libSDL2.a \
|
---|
| 26 | -framework AppKit \
|
---|
| 27 | -framework AudioToolbox \
|
---|
| 28 | -framework Carbon \
|
---|
| 29 | -framework CoreAudio \
|
---|
| 30 | -framework CoreFoundation \
|
---|
| 31 | -framework CoreGraphics \
|
---|
| 32 | -framework CoreVideo \
|
---|
| 33 | -framework ForceFeedback \
|
---|
| 34 | -framework IOKit \
|
---|
| 35 | -l iconv
|
---|
| 36 | endif
|
---|
[d54045b] | 37 |
|
---|
| 38 | HEADERS := $(wildcard cpu/*.h) $(wildcard emu/*.h)
|
---|
| 39 |
|
---|
| 40 | all: buchla
|
---|
| 41 |
|
---|
| 42 | build:
|
---|
| 43 | mkdir build
|
---|
| 44 |
|
---|
| 45 | build/gen: | build
|
---|
| 46 | gcc $(FLAGS) -o build/gen cpu/m68kmake.c
|
---|
| 47 |
|
---|
| 48 | GEN_C := m68kopac.c m68kopdm.c m68kopnz.c m68kops.c
|
---|
| 49 | GEN_H := m68kops.h
|
---|
| 50 |
|
---|
| 51 | GEN_CP := $(GEN_C:%=build/%)
|
---|
| 52 | GEN_HP := $(GEN_H:%=build/%)
|
---|
| 53 |
|
---|
| 54 | GEN_O := $(GEN_C:.c=.o)
|
---|
| 55 | GEN_OP := $(GEN_O:%=build/%)
|
---|
| 56 |
|
---|
| 57 | $(GEN_CP) $(GEN_HP): \
|
---|
| 58 | build/gen | build
|
---|
| 59 | cd cpu; ../build/gen ../build
|
---|
| 60 |
|
---|
| 61 | build/%.o: build/%.c $(HEADERS)
|
---|
| 62 | gcc $(FLAGS_CPU) -c -o $@ $<
|
---|
| 63 |
|
---|
| 64 | CPU_C := m68kcpu.c m68kdasm.c
|
---|
| 65 | CPU_O := $(CPU_C:.c=.o)
|
---|
| 66 | CPU_OP := $(CPU_O:%=build/%)
|
---|
| 67 |
|
---|
| 68 | build/%.o: cpu/%.c $(HEADERS) $(GEN_HP) | build
|
---|
| 69 | gcc $(FLAGS_CPU) -c -o $@ $<
|
---|
| 70 |
|
---|
[a06aa8b] | 71 | EMU_C := main.c cpu.c vid.c fpu.c tim.c lcd.c ser.c mid.c fdd.c snd.c \
|
---|
| 72 | led.c kbd.c sdl.c
|
---|
[d54045b] | 73 | EMU_O := $(EMU_C:.c=.o)
|
---|
| 74 | EMU_OP := $(EMU_O:%=build/%)
|
---|
| 75 |
|
---|
| 76 | build/%.o: emu/%.c $(HEADERS) | build
|
---|
| 77 | gcc $(FLAGS_EMU) -c -o $@ $<
|
---|
| 78 |
|
---|
| 79 | buchla: $(CPU_OP) $(GEN_OP) $(EMU_OP)
|
---|
[ff8d800] | 80 | gcc $(FLAGS_LNK) -o buchla \
|
---|
| 81 | $(CPU_OP) $(GEN_OP) $(EMU_OP) \
|
---|
[566ebca] | 82 | $(LIBS)
|
---|
[ff8d800] | 83 |
|
---|
| 84 | run: buchla
|
---|
| 85 | ./buchla
|
---|
[d54045b] | 86 |
|
---|
[4edbd1c] | 87 | val: buchla
|
---|
| 88 | valgrind --leak-resolution=high --track-fds=yes --leak-check=full \
|
---|
[9373f5e] | 89 | --show-reachable=yes --suppressions=misc/buchla.supp ./buchla
|
---|
[4edbd1c] | 90 |
|
---|
[d54045b] | 91 | clean:
|
---|
| 92 | rm -rf build
|
---|
| 93 | rm -f buchla
|
---|