]> arthur.barton.de Git - netatalk.git/blob - distrib/config/netatalk-config.in
Writing metadata xattr on directories with sticky bit set, FR#94
[netatalk.git] / distrib / config / netatalk-config.in
1 #!/bin/sh
2 # netatalk-config
3
4 af_libs=
5 af_cflags=
6 prefix=@prefix@
7 exec_prefix=@exec_prefix@
8
9
10 ##
11 ## Define usage()
12 ##
13 usage()
14 {
15         cat <<EOF
16 Usage: $0 [OPTIONS] [LIBRARIES]
17 Options:
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
28 Libraries:
29          netatalk
30 EOF
31         exit $1
32 }
33
34 ##
35 ## Process options
36 ##
37 parse()
38 {
39 # we must be called with at least one argument
40 if test $# -eq 0; then
41         usage 1 1>&2
42 fi
43
44 # at least one option should be selected
45 case "$1" in
46   --*)
47      ;;
48   *)
49      usage 1 1>&2
50      ;;
51 esac
52
53 # grab all -- arguments
54 while 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
79 echo -I @prefix@/include/netatalk/macros
80 exit
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
108 done
109
110 # if we have a default library use it
111 if test $# -eq 0; then
112 if test "X$af_lib_default" != "X"; then
113   af_lib__AF_LIB_DEFAULT=yes
114   return
115 fi
116 fi
117
118 while 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
128 done
129 }
130
131 print_result()
132 {
133 if test "X$af_echo_cflags" = "Xyes"; then
134     af_all_flags="$af_cflags"
135 fi
136
137 if test "X$af_echo_libs_L" = "Xyes" || test "X$af_echo_libs_l" = "Xyes"; then
138     af_all_flags="$af_all_flags $af_libs"
139 fi
140
141 if test -z "$af_all_flags" || test "X$af_all_flags" = "X "; then
142     exit 1
143 fi
144
145 # Straight out any possible duplicates, but be careful to
146 # get `-lfoo -lbar -lbaz' for `-lfoo -lbaz -lbar -lbaz'
147 af_other_flags=
148 af_lib_L_flags=
149 af_rev_libs=
150 for 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
167 done
168
169 af_ord_libs=
170 if 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
177 fi
178
179 echo $af_other_flags $af_lib_L_flags $af_ord_libs
180 }
181
182 ##
183 ## Main Body
184 ##
185
186 parse $*
187
188
189 ##
190 ## Initialize names
191 ##
192
193
194
195
196
197 if test "X$af_echo_prefix" = "Xyes"; then
198         echo $prefix
199 fi
200
201 if test "X$af_echo_exec_prefix" = "Xyes"; then
202         echo $exec_prefix
203 fi
204
205 if test "X$af_echo_version" = "Xyes"; then
206         echo @NETATALK_VERSION@
207         exit 0
208 fi
209
210
211 ##
212 ## Libraries
213 ##
214
215 #dummy because this should always be selected
216
217
218 if test "@includedir@" != /usr/include ; then
219   includes="-I@includedir@"
220 fi
221 if test "@libdir@" != /usr/lib ; then
222   libs="-L@libdir@"
223 fi
224 af_cflags="$af_cflags $includes"
225 af_libs="$libs -latalk"
226
227
228
229
230 print_result
231
232 exit 0
233