[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
|
---|
[2f9f352] | 20 | LIBS := $(SDL2_LIB)/libSDL2.a \
|
---|
| 21 | $(SDL2_LIB)/libSDL2_ttf.a \
|
---|
| 22 | $(SDL2_LIB)/libfreetype.a \
|
---|
| 23 | -ldl -lm
|
---|
[566ebca] | 24 | endif
|
---|
| 25 |
|
---|
| 26 | ifeq ($(OS), Darwin)
|
---|
[d54045b] | 27 | FLAGS_LNK := $(FLAGS) -Wall -Wextra
|
---|
[566ebca] | 28 | LIBS := $(SDL2_LIB)/libSDL2.a \
|
---|
[2f9f352] | 29 | $(SDL2_LIB)/libSDL2_ttf.a \
|
---|
| 30 | $(SDL2_LIB)/libfreetype.a \
|
---|
[566ebca] | 31 | -framework AppKit \
|
---|
| 32 | -framework AudioToolbox \
|
---|
| 33 | -framework Carbon \
|
---|
| 34 | -framework CoreAudio \
|
---|
| 35 | -framework CoreFoundation \
|
---|
| 36 | -framework CoreGraphics \
|
---|
| 37 | -framework CoreVideo \
|
---|
| 38 | -framework ForceFeedback \
|
---|
| 39 | -framework IOKit \
|
---|
| 40 | -l iconv
|
---|
| 41 | endif
|
---|
[d54045b] | 42 |
|
---|
| 43 | HEADERS := $(wildcard cpu/*.h) $(wildcard emu/*.h)
|
---|
| 44 |
|
---|
| 45 | all: buchla
|
---|
| 46 |
|
---|
| 47 | build:
|
---|
| 48 | mkdir build
|
---|
| 49 |
|
---|
| 50 | build/gen: | build
|
---|
| 51 | gcc $(FLAGS) -o build/gen cpu/m68kmake.c
|
---|
| 52 |
|
---|
| 53 | GEN_C := m68kopac.c m68kopdm.c m68kopnz.c m68kops.c
|
---|
| 54 | GEN_H := m68kops.h
|
---|
| 55 |
|
---|
| 56 | GEN_CP := $(GEN_C:%=build/%)
|
---|
| 57 | GEN_HP := $(GEN_H:%=build/%)
|
---|
| 58 |
|
---|
| 59 | GEN_O := $(GEN_C:.c=.o)
|
---|
| 60 | GEN_OP := $(GEN_O:%=build/%)
|
---|
| 61 |
|
---|
| 62 | $(GEN_CP) $(GEN_HP): \
|
---|
| 63 | build/gen | build
|
---|
| 64 | cd cpu; ../build/gen ../build
|
---|
| 65 |
|
---|
| 66 | build/%.o: build/%.c $(HEADERS)
|
---|
| 67 | gcc $(FLAGS_CPU) -c -o $@ $<
|
---|
| 68 |
|
---|
| 69 | CPU_C := m68kcpu.c m68kdasm.c
|
---|
| 70 | CPU_O := $(CPU_C:.c=.o)
|
---|
| 71 | CPU_OP := $(CPU_O:%=build/%)
|
---|
| 72 |
|
---|
| 73 | build/%.o: cpu/%.c $(HEADERS) $(GEN_HP) | build
|
---|
| 74 | gcc $(FLAGS_CPU) -c -o $@ $<
|
---|
| 75 |
|
---|
[a06aa8b] | 76 | EMU_C := main.c cpu.c vid.c fpu.c tim.c lcd.c ser.c mid.c fdd.c snd.c \
|
---|
| 77 | led.c kbd.c sdl.c
|
---|
[d54045b] | 78 | EMU_O := $(EMU_C:.c=.o)
|
---|
| 79 | EMU_OP := $(EMU_O:%=build/%)
|
---|
| 80 |
|
---|
| 81 | build/%.o: emu/%.c $(HEADERS) | build
|
---|
| 82 | gcc $(FLAGS_EMU) -c -o $@ $<
|
---|
| 83 |
|
---|
| 84 | buchla: $(CPU_OP) $(GEN_OP) $(EMU_OP)
|
---|
[ff8d800] | 85 | gcc $(FLAGS_LNK) -o buchla \
|
---|
| 86 | $(CPU_OP) $(GEN_OP) $(EMU_OP) \
|
---|
[566ebca] | 87 | $(LIBS)
|
---|
[ff8d800] | 88 |
|
---|
| 89 | run: buchla
|
---|
| 90 | ./buchla
|
---|
[d54045b] | 91 |
|
---|
[4edbd1c] | 92 | val: buchla
|
---|
| 93 | valgrind --leak-resolution=high --track-fds=yes --leak-check=full \
|
---|
[9373f5e] | 94 | --show-reachable=yes --suppressions=misc/buchla.supp ./buchla
|
---|
[4edbd1c] | 95 |
|
---|
[d54045b] | 96 | clean:
|
---|
| 97 | rm -rf build
|
---|
| 98 | rm -f buchla
|
---|