1#!/bin/sh 2# netatalk-config 3 4af_libs= 5af_cflags= 6prefix=/usr/local 7exec_prefix=${prefix} 8 9 10## 11## Define usage() 12## 13usage() 14{ 15 cat <<EOF 16Usage: $0 [OPTIONS] [LIBRARIES] 17Options: 18 --cflags print pre-processor and compiler flags 19 --libs print library linking information 20 --libs-dirs only print the -L/-R part of --libs 21 --libs-names only print the -l part of --libs 22 --help display this help and exit 23 --macros print the path to m4 macros 24 25 --prefix[=DIR] 26 --exec_prefix[=DIR] 27 --version output netatalk version information 28Libraries: 29 netatalk 30EOF 31 exit $1 32} 33 34## 35## Process options 36## 37parse() 38{ 39# we must be called with at least one argument 40if test $# -eq 0; then 41 usage 1 1>&2 42fi 43 44# at least one option should be selected 45case "$1" in 46 --*) 47 ;; 48 *) 49 usage 1 1>&2 50 ;; 51esac 52 53# grab all -- arguments 54while test $# -gt 0; do 55 case "$1" in 56 -*=*) af_optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;; 57 *) af_optarg= ;; 58 esac 59 60 case $1 in 61 --help) 62 usage 0 0>&2 63 ;; 64 --cflags) 65 af_echo_cflags=yes 66 ;; 67 --libs) 68 af_echo_libs_L=yes 69 af_echo_libs_l=yes 70 ;; 71 --libs-dirs) 72 af_echo_libs_L=yes 73 ;; 74 --libs-names) 75 af_echo_libs_l=yes 76 ;; 77 --macros*) 78 79echo -I /usr/local/include/netatalk/macros 80exit 81 82 ;; 83 --prefix=*) 84 prefix=$af_optarg 85 af_prefix_set=yes 86 ;; 87 --prefix) 88 af_echo_prefix=yes 89 ;; 90 --exec_prefix=*) 91 exec_prefix=$af_optarg 92 af_exec_prefix_set=yes 93 ;; 94 --exec_prefix) 95 af_echo_exec_prefix=yes 96 ;; 97 --version) 98 af_echo_version=yes 99 ;; 100 --*) 101 usage 1 1>&2 102 ;; 103 *) 104 break 105 ;; 106 esac 107 shift 108done 109 110# if we have a default library use it 111if test $# -eq 0; then 112if test "X$af_lib_default" != "X"; then 113 af_lib__AF_LIB_DEFAULT=yes 114 return 115fi 116fi 117 118while test $# -gt 0; do 119 case $1 in 120 netatalk) 121 af_lib_netatalk=yes 122 ;; 123 *) 124 usage 1 1>&2 125 ;; 126 esac 127 shift 128done 129} 130 131print_result() 132{ 133if test "X$af_echo_cflags" = "Xyes"; then 134 af_all_flags="$af_cflags" 135fi 136 137if test "X$af_echo_libs_L" = "Xyes" || test "X$af_echo_libs_l" = "Xyes"; then 138 af_all_flags="$af_all_flags $af_libs" 139fi 140 141if test -z "$af_all_flags" || test "X$af_all_flags" = "X "; then 142 exit 1 143fi 144 145# Straight out any possible duplicates, but be careful to 146# get `-lfoo -lbar -lbaz' for `-lfoo -lbaz -lbar -lbaz' 147af_other_flags= 148af_lib_L_flags= 149af_rev_libs= 150for i in $af_all_flags; do 151 case "$i" in 152 # a library, save it for later, in reverse order 153 -l*) af_rev_libs="$i $af_rev_libs" ;; 154 -L*|-R*) 155 if test "X$af_echo_libs_L" = "Xyes"; then 156 case " $af_lib_L_flags " in 157 *\ $i\ *) ;; # already there 158 *) af_lib_L_flags="$af_lib_L_flags $i" ;; # add it to output 159 esac 160 fi;; 161 *) 162 case " $af_other_flags " in 163 *\ $i\ *) ;; # already there 164 *) af_other_flags="$af_other_flags $i" ;; # add it to output 165 esac ;; 166 esac 167done 168 169af_ord_libs= 170if test "X$af_echo_libs_l" = "Xyes"; then 171 for i in $af_rev_libs; do 172 case " $af_ord_libs " in 173 *\ $i\ *) ;; # already there 174 *) af_ord_libs="$i $af_ord_libs" ;; # add it to output in reverse order 175 esac 176 done 177fi 178 179echo $af_other_flags $af_lib_L_flags $af_ord_libs 180} 181 182## 183## Main Body 184## 185 186parse $* 187 188 189## 190## Initialize names 191## 192 193 194 195 196 197if test "X$af_echo_prefix" = "Xyes"; then 198 echo $prefix 199fi 200 201if test "X$af_echo_exec_prefix" = "Xyes"; then 202 echo $exec_prefix 203fi 204 205if test "X$af_echo_version" = "Xyes"; then 206 echo 2.2.5 207 exit 0 208fi 209 210 211## 212## Libraries 213## 214 215#dummy because this should always be selected 216 217 218if test "${prefix}/include" != /usr/include ; then 219 includes="-I${prefix}/include" 220fi 221if test "${exec_prefix}/lib" != /usr/lib ; then 222 libs="-L${exec_prefix}/lib" 223fi 224af_cflags="$af_cflags $includes" 225af_libs="$libs -latalk" 226 227 228 229 230print_result 231 232exit 0 233 234