2
0
mirror of https://codeberg.org/kiss-community/repo synced 2024-12-23 15:50:06 -07:00
repo/testing/nss/files/nss-config.in
2019-07-28 15:04:33 +03:00

140 lines
2.5 KiB
Bash

#!/bin/sh
prefix=@prefix@
major_version=@MOD_MAJOR_VERSION@
minor_version=@MOD_MINOR_VERSION@
patch_version=@MOD_PATCH_VERSION@
usage() {
cat <<EOF
Usage: nss-config [OPTIONS] [LIBRARIES]
Options:
[--prefix[=DIR]]
[--exec-prefix[=DIR]]
[--includedir[=DIR]]
[--libdir[=DIR]]
[--version]
[--libs]
[--cflags]
Dynamic Libraries:
nss
nssutil
ssl
smime
EOF
exit
}
[ $# = 0 ] && usage
lib_ssl=yes
lib_smime=yes
lib_nss=yes
lib_nssutil=yes
while [ $# -gt 0 ]; do
case "$1" in
-*=*) optarg=${1##*=} ;;
*) optarg= ;;
esac
case $1 in
--prefix=*)
prefix=$optarg
;;
--prefix)
echo_prefix=yes
;;
--exec-prefix=*)
exec_prefix=$optarg
;;
--exec-prefix)
echo_exec_prefix=yes
;;
--includedir=*)
includedir=$optarg
;;
--includedir)
echo_includedir=yes
;;
--libdir=*)
libdir=$optarg
;;
--libdir)
echo_libdir=yes
;;
--version)
printf '%s\n' "${major_version}.${minor_version}.${patch_version}"
;;
--cflags)
echo_cflags=yes
;;
--libs)
echo_libs=yes
;;
ssl)
lib_ssl=yes
;;
smime)
lib_smime=yes
;;
nss)
lib_nss=yes
;;
nssutil)
lib_nssutil=yes
;;
*)
usage
;;
esac
shift
done
# Set variables that may be dependent upon other variables
[ "$exec_prefix" ] || exec_prefix=$(pkg-config --variable=exec_prefix nss)
[ "$includedir" ] || includedir=$(pkg-config --variable=includedir nss)
[ "$libdir" ] || libdir=$(pkg-config --variable=libdir nss)
[ "$echo_prefix" = yes ] &&
printf '%s\n' "$prefix"
[ "$echo_exec_prefix" = yes ] &&
printf '%s\n' "$exec_prefix"
[ "$echo_includedir" = yes ] &&
printf '%s\n' "$includedir"
[ "$echo_libdir" = yes ] &&
printf '%s\n' "$libdir"
[ "$echo_cflags" = yes ] &&
printf '%s\n' "-I$includedir"
[ "$echo_libs" = yes ] && {
libdirs="-Wl,-rpath-link,$libdir -L$libdir"
[ "$lib_ssl" ] && libdirs="$libdirs -lssl$major_version"
[ "$lib_smime" ] && libdirs="$libdirs -lsmime$major_version"
[ "$lib_nss" ] && libdirs="$libdirs -lnss$major_version"
[ "$lib_nssutil" ] && libdirs="$libdirs -lnssutil$major_version"
printf '%s\n' "$libdirs"
}