source: buchla-emu/Makefile@ 65e7a3a

Last change on this file since 65e7a3a was 65e7a3a, checked in by Thomas Lopatic <thomas@…>, 7 years ago

File extension for Windows executables.

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