18232165peter#!/bin/sh
28232165peter# Licensed to the Apache Software Foundation (ASF) under one or more
38232165peter# contributor license agreements.  See the NOTICE file distributed with
48232165peter# this work for additional information regarding copyright ownership.
58232165peter# The ASF licenses this file to You under the Apache License, Version 2.0
68232165peter# (the "License"); you may not use this file except in compliance with
78232165peter# the License.  You may obtain a copy of the License at
88232165peter#
98232165peter#     http://www.apache.org/licenses/LICENSE-2.0
108232165peter#
118232165peter# Unless required by applicable law or agreed to in writing, software
128232165peter# distributed under the License is distributed on an "AS IS" BASIS,
138232165peter# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
148232165peter# See the License for the specific language governing permissions and
158232165peter# limitations under the License.
168232165peter#
178232165peter
188232165peter# APR script designed to allow easy command line access to APR configuration
198232165peter# parameters.
208232165peter
218232165peterAPR_MAJOR_VERSION="@APR_MAJOR_VERSION@"
228232165peterAPR_DOTTED_VERSION="@APR_DOTTED_VERSION@"
238232165peter
248232165peterprefix="@prefix@"
258232165peterexec_prefix="@exec_prefix@"
268232165peterbindir="@bindir@"
278232165peterlibdir="@libdir@"
288232165peterdatarootdir="@datadir@"
298232165peterdatadir="@datadir@"
308232165peterinstallbuilddir="@installbuilddir@"
318232165peterincludedir="@includedir@"
328232165peter
338232165peterCC="@CC@"
348232165peterCPP="@CPP@"
358232165peterSHELL="@SHELL@"
368232165peterCPPFLAGS="@EXTRA_CPPFLAGS@"
378232165peterCFLAGS="@EXTRA_CFLAGS@"
388232165peterLDFLAGS="@EXTRA_LDFLAGS@"
398232165peterLIBS="@EXTRA_LIBS@"
408232165peterEXTRA_INCLUDES="@EXTRA_INCLUDES@"
418232165peterSHLIBPATH_VAR="@shlibpath_var@"
428232165peterAPR_SOURCE_DIR="@apr_srcdir@"
438232165peterAPR_BUILD_DIR="@apr_builddir@"
448232165peterAPR_SO_EXT="@so_ext@"
458232165peterAPR_LIB_TARGET="@export_lib_target@"
468232165peterAPR_LIBNAME="@APR_LIBNAME@"
478232165peter
488232165peter# NOTE: the following line is modified during 'make install': alter with care!
498232165peterlocation=@APR_CONFIG_LOCATION@
508232165peter
518232165petershow_usage()
528232165peter{
538232165peter    cat << EOF
548232165peterUsage: apr-$APR_MAJOR_VERSION-config [OPTION]
558232165peter
568232165peterKnown values for OPTION are:
578232165peter  --prefix[=DIR]    change prefix to DIR
588232165peter  --bindir          print location where binaries are installed
598232165peter  --includedir      print location where headers are installed
608232165peter  --cc              print C compiler name
618232165peter  --cpp             print C preprocessor name and any required options
628232165peter  --cflags          print C compiler flags
638232165peter  --cppflags        print C preprocessor flags
648232165peter  --includes        print include information
658232165peter  --ldflags         print linker flags
668232165peter  --libs            print additional libraries to link against
678232165peter  --srcdir          print APR source directory
688232165peter  --installbuilddir print APR build helper directory
698232165peter  --link-ld         print link switch(es) for linking to APR
708232165peter  --link-libtool    print the libtool inputs for linking to APR
718232165peter  --shlib-path-var  print the name of the shared library path env var
728232165peter  --apr-la-file     print the path to the .la file, if available
738232165peter  --apr-so-ext      print the extensions of shared objects on this platform
748232165peter  --apr-lib-target  print the libtool target information
758232165peter  --apr-libtool     print the path to APR's libtool
768232165peter  --version         print the APR's version as a dotted triple
778232165peter  --help            print this help
788232165peter
798232165peterWhen linking with libtool, an application should do something like:
808232165peter  APR_LIBS="\`apr-$APR_MAJOR_VERSION-config --link-libtool --libs\`"
818232165peteror when linking directly:
828232165peter  APR_LIBS="\`apr-$APR_MAJOR_VERSION-config --link-ld --libs\`"
838232165peter
848232165peterAn application should use the results of --cflags, --cppflags, --includes,
858232165peterand --ldflags in their build process.
868232165peterEOF
878232165peter}
888232165peter
898232165peterif test $# -eq 0; then
908232165peter    show_usage
918232165peter    exit 1
928232165peterfi
938232165peter
948232165peterif test "$location" = "installed"; then
958232165peter    LA_FILE="$libdir/lib${APR_LIBNAME}.la"
968232165peterelse
978232165peter    LA_FILE="$APR_BUILD_DIR/lib${APR_LIBNAME}.la"
988232165peterfi
998232165peter
1008232165peterflags=""
1018232165peter
1028232165peterwhile test $# -gt 0; do
1038232165peter    # Normalize the prefix.
1048232165peter    case "$1" in
1058232165peter    -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
1068232165peter    *) optarg= ;;
1078232165peter    esac
1088232165peter
1098232165peter    case "$1" in
1108232165peter    # It is possible for the user to override our prefix.
1118232165peter    --prefix=*)
1128232165peter    prefix=$optarg
1138232165peter    ;;
1148232165peter    --prefix)
1158232165peter    echo $prefix
1168232165peter    exit 0
1178232165peter    ;;
1188232165peter    --bindir)
1198232165peter    echo $bindir
1208232165peter    exit 0
1218232165peter    ;;
1228232165peter    --includedir)
1238232165peter    if test "$location" = "installed"; then
1248232165peter        flags="$includedir"
1258232165peter    elif test "$location" = "source"; then
1268232165peter        flags="$APR_SOURCE_DIR/include"
1278232165peter    else
1288232165peter        # this is for VPATH builds
1298232165peter        flags="$APR_BUILD_DIR/include $APR_SOURCE_DIR/include"
1308232165peter    fi
1318232165peter    echo $flags
1328232165peter    exit 0
1338232165peter    ;;
1348232165peter    --cc)
1358232165peter    echo $CC
1368232165peter    exit 0
1378232165peter    ;;
1388232165peter    --cpp)
1398232165peter    echo $CPP
1408232165peter    exit 0
1418232165peter    ;;
1428232165peter    --cflags)
1438232165peter    flags="$flags $CFLAGS"
1448232165peter    ;;
1458232165peter    --cppflags)
1468232165peter    flags="$flags $CPPFLAGS"
1478232165peter    ;;
1488232165peter    --libs)
1498232165peter    flags="$flags $LIBS"
1508232165peter    ;;
1518232165peter    --ldflags)
1528232165peter    flags="$flags $LDFLAGS"
1538232165peter    ;;
1548232165peter    --includes)
1558232165peter    if test "$location" = "installed"; then
1568232165peter        flags="$flags -I$includedir $EXTRA_INCLUDES"
1578232165peter    elif test "$location" = "source"; then
1588232165peter        flags="$flags -I$APR_SOURCE_DIR/include $EXTRA_INCLUDES"
1598232165peter    else
1608232165peter        # this is for VPATH builds
1618232165peter        flags="$flags -I$APR_BUILD_DIR/include -I$APR_SOURCE_DIR/include $EXTRA_INCLUDES"
1628232165peter    fi
1638232165peter    ;;
1648232165peter    --srcdir)
1658232165peter    echo $APR_SOURCE_DIR
1668232165peter    exit 0
1678232165peter    ;;
1688232165peter    --installbuilddir)
1698232165peter    if test "$location" = "installed"; then
1708232165peter        echo "${installbuilddir}"
1718232165peter    elif test "$location" = "source"; then
1728232165peter        echo "$APR_SOURCE_DIR/build"
1738232165peter    else
1748232165peter        # this is for VPATH builds
1758232165peter        echo "$APR_BUILD_DIR/build"
1768232165peter    fi
1778232165peter    exit 0
1788232165peter    ;;
1798232165peter    --version)
1808232165peter    echo $APR_DOTTED_VERSION
1818232165peter    exit 0
1828232165peter    ;;
1838232165peter    --link-ld)
1848232165peter    if test "$location" = "installed"; then
1858232165peter        ### avoid using -L if libdir is a "standard" location like /usr/lib
1868232165peter        flags="$flags -L$libdir -l${APR_LIBNAME}"
1878232165peter    else
1888232165peter        ### this surely can't work since the library is in .libs?
1898232165peter        flags="$flags -L$APR_BUILD_DIR -l${APR_LIBNAME}"
1908232165peter    fi
1918232165peter    ;;
1928232165peter    --link-libtool)
1938232165peter    # If the LA_FILE exists where we think it should be, use it.  If we're
1948232165peter    # installed and the LA_FILE does not exist, assume to use -L/-l
1958232165peter    # (the LA_FILE may not have been installed).  If we're building ourselves,
1968232165peter    # we'll assume that at some point the .la file be created.
1978232165peter    if test -f "$LA_FILE"; then
1988232165peter        flags="$flags $LA_FILE"
1998232165peter    elif test "$location" = "installed"; then
2008232165peter        ### avoid using -L if libdir is a "standard" location like /usr/lib
2018232165peter        # Since the user is specifying they are linking with libtool, we
2028232165peter        # *know* that -R will be recognized by libtool.
2038232165peter        flags="$flags -L$libdir -R$libdir -l${APR_LIBNAME}"
2048232165peter    else
2058232165peter        flags="$flags $LA_FILE"
2068232165peter    fi
2078232165peter    ;;
2088232165peter    --shlib-path-var)
2098232165peter    echo "$SHLIBPATH_VAR"
2108232165peter    exit 0
2118232165peter    ;;
2128232165peter    --apr-la-file)
2138232165peter    if test -f "$LA_FILE"; then
2148232165peter        flags="$flags $LA_FILE"
2158232165peter    fi
2168232165peter    ;;
2178232165peter    --apr-so-ext)
2188232165peter    echo "$APR_SO_EXT"
2198232165peter    exit 0
2208232165peter    ;;
2218232165peter    --apr-lib-target)
2228232165peter    echo "$APR_LIB_TARGET"
2238232165peter    exit 0
2248232165peter    ;;
2258232165peter    --apr-libtool)
2268232165peter    if test "$location" = "installed"; then
2278232165peter        echo "${installbuilddir}/libtool"
2288232165peter    else
2298232165peter        echo "$APR_BUILD_DIR/libtool"
2308232165peter    fi
2318232165peter    exit 0
2328232165peter    ;;
2338232165peter    --help)
2348232165peter    show_usage
2358232165peter    exit 0
2368232165peter    ;;
2378232165peter    *)
2388232165peter    show_usage
2398232165peter    exit 1
2408232165peter    ;;
2418232165peter    esac
2428232165peter
2438232165peter    # Next please.
2448232165peter    shift
2458232165peterdone
2468232165peter
2478232165peterif test -n "$flags"; then
2488232165peter  echo "$flags"
2498232165peterfi
2508232165peter
2518232165peterexit 0
252