ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/gvpe/m4/lib-prefix.m4
Revision: 1.1
Committed: Sat Mar 1 15:53:02 2003 UTC (21 years, 2 months ago) by pcg
Branch: MAIN
CVS Tags: rel-1_9, rel-1_8, rel-2_01, poll-based-iom, rel-3_0, VPE_0_9, VPE_1_2, rel-2_2, rel-2_0, VPE_1_4, VPE_1_6, rel-1_7, VPE-1_6_1, rel-2_21, rel-2_22, rel-2_25, VPE_1_0, HEAD
Log Message:
*** empty log message ***

File Contents

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