File: configure

package info (click to toggle)
cb2bib 2.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,584 kB
  • sloc: cpp: 28,329; sh: 516; makefile: 10
file content (365 lines) | stat: -rwxr-xr-x 12,429 bytes parent folder | download | duplicates (4)
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
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
#!/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_enable_cbpoll=NO
f_enable_lz4=y
f_enable_lzo=NO
f_enable_lzsse=NO
f_enable_qt_zlib=NO
f_enable_avx2=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_enable_cbpoll=y
       ;;
    --disable-cbpoll | -disable-cbpoll)
       f_enable_cbpoll=NO
       ;;
    --enable-lzo | -enable-lzo)
       f_enable_lz4=NO ; f_enable_lzo=y ; f_enable_lzsse=NO ; f_enable_qt_zlib=NO
       ;;
    --enable-lzsse | -enable-lzsse)
       f_enable_lz4=NO ; f_enable_lzO=NO ; f_enable_lzsse=y ; f_enable_qt_zlib=NO
       ;;
    --enable-qt-zlib | -enable-qt-zlib)
       f_enable_lz4=NO ; f_enable_lzO=NO ; f_enable_lzsse=NO ; f_enable_qt_zlib=y
       ;;
    --enable-lz4 | -enable-lz4)
       f_enable_lz4=y ; f_enable_lzO=NO ; f_enable_lzsse=NO ; f_enable_qt_zlib=NO
       ;;
    --enable-avx2 | -enable-avx2)
       f_enable_avx2=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-lz4          Enable linking with LZ4 library [default]
  --enable-lzo          Enable linking with LZO library
  --enable-qt-zlib      Enable linking with Qt's ZLIB library
  --enable-lzsse        Enable linking with LZSSE library
                        [see ./src/c2b/lzsse4/README.txt]
  --enable-avx2         Enable using AVX2 instructions
  --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
  --disable-cbpoll      Disable clipboard poll [default]

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 5.7.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 Qt5 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-qt5"
      qmake_dirs="/usr/bin:/usr/lib64/qt5/bin:/usr/lib/qt5/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
      qmake_name="qmake"
      qmake_dirs="/usr/lib/x86_64-linux-gnu/qt5/bin:/usr/lib/i386-linux-gnu/qt5/bin:/usr/lib/arm-linux-gnueabi/qt5/bin:/usr/lib/mips-linux-gnu/qt5/bin:/usr/lib/powerpc-linux-gnu/qt5/bin:/usr/lib/powerpc64le-linux-gnu/qt5/bin:/usr/lib64/qt5/bin:/usr/lib/qt5/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%^.*cb2bibdoc\.path .*$%cb2bibdoc.path = '$f_datadir'/doc%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 QLatin1String C2B_DATA_DIR.*$%const QLatin1String C2B_DATA_DIR("'$f_datadir'/");%g' src/c2b/cb2bib_parameters.h

f_configs=
if test "$f_enable_cbpoll" = y; then
  echo "Setting clipboardPoll enabled"
  f_configs="$f_configs -config enable_cbpoll"
fi
if test "$f_enable_lz4" = y; then
  echo "Setting LZ4 enabled"
  f_configs="$f_configs -config use_lz4"
fi
if test "$f_enable_lzo" = y; then
  echo "Setting LZO enabled"
  f_configs="$f_configs -config use_lzo"
fi
if test "$f_enable_lzsse" = y; then
  echo "Setting LZSSE enabled"
  f_configs="$f_configs -config use_lzsse"
fi
if test "$f_enable_qt_zlib" = y; then
  echo "Setting Qt ZLIB enabled"
  f_configs="$f_configs -config use_qt_zlib"
fi
if test "$f_enable_avx2" = y; then
  echo "Setting AVX2 enabled"
  f_configs="$f_configs -config use_avx2"
fi

if test "$f_disable_qmake_call" = NO; then
  echo ""
  echo "Running $f_qmake $f_configs -o Makefile"
  "$f_qmake" $f_configs -o Makefile
else
  echo ""
  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: 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 "-----------------------------------------------------------------------"
  echo " "
fi