From: Sascha Schumann Date: Sun, 9 Jul 2000 20:39:18 +0000 (+0000) Subject: Add support for building C++ sources. X-Git-Tag: PRE_FILE_COMPILE_API_CHANGE~336 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e51571595c66f1084b514ca8985dd5d47a8c9a08;p=php Add support for building C++ sources. In your extension's config.m4, you need to use the m4 macro PHP_REQUIRE_CXX This shall be called only, if your extension is enabled. C++ source files shall not be put into the LTLIBRARY_SOURCES macro. Instead, the filename of the object shall be put into LTLIBRARY_OBJECTS_X. I.e. if your extension foo consists of foo.cxx, use LTLIBRARY_OBJECTS_X = foo.lo --- diff --git a/acinclude.m4 b/acinclude.m4 index 0daebf6dfa..b2e702e53e 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -420,6 +420,14 @@ AC_DEFUN(PHP_BUILD_THREAD_SAFE,[ fi ]) +AC_DEFUN(PHP_REQUIRE_CXX,[ + if test -z "$php_cxx_done"; then + AC_PROG_CXX + AC_PROG_CXXCPP + php_cxx_done=yes + fi +]) + dnl dnl PHP_BUILD_SHARED dnl diff --git a/build/library.mk b/build/library.mk index 8950e944b2..3726c538cf 100644 --- a/build/library.mk +++ b/build/library.mk @@ -24,7 +24,7 @@ # $Id$ # -LTLIBRARY_OBJECTS = $(LTLIBRARY_SOURCES:.c=.lo) +LTLIBRARY_OBJECTS = $(LTLIBRARY_SOURCES:.c=.lo) $(LTLIBRARY_OBJECTS_X) $(LTLIBRARY_NAME): $(LTLIBRARY_OBJECTS) $(LTLIBRARY_DEPENDENCIES) $(LINK) $(LTLIBRARY_LDFLAGS) $(LTLIBRARY_OBJECTS) $(LTLIBRARY_LIBADD) diff --git a/build/rules.mk b/build/rules.mk index f55cff8647..3097da5076 100644 --- a/build/rules.mk +++ b/build/rules.mk @@ -26,36 +26,50 @@ include $(top_builddir)/config_vars.mk -COMPILE = $(CC) $(DEFS) $(INCLUDES) $(EXTRA_INCLUDES) $(CPPFLAGS) $(CFLAGS) $(EXTRA_CFLAGS) -LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(EXTRA_INCLUDES) $(CPPFLAGS) $(CFLAGS) $(EXTRA_CFLAGS) -CCLD = $(CC) -LINK = $(LIBTOOL) --mode=link $(CCLD) $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS) -o $@ +COMMON_FLAGS = $(DEFS) $(INCLUDES) $(EXTRA_INCLUDES) $(CPPFLAGS) +COMPILE = $(CC) $(COMMON_FLAGS) $(CFLAGS) $(EXTRA_CFLAGS) +CXX_COMPILE = $(CXX) $(COMMON_FLAGS) $(CXXFLAGS) $(EXTRA_CXXFLAGS) + +SHARED_COMPILE = $(SHARED_LIBTOOL) --mode=compile $(COMPILE) -c $< && touch $@ +CXX_SHARED_COMPILE = $(SHARED_LIBTOOL) --mode=compile $(CXX_COMPILE) -c $< && touch $@ + +LINK = $(LIBTOOL) --mode=link $(COMPILE) $(LDFLAGS) -o $@ + mkinstalldirs = $(top_srcdir)/build/shtool mkdir -p INSTALL = $(top_srcdir)/build/shtool install -c INSTALL_DATA = $(INSTALL) -m 644 -SHARED_COMPILE = $(SHARED_LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(EXTRA_INCLUDES) $(CPPFLAGS) $(CFLAGS) $(EXTRA_CFLAGS) -c $< && touch $@ + DEFS = -DHAVE_CONFIG_H -I. -I$(srcdir) -I$(top_builddir) -I$(top_builddir)/main moduledir = $(EXTENSION_DIR) .SUFFIXES: -.SUFFIXES: .slo .c .lo .o .s .y .l +.SUFFIXES: .slo .c .cxx .lo .o .s .y .l .c.o: $(COMPILE) -c $< +.cxx.o: + $(CXX_COMPILE) -c $< + .s.o: $(COMPILE) -c $< .c.lo: $(PHP_COMPILE) +.cxx.lo: + $(CXX_PHP_COMPILE) + .s.lo: $(PHP_COMPILE) .c.slo: $(SHARED_COMPILE) +.cxx.slo: + $(CXX_SHARED_COMPILE) + .y.c: $(YACC) $(YFLAGS) $< && mv y.tab.c $*.c if test -f y.tab.h; then \ diff --git a/configure.in b/configure.in index 1953c769f3..9d9a5123b5 100644 --- a/configure.in +++ b/configure.in @@ -694,6 +694,7 @@ PHP_SUBST(CONFIGURE_COMMAND) PHP_SUBST(CPP) PHP_SUBST(CPPFLAGS) PHP_SUBST(CXX) +PHP_SUBST(CXXFLAGS) PHP_SUBST(DEBUG_CFLAGS) PHP_SUBST(DEFS) PHP_SUBST(EXTENSION_DIR) @@ -751,6 +752,7 @@ if test "$enable_debug" != "yes"; then fi PHP_COMPILE='$(LIBTOOL) --mode=compile $(COMPILE) -c $<' +CXX_PHP_COMPILE='$(LIBTOOL) --mode=compile $(CXX_COMPILE) -c $<' if test "$enable_shared" = "yes"; then SHARED_LIBTOOL='$(LIBTOOL)' @@ -761,6 +763,7 @@ else SHARED_LIBTOOL='$(SHELL) $(top_builddir)/shlibtool' else PHP_COMPILE='$(COMPILE) -c $< && touch $@' + CXX_PHP_COMPILE='$(CXX_COMPILE) -c $< && touch $@' fi fi diff --git a/dynlib.m4 b/dynlib.m4 index 77c607c25c..5917b187f0 100644 --- a/dynlib.m4 +++ b/dynlib.m4 @@ -5,7 +5,7 @@ AC_DEFUN(LIB_SHARED_CONVENIENCE,[ lib_target="\$(LTLIBRARY_NAME)" cat >>$1<>$1<$lib_makefile<