aboutsummaryrefslogtreecommitdiff
path: root/acaux.m4
blob: 0ac92d0201ddce119cfac9600bebd82f0e6307a8 (plain)
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
# -*- ksh -*-
# See also perl 5.
AC_DEFUN(AC_SYS_SHAREDLIB,
[AC_REQUIRE([AC_PROG_CC])dnl
  AC_MSG_CHECKING(for shared library support)
  sharedlib_extension=so # right for almost everything
  sharedlib_suffix='.$(sharedlib_version)'
  sharedlib_cflags=
  sharedlib_buildflags=
  sharedlib_buildflags_gcc=
  sharedlib_linkflags=
  sharedlib_linkflags_gcc=
  sharedlib_postinstall=
  
  # We'll be changing some settings if gcc, below,
  # but let's do the uname patterns only once.
  case `(uname -a 2>&1) 2>/dev/null` in
    FreeBSD*) # xx right uname?
      # xx really need -DPIC in cflags?
      # xx extension must be .so?
      sharedlib_buildflags_gcc=-Wl,-Bshareable # xx must run ld?
      ;;
    HP-UX*)
      sharedlib_extension=sl
      sharedlib_suffix=
      sharedlib_cflags=+z
      sharedlib_buildflags=-Wl,-b		# xx must run ld?
      sharedlib_postinstall="chmod a+x"
      ;;
    IRIX*)
      sharedlib_buildflags='-shared -no_unresolved \
-set_version sgi$(sharedlib_version) -soname $(sharedlib)'
      sharedlib_linkflags='-rpath $(libdir)'
      sharedlib_linkflags_gcc='-Wl,-rpath,$(libdir)'
      ;;
    Linux*)
#      sharedlib_buildflags_gcc='-shared -Wl,-soname,$(sharedlib)'
      sharedlib_postinstall='ldconfig #'
      sharedlib_linkflags='-Wl,-rpath,$(libdir)'
      ;;
    OSF1*)
      # xx run ld? link with -lc?
      # version stuff not right, since old versions should also be
      # passed to -set_version.
      sharedlib_buildflags='-Wl,shared -set_version $(sharedlib_version)'
      sharedlib_linkflags='-Wl,-rpath,$(libdir)'
      ;;
    SunOS*4.*)
      sharedlib_cflags=-PIC
      sharedlib_linkflags='-L$(libdir)'
      ;;
    SunOS*5.*)
      sharedlib_cflags="-K pic"
      sharedlib_buildflags='-G -z text -h $(sharedlib)'
      sharedlib_linkflags='-R$(libdir)'
      ;;
  esac
  
  # If GCC, things are usually simpler.
  if test "$GCC" = yes; then
    sharedlib_cflags=-fPIC     # should we ever use -fpic?
    if test -n "$sharedlib_buildflags_gcc"; then
      sharedlib_buildflags=$sharedlib_buildflags_gcc
    else
      sharedlib_buildflags=-shared
    fi
    if test -n "$sharedlib_linkflags_gcc"; then
      sharedlib_linkflags=$sharedlib_linkflags_gcc
    fi
  fi

  test -z "$sharedlib_postinstall" && sharedlib_postinstall=:

  AC_MSG_RESULT($sharedlib_cflags/$sharedlib_buildflags/$sharedlib_linkflags)
  AC_SUBST(sharedlib_extension)dnl
  AC_SUBST(sharedlib_suffix)dnl
  AC_SUBST(sharedlib_cflags)dnl
  AC_SUBST(sharedlib_buildflags)dnl
  AC_SUBST(sharedlib_linkflags)dnl
  AC_SUBST(sharedlib_postinstall)dnl
])