Updated Bulgarian translation for the binutils/ directory
[binutils-gdb.git] / config / lib-prefix.m4
blob0c6ce029d66dead3d83a7cb7a3aada16f2779fa4
1 # lib-prefix.m4 serial 2 (gettext-0.12)
2 dnl Copyright (C) 2001-2003 Free Software Foundation, Inc.
3 dnl This file is free software, distributed under the terms of the GNU
4 dnl General Public License.  As a special exception to the GNU General
5 dnl Public License, this file may be distributed as part of a program
6 dnl that contains a configuration script generated by Autoconf, under
7 dnl the same distribution terms as the rest of that program.
9 dnl From Bruno Haible.
11 dnl AC_LIB_ARG_WITH is similar to AC_ARG_WITH except that it doesn't
12 dnl require excessive bracketing.
13 AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])
15 dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed
16 dnl to access previously installed libraries. The basic assumption is that
17 dnl a user will want packages to use other packages he previously installed
18 dnl with the same --prefix option.
19 dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate
20 dnl libraries, but is otherwise very convenient.
21 AC_DEFUN([AC_LIB_PREFIX],
23   AC_BEFORE([$0], [AC_LIB_LINKFLAGS])
24   AC_REQUIRE([AC_PROG_CC])
25   AC_REQUIRE([AC_CANONICAL_HOST])
26   AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
27   dnl By default, look in $includedir and $libdir.
28   use_additional=yes
29   AC_LIB_WITH_FINAL_PREFIX([
30     eval additional_includedir=\"$includedir\"
31     eval additional_libdir=\"$libdir\"
32   ])
33   AC_LIB_ARG_WITH([lib-prefix],
34 [  --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib
35   --without-lib-prefix    don't search for libraries in includedir and libdir],
37     if test "X$withval" = "Xno"; then
38       use_additional=no
39     else
40       if test "X$withval" = "X"; then
41         AC_LIB_WITH_FINAL_PREFIX([
42           eval additional_includedir=\"$includedir\"
43           eval additional_libdir=\"$libdir\"
44         ])
45       else
46         additional_includedir="$withval/include"
47         additional_libdir="$withval/lib"
48       fi
49     fi
51   if test $use_additional = yes; then
52     dnl Potentially add $additional_includedir to $CPPFLAGS.
53     dnl But don't add it
54     dnl   1. if it's the standard /usr/include,
55     dnl   2. if it's already present in $CPPFLAGS,
56     dnl   3. if it's /usr/local/include and we are using GCC on Linux,
57     dnl   4. if it doesn't exist as a directory.
58     if test "X$additional_includedir" != "X/usr/include"; then
59       haveit=
60       for x in $CPPFLAGS; do
61         AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
62         if test "X$x" = "X-I$additional_includedir"; then
63           haveit=yes
64           break
65         fi
66       done
67       if test -z "$haveit"; then
68         if test "X$additional_includedir" = "X/usr/local/include"; then
69           if test -n "$GCC"; then
70             case $host_os in
71               linux*) haveit=yes;;
72             esac
73           fi
74         fi
75         if test -z "$haveit"; then
76           if test -d "$additional_includedir"; then
77             dnl Really add $additional_includedir to $CPPFLAGS.
78             CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir"
79           fi
80         fi
81       fi
82     fi
83     dnl Potentially add $additional_libdir to $LDFLAGS.
84     dnl But don't add it
85     dnl   1. if it's the standard /usr/lib,
86     dnl   2. if it's already present in $LDFLAGS,
87     dnl   3. if it's /usr/local/lib and we are using GCC on Linux,
88     dnl   4. if it doesn't exist as a directory.
89     if test "X$additional_libdir" != "X/usr/lib"; then
90       haveit=
91       for x in $LDFLAGS; do
92         AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
93         if test "X$x" = "X-L$additional_libdir"; then
94           haveit=yes
95           break
96         fi
97       done
98       if test -z "$haveit"; then
99         if test "X$additional_libdir" = "X/usr/local/lib"; then
100           if test -n "$GCC"; then
101             case $host_os in
102               linux*) haveit=yes;;
103             esac
104           fi
105         fi
106         if test -z "$haveit"; then
107           if test -d "$additional_libdir"; then
108             dnl Really add $additional_libdir to $LDFLAGS.
109             LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir"
110           fi
111         fi
112       fi
113     fi
114   fi
117 dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix,
118 dnl acl_final_exec_prefix, containing the values to which $prefix and
119 dnl $exec_prefix will expand at the end of the configure script.
120 AC_DEFUN([AC_LIB_PREPARE_PREFIX],
122   dnl Unfortunately, prefix and exec_prefix get only finally determined
123   dnl at the end of configure.
124   if test "X$prefix" = "XNONE"; then
125     acl_final_prefix="$ac_default_prefix"
126   else
127     acl_final_prefix="$prefix"
128   fi
129   if test "X$exec_prefix" = "XNONE"; then
130     acl_final_exec_prefix='${prefix}'
131   else
132     acl_final_exec_prefix="$exec_prefix"
133   fi
134   acl_save_prefix="$prefix"
135   prefix="$acl_final_prefix"
136   eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
137   prefix="$acl_save_prefix"
140 dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the
141 dnl variables prefix and exec_prefix bound to the values they will have
142 dnl at the end of the configure script.
143 AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX],
145   acl_save_prefix="$prefix"
146   prefix="$acl_final_prefix"
147   acl_save_exec_prefix="$exec_prefix"
148   exec_prefix="$acl_final_exec_prefix"
149   $1
150   exec_prefix="$acl_save_exec_prefix"
151   prefix="$acl_save_prefix"