summaryrefslogtreecommitdiff
path: root/dynlib.m4
blob: 19c9e84f5da13c5f02f90dd8738eaf035d02af89 (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
82
#  +----------------------------------------------------------------------+
#  | PHP version 4.0                                                      |
#  +----------------------------------------------------------------------+
#  | Copyright (c) 1997, 1998, 1999, 2000 The PHP Group                   |
#  +----------------------------------------------------------------------+
#  | This source file is subject to version 2.02 of the PHP license,      |
#  | that is bundled with this package in the file LICENSE, and is        |
#  | available at through the world-wide-web at                           |
#  | http://www.php.net/license/2_02.txt.                                 |
#  | If you did not receive a copy of the PHP license and are unable to   |
#  | obtain it through the world-wide-web, please send a note to          |
#  | license@php.net so we can mail you a copy immediately.               |
#  +----------------------------------------------------------------------+
#  | Authors: Sascha Schumann <sascha@schumann.cx>                        |
#  +----------------------------------------------------------------------+
#
# $Id$ 
#



AC_DEFUN(LIB_SHARED_CONVENIENCE,[
  lib_target="\$(LTLIBRARY_NAME)"
  cat >>$1<<EOF
\$(LTLIBRARY_NAME): \$(LTLIBRARY_SHARED_OBJECTS) \$(LTLIBRARY_DEPENDENCIES)
	\$(SHARED_LIBTOOL) --mode=link \$(COMPILE) \$(LDFLAGS) -o \[$]@ \$(LTLIBRARY_LDFLAGS) \$(LTLIBRARY_OBJECTS) \$(LTLIBRARY_SHARED_LIBADD)

EOF
])

AC_DEFUN(LIB_SHARED_MODULE,[
  lib_target="\$(LTLIBRARY_SHARED_NAME)"
  cat >>$1<<EOF
\$(LTLIBRARY_SHARED_NAME): \$(LTLIBRARY_SHARED_OBJECTS) \$(LTLIBRARY_DEPENDENCIES)
	\$(SHARED_LIBTOOL) --mode=link \$(COMPILE) \$(LDFLAGS) -o \[$]@ -avoid-version -module -rpath \$(phplibdir) \$(LTLIBRARY_LDFLAGS) \$(LTLIBRARY_OBJECTS) \$(LTLIBRARY_SHARED_LIBADD)
	\$(SHARED_LIBTOOL) --mode=install cp \[$]@ \$(phplibdir)

EOF
])

AC_DEFUN(LIB_STATIC_CONVENIENCE,[
  lib_target="\$(LTLIBRARY_NAME)"
  cat >>$1<<EOF
\$(LTLIBRARY_NAME): \$(LTLIBRARY_OBJECTS) \$(LTLIBRARY_DEPENDENCIES)
	\$(LINK) \$(LTLIBRARY_LDFLAGS) \$(LTLIBRARY_OBJECTS) \$(LTLIBRARY_LIBADD)

EOF
])

dnl LIB_BUILD(path, shared, convenience)
dnl sets up path to build a shared/static convenience/module
AC_DEFUN(LIB_BUILD,[
  lib_makefile="$1/libs.mk"
  lib_target=""
  
  $php_shtool mkdir -p $1
  cat >$lib_makefile<<EOF
LTLIBRARY_OBJECTS = \$(LTLIBRARY_SOURCES:.c=.lo) \$(LTLIBRARY_OBJECTS_X)
LTLIBRARY_SHARED_OBJECTS = \$(LTLIBRARY_OBJECTS:.lo=.slo)
EOF

  if test "$2" = "shared" || test "$2" = "yes"; then
    lib_build_shared=yes
    if test -n "$3"; then
dnl ---------------------------------------- Shared Convenience
      LIB_SHARED_CONVENIENCE($lib_makefile)
    else
dnl ---------------------------------------- Shared Module
      LIB_SHARED_MODULE($lib_makefile)
    fi
  else
dnl ---------------------------------------- Static Convenience = Static Module
    LIB_STATIC_CONVENIENCE($lib_makefile)
  fi

dnl ---------------------------------------- Generate build targets
  if test -n "$lib_target"; then
    cat >>$lib_makefile<<EOF
targets = $lib_target
EOF
  fi
])