Skip to content

Commit d9f52fe

Browse files
committed
First cut at standard way of making dynamically loadable extensions on UNIX.
Examples on how to test: ./configure --with-xml static ./configure --with-xml=/opt static ./configure --with-xml=shared shared ./configure --with-xml=shared,/opt shared The difference between these two is that when the extension is shared, it is not merged into libphpext.a. The shared extension is currently always built. I can't find a way to do just one or the other with automake/libtool, if someone has a clever idea, please come forward. :-) "make install" installs the .so (as well as a lot of other cruft) in $prefix/lib/php.
1 parent 5732380 commit d9f52fe

12 files changed

+5274
-1199
lines changed

Makefile.in

+9-2
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ APXS_LDFLAGS = $(EXTRA_LIBS) $(LIBS)
6565
APXS_EXP = @APXS_EXP@
6666
WARNING_LEVEL = @WARNING_LEVEL@
6767
LEX_CFLAGS = -w$(WARNING_LEVEL) @LEX_CFLAGS@
68+
EXT_SHARED = @EXT_SHARED@
6869

6970
SOURCE = main.c internal_functions.c snprintf.c php3_sprintf.c \
7071
configuration-parser.c configuration-scanner.c request_info.c \
@@ -170,7 +171,6 @@ distdir:
170171
flex -Pcfg -oconfiguration-scanner.c -i configuration-scanner.l ;\
171172
bison -p cfg -v -d configuration-parser.y -o configuration-parser.c
172173
find $(distdir) -name CVS -o -name .cvsignore | xargs rm -rf
173-
174174

175175
maintainer-clean-depend: maintainer-clean-depend-recursive
176176

@@ -203,9 +203,16 @@ php_config.h.in: @MAINT@ stamp-h.in
203203
stamp-h.in: configure.in aclocal.m4 acconfig.h
204204
cd ${srcdir} && autoheader && touch ${srcdir}/stamp-h.in
205205

206-
install: $(BINNAME)
206+
install: install-recursive $(BINNAME)
207207
$(INSTALL_IT)
208208

209+
install-recursive:
210+
if test "$(EXT_SHARED)" != ""; then \
211+
for dir in $(EXT_SHARED); do \
212+
test -d ext/$$dir && (cd ext/$$dir; $(MAKE) install); \
213+
done; \
214+
fi
215+
209216
indent: clean
210217
indent -v -kr -cli4 -ts4 \
211218
-T pval -T HashTable -T Bucket -T Token -T TokenCache -T TokenCacheManager \

acinclude.m4

+10-3
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,22 @@ dnl to make dynamic libraries as well.
138138
dnl
139139
AC_DEFUN(PHP_EXTENSION,[
140140
EXT_SUBDIRS="$EXT_SUBDIRS $1"
141-
_extlib="libphpext_$1.a"
142-
EXT_LIBS="$EXT_LIBS $1/$_extlib"
143-
EXTINFO_DEPS="$EXTINFO_DEPS ../ext/$1/extinfo.c.stub"
141+
if test "$2" != "shared" -a "$2" != "yes"; then
142+
_extlib="libphpext_$1.a"
143+
EXT_LIBS="$EXT_LIBS $1/$_extlib"
144+
EXTINFO_DEPS="$EXTINFO_DEPS ../ext/$1/extinfo.c.stub"
145+
EXT_STATIC="$EXT_STATIC $1"
146+
else
147+
EXT_SHARED="$EXT_SHARED $1"
148+
fi
144149
dnl EXT_INCLUDE_CODE="\#include \"ext/$1/php3_$1.h\"\\n$EXT_INCLUDE_CODE"
145150
dnl EXT_MODULE_PTRS="phpext_$1_ptr, $EXT_MODULE_PTRS"
146151
dnl "
147152
])
148153

149154
AC_SUBST(EXT_SUBDIRS)
155+
AC_SUBST(EXT_STATIC)
156+
AC_SUBST(EXT_SHARED)
150157
AC_SUBST(EXT_LIBS)
151158
AC_SUBST(EXTINFO_DEPS)
152159
dnl AC_SUBST(EXT_INCLUDE_CODE)

0 commit comments

Comments
 (0)