File: configure

package info (click to toggle)
cb2bib 1.4.9-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 3,500 kB
  • ctags: 2,613
  • sloc: cpp: 26,112; sh: 481; makefile: 17
file content (330 lines) | stat: -rwxr-xr-x 11,438 bytes parent folder | download | duplicates (2)
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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
#!/bin/sh
#------------------------------------------------------------------------------
# cb2Bib configuration script:
# - Checks for QTDIR
#   -- If set, checks for qmake at QTDIR
#   -- If not set, checks for qmake at PATH and other usual locations
# - Manages Installation directory data
# - Runs qmake
#
# Modifications for the cb2Bib Gentoo build descriptions
# by Hugo Mildenberger and Andreas K. Huettel
# Copyright 2009 Hugo Mildenberger and Andreas K. Huettel
# - December 2009: do not use temporary files, fix sed regular
#   expression, set both enable/disable for options, and add 
#   call to qmake option.
#
# Modifications for the cb2Bib Debian distribution package
# by Filippo Rusconi
# Copyright 2009 Filippo Rusconi
# - June 2009: replace ' ' with ':' along with use of IFS=: as
#   word-splitting delimiter for PATH-related tasks (Thanks Lionel
#   Mamane).
# - September 2009: protect all shell variables against spaces.
#
#------------------------------------------------------------------------------
# ( originally based upon 'shell script to configure doxygen',
#   http://www.stack.nl/~dimitri/doxygen/
#   Copyright (C) 1997-2001 by Dimitri van Heesch )
#
# Permission to use, copy, modify, and distribute this software and its
# documentation under the terms of the GNU General Public License is hereby
# granted. No representations are made about the suitability of this software
# for any purpose. It is provided "as is" without express or implied warranty
# See the GNU General Public License for more details
#------------------------------------------------------------------------------

platform=`uname -s`

echo
echo "Configuration script for cb2Bib (Unix/Linux/MacOSX)"
echo
f_prefix=/usr
f_bindir=/usr/bin
f_datadir=/usr/share/cb2bib
f_desktopdatadir=/usr/share/applications
f_icondir=/usr/share/pixmaps

f_qmake=NO
f_make=NO
f_disable_cbpoll=NO
f_disable_lzo=NO
f_disable_qmake_call=NO

while test -n "$1";  do
  case $1 in
    --prefix | -prefix)
       shift; f_prefix="$1" ; f_bindir="$1/bin" ; f_datadir="$1/share/cb2bib" ; f_desktopdatadir="$1/share/applications" ; f_icondir="$1/share/pixmaps"
       ;;
    --bindir | -bindir)
       shift; unset f_prefix ; f_bindir="$1"
       ;;
    --datadir | -datadir)
       shift; unset f_prefix ; f_datadir="$1/cb2bib"
       ;;
    --desktopdatadir | -desktopdatadir)
       shift; unset f_prefix ; f_desktopdatadir="$1"
       ;;
    --icondir | -icondir)
       shift; unset f_prefix ; f_icondir="$1"
       ;;
    --qmakepath | -qmakepath)
       shift; unset f_qmake ; f_qmake="$1"
       ;;
    -h | --help | -help)
       f_help=y
       ;;
    --enable-cbpoll | -enable-cbpoll)
       f_disable_cbpoll=NO
       ;;
    --disable-cbpoll | -disable-cbpoll)
       f_disable_cbpoll=y
       ;;
    --enable-lzo | -enable-lzo)
       f_disable_lzo=NO
       ;;
    --disable-lzo | -disable-lzo)
       f_disable_lzo=y
       ;;
    --enable-qmake-call | -enable-qmake-call)
       f_disable_qmake_call=NO
       ;;
    --disable-qmake-call | -disable-qmake-call)
       f_disable_qmake_call=y
       ;;
    *)
       echo "-----------------------------------------------------------------------"
       echo Error: Unknown argument $1
       echo "-----------------------------------------------------------------------"
       echo ""
       f_help=y
       f_error=y
       ;;
  esac
  shift
done

if test "$f_help" = y; then
  cat <<EOF
Usage: $0 [--help] [--prefix dir] [--bindir dir] [--datadir dir] ...

Options:

  General:
  --help                Print this help
  --qmakepath dir       qmake fullpath name
                        [example: --qmakepath /usr/bin/qmake]
  --prefix dir          Installation prefix directory
                        [default: /usr]
  --bindir dir          Executable installation directory
                        [default: /usr/bin]
  --datadir dir         Data installation directory
                        [default: /usr/share/cb2bib]
  --enable-lzo          Enable linking with lzo library [default]
  --disable-lzo         Disable linking with lzo library
  --enable-qmake-call   Enable configure to call qmake [default]
  --disable-qmake-call  Disable configure to call qmake


  Unix/Linux only:
  --desktopdatadir dir  Desktop data installation directory
                        [default: /usr/share/applications]
  --icondir dir         Icon installation directory
                        [default: /usr/share/pixmaps]
  --enable-cbpoll       Enable clipboard poll [default]
  --disable-cbpoll      Disable clipboard poll

EOF
  test "$f_error" = y && exit 1
  exit 0;
fi

echo "-----------------------------------------------------------------------"
echo "Platform: $platform"
echo "-----------------------------------------------------------------------"
echo "Setting installation directories..."
if test "$f_prefix"; then
  echo "Setting installation relative to dir: $f_prefix"
fi
if test "$f_bindir"; then
  echo "Setting installation executable to dir: $f_bindir"
fi
if test "$f_datadir"; then
  echo "Setting installation cb2Bib data files relative to dir: $f_datadir"
fi
if test "$f_desktopdatadir"; then
  echo "Setting installation desktop data files to dir: $f_desktopdatadir"
fi
if test "$f_icondir"; then
  echo "Setting installation icon file to dir: $f_icondir"
fi
echo "-----------------------------------------------------------------------"

echo
echo "-----------------------------------------------------------------------"
echo "cb2Bib Info:"
echo "-----------------------------------------------------------------------"
echo "- This version requires Qt 4.4.0 or later."
echo " "
echo "- Set the environment variable QTDIR if this script cannot determine"
echo "  the right Qt qmake."
echo "- QTDIR will only be used during configuration; it can later be reset"
echo "  to its original value."
echo " "
echo "- Alternatively, set Qt 4.4 qmake's fullpath name with"
echo "  --qmakepath flag."
echo "-----------------------------------------------------------------------"

#- check for qt ---------------------------------------------------------------

echo
echo "Checking for Qt/qmake:"
  if test "$f_qmake" != NO; then
    echo -n "Checking for qmake tool... "
    if test ! -x "$f_qmake"; then
      echo "Specified $f_qmake could not be found."
      exit 2
    else
      echo "using $f_qmake."
    fi
  elif test -z "$QTDIR"; then
    echo "Environment variable QTDIR not set, checking elsewhere for qmake..."
    echo -n "Checking for qmake tool... "
    if test "$f_qmake" = NO; then
      qmake_name="qmake"
      qmake_dirs="/usr/lib64/qt4/bin:/usr/lib/qt4/bin:/usr/bin:/usr/lib/qt/bin:/usr/share/qt/bin:/Developer/Tools/Qt:$PATH"
      qmake_prog=NO
      IFS=:
      for j in $qmake_dirs; do
        if test -x "$j/$qmake_name"; then
          qmake_prog="$j/$qmake_name"
          break 1
        fi
      done
      unset IFS
      f_qmake="$qmake_prog" 
    fi
    if test "$f_qmake" = NO; then
      echo "not found!"
      echo
      echo "Please, check if required Qt/qmake is properly installed."
      echo "If so, set QTDIR environment variable to your Qt root directory."
      exit 2
    fi
    echo "using $f_qmake."
  else
    echo "Using QTDIR environment variable for Qt directory location."
    echo "Checking for Qt tools at $QTDIR..."
    echo -n "Checking for qmake tool... "
    if test ! -x "$QTDIR/bin/qmake"; then
      echo "QTDIR is set, but the qmake could not be found in $QTDIR/bin."
      exit 2
    else
      f_qmake="$QTDIR/bin/qmake"
      echo "using $QTDIR/bin/qmake."
    fi
  fi
  "$f_qmake" -v


#------------------------------------------------------------------------------
# Set directories for binaries search
#------------------------------------------------------------------------------
bin_dirs="/usr/bin:/usr/local/bin:/bin:/sbin:$PATH"
#------------------------------------------------------------------------------


# - check for make ------------------------------------------------------------

echo
echo "Checking for additional tools:"
echo -n "Checking for make..."
if test "$f_make" = NO; then
  make_names="gmake:make"
  make_prog=NO
  IFS=:
  for i in $make_names; do
    for j in $bin_dirs ; do
      if test -x "$j/$i"; then
        if test -n "`$j/$i --version 2>/dev/null | grep GNU`"; then
          make_prog="$j/$i"
          break 2
        fi
      fi
    done
  done
  unset IFS
  f_make="$make_prog" 
fi

if test "$f_make" != NO; then
  echo "using $f_make."
else
  echo "not found."
fi

#- Setting dirs and start qmake -----------------------------------------------

echo
sed -i -e 's%^.*cb2bibdata\.path .*$%cb2bibdata.path = '$f_datadir'%g' \
       -e 's%^.*target\.path .*$%target.path = '$f_bindir'%g' \
       -e 's%^.*script\.path .*$%script.path = '$f_bindir'%g' \
       -e 's%^.*desktop\.path .*$%desktop.path = '$f_desktopdatadir'%g' \
       -e 's%^.*icons\.path .*$%icons.path = '$f_icondir'%g' src/src.pro
sed -i 's%^const QString C2B_DATA_DIR.*$%const QString C2B_DATA_DIR("'$f_datadir'/");%g' src/c2b/cb2bib_parameters.h

f_configs=
if test "$f_disable_cbpoll" = y; then
  echo "Setting clipboardPoll disabled"
  f_configs="$f_configs -config disable_cbpoll"
fi
if test "$f_disable_lzo" = y; then
  echo "Setting lzo disabled"
  f_configs="$f_configs -config disable_lzo"
fi

if test "$f_disable_qmake_call" = NO; then
  if test "$platform" = Darwin; then # Warning: Test for MacOSX/Darwin might be outdated
    echo "Running $f_qmake -spec macx-g++ $f_configs -o Makefile"
    "$f_qmake" -spec macx-g++ $f_configs -o Makefile
  else
    echo "Running $f_qmake $f_configs -o Makefile"
    "$f_qmake" $f_configs -o Makefile
  fi
else
  echo "Writing qmake flags to file 'qmake-additional-args'"
  echo $f_configs > qmake-additional-args
fi

echo " "
if test "$f_make" = NO; then
  echo "-----------------------------------------------------------------------"
  echo "Configuration ended. 'make' not found."
  echo "Build toolchain might not be completed."
  echo "-----------------------------------------------------------------------"
  exit 1
else
  echo "-----------------------------------------------------------------------"
  echo "- NOTE: 'make install' will copy the required runtime files to the"
  echo "  specified locations. Besides cb2bib binary, 'make install' will copy"
  echo "  the scripts c2bimport and c2bciter, and will set their executable"
  echo "  permissions. Also, it will set cb2bib, c2bimport, and c2bciter"
  echo "  desktop files."
  if test "$f_disable_lzo" = NO; then
    echo "-----------------------------------------------------------------------"
    echo "- NOTE: cb2Bib requires lzo library. If it were unavailable in your"
    echo "  platform, reconfigure using --disable-lzo."
  fi
  echo "-----------------------------------------------------------------------"
  echo "- NOTE: Type 'make distclean' or, preferably, untar again to set other"
  echo "  configure flags."
  echo "-----------------------------------------------------------------------"
  echo " "
  echo "-----------------------------------------------------------------------"
  if test "$f_disable_qmake_call" = NO; then
    echo "Configuration ended. Type 'make' and 'make install'."
  else
    echo "Configuration ended. Run qmake, and type 'make' and 'make install'."
  fi
  echo "-----------------------------------------------------------------------"
fi