File: configure

package info (click to toggle)
notepadqq 2.0.0~beta1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 9,188 kB
  • sloc: cpp: 17,647; sh: 223; xml: 36; makefile: 32
file content (184 lines) | stat: -rwxr-xr-x 5,121 bytes parent folder | download
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
#!/bin/sh
# Don't set `-e'!

# Basic environment variables
test -n "$MAKE"      || MAKE="make"
test -n "$CXX"       || CXX="c++"
test -n "$QTCHOOSER" || QTCHOOSER="$(command -v qtchooser 2> /dev/null)"
test -n "$TMPDIR"    || TMPDIR="$PWD"

# Use qtchooser if we have it, otherwise use Posix command -v
if test -n "$QTCHOOSER"; then
    test -n "$QMAKE"    || QMAKE="$QTCHOOSER -run-tool=qmake -qt=5"
    test -n "$LRELEASE" || LRELEASE="$QTCHOOSER -run-tool=lrelease -qt=5"
else
    test -n "$QMAKE"    || QMAKE="$(command -v qmake-qt5 2>/dev/null || command -v qmake 2>/dev/null)"
    test -n "$LRELEASE" || LRELEASE="$(command -v lrelease-qt5 2>/dev/null || command -v lrelease 2>/dev/null)"
fi


errorExit() {
    echo $1
    test x"$2" != x"1" || fail_on_missing="yes"
    test $fail_on_missing != "yes" || exit 1
}

help() {
cat << EOF

Usage: ./configure [OPTION]... [VAR=VALUE]...

To assign environment variables (e.g. CFLAGS...), specify them as
VAR=VALUE.  See below for descriptions of some of the useful variables.

Defaults for the options are specified in brackets.

  -h, --help              display this help and exit

  --prefix PREFIX,
  --prefix=PREFIX         install files in PREFIX [/usr/local]

  -d, --debug             build with debugging symbols intact

  --fail-on-missing       return exit 1 if non-optional components are missing

  --lrelease COMMAND,
  --lrelease=COMMAND      specify lrelease command [$LRELEASE]

  --qmake COMMAND,
  --qmake=COMMAND         specify qmake command [$QMAKE]
  --qmake-args ARGS       arguments to pass directly to qmake

Some influential environment variables:
  MAKE        make command
  CXX         C++ compiler
  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
              nonstandard directory <lib dir>
  CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
              you have headers in a nonstandard directory <include dir>
  CXXFLAGS    C++ compiler flags

EOF
}

# check "toolname/description" "command" errorExit
# set errorExit to 1 for an error exit, otherwise leave it empty.
# examples:
# check "a Git client tool" git
# check c++ g++ 1
check() {
    printf "checking for $1... "
    t=$(basename $2)
    command -v $t 2>/dev/null 1>/dev/null
    test $(echo $?) -eq 0 && echo "$(command -v $t)" || errorExit "not found!" $3
}


fail_on_missing="no"
while [ "$#" -ge 1 ]; do
    key="$1"
    shift

    case $key in
        -h|--help)
        help
        exit 0
        ;;
        -d|--debug)
        BUILDMODE="debug"
        echo "WARNING: Building in debug mode!"
        ;;
        --prefix=*) # --prefix=<something>
        PREFIX="${key#*=}"
        ;;
        --prefix) # --prefix <something>
        PREFIX="$1"
        shift
        ;;
        --fail-on-missing)
        fail_on_missing="yes"
        ;;
        --lrelease=*)
        LRELEASE="${key#*=}"
        ;;
        --lrelease)
        LRELEASE="$1"
        shift
        ;;
        --qmake=*)
        QMAKE="${key#*=}"
        ;;
        --qmake)
        QMAKE="$1"
        shift
        ;;
        --qmake-args)
        # Leave qmake args in $@
        break
        ;;
        *)
        echo WARNING: Unknown option "$key"
        ;;
    esac
done


# check for QT5 qmake
printf "checking for QT5 qmake... "
$QMAKE -help 2>/dev/null 1>/dev/null
test $? -eq 0 && echo "$QMAKE" || \
    errorExit "not found!\n  Try to run configure with \`--qmake /path/to/qmake-executable'." 1

# check for lrelease
printf "checking for lrelease... "
$LRELEASE -help 2>/dev/null 1>/dev/null
test $? -eq 0 && echo "$LRELEASE" || \
    errorExit "not found!\n  Try to run configure with \`--lrelease /path/to/lrelease-executable'." 1

check c++ "$CXX" 1

# check C++ compiler functionality
rm -f test test.cpp
cat << EOF > test.cpp
#include <iostream>

int main()
{
  std::cout << "Hello World!" << std::endl;
  return 0;
}
EOF
printf "checking whether c++ compiler builds test program... "
$CXX -o "$TMPDIR/test" test.cpp && echo "ok" || errorExit "error!" 1
printf "checking whether c++ compiler supports -std=c++0x... "
rm -f test
$CXX -std=c++0x -o "$TMPDIR/test" test.cpp && echo "ok" || errorExit "error!" 1
printf "checking whether compiled test program works... "
"$TMPDIR/test" 2>/dev/null 1>/dev/null && echo "ok" || errorExit "error!" 1
rm -f "$TMPDIR/test" test.cpp

check make "$MAKE" 1
check pkg-config pkg-config 1

# check for libraries via pkg-config
libraries="Qt5Core Qt5Gui Qt5Network Qt5WebEngine Qt5Widgets Qt5WebEngineWidgets Qt5PrintSupport Qt5Svg Qt5WebSockets Qt5WebChannel uchardet"
for l in $libraries ; do
    printf "checking for ${l} library... "
    pkg-config --libs $l 2>/dev/null 1>/dev/null
    test $(echo $?) -eq 0 && pkg-config --libs $l || errorExit "not found!"
done

if [ -f "Makefile" ]; then
    make distclean 2>/dev/null 1>/dev/null || true
fi


printf "generate Makefile... "

$QMAKE PREFIX="$PREFIX" \
QMAKE_CXX="$CXX" \
QMAKE_CXXFLAGS="$CXXFLAGS $CPPFLAGS" \
QMAKE_LFLAGS="$LDFLAGS" \
LRELEASE="$LRELEASE" \
CONFIG+="$BUILDMODE" \
"$@" notepadqq.pro && echo "done" || errorExit "error!" 1