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
|
#!/bin/bash
## NOTE:
## I know this is not a clean way to check for some stuff
## and edit the Makefile, but hey, it does work!
# Configure script for eAthena
# Copyright (C) 2005 dontBR
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# Default variables
status_mmx="No"
status_sse="No"
status_sse2="No"
status_sse3="No"
status_pcre="No"
prefix='/opt/eathena/'
# Functions
function check_sed {
echo -n "Checking for sed... "
if [ -f $(which sed) ]; then
echo "yes"
else
echo "Error: sed not found in $PATH"
exit 1
fi
}
function check_gcc {
echo -n "Checking for gcc... "
if [ -f $(which gcc) ]; then
echo "yes"
else
echo "Error: GCC not found in $PATH"
exit 1
fi
}
function check_make {
echo -n "Checking for (g)make... "
if [ -f $(which make) ]; then
maker=make
echo "yes"
else if [ -f $(which gmake) ]; then
maker=gmake
echo "yes"
else
echo "Error: (g)make not found in $PATH"
exit 1
fi
fi
}
function check_sockets {
echo -n "Checking for sockets... "
echo "#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
int main(){
}" > test_sockets.c
if $(gcc test_sockets.c -o test_sockets); then
echo "yes"
rm -f test_sockets.c test_sockets
else
echo "Error: Unix sockets not found/working."
exit 1
rm -f test_sockets.c
fi
}
function check_mysql_headers {
echo -n "Checking for MySQL headers... "
if [ -d /usr/local/lib/mysql ]; then # Default
echo "yes"
mysql_headers_path='/usr/local/lib/mysql'
else
if [ -d /usr/include/mysql ]; then # Gentoo/Debian/?
echo "yes"
mysql_headers_path='/usr/include/mysql'
else
echo "Error: MySQL headers not found."
mysql_headers_path='Not found.'
fi
fi
}
function optimize {
case $@ in
mmx ) status_mmx="Yes" ;;
sse ) status_sse="Yes" ;;
sse2 ) status_sse2="Yes" ;;
sse3 ) status_sse3="Yes" ;;
all ) status_mmx="Yes"
status_sse="Yes"
status_sse2="Yes"
status_sse3="Yes" ;;
esac
}
function make_changes {
if [ "$maker" != "make" ]; then
sed -e 's,MAKE = make,MAKE = '$maker',g' Makefile -i
fi
if [ "$status_mmx" = "Yes" ]; then
sed -e 's,# OPT += -mmmx,OPT += -mmmx,g' Makefile -i
fi
if [ "$status_sse" = "Yes" ]; then
sed -e 's,# OPT += -msse,OPT += -msse,g' Makefile -i
fi
if [ "$status_sse2" = "Yes" ]; then
sed -e 's,# OPT += -msse2,OPT += -msse2,g' Makefile -i
fi
if [ "$status_sse3" = "Yes" ]; then
sed -e 's,# OPT += -msse3,OPT += -msse3,g' Makefile -i
fi
if [ "$status_pcre" = "Yes" ]; then
sed -e 's,# OPT += -DPCRE_SUPPORT,OPT += -DPCRE_SUPPORT,g' Makefile -i
fi
if [ "$mysql_headers_path" != "/usr/local/lib/mysql" ] && [ "$mysql_headers_path" != "Not found." ]; then
sed -e 's,LIBS += -L/usr/local/lib/mysql -lmysqlclient,LIBS += -L'$mysql_headers_path' -lmysqlclient,g' Makefile -i
fi
}
function opt_check_pcre {
echo -n "Checking for PCRE... "
if [ -f /usr/local/lib/pcre.h ]; then
echo "yes"
status_pcre="Yes"
else
echo "Error: PCRE not found."
status_pcre="No"
fi
}
function make_report {
echo "Configuration report:"
echo eAthena
echo
echo Enable PCRE support..... : $status_pcre
echo
echo Enable MMX optimization. : $status_mmx
echo Enable SSE optimization. : $status_sse
echo Enable SSE2 optimization : $status_sse2
echo Enable SSE3 optimization : $status_sse3
echo
echo MySQL headers path...... : $mysql_headers_path
echo
echo eAthena will be installed in $prefix
echo Please type \'make txt\' or \'make sql\' now to compile eAthena.
}
function helptext {
echo "eAthena Configure Script version 0.1"
echo
echo "Options:"
echo
echo " -h Display this help message and exit."
echo " -d Enter debug mode."
echo " -o Turn on optimization flags."
echo " Supported:"
echo " mmx"
echo " sse"
echo " sse2"
echo " sse3"
echo " all"
echo " -e Enable PCRE support."
echo " -p Root directory where eA is going to be installed."
echo " DON'T FORGET THE LAST SLASH!"
echo " For example:"
echo " ./configure -p /usr/local/"
echo " This will create /usr/local/bin/login-server,"
echo " /usr/local/etc/eathena/save/account.txt, etc"
echo " Default is /opt/eathena/"
echo
echo "Report bugs (about the configure script) to dontBR at the eAthena Support Board."
}
function make_installable {
echo -e '' >> Makefile
echo -e 'install: conf/%.conf conf/%.txt' >> Makefile
echo -e ' $(shell mkdir -p '$prefix'bin/)' >> Makefile
echo -e ' $(shell mkdir -p '$prefix'etc/eathena/)' >> Makefile
echo -e ' $(shell mkdir -p '$prefix'var/log/eathena/)' >> Makefile
echo -e ' $(shell mv save '$prefix'etc/eathena/save)' >> Makefile
echo -e ' $(shell mv db '$prefix'etc/eathena/db)' >> Makefile
echo -e ' $(shell mv conf '$prefix'etc/eathena/conf)' >> Makefile
echo -e ' $(shell mv npc '$prefix'etc/eathena/npc)' >> Makefile
echo -e ' $(shell mv log/* '$prefix'var/log/eathena/)' >> Makefile
echo -e ' $(shell cp *-server* '$prefix'bin/)' >> Makefile
echo -e ' $(shell cp ladmin '$prefix'bin/)' >> Makefile
echo -e ' $(shell ln -s '$prefix'etc/eathena/save/ '$prefix'bin/)' >> Makefile
echo -e ' $(shell ln -s '$prefix'etc/eathena/db/ '$prefix'bin/)' >> Makefile
echo -e ' $(shell ln -s '$prefix'etc/eathena/conf/ '$prefix'bin/)' >> Makefile
echo -e ' $(shell ln -s '$prefix'etc/eathena/npc/ '$prefix'bin/)' >> Makefile
echo -e ' $(shell ln -s '$prefix'var/log/eathena/ '$prefix'bin/log)' >> Makefile
echo '' >> Makefile
echo -e 'bin-clean:' >> Makefile
echo -e ' $(shell rm '$prefix'bin/login-server*)' >> Makefile
echo -e ' $(shell rm '$prefix'bin/char-server*)' >> Makefile
echo -e ' $(shell rm '$prefix'bin/map-server*)' >> Makefile
echo -e ' $(shell rm '$prefix'bin/ladmin)' >> Makefile
echo '' >> Makefile
echo -e 'uninstall:' >> Makefile
echo -e ' bin-clean' >> Makefile
echo -e ' $(shell rm '$prefix'bin/save)' >> Makefile
echo -e ' $(shell rm '$prefix'bin/db)' >> Makefile
echo -e ' $(shell rm '$prefix'bin/conf)' >> Makefile
echo -e ' $(shell rm '$prefix'bin/npc)' >> Makefile
echo -e ' $(shell rm '$prefix'bin/log)' >> Makefile
echo -e ' $(shell rm -rf '$prefix'etc/eathena)' >> Makefile
echo -e ' $(shell rm -rf '$prefix'var/log/eathena)' >> Makefile
}
# Arguments
while getopts ":hdo:ep:" opt; do
case $opt in
h ) helptext ; exit ;;
d ) set -x ;;
o ) optimize ${OPTARG} ;;
e ) opt_check_pcre ;;
p ) prefix=${OPTARG} ; [ -d ${OPTARG} ] || echo "The directory $prefix does not exist. Creating...";;
esac
done
# Execution
echo "eAthena configure script"
echo "Note: This is ALPHA software! Do NOT use it on a production server!"
echo
echo "Checking for dependencies.."
check_sed
check_gcc
check_make
check_sockets
check_mysql_headers
make_changes
make_installable
echo
make_report
exit
|