apr-config.in revision 272461
113177Srobm#!/bin/sh 213177Srobm# Licensed to the Apache Software Foundation (ASF) under one or more 313177Srobm# contributor license agreements. See the NOTICE file distributed with 413177Srobm# this work for additional information regarding copyright ownership. 513177Srobm# The ASF licenses this file to You under the Apache License, Version 2.0 613177Srobm# (the "License"); you may not use this file except in compliance with 713177Srobm# the License. You may obtain a copy of the License at 813177Srobm# 913177Srobm# http://www.apache.org/licenses/LICENSE-2.0 1013177Srobm# 1113177Srobm# Unless required by applicable law or agreed to in writing, software 1213177Srobm# distributed under the License is distributed on an "AS IS" BASIS, 1313177Srobm# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1413177Srobm# See the License for the specific language governing permissions and 1513177Srobm# limitations under the License. 1613177Srobm# 1713177Srobm 1813177Srobm# APR script designed to allow easy command line access to APR configuration 1913177Srobm# parameters. 2013177Srobm 2113177SrobmAPR_MAJOR_VERSION="@APR_MAJOR_VERSION@" 2213177SrobmAPR_DOTTED_VERSION="@APR_DOTTED_VERSION@" 2313177Srobm 2413177Srobmprefix="@prefix@" 2513177Srobmexec_prefix="@exec_prefix@" 2613177Srobmbindir="@bindir@" 2713177Srobmlibdir="@libdir@" 2813177Srobmdatarootdir="@datadir@" 2913177Srobmdatadir="@datadir@" 3013177Srobminstallbuilddir="@installbuilddir@" 3113177Srobmincludedir="@includedir@" 3213177Srobm 3313177SrobmCC="@CC@" 3413177SrobmCPP="@CPP@" 3513177SrobmSHELL="@SHELL@" 3613177SrobmCPPFLAGS="@EXTRA_CPPFLAGS@" 3713177SrobmCFLAGS="@EXTRA_CFLAGS@" 3813177SrobmLDFLAGS="@EXTRA_LDFLAGS@" 3913177SrobmLIBS="@EXTRA_LIBS@" 4013177SrobmEXTRA_INCLUDES="@EXTRA_INCLUDES@" 4113177SrobmSHLIBPATH_VAR="@shlibpath_var@" 4213177SrobmAPR_SOURCE_DIR="@apr_srcdir@" 4313177SrobmAPR_BUILD_DIR="@apr_builddir@" 4413177SrobmAPR_SO_EXT="@so_ext@" 4513177SrobmAPR_LIB_TARGET="@export_lib_target@" 4613177SrobmAPR_LIBNAME="@APR_LIBNAME@" 4713177Srobm 4813177Srobm# NOTE: the following line is modified during 'make install': alter with care! 49location=@APR_CONFIG_LOCATION@ 50 51show_usage() 52{ 53 cat << EOF 54Usage: apr-$APR_MAJOR_VERSION-config [OPTION] 55 56Known values for OPTION are: 57 --prefix[=DIR] change prefix to DIR 58 --bindir print location where binaries are installed 59 --includedir print location where headers are installed 60 --cc print C compiler name 61 --cpp print C preprocessor name and any required options 62 --cflags print C compiler flags 63 --cppflags print C preprocessor flags 64 --includes print include information 65 --ldflags print linker flags 66 --libs print additional libraries to link against 67 --srcdir print APR source directory 68 --installbuilddir print APR build helper directory 69 --link-ld print link switch(es) for linking to APR 70 --link-libtool print the libtool inputs for linking to APR 71 --shlib-path-var print the name of the shared library path env var 72 --apr-la-file print the path to the .la file, if available 73 --apr-so-ext print the extensions of shared objects on this platform 74 --apr-lib-target print the libtool target information 75 --apr-libtool print the path to APR's libtool 76 --version print the APR's version as a dotted triple 77 --help print this help 78 79When linking with libtool, an application should do something like: 80 APR_LIBS="\`apr-$APR_MAJOR_VERSION-config --link-libtool --libs\`" 81or when linking directly: 82 APR_LIBS="\`apr-$APR_MAJOR_VERSION-config --link-ld --libs\`" 83 84An application should use the results of --cflags, --cppflags, --includes, 85and --ldflags in their build process. 86EOF 87} 88 89if test $# -eq 0; then 90 show_usage 91 exit 1 92fi 93 94if test "$location" = "installed"; then 95 LA_FILE="$libdir/lib${APR_LIBNAME}.la" 96else 97 LA_FILE="$APR_BUILD_DIR/lib${APR_LIBNAME}.la" 98fi 99 100flags="" 101 102while test $# -gt 0; do 103 # Normalize the prefix. 104 case "$1" in 105 -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;; 106 *) optarg= ;; 107 esac 108 109 case "$1" in 110 # It is possible for the user to override our prefix. 111 --prefix=*) 112 prefix=$optarg 113 ;; 114 --prefix) 115 echo $prefix 116 exit 0 117 ;; 118 --bindir) 119 echo $bindir 120 exit 0 121 ;; 122 --includedir) 123 if test "$location" = "installed"; then 124 flags="$includedir" 125 elif test "$location" = "source"; then 126 flags="$APR_SOURCE_DIR/include" 127 else 128 # this is for VPATH builds 129 flags="$APR_BUILD_DIR/include $APR_SOURCE_DIR/include" 130 fi 131 echo $flags 132 exit 0 133 ;; 134 --cc) 135 echo $CC 136 exit 0 137 ;; 138 --cpp) 139 echo $CPP 140 exit 0 141 ;; 142 --cflags) 143 flags="$flags $CFLAGS" 144 ;; 145 --cppflags) 146 flags="$flags $CPPFLAGS" 147 ;; 148 --libs) 149 flags="$flags $LIBS" 150 ;; 151 --ldflags) 152 flags="$flags $LDFLAGS" 153 ;; 154 --includes) 155 if test "$location" = "installed"; then 156 flags="$flags -I$includedir $EXTRA_INCLUDES" 157 elif test "$location" = "source"; then 158 flags="$flags -I$APR_SOURCE_DIR/include $EXTRA_INCLUDES" 159 else 160 # this is for VPATH builds 161 flags="$flags -I$APR_BUILD_DIR/include -I$APR_SOURCE_DIR/include $EXTRA_INCLUDES" 162 fi 163 ;; 164 --srcdir) 165 echo $APR_SOURCE_DIR 166 exit 0 167 ;; 168 --installbuilddir) 169 if test "$location" = "installed"; then 170 echo "${installbuilddir}" 171 elif test "$location" = "source"; then 172 echo "$APR_SOURCE_DIR/build" 173 else 174 # this is for VPATH builds 175 echo "$APR_BUILD_DIR/build" 176 fi 177 exit 0 178 ;; 179 --version) 180 echo $APR_DOTTED_VERSION 181 exit 0 182 ;; 183 --link-ld) 184 if test "$location" = "installed"; then 185 ### avoid using -L if libdir is a "standard" location like /usr/lib 186 flags="$flags -L$libdir -l${APR_LIBNAME}" 187 else 188 ### this surely can't work since the library is in .libs? 189 flags="$flags -L$APR_BUILD_DIR -l${APR_LIBNAME}" 190 fi 191 ;; 192 --link-libtool) 193 # If the LA_FILE exists where we think it should be, use it. If we're 194 # installed and the LA_FILE does not exist, assume to use -L/-l 195 # (the LA_FILE may not have been installed). If we're building ourselves, 196 # we'll assume that at some point the .la file be created. 197 if test -f "$LA_FILE"; then 198 flags="$flags $LA_FILE" 199 elif test "$location" = "installed"; then 200 ### avoid using -L if libdir is a "standard" location like /usr/lib 201 # Since the user is specifying they are linking with libtool, we 202 # *know* that -R will be recognized by libtool. 203 flags="$flags -L$libdir -R$libdir -l${APR_LIBNAME}" 204 else 205 flags="$flags $LA_FILE" 206 fi 207 ;; 208 --shlib-path-var) 209 echo "$SHLIBPATH_VAR" 210 exit 0 211 ;; 212 --apr-la-file) 213 if test -f "$LA_FILE"; then 214 flags="$flags $LA_FILE" 215 fi 216 ;; 217 --apr-so-ext) 218 echo "$APR_SO_EXT" 219 exit 0 220 ;; 221 --apr-lib-target) 222 echo "$APR_LIB_TARGET" 223 exit 0 224 ;; 225 --apr-libtool) 226 if test "$location" = "installed"; then 227 echo "${installbuilddir}/libtool" 228 else 229 echo "$APR_BUILD_DIR/libtool" 230 fi 231 exit 0 232 ;; 233 --help) 234 show_usage 235 exit 0 236 ;; 237 *) 238 show_usage 239 exit 1 240 ;; 241 esac 242 243 # Next please. 244 shift 245done 246 247if test -n "$flags"; then 248 echo "$flags" 249fi 250 251exit 0 252