~drizzle-trunk/drizzle/development

1081.1.1 by Monty Taylor
Whole boat-load of build fixes.
1
# lib-link.m4 serial 18 (gettext-0.18)
2
dnl Copyright (C) 2001-2009 Free Software Foundation, Inc.
202.3.1 by Monty Taylor
Added very initial gettextize stuff.
3
dnl This file is free software; the Free Software Foundation
4
dnl gives unlimited permission to copy and/or distribute it,
5
dnl with or without modifications, as long as this notice is preserved.
6
7
dnl From Bruno Haible.
8
1081.1.1 by Monty Taylor
Whole boat-load of build fixes.
9
AC_PREREQ([2.54])
202.3.1 by Monty Taylor
Added very initial gettextize stuff.
10
11
dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and
12
dnl the libraries corresponding to explicit and implicit dependencies.
13
dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and
14
dnl augments the CPPFLAGS variable.
15
dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname
16
dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
17
AC_DEFUN([AC_LIB_LINKFLAGS],
18
[
19
  AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
20
  AC_REQUIRE([AC_LIB_RPATH])
1081.1.1 by Monty Taylor
Whole boat-load of build fixes.
21
  pushdef([Name],[translit([$1],[./-], [___])])
22
  pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
23
                                [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
202.3.1 by Monty Taylor
Added very initial gettextize stuff.
24
  AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [
25
    AC_LIB_LINKFLAGS_BODY([$1], [$2])
26
    ac_cv_lib[]Name[]_libs="$LIB[]NAME"
27
    ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME"
28
    ac_cv_lib[]Name[]_cppflags="$INC[]NAME"
29
    ac_cv_lib[]Name[]_prefix="$LIB[]NAME[]_PREFIX"
30
  ])
31
  LIB[]NAME="$ac_cv_lib[]Name[]_libs"
32
  LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs"
33
  INC[]NAME="$ac_cv_lib[]Name[]_cppflags"
34
  LIB[]NAME[]_PREFIX="$ac_cv_lib[]Name[]_prefix"
35
  AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
36
  AC_SUBST([LIB]NAME)
37
  AC_SUBST([LTLIB]NAME)
38
  AC_SUBST([LIB]NAME[_PREFIX])
39
  dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the
40
  dnl results of this search when this library appears as a dependency.
41
  HAVE_LIB[]NAME=yes
1081.1.1 by Monty Taylor
Whole boat-load of build fixes.
42
  popdef([NAME])
43
  popdef([Name])
202.3.1 by Monty Taylor
Added very initial gettextize stuff.
44
])
45
992.1.5 by Monty Taylor
Added ability to make a searched-for lib use -isystem so we can do that for protobuf.
46
dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode, [system])
202.3.1 by Monty Taylor
Added very initial gettextize stuff.
47
dnl searches for libname and the libraries corresponding to explicit and
48
dnl implicit dependencies, together with the specified include files and
49
dnl the ability to compile and link the specified testcode. If found, it
50
dnl sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} and
51
dnl LTLIB${NAME} variables and augments the CPPFLAGS variable, and
52
dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs
53
dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty.
54
dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname
55
dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
56
AC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
57
[
58
  AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
59
  AC_REQUIRE([AC_LIB_RPATH])
1081.1.1 by Monty Taylor
Whole boat-load of build fixes.
60
  pushdef([Name],[translit([$1],[./-], [___])])
61
  pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
62
                                [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
202.3.1 by Monty Taylor
Added very initial gettextize stuff.
63
64
  dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME
65
  dnl accordingly.
992.1.5 by Monty Taylor
Added ability to make a searched-for lib use -isystem so we can do that for protobuf.
66
  AC_LIB_LINKFLAGS_BODY([$1], [$2], [$5])
202.3.1 by Monty Taylor
Added very initial gettextize stuff.
67
68
  dnl Add $INC[]NAME to CPPFLAGS before performing the following checks,
69
  dnl because if the user has installed lib[]Name and not disabled its use
70
  dnl via --without-lib[]Name-prefix, he wants to use it.
71
  ac_save_CPPFLAGS="$CPPFLAGS"
72
  AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
73
74
  AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [
75
    ac_save_LIBS="$LIBS"
76
    LIBS="$LIBS $LIB[]NAME"
77
    AC_TRY_LINK([$3], [$4], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name=no])
78
    LIBS="$ac_save_LIBS"
79
  ])
80
  if test "$ac_cv_lib[]Name" = yes; then
81
    HAVE_LIB[]NAME=yes
82
    AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the $1 library.])
83
    AC_MSG_CHECKING([how to link with lib[]$1])
84
    AC_MSG_RESULT([$LIB[]NAME])
85
  else
86
    HAVE_LIB[]NAME=no
87
    dnl If $LIB[]NAME didn't lead to a usable library, we don't need
88
    dnl $INC[]NAME either.
89
    CPPFLAGS="$ac_save_CPPFLAGS"
90
    LIB[]NAME=
91
    LTLIB[]NAME=
92
    LIB[]NAME[]_PREFIX=
93
  fi
94
  AC_SUBST([HAVE_LIB]NAME)
95
  AC_SUBST([LIB]NAME)
96
  AC_SUBST([LTLIB]NAME)
97
  AC_SUBST([LIB]NAME[_PREFIX])
1081.1.1 by Monty Taylor
Whole boat-load of build fixes.
98
  popdef([NAME])
99
  popdef([Name])
202.3.1 by Monty Taylor
Added very initial gettextize stuff.
100
])
101
102
dnl Determine the platform dependent parameters needed to use rpath:
103
dnl   acl_libext,
104
dnl   acl_shlibext,
105
dnl   acl_hardcode_libdir_flag_spec,
106
dnl   acl_hardcode_libdir_separator,
107
dnl   acl_hardcode_direct,
108
dnl   acl_hardcode_minus_L.
109
AC_DEFUN([AC_LIB_RPATH],
110
[
111
  dnl Tell automake >= 1.10 to complain if config.rpath is missing.
112
  m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])])
113
  AC_REQUIRE([AC_PROG_CC])                dnl we use $CC, $GCC, $LDFLAGS
114
  AC_REQUIRE([AC_LIB_PROG_LD])            dnl we use $LD, $with_gnu_ld
115
  AC_REQUIRE([AC_CANONICAL_HOST])         dnl we use $host
116
  AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
1081.1.1 by Monty Taylor
Whole boat-load of build fixes.
117
  AC_CACHE_CHECK([for shared library run path origin], [acl_cv_rpath], [
202.3.1 by Monty Taylor
Added very initial gettextize stuff.
118
    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
119
    ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
120
    . ./conftest.sh
121
    rm -f ./conftest.sh
122
    acl_cv_rpath=done
123
  ])
124
  wl="$acl_cv_wl"
125
  acl_libext="$acl_cv_libext"
126
  acl_shlibext="$acl_cv_shlibext"
127
  acl_libname_spec="$acl_cv_libname_spec"
128
  acl_library_names_spec="$acl_cv_library_names_spec"
129
  acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
130
  acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
131
  acl_hardcode_direct="$acl_cv_hardcode_direct"
132
  acl_hardcode_minus_L="$acl_cv_hardcode_minus_L"
133
  dnl Determine whether the user wants rpath handling at all.
1081.1.1 by Monty Taylor
Whole boat-load of build fixes.
134
  AC_ARG_ENABLE([rpath],
202.3.1 by Monty Taylor
Added very initial gettextize stuff.
135
    [  --disable-rpath         do not hardcode runtime library paths],
136
    :, enable_rpath=yes)
137
])
138
1081.1.1 by Monty Taylor
Whole boat-load of build fixes.
139
dnl AC_LIB_FROMPACKAGE(name, package)
140
dnl declares that libname comes from the given package. The configure file
141
dnl will then not have a --with-libname-prefix option but a
142
dnl --with-package-prefix option. Several libraries can come from the same
143
dnl package. This declaration must occur before an AC_LIB_LINKFLAGS or similar
144
dnl macro call that searches for libname.
145
AC_DEFUN([AC_LIB_FROMPACKAGE],
146
[
147
  pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
148
                                [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
149
  define([acl_frompackage_]NAME, [$2])
150
  popdef([NAME])
151
  pushdef([PACK],[$2])
152
  pushdef([PACKUP],[translit(PACK,[abcdefghijklmnopqrstuvwxyz./-],
153
                                  [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
154
  define([acl_libsinpackage_]PACKUP,
155
    m4_ifdef([acl_libsinpackage_]PACKUP, [acl_libsinpackage_]PACKUP[[, ]],)[lib$1])
156
  popdef([PACKUP])
157
  popdef([PACK])
158
])
159
160
dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies, system]) searches for
161
dnl libname and the libraries corresponding to explicit and implicit
162
dnl dependencies.
202.3.1 by Monty Taylor
Added very initial gettextize stuff.
163
dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
164
dnl Also, sets the LIB${NAME}_PREFIX variable to nonempty if libname was found
165
dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
992.1.5 by Monty Taylor
Added ability to make a searched-for lib use -isystem so we can do that for protobuf.
166
dnl If system==system, -isystem is used instead of -I
202.3.1 by Monty Taylor
Added very initial gettextize stuff.
167
AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
168
[
169
  AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
1081.1.1 by Monty Taylor
Whole boat-load of build fixes.
170
  pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
171
                                [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
172
  pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])])
173
  pushdef([PACKUP],[translit(PACK,[abcdefghijklmnopqrstuvwxyz./-],
174
                                  [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
175
  pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])])
202.3.1 by Monty Taylor
Added very initial gettextize stuff.
176
  dnl Autoconf >= 2.61 supports dots in --with options.
1081.1.1 by Monty Taylor
Whole boat-load of build fixes.
177
  pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[translit(PACK,[.],[_])],PACK)])
202.3.1 by Monty Taylor
Added very initial gettextize stuff.
178
  dnl By default, look in $includedir and $libdir.
179
  use_additional=yes
992.1.6 by Monty Taylor
Dagnabbit. Sun Studio. Sun Studio. Sun Studio.
180
  if test "x$GCC" = "xyes" -a "x$3" = "xsystem"
992.1.5 by Monty Taylor
Added ability to make a searched-for lib use -isystem so we can do that for protobuf.
181
  then
182
    i_system="-isystem "
183
  else
184
    i_system="-I"
185
  fi
1081.1.1 by Monty Taylor
Whole boat-load of build fixes.
186
202.3.1 by Monty Taylor
Added very initial gettextize stuff.
187
  AC_LIB_WITH_FINAL_PREFIX([
188
    eval additional_includedir=\"$includedir\"
189
    eval additional_libdir=\"$libdir\"
190
  ])
1081.1.1 by Monty Taylor
Whole boat-load of build fixes.
191
  AC_ARG_WITH(P_A_C_K[-prefix],
192
[[  --with-]]P_A_C_K[[-prefix[=DIR]  search for ]PACKLIBS[ in DIR/include and DIR/lib
193
  --without-]]P_A_C_K[[-prefix     don't search for ]PACKLIBS[ in includedir and libdir]],
202.3.1 by Monty Taylor
Added very initial gettextize stuff.
194
[
195
    if test "X$withval" = "Xno"; then
196
      use_additional=no
197
    else
198
      if test "X$withval" = "X"; then
199
        AC_LIB_WITH_FINAL_PREFIX([
200
          eval additional_includedir=\"$includedir\"
201
          eval additional_libdir=\"$libdir\"
202
        ])
203
      else
204
        additional_includedir="$withval/include"
205
        additional_libdir="$withval/$acl_libdirstem"
1081.1.1 by Monty Taylor
Whole boat-load of build fixes.
206
        if test "$acl_libdirstem2" != "$acl_libdirstem" \
207
           && ! test -d "$withval/$acl_libdirstem"; then
208
          additional_libdir="$withval/$acl_libdirstem2"
209
        fi
202.3.1 by Monty Taylor
Added very initial gettextize stuff.
210
      fi
211
    fi
212
])
213
  dnl Search the library and its dependencies in $additional_libdir and
214
  dnl $LDFLAGS. Using breadth-first-seach.
215
  LIB[]NAME=
216
  LTLIB[]NAME=
217
  INC[]NAME=
218
  LIB[]NAME[]_PREFIX=
219
  rpathdirs=
220
  ltrpathdirs=
221
  names_already_handled=
222
  names_next_round='$1 $2'
223
  while test -n "$names_next_round"; do
224
    names_this_round="$names_next_round"
225
    names_next_round=
226
    for name in $names_this_round; do
227
      already_handled=
228
      for n in $names_already_handled; do
229
        if test "$n" = "$name"; then
230
          already_handled=yes
231
          break
232
        fi
233
      done
234
      if test -z "$already_handled"; then
235
        names_already_handled="$names_already_handled $name"
236
        dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
237
        dnl or AC_LIB_HAVE_LINKFLAGS call.
238
        uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
239
        eval value=\"\$HAVE_LIB$uppername\"
240
        if test -n "$value"; then
241
          if test "$value" = yes; then
242
            eval value=\"\$LIB$uppername\"
243
            test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value"
244
            eval value=\"\$LTLIB$uppername\"
245
            test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value"
246
          else
247
            dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined
248
            dnl that this library doesn't exist. So just drop it.
249
            :
250
          fi
251
        else
252
          dnl Search the library lib$name in $additional_libdir and $LDFLAGS
253
          dnl and the already constructed $LIBNAME/$LTLIBNAME.
254
          found_dir=
255
          found_la=
256
          found_so=
257
          found_a=
258
          eval libname=\"$acl_libname_spec\"    # typically: libname=lib$name
259
          if test -n "$acl_shlibext"; then
260
            shrext=".$acl_shlibext"             # typically: shrext=.so
261
          else
262
            shrext=
263
          fi
264
          if test $use_additional = yes; then
265
            dir="$additional_libdir"
266
            dnl The same code as in the loop below:
267
            dnl First look for a shared library.
268
            if test -n "$acl_shlibext"; then
269
              if test -f "$dir/$libname$shrext"; then
270
                found_dir="$dir"
271
                found_so="$dir/$libname$shrext"
272
              else
273
                if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
274
                  ver=`(cd "$dir" && \
275
                        for f in "$libname$shrext".*; do echo "$f"; done \
276
                        | sed -e "s,^$libname$shrext\\\\.,," \
277
                        | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
278
                        | sed 1q ) 2>/dev/null`
279
                  if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
280
                    found_dir="$dir"
281
                    found_so="$dir/$libname$shrext.$ver"
282
                  fi
283
                else
284
                  eval library_names=\"$acl_library_names_spec\"
285
                  for f in $library_names; do
286
                    if test -f "$dir/$f"; then
287
                      found_dir="$dir"
288
                      found_so="$dir/$f"
289
                      break
290
                    fi
291
                  done
292
                fi
293
              fi
294
            fi
295
            dnl Then look for a static library.
296
            if test "X$found_dir" = "X"; then
297
              if test -f "$dir/$libname.$acl_libext"; then
298
                found_dir="$dir"
299
                found_a="$dir/$libname.$acl_libext"
300
              fi
301
            fi
302
            if test "X$found_dir" != "X"; then
303
              if test -f "$dir/$libname.la"; then
304
                found_la="$dir/$libname.la"
305
              fi
306
            fi
307
          fi
308
          if test "X$found_dir" = "X"; then
309
            for x in $LDFLAGS $LTLIB[]NAME; do
310
              AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
311
              case "$x" in
312
                -L*)
313
                  dir=`echo "X$x" | sed -e 's/^X-L//'`
314
                  dnl First look for a shared library.
315
                  if test -n "$acl_shlibext"; then
316
                    if test -f "$dir/$libname$shrext"; then
317
                      found_dir="$dir"
318
                      found_so="$dir/$libname$shrext"
319
                    else
320
                      if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
321
                        ver=`(cd "$dir" && \
322
                              for f in "$libname$shrext".*; do echo "$f"; done \
323
                              | sed -e "s,^$libname$shrext\\\\.,," \
324
                              | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
325
                              | sed 1q ) 2>/dev/null`
326
                        if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
327
                          found_dir="$dir"
328
                          found_so="$dir/$libname$shrext.$ver"
329
                        fi
330
                      else
331
                        eval library_names=\"$acl_library_names_spec\"
332
                        for f in $library_names; do
333
                          if test -f "$dir/$f"; then
334
                            found_dir="$dir"
335
                            found_so="$dir/$f"
336
                            break
337
                          fi
338
                        done
339
                      fi
340
                    fi
341
                  fi
342
                  dnl Then look for a static library.
343
                  if test "X$found_dir" = "X"; then
344
                    if test -f "$dir/$libname.$acl_libext"; then
345
                      found_dir="$dir"
346
                      found_a="$dir/$libname.$acl_libext"
347
                    fi
348
                  fi
349
                  if test "X$found_dir" != "X"; then
350
                    if test -f "$dir/$libname.la"; then
351
                      found_la="$dir/$libname.la"
352
                    fi
353
                  fi
354
                  ;;
355
              esac
356
              if test "X$found_dir" != "X"; then
357
                break
358
              fi
359
            done
360
          fi
361
          if test "X$found_dir" != "X"; then
362
            dnl Found the library.
363
            LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name"
364
            if test "X$found_so" != "X"; then
365
              dnl Linking with a shared library. We attempt to hardcode its
366
              dnl directory into the executable's runpath, unless it's the
367
              dnl standard /usr/lib.
1081.1.1 by Monty Taylor
Whole boat-load of build fixes.
368
              if test "$enable_rpath" = no \
369
                 || test "X$found_dir" = "X/usr/$acl_libdirstem" \
370
                 || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then
202.3.1 by Monty Taylor
Added very initial gettextize stuff.
371
                dnl No hardcoding is needed.
372
                LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
373
              else
374
                dnl Use an explicit option to hardcode DIR into the resulting
375
                dnl binary.
376
                dnl Potentially add DIR to ltrpathdirs.
377
                dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
378
                haveit=
379
                for x in $ltrpathdirs; do
380
                  if test "X$x" = "X$found_dir"; then
381
                    haveit=yes
382
                    break
383
                  fi
384
                done
385
                if test -z "$haveit"; then
386
                  ltrpathdirs="$ltrpathdirs $found_dir"
387
                fi
388
                dnl The hardcoding into $LIBNAME is system dependent.
389
                if test "$acl_hardcode_direct" = yes; then
390
                  dnl Using DIR/libNAME.so during linking hardcodes DIR into the
391
                  dnl resulting binary.
392
                  LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
393
                else
394
                  if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
395
                    dnl Use an explicit option to hardcode DIR into the resulting
396
                    dnl binary.
397
                    LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
398
                    dnl Potentially add DIR to rpathdirs.
399
                    dnl The rpathdirs will be appended to $LIBNAME at the end.
400
                    haveit=
401
                    for x in $rpathdirs; do
402
                      if test "X$x" = "X$found_dir"; then
403
                        haveit=yes
404
                        break
405
                      fi
406
                    done
407
                    if test -z "$haveit"; then
408
                      rpathdirs="$rpathdirs $found_dir"
409
                    fi
410
                  else
411
                    dnl Rely on "-L$found_dir".
412
                    dnl But don't add it if it's already contained in the LDFLAGS
413
                    dnl or the already constructed $LIBNAME
414
                    haveit=
415
                    for x in $LDFLAGS $LIB[]NAME; do
416
                      AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
417
                      if test "X$x" = "X-L$found_dir"; then
418
                        haveit=yes
419
                        break
420
                      fi
421
                    done
422
                    if test -z "$haveit"; then
423
                      LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir"
424
                    fi
425
                    if test "$acl_hardcode_minus_L" != no; then
426
                      dnl FIXME: Not sure whether we should use
427
                      dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
428
                      dnl here.
429
                      LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
430
                    else
431
                      dnl We cannot use $acl_hardcode_runpath_var and LD_RUN_PATH
432
                      dnl here, because this doesn't fit in flags passed to the
433
                      dnl compiler. So give up. No hardcoding. This affects only
434
                      dnl very old systems.
435
                      dnl FIXME: Not sure whether we should use
436
                      dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
437
                      dnl here.
438
                      LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
439
                    fi
440
                  fi
441
                fi
442
              fi
443
            else
444
              if test "X$found_a" != "X"; then
445
                dnl Linking with a static library.
446
                LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a"
447
              else
448
                dnl We shouldn't come here, but anyway it's good to have a
449
                dnl fallback.
450
                LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name"
451
              fi
452
            fi
453
            dnl Assume the include files are nearby.
454
            additional_includedir=
455
            case "$found_dir" in
456
              */$acl_libdirstem | */$acl_libdirstem/)
457
                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'`
1081.1.1 by Monty Taylor
Whole boat-load of build fixes.
458
                if test "$name" = '$1'; then
459
                  LIB[]NAME[]_PREFIX="$basedir"
460
                fi
461
                additional_includedir="$basedir/include"
462
                ;;
463
              */$acl_libdirstem2 | */$acl_libdirstem2/)
464
                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'`
465
                if test "$name" = '$1'; then
466
                  LIB[]NAME[]_PREFIX="$basedir"
467
                fi
202.3.1 by Monty Taylor
Added very initial gettextize stuff.
468
                additional_includedir="$basedir/include"
469
                ;;
470
            esac
471
            if test "X$additional_includedir" != "X"; then
472
              dnl Potentially add $additional_includedir to $INCNAME.
473
              dnl But don't add it
474
              dnl   1. if it's the standard /usr/include,
475
              dnl   2. if it's /usr/local/include and we are using GCC on Linux,
476
              dnl   3. if it's already present in $CPPFLAGS or the already
477
              dnl      constructed $INCNAME,
478
              dnl   4. if it doesn't exist as a directory.
479
              if test "X$additional_includedir" != "X/usr/include"; then
480
                haveit=
481
                if test "X$additional_includedir" = "X/usr/local/include"; then
482
                  if test -n "$GCC"; then
483
                    case $host_os in
484
                      linux* | gnu* | k*bsd*-gnu) haveit=yes;;
485
                    esac
486
                  fi
487
                fi
488
                if test -z "$haveit"; then
489
                  for x in $CPPFLAGS $INC[]NAME; do
490
                    AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
992.1.5 by Monty Taylor
Added ability to make a searched-for lib use -isystem so we can do that for protobuf.
491
                    if test "X$x" = "X${i_system}$additional_includedir"; then
202.3.1 by Monty Taylor
Added very initial gettextize stuff.
492
                      haveit=yes
493
                      break
494
                    fi
495
                  done
496
                  if test -z "$haveit"; then
497
                    if test -d "$additional_includedir"; then
498
                      dnl Really add $additional_includedir to $INCNAME.
992.1.5 by Monty Taylor
Added ability to make a searched-for lib use -isystem so we can do that for protobuf.
499
                      INC[]NAME="${INC[]NAME}${INC[]NAME:+ }${i_system}$additional_includedir"
202.3.1 by Monty Taylor
Added very initial gettextize stuff.
500
                    fi
501
                  fi
502
                fi
503
              fi
504
            fi
505
            dnl Look for dependencies.
506
            if test -n "$found_la"; then
507
              dnl Read the .la file. It defines the variables
508
              dnl dlname, library_names, old_library, dependency_libs, current,
509
              dnl age, revision, installed, dlopen, dlpreopen, libdir.
510
              save_libdir="$libdir"
511
              case "$found_la" in
512
                */* | *\\*) . "$found_la" ;;
513
                *) . "./$found_la" ;;
514
              esac
515
              libdir="$save_libdir"
516
              dnl We use only dependency_libs.
517
              for dep in $dependency_libs; do
518
                case "$dep" in
519
                  -L*)
520
                    additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
521
                    dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME.
522
                    dnl But don't add it
523
                    dnl   1. if it's the standard /usr/lib,
524
                    dnl   2. if it's /usr/local/lib and we are using GCC on Linux,
525
                    dnl   3. if it's already present in $LDFLAGS or the already
526
                    dnl      constructed $LIBNAME,
527
                    dnl   4. if it doesn't exist as a directory.
1081.1.1 by Monty Taylor
Whole boat-load of build fixes.
528
                    if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \
529
                       && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then
202.3.1 by Monty Taylor
Added very initial gettextize stuff.
530
                      haveit=
1081.1.1 by Monty Taylor
Whole boat-load of build fixes.
531
                      if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \
532
                         || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then
202.3.1 by Monty Taylor
Added very initial gettextize stuff.
533
                        if test -n "$GCC"; then
534
                          case $host_os in
535
                            linux* | gnu* | k*bsd*-gnu) haveit=yes;;
536
                          esac
537
                        fi
538
                      fi
539
                      if test -z "$haveit"; then
540
                        haveit=
541
                        for x in $LDFLAGS $LIB[]NAME; do
542
                          AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
543
                          if test "X$x" = "X-L$additional_libdir"; then
544
                            haveit=yes
545
                            break
546
                          fi
547
                        done
548
                        if test -z "$haveit"; then
549
                          if test -d "$additional_libdir"; then
550
                            dnl Really add $additional_libdir to $LIBNAME.
551
                            LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir"
552
                          fi
553
                        fi
554
                        haveit=
555
                        for x in $LDFLAGS $LTLIB[]NAME; do
556
                          AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
557
                          if test "X$x" = "X-L$additional_libdir"; then
558
                            haveit=yes
559
                            break
560
                          fi
561
                        done
562
                        if test -z "$haveit"; then
563
                          if test -d "$additional_libdir"; then
564
                            dnl Really add $additional_libdir to $LTLIBNAME.
565
                            LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir"
566
                          fi
567
                        fi
568
                      fi
569
                    fi
570
                    ;;
571
                  -R*)
572
                    dir=`echo "X$dep" | sed -e 's/^X-R//'`
573
                    if test "$enable_rpath" != no; then
574
                      dnl Potentially add DIR to rpathdirs.
575
                      dnl The rpathdirs will be appended to $LIBNAME at the end.
576
                      haveit=
577
                      for x in $rpathdirs; do
578
                        if test "X$x" = "X$dir"; then
579
                          haveit=yes
580
                          break
581
                        fi
582
                      done
583
                      if test -z "$haveit"; then
584
                        rpathdirs="$rpathdirs $dir"
585
                      fi
586
                      dnl Potentially add DIR to ltrpathdirs.
587
                      dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
588
                      haveit=
589
                      for x in $ltrpathdirs; do
590
                        if test "X$x" = "X$dir"; then
591
                          haveit=yes
592
                          break
593
                        fi
594
                      done
595
                      if test -z "$haveit"; then
596
                        ltrpathdirs="$ltrpathdirs $dir"
597
                      fi
598
                    fi
599
                    ;;
600
                  -l*)
601
                    dnl Handle this in the next round.
602
                    names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
603
                    ;;
604
                  *.la)
605
                    dnl Handle this in the next round. Throw away the .la's
606
                    dnl directory; it is already contained in a preceding -L
607
                    dnl option.
608
                    names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
609
                    ;;
610
                  *)
611
                    dnl Most likely an immediate library name.
612
                    LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep"
613
                    LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep"
614
                    ;;
615
                esac
616
              done
617
            fi
618
          else
619
            dnl Didn't find the library; assume it is in the system directories
620
            dnl known to the linker and runtime loader. (All the system
621
            dnl directories known to the linker should also be known to the
622
            dnl runtime loader, otherwise the system is severely misconfigured.)
623
            LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
624
            LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
625
          fi
626
        fi
627
      fi
628
    done
629
  done
630
  if test "X$rpathdirs" != "X"; then
631
    if test -n "$acl_hardcode_libdir_separator"; then
632
      dnl Weird platform: only the last -rpath option counts, the user must
633
      dnl pass all path elements in one option. We can arrange that for a
634
      dnl single library, but not when more than one $LIBNAMEs are used.
635
      alldirs=
636
      for found_dir in $rpathdirs; do
637
        alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir"
638
      done
639
      dnl Note: acl_hardcode_libdir_flag_spec uses $libdir and $wl.
640
      acl_save_libdir="$libdir"
641
      libdir="$alldirs"
642
      eval flag=\"$acl_hardcode_libdir_flag_spec\"
643
      libdir="$acl_save_libdir"
644
      LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
645
    else
646
      dnl The -rpath options are cumulative.
647
      for found_dir in $rpathdirs; do
648
        acl_save_libdir="$libdir"
649
        libdir="$found_dir"
650
        eval flag=\"$acl_hardcode_libdir_flag_spec\"
651
        libdir="$acl_save_libdir"
652
        LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
653
      done
654
    fi
655
  fi
656
  if test "X$ltrpathdirs" != "X"; then
657
    dnl When using libtool, the option that works for both libraries and
658
    dnl executables is -R. The -R options are cumulative.
659
    for found_dir in $ltrpathdirs; do
660
      LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir"
661
    done
662
  fi
1081.1.1 by Monty Taylor
Whole boat-load of build fixes.
663
  popdef([P_A_C_K])
664
  popdef([PACKLIBS])
665
  popdef([PACKUP])
666
  popdef([PACK])
667
  popdef([NAME])
202.3.1 by Monty Taylor
Added very initial gettextize stuff.
668
])
669
670
dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR,
671
dnl unless already present in VAR.
672
dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes
673
dnl contains two or three consecutive elements that belong together.
674
AC_DEFUN([AC_LIB_APPENDTOVAR],
675
[
676
  for element in [$2]; do
677
    haveit=
678
    for x in $[$1]; do
679
      AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
680
      if test "X$x" = "X$element"; then
681
        haveit=yes
682
        break
683
      fi
684
    done
685
    if test -z "$haveit"; then
686
      [$1]="${[$1]}${[$1]:+ }$element"
687
    fi
688
  done
689
])
690
691
dnl For those cases where a variable contains several -L and -l options
692
dnl referring to unknown libraries and directories, this macro determines the
693
dnl necessary additional linker options for the runtime path.
694
dnl AC_LIB_LINKFLAGS_FROM_LIBS([LDADDVAR], [LIBSVALUE], [USE-LIBTOOL])
695
dnl sets LDADDVAR to linker options needed together with LIBSVALUE.
696
dnl If USE-LIBTOOL evaluates to non-empty, linking with libtool is assumed,
697
dnl otherwise linking without libtool is assumed.
698
AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS],
699
[
700
  AC_REQUIRE([AC_LIB_RPATH])
701
  AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
702
  $1=
703
  if test "$enable_rpath" != no; then
704
    if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
705
      dnl Use an explicit option to hardcode directories into the resulting
706
      dnl binary.
707
      rpathdirs=
708
      next=
709
      for opt in $2; do
710
        if test -n "$next"; then
711
          dir="$next"
712
          dnl No need to hardcode the standard /usr/lib.
1081.1.1 by Monty Taylor
Whole boat-load of build fixes.
713
          if test "X$dir" != "X/usr/$acl_libdirstem" \
714
             && test "X$dir" != "X/usr/$acl_libdirstem2"; then
202.3.1 by Monty Taylor
Added very initial gettextize stuff.
715
            rpathdirs="$rpathdirs $dir"
716
          fi
717
          next=
718
        else
719
          case $opt in
720
            -L) next=yes ;;
721
            -L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'`
722
                 dnl No need to hardcode the standard /usr/lib.
1081.1.1 by Monty Taylor
Whole boat-load of build fixes.
723
                 if test "X$dir" != "X/usr/$acl_libdirstem" \
724
                    && test "X$dir" != "X/usr/$acl_libdirstem2"; then
202.3.1 by Monty Taylor
Added very initial gettextize stuff.
725
                   rpathdirs="$rpathdirs $dir"
726
                 fi
727
                 next= ;;
728
            *) next= ;;
729
          esac
730
        fi
731
      done
732
      if test "X$rpathdirs" != "X"; then
733
        if test -n ""$3""; then
734
          dnl libtool is used for linking. Use -R options.
735
          for dir in $rpathdirs; do
736
            $1="${$1}${$1:+ }-R$dir"
737
          done
738
        else
739
          dnl The linker is used for linking directly.
740
          if test -n "$acl_hardcode_libdir_separator"; then
741
            dnl Weird platform: only the last -rpath option counts, the user
742
            dnl must pass all path elements in one option.
743
            alldirs=
744
            for dir in $rpathdirs; do
745
              alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir"
746
            done
747
            acl_save_libdir="$libdir"
748
            libdir="$alldirs"
749
            eval flag=\"$acl_hardcode_libdir_flag_spec\"
750
            libdir="$acl_save_libdir"
751
            $1="$flag"
752
          else
753
            dnl The -rpath options are cumulative.
754
            for dir in $rpathdirs; do
755
              acl_save_libdir="$libdir"
756
              libdir="$dir"
757
              eval flag=\"$acl_hardcode_libdir_flag_spec\"
758
              libdir="$acl_save_libdir"
759
              $1="${$1}${$1:+ }$flag"
760
            done
761
          fi
762
        fi
763
      fi
764
    fi
765
  fi
766
  AC_SUBST([$1])
767
])