• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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#
7prefix="/usr/local"
8exec_prefix="${prefix}"
9includedir="${prefix}/include"
10libdir="${exec_prefix}/lib"
11V_RPATH_OPT="-Wl,-rpath,"
12LIBS=""
13
14static=0
15show_cflags=0
16show_libs=0
17while [ "$#" != 0 ]
18do
19	case "$1" in
20
21	--static)
22		static=1
23		;;
24
25	--cflags)
26		show_cflags=1
27		;;
28
29	--libs)
30		show_libs=1
31		;;
32
33	--additional-libs)
34		show_additional_libs=1
35		;;
36	esac
37	shift
38done
39if [ "$V_RPATH_OPT" != "" ]
40then
41	#
42	# If libdir isn't /usr/lib, add it to the run-time linker path.
43	#
44	if [ "$libdir" != "/usr/lib" ]
45	then
46		RPATH=$V_RPATH_OPT$libdir
47	fi
48fi
49if [ "$static" = 1 ]
50then
51	#
52	# Include LIBS so that the flags include libraries containing
53	# routines that libpcap uses.
54	#
55	if [ "$show_cflags" = 1 -a "$show_libs" = 1 ]
56	then
57		echo "-I$includedir -L$libdir -lpcap $LIBS"
58	elif [ "$show_cflags" = 1 -a "$show_additional_libs" = 1 ]
59	then
60		echo "-I$includedir -L$libdir $LIBS"
61	elif [ "$show_cflags" = 1 ]
62	then
63		echo "-I$includedir"
64	elif [ "$show_libs" = 1 ]
65	then
66		echo "-L$libdir -lpcap $LIBS"
67	elif [ "$show_additional_libs" = 1 ]
68	then
69		echo "$LIBS"
70	fi
71else
72	#
73	# Omit LIBS - libpcap is assumed to be linked with those
74	# libraries, so there's no need to do so explicitly.
75	#
76	if [ "$show_cflags" = 1 -a "$show_libs" = 1 ]
77	then
78		echo "-I$includedir -L$libdir $RPATH -lpcap"
79	elif [ "$show_cflags" = 1 -a "$show_additional_libs" = 1 ]
80	then
81		echo "-I$includedir"
82	elif [ "$show_cflags" = 1 ]
83	then
84		echo "-I$includedir"
85	elif [ "$show_libs" = 1 ]
86	then
87		echo "-L$libdir $RPATH -lpcap"
88	fi
89fi
90