1 1.1 christos #! /bin/sh 2 1.1 christos 3 1.1 christos # 4 1.1 christos # Script to give the appropriate compiler flags and linker flags 5 1.1 christos # to use when building code that uses libpcap. 6 1.1 christos # 7 1.3 christos prefix="@prefix@" 8 1.3 christos exec_prefix="@exec_prefix@" 9 1.3 christos includedir="@includedir@" 10 1.3 christos libdir="@libdir@" 11 1.3 christos V_RPATH_OPT="@V_RPATH_OPT@" 12 1.3 christos LIBS="@LIBS@" 13 1.3 christos 14 1.1 christos static=0 15 1.1 christos show_cflags=0 16 1.1 christos show_libs=0 17 1.1 christos while [ "$#" != 0 ] 18 1.1 christos do 19 1.1 christos case "$1" in 20 1.1 christos 21 1.1 christos --static) 22 1.1 christos static=1 23 1.1 christos ;; 24 1.1 christos 25 1.1 christos --cflags) 26 1.1 christos show_cflags=1 27 1.1 christos ;; 28 1.1 christos 29 1.1 christos --libs) 30 1.1 christos show_libs=1 31 1.1 christos ;; 32 1.1 christos 33 1.1 christos --additional-libs) 34 1.1 christos show_additional_libs=1 35 1.1 christos ;; 36 1.1 christos esac 37 1.1 christos shift 38 1.1 christos done 39 1.3 christos if [ "$V_RPATH_OPT" != "" ] 40 1.1 christos then 41 1.1 christos # 42 1.1 christos # If libdir isn't /usr/lib, add it to the run-time linker path. 43 1.1 christos # 44 1.3 christos if [ "$libdir" != "/usr/lib" ] 45 1.1 christos then 46 1.3 christos RPATH=$V_RPATH_OPT$libdir 47 1.1 christos fi 48 1.1 christos fi 49 1.2 christos if [ "@includedir@" != "/usr/include" ] 50 1.2 christos then 51 1.2 christos i="-I@includedir@" 52 1.2 christos fi 53 1.2 christos if [ "@libdir@" != "/usr/lib" ] 54 1.2 christos then 55 1.2 christos l="-L@libdir@" 56 1.2 christos fi 57 1.2 christos if [ -n "@LIBS@" ] 58 1.2 christos then 59 1.2 christos L="@LIBS@" 60 1.2 christos fi 61 1.2 christos 62 1.1 christos if [ "$static" = 1 ] 63 1.1 christos then 64 1.1 christos # 65 1.1 christos # Include LIBS so that the flags include libraries containing 66 1.1 christos # routines that libpcap uses. 67 1.1 christos # 68 1.1 christos if [ "$show_cflags" = 1 -a "$show_libs" = 1 ] 69 1.1 christos then 70 1.3 christos echo "-I$includedir -L$libdir -lpcap $LIBS" 71 1.1 christos elif [ "$show_cflags" = 1 -a "$show_additional_libs" = 1 ] 72 1.1 christos then 73 1.3 christos echo "-I$includedir -L$libdir $LIBS" 74 1.1 christos elif [ "$show_cflags" = 1 ] 75 1.1 christos then 76 1.3 christos echo "-I$includedir" 77 1.1 christos elif [ "$show_libs" = 1 ] 78 1.1 christos then 79 1.3 christos echo "-L$libdir -lpcap $LIBS" 80 1.1 christos elif [ "$show_additional_libs" = 1 ] 81 1.1 christos then 82 1.3 christos echo "$LIBS" 83 1.1 christos fi 84 1.1 christos else 85 1.1 christos # 86 1.1 christos # Omit LIBS - libpcap is assumed to be linked with those 87 1.1 christos # libraries, so there's no need to do so explicitly. 88 1.1 christos # 89 1.1 christos if [ "$show_cflags" = 1 -a "$show_libs" = 1 ] 90 1.1 christos then 91 1.3 christos echo "-I$includedir -L$libdir $RPATH -lpcap" 92 1.1 christos elif [ "$show_cflags" = 1 -a "$show_additional_libs" = 1 ] 93 1.1 christos then 94 1.3 christos echo "-I$includedir" 95 1.1 christos elif [ "$show_cflags" = 1 ] 96 1.1 christos then 97 1.3 christos echo "-I$includedir" 98 1.1 christos elif [ "$show_libs" = 1 ] 99 1.1 christos then 100 1.3 christos echo "-L$libdir $RPATH -lpcap" 101 1.1 christos fi 102 1.1 christos fi 103