summaryrefslogtreecommitdiff
path: root/Makefile
blob: f913f4cbe6500e93115c578c59a92a10eeee1b8f (plain)
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
ifeq ($(SYSTEM),)
SYSTEM=$(shell uname)
endif
TRUESYSTEM=$(shell uname)
MACHINE=$(shell uname -m)
DISTRIB=$(shell cat /etc/issue | cut -f 1 -d\ | head -1)
GL_GLUE=gl-glue.s
CC = gcc
CXX = g++
LD = g++
AS = as
LUAJIT = ../LuaJIT/src/libluajit.a
ifeq ($(SYSTEM),Darwin)
LIPO = lipo
ARCH_FLAGS=-arch i386
LDFLAGS_MESA=-all_load ../Mesa-7.4.4/lib/libGLU.a ../Mesa-7.4.4/lib/libmesa.a ../Mesa-7.4.4/lib/libglapi.a ../Mesa-7.4.4/lib/osmesa.o
CPPFLAGS_READLINE=
LDFLAGS_READLINE=-lreadline -lncurses
SHARED_FLAGS=-dynamiclib
SHARED_EXT=dylib
LIBS=-liconv
LD = g++ -arch i386
LDFLAGS_GL = -L/usr/X11/lib -lGLU -lGL -X11 -dylib_file \
/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:\
/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib
STRIP = strip -x
ifeq ($(TRUESYSTEM),Linux)
CC = i686-apple-darwin9-gcc
CXX = i686-apple-darwin9-g++
LD = i686-apple-darwin9-g++ -arch i386 -mmacosx-version-min=10.5
STRIP = i686-apple-darwin9-strip -x
AS = i686-apple-darwin9-as -arch i386
LIPO = i686-apple-darwin9-lipo
ARCH_FLAGS =
LDFLAGS_MESA = -all_load ../Mesa-7.4.4-darwin9/lib/libGLU.a ../Mesa-7.4.4-darwin9/lib/libOSMesa.a
LUAJIT = ../LuaJIT-darwin9/src/libluajit.a
endif
else
ARCH_FLAGS=-march=i686 -m32
ASFLAGS=-march=i686 --32
LDFLAGS_MESA=-u gluNewTess -Wl,--whole-archive ../Mesa-7.4.4/lib/libGLU.a ../Mesa-7.4.4/lib/libOSMesa.a -Wl,--no-whole-archive
CPPFLAGS_READLINE=-DREADLINE_STATIC
LDFLAGS_READLINE=/usr/lib/libreadline.a /usr/lib/libncurses.a
ifeq ($(MACHINE),x86_64)
ifeq ($(DISTRIB),Debian)
#LDFLAGS_READLINE=/usr/lib32/libreadline.a /usr/lib32/libncurses.a
endif
endif
ifeq ($(MACHINE),i686)
ifeq ($(DISTRIB),Debian)
HAVES = -DHAVE_UCL
BASIC_LDFLAGS = /usr/lib/libucl.a
endif
endif
SHARED_FLAGS=-shared
SHARED_EXT=so
LD = g++ -m32
LDFLAGS_GL = -lGLU -lGL
STRIP = strip --strip-unneeded
endif

INCLUDES = \
-I../mogltk/include \
-I../Baltisot/include \
-I../Baltisot/lib/zlib/include \
-I../LuaJIT/src \
-I../lua-modules/src \
\
-I ../Mesa-7.4.4/include \
-I ../tinyxml \
-I /usr/include/mysql \
-I /usr/include/FTGL -I /usr/include/freetype2 \
-I /usr/include/oracle/11.2.0.1.0/client/ \
-I ../PSX-Bundle/includes \
-I../lua-modules-iup/im/include -I../lua-modules-iup/cd/include -I../lua-modules-iup/iup/include \

HAVES += -DHAVE_VSSCANF -DHAVE_LIBJPEG -DHAVE_FCNTL -DHAVE_MYSQL -DHAVE_UNISTD_H -DHAVE_FORK -DHAVE_PIPE -DHAVE_FSYNC -DHAVE_MALLOC_H -DHAVE_ASPRINTF -DHAVE_VASPRINTF

LIBS += -lz -ldl -lpthread

CPPFLAGS_NO_ARCH += $(INCLUDES) -g -DSTDC_HEADERS $(CPPFLAGS_READLINE) -DHOOK_STDS -fexceptions -DWORDS_LITTLEENDIAN -fexceptions $(HAVES) -DUSE_MPQLIB
CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS)

BASIC_LDFLAGS += $(ARCH_FLAGS) $(LIBS)

LDFLAGS += $(BASIC_LDFLAGS) $(LDFLAGS_READLINE) -L/usr/lib/oracle/11.2.0.1.0/client/lib $(LUAJIT)


vpath %.c ../Baltisot/lib:../Baltisot/src:../mogltk/lib:../tinyxml:../lua-modules/src:src
vpath %.cc ../Baltisot/lib:../Baltisot/src:../mogltk/lib:../tinyxml:../lua-modules/src:src:../lua-modules-cd-tool/src:../lua-modules-iup/src
vpath %.cpp ../Baltisot/lib:../Baltisot/src:../mogltk/lib:../tinyxml:../lua-modules/src:src:../PSX-Bundle/lib
vpath %.lua ../Baltisot/lib:../Baltisot/src

LUAINTERFACE_SOURCES = \
lua-interface.cpp \
lua-interface-hc.c \
lua-plugin.cc \

BALTISOT_SOURCES = \
Main.cc \
ldirlib.c \
\
LockSmith.cc \
\
RandISAAC.cc \
Exceptions.cc \
String.cc \
Regex.cc \
\
Base64.cc \
Base85.cc \
\
Handle.cc \
Input.cc \
InPipe.cc \
Output.cc \
Buffer.cc \
\
ConfigFile.cc \
\
Socket.cc \
\
Task.cc \
TaskMan.cc \
ChainTasks.cc \
CopyJob.cc \
ReadJob.cc \
HttpServ.cc \
MailServer.cc \
Action.cc \
Domain.cc \
HtmlSkinner.cc \
Variables.cc \
Message.cc \
Form.cc \
SocketClient.cc \
HttpClient.cc \
MailClient.cc \
HashFunction.cc \
\
BLua.cc \
LuaTask.cc \
LuaHandle.cc \
LuaCommandLine.cc \
\
fileutils.cc \
generic.cc \
checkargs.c \
datecalc.c \
\
hashtab.c \
recycle.c \
lookupa.c \
\
md5.c \
sha1.c \
sha256.c \

DEBUG_MODULES = \
lua-interface-main.c \
tinystr.cpp \
tinyxml.cpp \
tinyxmlerror.cpp \
tinyxmlparser.cpp \
plugin-luaconfigfiles.cc \
LuaConfigFile.cc \
plugin-luaxml.cc \
LuaXML.cc \
plugin-luahandle.cc \
plugin-luahttp.cc \
LuaHttp.cc \
plugin-luaregex.cc \
LuaRegex.cc \
plugin-luatask.cc \
plugin-lualibs.cc \
loadlualibs.cc \
supportlib.lua \
tasklib.lua \
ajaxlib.lua \
htmllib.lua \
xmllib.lua \
httplib.lua \
dblib.lua \
plugin-luacd.cc \
luacd.cpp \
cdabstract.cpp \
cdreader.cpp \
cdutils.cpp \
dvdabstract.cpp \
isobuilder.cpp \
yazedc.cpp \
LuaOCCI.cpp \
plugin-luaocci.cc \
plugin-luaiup.cc \

WHOLE_SOURCES = $(BALTISOT_SOURCES) $(LUAINTERFACE_SOURCES) $(GL_GLUE)
DEBUG_SOURCES = $(DEBUG_MODULES)

LUAINTERFACE_OBJECTS = $(addsuffix .o, $(notdir $(basename $(LUAINTERFACE_SOURCES))))
DEBUG_OBJECTS = $(addsuffix .o, $(notdir $(basename $(DEBUG_SOURCES))))

ALL_OBJECTS = $(addsuffix .o, $(notdir $(basename $(WHOLE_SOURCES))))
ALL_DEPS = $(addsuffix .dep, $(notdir $(basename $(WHOLE_SOURCES) $(DEBUG_SOURCES))))

all: dep lua-interface

dist: lua-interface lua-interface-gl.$(SHARED_EXT)
	mkdir -p ../lua-interface-dist
	ln -sf lua-interface-mesa.$(SHARED_EXT) lua-interface.$(SHARED_EXT)
	$(STRIP) $+
	cp lua-interface lua-interface*.$(SHARED_EXT) ../lua-interface-dist

dep: $(ALL_DEPS)

lua-interface-mesa.$(SHARED_EXT): $(ALL_OBJECTS)
	$(LD) $(SHARED_FLAGS) -o lua-interface.$(SHARED_EXT) $(ALL_OBJECTS) $(LDFLAGS) $(LDFLAGS_MESA)
	mv lua-interface.$(SHARED_EXT) $@
	ln -sf $@ lua-interface.$(SHARED_EXT)

lua-interface-gl.$(SHARED_EXT): $(ALL_OBJECTS)
	$(LD) $(SHARED_FLAGS) -o lua-interface.$(SHARED_EXT) $(ALL_OBJECTS) $(LDFLAGS) $(LDFLAGS_GL)
	mv lua-interface.$(SHARED_EXT) $@
	ln -sf $@ lua-interface.$(SHARED_EXT)

lua-interface: lua-interface-mesa.$(SHARED_EXT) lua-interface-main.o
	$(LD) -o $@ -ldl lua-interface-main.o

lua-interface-dbg: $(ALL_OBJECTS) $(DEBUG_OBJECTS)
	$(LD) -o lua-interface-dbg $(ALL_OBJECTS) $(DEBUG_OBJECTS) $(LDFLAGS) $(LDFLAGS_MESA) -locci -lclntsh -lnnz11 ../lua-modules-iup/luaiup.a -lXm -lXpm -lXmu -lXt -lXext -lX11 -lm

clean:
	rm -f lua-interface-mesa lua-interface-gl *.o *.dep *.so *.dylib

%.dep : %.c
	$(CC) $(CPPFLAGS_NO_ARCH) -M -MF $@ $<

%.dep : %.cpp
	$(CXX) $(CPPFLAGS_NO_ARCH) -M -MF $@ $<

%.dep : %.cc
	$(CXX) $(CPPFLAGS_NO_ARCH) -M -MF $@ $<

lua-interface-hc.c : lua-interface.lua
	bin2c $< $@ lua_interface_lua

%.c : %.lua
	bin2c $< $@ $(basename $@)

gl-glue.dep:
	touch gl-glue.dep

gl-glue.s:
	src/generate-gl-glue.sh $(SYSTEM) > gl-glue.s

-include $(ALL_DEPS)

.PHONY: dist