1335640Shselasky#! /bin/sh 2335640Shselasky 3335640Shselasky# 4335640Shselasky# Script to give the appropriate compiler flags and linker flags 5335640Shselasky# to use when building code that uses libpcap. 6335640Shselasky# 7335640Shselasky# These variables come from the configure script, so includedir and 8335640Shselasky# libdir may be defined in terms of prefix and exec_prefix, so the 9335640Shselasky# latter must be defined as well. 10335640Shselasky# 11335640Shselaskyprefix="@prefix@" 12335640Shselaskyexec_prefix="@exec_prefix@" 13335640Shselaskyincludedir="@includedir@" 14335640Shselaskylibdir="@libdir@" 15335640ShselaskyV_RPATH_OPT="@V_RPATH_OPT@" 16335640ShselaskyLIBS="@LIBS@" 17335640ShselaskyPACKAGE_NAME="@PACKAGE_NAME@" 18335640Shselasky 19335640Shselaskystatic=0 20335640Shselaskyshow_cflags=0 21335640Shselaskyshow_libs=0 22335640Shselaskywhile [ "$#" != 0 ] 23335640Shselaskydo 24335640Shselasky case "$1" in 25335640Shselasky 26335640Shselasky --static) 27335640Shselasky static=1 28335640Shselasky ;; 29335640Shselasky 30335640Shselasky --cflags) 31335640Shselasky show_cflags=1 32335640Shselasky ;; 33335640Shselasky 34335640Shselasky --libs) 35335640Shselasky show_libs=1 36335640Shselasky ;; 37335640Shselasky 38335640Shselasky --additional-libs) 39335640Shselasky show_additional_libs=1 40335640Shselasky ;; 41335640Shselasky esac 42335640Shselasky shift 43335640Shselaskydone 44335640Shselaskyif [ "$V_RPATH_OPT" != "" ] 45335640Shselaskythen 46335640Shselasky # 47335640Shselasky # If libdir isn't /usr/lib, add it to the run-time linker path. 48335640Shselasky # 49335640Shselasky if [ "$libdir" != "/usr/lib" ] 50335640Shselasky then 51335640Shselasky RPATH=$V_RPATH_OPT$libdir 52335640Shselasky fi 53335640Shselaskyfi 54335640Shselaskyif [ "$static" = 1 ] 55335640Shselaskythen 56335640Shselasky # 57335640Shselasky # Include LIBS so that the flags include libraries containing 58335640Shselasky # routines that libpcap uses. 59335640Shselasky # 60335640Shselasky if [ "$show_cflags" = 1 -a "$show_libs" = 1 ] 61335640Shselasky then 62335640Shselasky echo "-I$includedir -L$libdir -lpcap $LIBS" 63335640Shselasky elif [ "$show_cflags" = 1 -a "$show_additional_libs" = 1 ] 64335640Shselasky then 65335640Shselasky echo "-I$includedir -L$libdir $LIBS" 66335640Shselasky elif [ "$show_cflags" = 1 ] 67335640Shselasky then 68335640Shselasky echo "-I$includedir" 69335640Shselasky elif [ "$show_libs" = 1 ] 70335640Shselasky then 71335640Shselasky echo "-L$libdir -lpcap $LIBS" 72335640Shselasky elif [ "$show_additional_libs" = 1 ] 73335640Shselasky then 74335640Shselasky echo "$LIBS" 75335640Shselasky fi 76335640Shselaskyelse 77335640Shselasky # 78335640Shselasky # Omit LIBS - libpcap is assumed to be linked with those 79335640Shselasky # libraries, so there's no need to do so explicitly. 80335640Shselasky # 81335640Shselasky if [ "$show_cflags" = 1 -a "$show_libs" = 1 ] 82335640Shselasky then 83335640Shselasky echo "-I$includedir -L$libdir $RPATH -l$PACKAGE_NAME" 84335640Shselasky elif [ "$show_cflags" = 1 -a "$show_additional_libs" = 1 ] 85335640Shselasky then 86335640Shselasky echo "-I$includedir" 87335640Shselasky elif [ "$show_cflags" = 1 ] 88335640Shselasky then 89335640Shselasky echo "-I$includedir" 90335640Shselasky elif [ "$show_libs" = 1 ] 91335640Shselasky then 92335640Shselasky echo "-L$libdir $RPATH -l$PACKAGE_NAME" 93335640Shselasky fi 94335640Shselaskyfi 95