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