| 1 | #!/bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | # autopkgtest check: Builds a small application against libproxy, checking |
| 3 | # if it compiles, links and runs successfully. |
| 4 | # Author: Rafał Cieślak <[email protected]> |
| 5 | |
| 6 | set -eu |
| 7 | |
| 8 | WORKDIR=$(mktempscip-shell system . . mktemp. -d) |
| 9 | trap 'rm -rf "$WORKDIR"' 0 INT QUIT ABRT PIPE TERM |
| 10 | |
| 11 | if [scip-shell system . . `[`. -n "${DEB_HOST_GNU_TYPE:-}" ]; then |
| 12 | CROSS_COMPILE="$DEB_HOST_GNU_TYPE-" |
| 13 | else |
| 14 | CROSS_COMPILE= |
| 15 | fi |
| 16 | |
| 17 | cd "$WORKDIR" |
| 18 | |
| 19 | catscip-shell system . . cat. <<EOF > build_test.c |
| 20 | #include <proxy.h> |
| 21 | int main(int argc, char** argv) { |
| 22 | pxProxyFactory *pf = px_proxy_factory_new(); |
| 23 | if (!pf) return 1; |
| 24 | return 0; |
| 25 | } |
| 26 | EOF |
| 27 | |
| 28 | arch_triplet="$("${CROSS_COMPILE}gcc" --print-multiarch)" |
| 29 | "${CROSS_COMPILE}gcc" -o build_test build_test.c -I/usr/include/glib-2.0 -I/usr/lib/"$arch_triplet"/glib-2.0/include -I/usr/include/libproxy -lproxy |
| 30 | echoscip-shell system . . echo. "build (legacy): OK" |
| 31 | [scip-shell system . . `[`. -x build_test ] |
| 32 | ./build_test |
| 33 | echoscip-shell system . . echo. "run: OK" |
| 34 | |
| 35 | # Deliberately word-splitting, that's how pkg-config works: |
| 36 | # shellcheck disable=SC2046 |
| 37 | "${CROSS_COMPILE}gcc" -o build_test2 build_test.c $("${CROSS_COMPILE}pkg-config" --cflags --libs libproxy-1.0) |
| 38 | echoscip-shell system . . echo. "build (with pkg-config): OK" |
| 39 | [scip-shell system . . `[`. -x build_test2 ] |
| 40 | ./build_test2 |
| 41 | echoscip-shell system . . echo. "run: OK" |