-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
172 lines (145 loc) · 3.59 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
ifndef OS
OS:=$(shell uname -s)
endif
FIXUP:=true
ifeq ($(OS),Windows)
ifndef SDL2_PREFIX
SDL2_PREFIX:="sdl/i686-w64-mingw32"
endif
ifndef GLEW_PREFIX
GLEW_PREFIX:=glew
endif
ifndef GLEW32S_LIB
GLEW32S_LIB:=$(GLEW_PREFIX)/lib/Release/Win32/glew32s.lib
endif
MEM:=mem_win.o
TERMINAL:=terminal_win.o
EXE:=.exe
CC:=i686-w64-mingw32-gcc-win32
CFLAGS:=-std=gnu99 -Wreturn-type -Werror=return-type -Werror=implicit-function-declaration -I"$(SDL2_PREFIX)/include/SDL2" -I"$(GLEW_PREFIX)/include" -DGLEW_STATIC
LDFLAGS:= $(GLEW32S_LIB) -L"$(SDL2_PREFIX)/lib" -lm -lmingw32 -lSDL2main -lSDL2 -lws2_32 -lopengl32 -lglu32 -mwindows
CPU:=i686
else
MEM:=mem.o
TERMINAL:=terminal.o
EXE:=
ifeq ($(OS),Darwin)
LIBS=sdl2 glew
else
LIBS=sdl2 glew gl zlib
endif #Darwin
HAS_PROC:=$(shell if [ -d /proc ]; then /bin/echo -e -DHAS_PROC; fi)
CFLAGS:=-std=gnu99 -Wreturn-type -Werror=return-type -Werror=implicit-function-declaration -Wno-unused-value $(HAS_PROC)
ifeq ($(OS),Darwin)
#This should really be based on whether or not the C compiler is clang rather than based on the OS
CFLAGS+= -Wno-logical-op-parentheses
endif
ifdef PORTABLE
CFLAGS+= -DGLEW_STATIC -Iglew/include
LDFLAGS:=-lm glew/lib/libGLEW.a
ifeq ($(OS),Darwin)
CFLAGS+= -IFrameworks/SDL2.framework/Headers
LDFLAGS+= -FFrameworks -framework SDL2 -framework OpenGL
FIXUP:=install_name_tool -change @rpath/SDL2.framework/Versions/A/SDL2 @executable_path/Frameworks/SDL2.framework/Versions/A/SDL2
else
CFLAGS+= -Isdl/include
LDFLAGS+= -Wl,-rpath='$$ORIGIN/lib' -Llib -lSDL2 $(shell pkg-config --libs gl)
endif #Darwin
else
ifdef GTK2
LIBS+= gtk+-2.0
CFLAGS+= -DGTK2
else
LIBS+= gtk+-3.0
endif #GTK2
CFLAGS:=$(shell pkg-config --cflags-only-I $(LIBS)) $(CFLAGS)
LDFLAGS:=-lm $(shell pkg-config --libs $(LIBS))
ifeq ($(OS),Darwin)
LDFLAGS+= -framework OpenGL
endif
endif #PORTABLE
endif #Windows
ifdef DEBUG
CFLAGS:=-ggdb $(CFLAGS)
LDFLAGS:=-ggdb $(LDFLAGS)
else
ifdef NOLTO
CFLAGS:=-O2 $(CFLAGS)
LDFLAGS:=-O2 $(LDFLAGS)
else
CFLAGS:=-O2 -flto $(CFLAGS)
LDFLAGS:=-O2 -flto $(LDFLAGS)
endif #NOLTO
endif #DEBUG
ifdef Z80_LOG_ADDRESS
CFLAGS+= -DZ80_LOG_ADDRESS
endif
ifdef PROFILE
LDFLAGS+= -Wl,--no-as-needed -lprofiler -Wl,--as-needed
endif
ifdef NOGL
CFLAGS+= -DDISABLE_OPENGL
endif
ifdef M68030
CFLAGS+= -DM68030
endif
ifdef M68020
CFLAGS+= -DM68020
endif
ifdef M68010
CFLAGS+= -DM68010
endif
ifndef CPU
CPU:=$(shell uname -m)
endif
#OpenBSD uses different names for these architectures
ifeq ($(CPU),amd64)
CPU:=x86_64
else
ifeq ($(CPU),i386)
CPU:=i686
endif
endif
TRANSOBJS=gen.o backend.o $(MEM) arena.o tern.o
M68KOBJS=68kinst.o m68k_core.o
ifeq ($(CPU),x86_64)
M68KOBJS+= m68k_core_x86.o
TRANSOBJS+= gen_x86.o backend_x86.o
else
ifeq ($(CPU),i686)
M68KOBJS+= m68k_core_x86.o
TRANSOBJS+= gen_x86.o backend_x86.o
endif
endif
Z80OBJS=z80inst.o z80_to_x86.o
AUDIOOBJS=ym2612.o psg.o wave.o
CONFIGOBJS=config.o tern.o util.o
MAINOBJS=blastem.o system.o genesis.o debug.o gdb_remote.o vdp.o gresource.o gtk_gui.o render_sdl.o ppm.o io.o romdb.o hash.o menu.o xband.o realtec.o i2c.o nor.o sega_mapper.o multi_game.o serialize.o ajunzip.o $(TERMINAL) $(CONFIGOBJS) gst.o $(M68KOBJS) $(TRANSOBJS) $(AUDIOOBJS)
ifeq ($(CPU),x86_64)
CFLAGS+=-DX86_64 -m64
LDFLAGS+=-m64
else
ifeq ($(CPU),i686)
CFLAGS+=-DX86_32 -m32
LDFLAGS+=-m32
else
$(error $(CPU) is not a supported architecture)
endif
endif
ifdef NOZ80
CFLAGS+=-DNO_Z80
else
MAINOBJS+= sms.o $(Z80OBJS)
endif
ifeq ($(OS),Windows)
MAINOBJS+= res.o
endif
ALL=blastem-gtk$(EXE)
all : $(ALL)
blastem-gtk$(EXE) : $(MAINOBJS)
$(CC) -o $@ $^ $(LDFLAGS)
$(FIXUP) ./$@
res.o : blastem.rc
i686-w64-mingw32-windres blastem.rc res.o
clean :
rm -rf blastem-gtk *.o