michael@0: # -*- tab-width: 4; -*- michael@0: # Configure paths for NSPR michael@0: # Public domain - Chris Seawood 2001-04-05 michael@0: # Based upon gtk.m4 (also PD) by Owen Taylor michael@0: michael@0: dnl AM_PATH_NSPR([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) michael@0: dnl Test for NSPR, and define NSPR_CFLAGS and NSPR_LIBS michael@0: dnl michael@0: dnl If the nspr-config script is available, use it to find the michael@0: dnl appropriate CFLAGS and LIBS, and to check for the required michael@0: dnl version, and run ACTION-IF-FOUND. michael@0: dnl michael@0: dnl Otherwise, if NO_NSPR_CONFIG_SYSTEM_VERSION is set, we use it, michael@0: dnl NO_NSPR_CONFIG_SYSTEM_CFLAGS, and NO_NSPR_CONFIG_SYSTEM_LIBS to michael@0: dnl provide default values, and run ACTION-IF-FOUND. (Some systems michael@0: dnl ship NSPR without nspr-config, but can glean the appropriate flags michael@0: dnl and version.) michael@0: dnl michael@0: dnl Otherwise, run ACTION-IF-NOT-FOUND. michael@0: AC_DEFUN([AM_PATH_NSPR], michael@0: [dnl michael@0: michael@0: AC_ARG_WITH(nspr-prefix, michael@0: [ --with-nspr-prefix=PFX Prefix where NSPR is installed], michael@0: nspr_config_prefix="$withval", michael@0: nspr_config_prefix="") michael@0: michael@0: AC_ARG_WITH(nspr-exec-prefix, michael@0: [ --with-nspr-exec-prefix=PFX michael@0: Exec prefix where NSPR is installed], michael@0: nspr_config_exec_prefix="$withval", michael@0: nspr_config_exec_prefix="") michael@0: michael@0: if test -n "$nspr_config_exec_prefix"; then michael@0: nspr_config_args="$nspr_config_args --exec-prefix=$nspr_config_exec_prefix" michael@0: if test -z "$NSPR_CONFIG"; then michael@0: NSPR_CONFIG=$nspr_config_exec_prefix/bin/nspr-config michael@0: fi michael@0: fi michael@0: if test -n "$nspr_config_prefix"; then michael@0: nspr_config_args="$nspr_config_args --prefix=$nspr_config_prefix" michael@0: if test -z "$NSPR_CONFIG"; then michael@0: NSPR_CONFIG=$nspr_config_prefix/bin/nspr-config michael@0: fi michael@0: fi michael@0: michael@0: unset ac_cv_path_NSPR_CONFIG michael@0: AC_PATH_PROG(NSPR_CONFIG, nspr-config, no) michael@0: min_nspr_version=ifelse([$1], ,4.0.0,$1) michael@0: AC_MSG_CHECKING(for NSPR - version >= $min_nspr_version) michael@0: michael@0: no_nspr="" michael@0: if test "$NSPR_CONFIG" != "no"; then michael@0: NSPR_CFLAGS=`$NSPR_CONFIG $nspr_config_args --cflags` michael@0: NSPR_LIBS=`$NSPR_CONFIG $nspr_config_args --libs` michael@0: NSPR_VERSION_STRING=`$NSPR_CONFIG $nspr_config_args --version` michael@0: elif test -n "${NO_NSPR_CONFIG_SYSTEM_VERSION}"; then michael@0: NSPR_CFLAGS="${NO_NSPR_CONFIG_SYSTEM_CFLAGS}" michael@0: NSPR_LIBS="${NO_NSPR_CONFIG_SYSTEM_LDFLAGS}" michael@0: NSPR_VERSION_STRING="$NO_NSPR_CONFIG_SYSTEM_VERSION" michael@0: else michael@0: no_nspr="yes" michael@0: fi michael@0: michael@0: if test -z "$no_nspr"; then michael@0: nspr_config_major_version=`echo $NSPR_VERSION_STRING | \ michael@0: sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` michael@0: nspr_config_minor_version=`echo $NSPR_VERSION_STRING | \ michael@0: sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` michael@0: nspr_config_micro_version=`echo $NSPR_VERSION_STRING | \ michael@0: sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` michael@0: min_nspr_major_version=`echo $min_nspr_version | \ michael@0: sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` michael@0: min_nspr_minor_version=`echo $min_nspr_version | \ michael@0: sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` michael@0: min_nspr_micro_version=`echo $min_nspr_version | \ michael@0: sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` michael@0: if test "$nspr_config_major_version" -ne "$min_nspr_major_version"; then michael@0: no_nspr="yes" michael@0: elif test "$nspr_config_major_version" -eq "$min_nspr_major_version" && michael@0: test "$nspr_config_minor_version" -lt "$min_nspr_minor_version"; then michael@0: no_nspr="yes" michael@0: elif test "$nspr_config_major_version" -eq "$min_nspr_major_version" && michael@0: test "$nspr_config_minor_version" -eq "$min_nspr_minor_version" && michael@0: test "$nspr_config_micro_version" -lt "$min_nspr_micro_version"; then michael@0: no_nspr="yes" michael@0: fi michael@0: fi michael@0: michael@0: if test -z "$no_nspr"; then michael@0: AC_MSG_RESULT(yes) michael@0: ifelse([$2], , :, [$2]) michael@0: else michael@0: AC_MSG_RESULT(no) michael@0: ifelse([$3], , :, [$3]) michael@0: fi michael@0: michael@0: michael@0: AC_SUBST(NSPR_CFLAGS) michael@0: AC_SUBST(NSPR_LIBS) michael@0: michael@0: ])