| 1 |
#!/bin/sh |
| 2 |
# vim:set sw=4 sts=4 et: |
| 3 |
# Copyright 2021 Simon McVittie |
| 4 |
# SPDX-License-Identifier: LGPL-2.1-or-later |
| 5 |
|
| 6 |
set -eux |
| 7 |
|
| 8 |
WORKDIR="$(mktemp -d)" |
| 9 |
trap 'cd /; rm -fr "$WORKDIR"' EXIT |
| 10 |
|
| 11 |
if [ -n "${DEB_HOST_GNU_TYPE:-}" ]; then |
| 12 |
CROSS_COMPILE="$DEB_HOST_GNU_TYPE-" |
| 13 |
else |
| 14 |
CROSS_COMPILE= |
| 15 |
fi |
| 16 |
|
| 17 |
CC="${CROSS_COMPILE}gcc" |
| 18 |
PKG_CONFIG="${CROSS_COMPILE}pkg-config" |
| 19 |
|
| 20 |
cd "$WORKDIR" |
| 21 |
|
| 22 |
cat > test.c <<EOF |
| 23 |
#include <crypt.h> |
| 24 |
#include <stdio.h> |
| 25 |
#include <stdlib.h> |
| 26 |
|
| 27 |
int main (int argc, char **argv) { |
| 28 |
char *salt; |
| 29 |
|
| 30 |
salt = crypt_gensalt_ra(NULL, 0, NULL, 0); |
| 31 |
|
| 32 |
if (salt == NULL) { |
| 33 |
perror("crypt_gensalt_ra"); |
| 34 |
return 1; |
| 35 |
} |
| 36 |
|
| 37 |
free(salt); |
| 38 |
return 0; |
| 39 |
} |
| 40 |
EOF |
| 41 |
|
| 42 |
# Deliberately word-splitting pkg-config's output: |
| 43 |
# shellcheck disable=SC2046 |
| 44 |
"$CC" -o test-crypt test.c $("$PKG_CONFIG" --cflags --libs libcrypt) |
| 45 |
./test-crypt |
| 46 |
|
| 47 |
# shellcheck disable=SC2046 |
| 48 |
"$CC" -o test-crypt-static -static test.c $("$PKG_CONFIG" --static --cflags --libs libcrypt) |
| 49 |
./test-crypt-static |
| 50 |
|
| 51 |
# shellcheck disable=SC2046 |
| 52 |
"$CC" -o test-xcrypt test.c $("$PKG_CONFIG" --cflags --libs libxcrypt) |
| 53 |
./test-xcrypt |
| 54 |
|
| 55 |
# shellcheck disable=SC2046 |
| 56 |
"$CC" -o test-xcrypt-static -static test.c $("$PKG_CONFIG" --static --cflags --libs libxcrypt) |
| 57 |
./test-xcrypt-static |
| 58 |
|
| 59 |
"$CC" -o test-dynamic test.c -lcrypt |
| 60 |
./test-dynamic |
| 61 |
|
| 62 |
"$CC" -o test-static -static test.c -lcrypt |
| 63 |
./test-static |
| 64 |
|