File: aclocal_shl.m4

package info (click to toggle)
mpich2 1.2.1.1-5
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 73,904 kB
  • ctags: 65,947
  • sloc: ansic: 343,583; makefile: 55,174; java: 34,959; sh: 27,558; perl: 17,355; cpp: 10,472; python: 9,649; f90: 5,753; fortran: 5,128; cs: 4,019; csh: 152; xml: 91; php: 8
file content (355 lines) | stat: -rw-r--r-- 13,124 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
dnl
dnl Definitions for creating shared libraries
dnl
dnl The purpose of these definitions is to provide common support for 
dnl shared libraries, with *or without* the use of the GNU Libtool package.
dnl For many of our important platforms, the Libtool approach is overkill,
dnl and can be particularly painful for developers.
dnl
dnl To use libtool, you need macros that are defined by libtool for libtool
dnl Don't even think about the consequences of this for updating and for
dnl using user-versions of libtool :(
dnl 
dnl !!!!!!!!!!!!!!!!!!!!!
dnl libtool requires ac 2.50 !!!!!!!!!!!!!!!!!
dnl 
dnl builtin(include,libtool.m4)
dnl
dnl/*D
dnl PAC_ARG_SHAREDLIBS - Add --enable-sharedlibs=kind to configure.
dnl 
dnl Synopsis:
dnl PAC_ARG_SHAREDLIBS
dnl
dnl Output effects:
dnl Adds '--enable-sharedlibs=kind' to the command line.  If this is enabled,
dnl then based on the value of 'kind', programs are selected for the 
dnl names 'CC_SHL' and 'CC_LINK_SHL' that configure will substitute for in
dnl 'Makefile.in's.  These symbols are generated by 'simplemake' when
dnl shared library support is selected.
dnl The variable 'C_LINKPATH_SHL' is set to the option to specify the 
dnl path to search at runtime for libraries (-rpath in gcc/GNU ld).
dnl The variable 'SHLIB_EXT' is set to the extension used by shared 
dnl libraries; under most forms of Unix, this is 'so'; under Mac OS/X, this
dnl is 'dylib', and under Windows (including cygwin), this is 'dll'.
dnl
dnl Supported values of 'kind' include \:
dnl+    gcc - Use gcc to create both shared objects and libraries
dnl.    osx-gcc - Use gcc on Mac OS/X to create both shared objects and
dnl               libraries
dnl.    solaris-cc - Use native Solaris cc to create shared objects and 
dnl               libraries
dnl.    cygwin-gcc - Use gcc on Cygwin to create shared objects and libraries
dnl-    none - The same as '--disable-sharedlibs'
dnl
dnl Others will be added as experience dictates.  Likely names are
dnl + libtool - For general GNU libtool
dnl - linux-pgcc - For Portland group under Linux
dnl
dnl Notes:
dnl Shared libraries are only partially implemented.  Additional symbols
dnl will probably be defined, including symbols to specify how shared library
dnl search paths are specified and how shared library names are set.
dnl D*/
AC_DEFUN([PAC_ARG_SHAREDLIBS],[
AC_ARG_ENABLE(sharedlibs,
[--enable-sharedlibs=kind - Enable shared libraries.  kind may be
    gcc     - Standard gcc and GNU ld options for creating shared libraries
    osx-gcc - Special options for gcc needed only on OS/X
    solaris-cc - Solaris native (SPARC) compilers for 32 bit systems
    cygwin-gcc - Special options for gcc needed only for cygwin
    none    - same as --disable-sharedlibs
Only gcc, osx-gcc, and solaris-cc are currently supported],
,enable_sharedlibs=none;enable_shared=no)
dnl
CC_SHL=true
C_LINK_SHL=true
SHLIB_EXT=unknown
SHLIB_FROM_LO=no
SHLIB_INSTALL='$(INSTALL_PROGRAM)'
case "$enable_sharedlibs" in 
    no|none)
    ;;
    gcc-osx|osx-gcc)
    AC_MSG_RESULT([Creating shared libraries using GNU for Mac OSX])
    C_LINK_SHL='${CC} -dynamiclib -undefined suppress -single_module -flat_namespace'
    CC_SHL='${CC} -fPIC'
    # No way in osx to specify the location of the shared libraries at link
    # time (see the code in createshlib in mpich2/src/util)
    C_LINKPATH_SHL=""
    SHLIB_EXT="dylib"
    enable_sharedlibs="osx-gcc"
    ;;
    gcc)
    AC_MSG_RESULT([Creating shared libraries using GNU])
    # Not quite right yet.  See mpich/util/makesharedlib
    # Use syntax that works in both Make and the shell
    #C_LINK_SHL='${CC} -shared -Wl,-r'
    C_LINK_SHL='${CC} -shared'
    # For example, include the libname as ${LIBNAME_SHL}
    #C_LINK_SHL='${CC} -shared -Wl,-h,<finallibname>'
    # May need -fPIC .  Test to see which one works.
    PAC_C_CHECK_COMPILER_OPTION(-fpic,fpic_ok=yes,fpic_ok=no)
    if test "$fpic_ok" != yes ; then
        PAC_C_CHECK_COMPILER_OPTION(-fPIC,fPIC_ok=yes,fPIC_ok=no)
        if test "$fPIC_ok" != yes ; then
	     AC_MSG_ERROR([Neither -fpic nor -fPIC accepted by $CC])
        else
	     CC_SHL='${CC} -fPIC'
        fi
    else
        CC_SHL='${CC} -fpic'
    fi
    #C_LINKPATH_SHL="-Wl,-rpath -Wl,"
    # More recent versions allow multiple args, separated by commas
    C_LINKPATH_SHL="-Wl,-rpath,"
    SHLIB_EXT=so
    # We need to test that this isn't osx.  The following is a 
    # simple hack
    osname=`uname -s`
    case $osname in 
        *Darwin*|*darwin*)
	AC_MSG_ERROR([You must specify --enable-sharedlibs=osx-gcc for Mac OS/X])
        ;;	
        *CYGWIN*|*cygwin*)
	AC_MSG_ERROR([You must specify --enable-sharedlibs=cygwin-gcc for Cygwin])
	;;
	*SunOS*)
	AC_MSG_ERROR([You must specify --enable-sharedlibs=solaris-gcc for Solaris with gcc])
	;;
    esac
    ;;

    cygwin|cygwin-gcc|gcc-cygwin)
    AC_MSG_RESULT([Creating shared libraries using GNU under CYGWIN])
    C_LINK_SHL='${CC} -shared'
    CC_SHL='${CC}'
    # DLL Libraries need to be in the user's path (!)
    C_LINKPATH_SHL=""
    SHLIB_EXT="dll"
    enable_sharedlibs="cygwin-gcc"
    ;;	

    libtool)
    # set TRY_LIBTOOL to yes to experiment with libtool.  You are on your
    # own - only send fixes, not bug reports.
    if test "$TRY_LIBTOOL" != yes ; then
        AC_MSG_ERROR([Creating shared libraries using libtool not yet supported])
    else
    # Using libtool requires a heavy-weight process to test for 
    # various stuff that libtool needs.  Without this, you'll get a
    # bizarre error message about libtool being unable to find
    # configure.in or configure.ac (!)
        # Libtool expects to see at least enable-shared.
        if test "X$enable_shared" = "X" ; then enable_shared=yes ; fi
	# Initialize libtool
	# This works, but libtool version 2 places the object files
	# in a different place, making it harder to integrate with
	# our base approach.  Disabling for now
	dnl LT_PREREQ([2.2.6])
        dnl LT_INIT([disable-shared])
	AC_MSG_ERROR([To use this test verison, edit aclocal_shl.m4])
        # Likely to be
        # either CC or CC_SHL is libtool $cc
        CC_SHL='${LIBTOOL} --mode=compile ${CC}'
        # CC_LINK_SHL includes the final installation path
        # For many systems, the link may need to include *all* libraries
        # (since many systems don't allow any unsatisfied dependencies)
        # We need to give libtool the .lo file, not the .o files
        SHLIB_FROM_LO=yes
        # We also need to add -no-undefined when the compiler is gcc and
        # we are building under cygwin
        sysname=`uname -s | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
        isCygwin=no
        case "$sysname" in 
 	*CYGWIN*) isCygwin=yes ;;
        esac
        if test "$isCygwin" = yes ; then
            C_LINK_SHL='${LIBTOOL} --mode=link ${CC} -no-undefined -rpath ${libdir}'
        else
            C_LINK_SHL='${LIBTOOL} --mode=link ${CC} -rpath ${libdir}'
        fi
        C_LINKPATH_SHL="-rpath "
        # We also need a special install process with libtool.  Note that this
        # will also install the static libraries
        SHLIB_INSTALL='$(LIBTOOL) --mode=install $(INSTALL_PROGRAM)'
        # Note we may still need to add
        #'$(LIBTOOL) --mode=finish $(libdir)'
    fi
    ;;
dnl
dnl Other, such as solaris-cc
    solaris|solaris-cc)
    AC_MSG_RESULT([Creating shared libraries using Solaris])
    # pic32 is appropriate for both 32 and 64 bit Solaris
    C_LINK_SHL='${CC} -G -xcode=pic32'
    CC_SHL='${CC} -xcode=pic32'
    C_LINKPATH_SHL="-R"
    SHLIB_EXT=so
    enable_sharedlibs="solaris-cc"
    ;;

    solaris-gcc)
    # This is the same as gcc, except for the C_LINKPATH_SHL
    AC_MSG_RESULT([Creating shared libraries using Solaris with gcc])
    C_LINK_SHL='${CC} -shared'
    CC_SHL='${CC} -fPIC'
    C_LINKPATH_SHL="-R"
    SHLIB_EXT=so
    enable_sharedlibs="solaris-gcc"
    ;;

    linuxppc-xlc)
    # This is only the beginning of xlc support, thanks to andy@vpac.org
    CC_SHL='${CC} -qmkshrobj'
    # More recent versions allow multiple args, separated by commas
    C_LINKPATH_SHL="-Wl,-rpath,"
    #C_LINKPATH_SHL="-Wl,-rpath -Wl,"
    C_LINK_SHL='${CC} -shared -qmkshrobj'
    SHLIB_EXT=so
    # Note that the full line should be more like
    # $CLINKER -shared -qmkshrobj -Wl,-h,$libbase.$slsuffix -o ../shared/$libbase.$slsuffix *.o $OtherLibs
    # for the appropriate values of $libbase and $slsuffix
    # The -h name sets the name of the object; this is necessary to
    # ensure that the dynamic linker can find the proper shared library.
    ;;

    *)
    AC_MSG_ERROR([Unknown value $enable_sharedlibs for enable-sharedlibs.  Values should be gcc or osx-gcc])
    enable_sharedlibs=no
    ;;  
esac
# Check for the shared-library extension
PAC_CC_SHLIB_EXT
dnl
AC_SUBST(CC_SHL)
AC_SUBST(C_LINK_SHL)
AC_SUBST(C_LINKPATH_SHL)
AC_SUBST(SHLIB_EXT)
AC_SUBST(SHLIB_FROM_LO)
AC_SUBST(SHLIB_INSTALL)
])

dnl /*D
dnl PAC_xx_SHAREDLIBS - Get compiler and linker for shared libraries
dnl These routines may be used to determine the compiler and the
dnl linker to be used in creating shared libraries
dnl Rather than set predefined variable names, they set an argument 
dnl (if provided)
dnl
dnl Synopsis
dnl PAC_CC_SHAREDLIBS(type,CCvar,CLINKvar)
dnl D*/
AC_DEFUN([PAC_CC_SHAREDLIBS],
[
pac_kinds=$1
ifelse($1,,[
    pac_prog=""
    AC_CHECK_PROG(pac_prog,gcc,yes,no)
    # If we are gcc but OS X, set the special type
    # We need a similar setting for cygwin
    if test "$pac_prog" = yes ; then 
        osname=`uname -s`
    	case $osname in 
             *Darwin*|*darwin*) pac_kinds=gcc-osx
             ;;				
	     *) pac_kinds=gcc
	     ;;
	esac
    fi
    pac_prog=""
    AC_CHECK_PROG(pac_prog,libtool,yes,no)
    if test "$pac_prog" = yes ; then pac_kinds="$pac_kinds libtool" ; fi
])
for pac_arg in $pac_kinds ; do
    case $pac_arg in 
    gcc)
    # For example, include the libname as ${LIBNAME_SHL}
    #C_LINK_SHL='${CC} -shared -Wl,-h,<finallibname>'
    pac_cc_sharedlibs='gcc -shared'
    # Make sure we select the correct fpic option
    PAC_C_CHECK_COMPILER_OPTION(-fpic,fpic_ok=yes,fpic_ok=no)
    if test "$fpic_ok" != yes ; then
        PAC_C_CHECK_COMPILER_OPTION(-fPIC,fPIC_ok=yes,fPIC_ok=no)
        if test "$fPIC_ok" != yes ; then
	     AC_MSG_ERROR([Neither -fpic nor -fPIC accepted by $CC])
        else
	     pac_cc_sharedlibs="$pac_cc_sharedlibs -fPIC"
        fi
    else
        pac_cc_sharedlibs="$pac_cc_sharedlibs -fpic"
    fi
    pac_clink_sharedlibs='gcc -shared'
    pac_type_sharedlibs=gcc
    ;;
    gcc-osx|osx-gcc)
    pac_clink_sharedlibs='${CC} -dynamiclib -undefined suppress -single_module -flat_namespace'
    pac_cc_sharedlibs='${CC} -fPIC'
    pac_type_sharedlibs=gcc-osx
    ;;
    libtool)
    AC_CHECK_PROGS(LIBTOOL,libtool,false)
    if test "$LIBTOOL" = "false" ; then
	AC_MSG_WARN([Could not find libtool])
    else
        # Likely to be
        # either CC or CC_SHL is libtool $cc
        pac_cc_sharedlibs'${LIBTOOL} -mode=compile ${CC}'
        pac_clink_sharedlibs='${LIBTOOL} -mode=link ${CC} -rpath ${libdir}'
	pac_type_sharedlibs=libtool
    fi
    ;;
    *)
    ;;
    esac
    if test -n "$pac_cc_sharedlibs" ; then break ; fi
done
if test -z "$pac_cc_sharedlibs" ; then pac_cc_sharedlibs=true ; fi
if test -z "$pac_clink_sharedlibs" ; then pac_clink_sharedlibs=true ; fi
ifelse($2,,CC_SHL=$pac_cc_sharedlibs,$2=$pac_cc_sharedlibs)
ifelse($3,,C_LINK_SHL=$pac_clink_sharedlibs,$3=$pac_clink_sharedlibs)
ifelse($4,,SHAREDLIB_TYPE=$pac_type_sharedlibs,$4=$pac_type_sharedlibs)
])

dnl This macro ensures that all of the necessary substitutions are 
dnl made by any subdirectory configure (which may simply SUBST the
dnl necessary values rather than trying to determine them from scratch)
dnl This is a more robust (and, in the case of libtool, only 
dnl managable) method.
AC_DEFUN([PAC_CC_SUBDIR_SHLIBS],[
	AC_SUBST(CC_SHL)
        AC_SUBST(C_LINK_SHL)
        AC_SUBST(LIBTOOL)
        AC_SUBST(ENABLE_SHLIB)
        AC_SUBST(SHLIB_EXT)
	if test "$ENABLE_SHLIB" = "libtool" ; then
	    if test -z "$LIBTOOL" ; then
		AC_MSG_WARN([libtool selected for shared library support but LIBTOOL is not defined])
            fi
	    # Libtool needs master_top_builddir
	    if test "X$master_top_builddir" = "X" ; then
	        AC_MSG_ERROR([Libtool requires master_top_builddir - check configure.in sources])
	    fi
	    AC_SUBST(master_top_builddir)
	fi
])

dnl PAC_CC_SHLIB_EXT - get the extension for shared libraries
dnl Set the variable SHLIB_EXT if it is other than unknown.
AC_DEFUN([PAC_CC_SHLIB_EXT],[
# Not all systems use .so as the extension for shared libraries (cygwin
# and OSX are two important examples).  If we did not set the SHLIB_EXT,
# then try and determine it.  We need this to properly implement
# clean steps that look for libfoo.$SHLIB_EXT .
if test "$SHLIB_EXT" = "unknown" ; then
    osname=`uname -s`
    case $osname in 
        *Darwin*|*darwin*) SHLIB_EXT=dylib
        ;;	
        *CYGWIN*|*cygwin*) SHLIB_EXT=dll
        ;;
	*Linux*|*LINUX*|*SunOS*) SHLIB_EXT=so
	;;
   esac
fi
])