Correcting the download URL. Also having it search for 'LibreWRT'
[librewrt/.git] / packages / lang / pyqt4 / files / qt_versioning.sh
1 #!/bin/bash
2
3 die()
4 {
5         echo "PyQt qt_versioning.sh: $*" >&2
6         exit 1
7 }
8
9 [ $# -eq 3 ] || die "Invalid arguments"
10
11 action="$1"
12 qtincdir="$2"
13 tmpfile="$3"
14
15 cp -f "$qtincdir/QtCore/qglobal.h" "$tmpfile" || die "cp failed"
16 echo "int QT_VERSION_IS = QT_VERSION;" >> "$tmpfile" || die "patching failed (1)"
17 echo "int QT_EDITION_IS = QT_EDITION;" >> "$tmpfile" || die "patching failed (2)"
18 # First resolve all preprocessor macros
19 cpp -x c++ -traditional-cpp "-I$qtincdir" "$tmpfile" > "$tmpfile.processed" || die "CPP failed"
20
21 if [ "$action" = "version" ]; then
22         raw="$(grep -e 'QT_VERSION_IS' "$tmpfile.processed" | cut -d'=' -f2 | cut -d';' -f1)"
23 elif [ "$action" = "edition" ]; then
24         raw="$(grep -e 'QT_EDITION_IS' "$tmpfile.processed" | cut -d'=' -f2 | cut -d';' -f1)"
25 else
26         die "Invalid action"
27 fi
28 # We use python to evaluate the arithmetic C++ expression. Languages are similar
29 # enough in that area for this to succeed.
30 python -c "print \"%d\" % ($raw)" || die "C++ evaluation failed"
31
32 exit 0