forked from ViviCoder/GM-Assistant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·229 lines (194 loc) · 6.03 KB
/
configure
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
##########################################################################
# Copyright © 2011-2012 Vincent Prat & Simon Nicolas
#
# 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 3 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.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
##########################################################################
#!/bin/sh
# Initializing some options
debug="false"
prefix="$HOME/gm-assistant"
system_install="true"
sysconfdir="/etc"
# Reading options
supported_short_options="gh"
supported_long_options="help,debug,prefix:,user,build:,includedir:,mandir:,infodir:,sysconfdir:,localstatedir:,libexecdir:,disable-maintainer-mode,disable-dependency-tracking"
options=$(getopt -s sh -l $supported_long_options $supported_short_options $@)
if [ $? -eq 1 ] # unsupported options
then
echo "Try the --help option for more information"
exit 1
fi
# initialization
arg=0
for opt in $options
do
if [ $arg -eq 0 -o "$opt" = "--" ]
then
case $opt in
-g | --debug) debug="true";;
-h | --help) echo -e "Usage: configure [options]\n\n -g, --debug\tEnable debugging\n -h, --help\tDisplay this usage guide\n --prefix=dir\t'make install' will install this software in dir\n --user\t\t'make install' will install this software in a user scope"
exit 0;;
--prefix) arg=1;;
--user) system_install="false"
config_path="$HOME/.config/gm-assistant";;
--sysconfdir) arg=2;;
--) break;;
esac
elif [ $arg -eq 1 ]
then
prefix=$(echo $opt | tr -d "'")
arg=0
elif [ $arg -eq 2 ]
then
sysconfdir=$(echo $opt | tr -d "'")
arg=0
fi
done
# Setting configuration path
config_path="$sysconfdir/xdg/gm-assistant"
conf_file="gm-assistant.conf"
# Find the OS
OS=$(uname)
echo "******************************"
echo "* Detecting operating system *"
echo "******************************"
echo
echo Operating system: $OS
# OS-dependent variables
if [ $OS = "Linux" ]
then
inc_path="/usr/include/"
sed_i="-i"
elif [ $OS = "Darwin" ]
then
inc_path="/opt/local/include/"
sed_i='-i ""'
fi
echo
echo "*************************"
echo "* Checking softwares... *"
echo "*************************"
echo
# Needed softwares
softs="uname echo getopt ls grep head pkg-config qmake lupdate lrelease make sed install tr"
for soft in $softs
do
path=$(which $soft)
if [ $? = 1 ]
then
echo $soft missing !
exit 1
else
echo $soft: $path
fi
done
echo
echo "*********************************"
echo "* Checking development files... *"
echo "*********************************"
# Needed headers
# libXML++
echo
echo libXML++:
xml_devs="libxml++"
xml_dev_path=$(ls -l $inc_path | grep -o -e "libxml++-2\.[0-9]\{1,\}" | head -n 1)
for dev in $xml_devs
do
if [ -e "$inc_path$xml_dev_path/libxml++/$dev.h" ]
then
echo $inc_path$xml_dev_path/libxml++/$dev.h: OK
else
echo $dev.h missing !
exit
fi
done
# SDL
echo
echo SDL:
sdl_devs="SDL_mixer SDL_sound"
sdl_dev_path=$inc_path"SDL"
for dev in $sdl_devs
do
if [ -e "$sdl_dev_path/$dev.h" ]
then
echo $sdl_dev_path/$dev.h: OK
else
echo $dev.h missing !
exit
fi
done
echo
echo "********************************"
echo "* Preparing the compilation... *"
echo "********************************"
echo
target="gm-assistant"
pro_file=$target.pro
qmake -project -o $pro_file
lupdate $pro_file
lrelease $pro_file
qmake $pro_file
# adding the -g flag if the debug option is enabled
if [ $debug = "true" ]
then
sed $sed_i "s#-pipe#-pipe -g#" Makefile
fi
echo
echo "************************"
echo "* Adding librairies... *"
echo "************************"
echo
echo $xml_dev_path
echo SDL
echo SDL_mixer
echo SDL_sound
# adding libxml++ and SDL includes in the Makefile
sed $sed_i "s#-I\.#$(pkg-config $xml_dev_path --cflags-only-I) $(pkg-config sdl --cflags-only-I)#" Makefile
# adding libxml++ and SDL binaries
sed $sed_i "s#-lQtCore#-lQtCore $(pkg-config $xml_dev_path --libs) -lSDL_mixer -lSDL_sound#" Makefile
# cleaning previous compilation
make -s clean
rm -f *.o
rm -f ui_*.h
# add files to clean
sed $sed_i 's#DEL_FILE) Makefile#DEL_FILE) Makefile\n\t-$(DEL_FILE) translations/*.qm\n\t-$(DEL_FILE) '$pro_file'\n\t-$(DEL_FILE) '$conf_file'#' Makefile
# preparing conf file
echo "[directories]" > $conf_file
echo "install=$prefix/share" >> $conf_file
# preparing the installation
prefix=$(echo $prefix | sed "s#\~#$HOME#")
config_path=$(echo $config_path | sed "s#\~#$HOME#")
sed $sed_i "s#DESTDIR.*=.*#DESTDIR\t= $prefix#" Makefile
if [ $system_install = "true" ]
then
sed $sed_i 's#-o main.o#-DSYSTEM_INSTALL -o main.o#' Makefile
fi
sed $sed_i 's#^install:.*#BINS=$(DESTDIR)/bin\nSHARE=$(DESTDIR)/share\nTRANSLATIONS=$(SHARE)/translations\nCONF='$config_path'\n\ninstall:\n\t\install -d $(DESTDIR) $(BINS) $(TRANSLATIONS) $(CONF)\n\t$(INSTALL_PROGRAM) gm-assistant $(BINS)\n\t$(INSTALL_FILE) translations/*.qm $(TRANSLATIONS)\n\t$(INSTALL_FILE) '$conf_file' $(CONF)#' Makefile
echo
echo "********************"
echo "* Ready to compile *"
echo "********************"
echo
# adding the rule for generating the documentation
dox=$(which doxygen)
if [ $? = 0 ]
then
echo "To generate the documentation, type make doc"
echo -e "doc:\n\tdoxygen dox.conf" >> Makefile
else
echo "In order to be able to generate the documentation, you need doxygen"
echo
fi
echo "To compile, type make"