# ********************************************************************** # # Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved. # # This copy of Ice is licensed to you under the terms described in the # ICE_LICENSE file included in this distribution. # # ********************************************************************** # # Use specific PHP version # PHP_CONFIG ?= php-config # # The extension is by default built with namespaces enabled # it is possible to build the PHP extension with namespaces # disabled by setting `USE_NAMESPACES` property to `no` # USE_NAMESPACES ?= yes # ---------------------------------------------------------------------- # Don't change anything below this line! # ---------------------------------------------------------------------- php_cppflags = $(shell $(PHP_CONFIG) --includes) ifeq ($(USE_NAMESPACES),no) slice2php_flags = --no-namespace else php_cppflags := $(php_cppflags) -DICEPHP_USE_NAMESPACES endif ifeq ($(os),Darwin) php_ldflags := ${wl}-flat_namespace ${wl}-undefined ${wl}suppress endif ifeq ($(filter all cpp,$(ICE_BIN_DIST)),) php_cpp_includes = -I$(top_srcdir)/cpp/include -I$(top_srcdir)/cpp/include/generated else php_cpp_includes = -I$(includedir) endif ifeq ($(os),Linux) allow-undefined-symbols := yes endif # # On the default platform, always write/install the module in the lib directory. # $(foreach p,$(supported-platforms),$(eval $$p_targetdir[IcePHP] := /$$p)) $(firstword $(supported-platforms))_targetdir[IcePHP] := $(firstword $(supported-platforms))_installdir[IcePHP] := # # PHP installation directory # install_phpdir ?= $(if $(usr_dir_install),$(prefix)/share/php,$(prefix)/php) install_phplibdir ?= $(if $(usr_dir_install),$(shell $(PHP_CONFIG) --extension-dir),$(prefix)/php) # # Rules to build a php module. We just compute the name of the php module # and delegate to make-shared-module. # mkphpmodulename ?= $(patsubst lib%,%,$(call mkshlibname,$(1))) make-shared-php-module = $(call make-shared-module,$(call mkphpmodulename,$1),$2,$3,$4,$5,$6,$7,$8,$9) get-shared-php-module-targets = $(call get-shared-module-targets,$(call mkphpmodulename,$1),$2,$3,$4) install-shared-php-module = $(call install-shared-module,$(call mkphpmodulename,$1),$2,$3,$4,$5) $(DESTDIR)$(install_phpdir): $(Q)$(MKDIR) -p $@ installdirs += $(install_phpdir) # # $(call make-php-package,$1=slicedir,$2=generateddir,$3=package,$4=sliceflags) # # Compile slice files from $(slicedir)/ to php/. # define make-php-package ifeq ($(filter all php, $(ICE_BIN_DIST)),) $2/$3/.depend/%.ice.d: | $2/$3/.depend ; $2/$3/.depend: $(Q)$(MKDIR) -p $$@ .PRECIOUS: $2/$3/.depend/%.ice.d ifeq ($(filter %clean,$(MAKECMDGOALS)),) # Include the dependencies -include $(addprefix $2/$3/.depend/,$(call source-to-dependency,$(wildcard $1/$3/*.ice))) endif $2/$3/%.php: $1/$3/%.ice $2/$3/.depend/%.ice.d $(slice2php_path) $(E) "Compiling $$<" $(Q)$(slice2php_path) $(slice2php_flags) -I$1 --output-dir $2/$3 $4 --depend $$< | \ sed 's/\(.*: \\\)/$(subst /,\/,$2)\/$3\/\1/' > $2/$3/.depend/$$(*F).ice.d $(Q)$(slice2php_path) $(slice2php_flags) -I$1 --output-dir $2/$3 $4 $$< distclean clean:: $(E) "Cleaning package $3" $(Q)$(RM) -r $2/$3/.depend $(Q)$(RM) $(patsubst $1/$3/%.ice,$2/$3/%.php,$(wildcard $1/$3/*.ice)) generate-srcs srcs all:: $(patsubst $1/$3/%.ice,$2/$3/%.php,$(wildcard $1/$3/*.ice)) $$(eval $$(call install-data-files,$(patsubst $1/$3/%.ice,$2/$3/%.php,$(wildcard $1/$3/*.ice)),$2,$(install_phpdir),install)) endif endef # # $(call make-php-test-project,$1=testdir) # define make-php-test-project $1/.depend/%.ice.d: | $1/.depend ; $1/.depend: $(Q)$(MKDIR) -p $$@ .PRECIOUS: $1/.depend/%.ice.d ifeq ($(filter %clean,$(MAKECMDGOALS)),) # Include the dependencies -include $(addprefix $1/.depend/,$(call source-to-dependency,$(wildcard $1/*.ice))) endif $1/%.php: $1/%.ice $1/.depend/%.ice.d $(slice2php_path) $(E) "Compiling $$<" $(Q)$(slice2php_path) $(slice2php_flags) -I$(slicedir) -I$1 --output-dir $1 $$($1_sliceflags) --depend $$< | \ sed 's/\(.*: \\\)/$(subst /,\/,$2)\/$3\/\1/' > $1/.depend/$$(*F).ice.d $(Q)$(slice2php_path) $(slice2php_flags) -I$(slicedir) -I$1 --output-dir $1 $$($1_sliceflags) $$< distclean clean:: $(E) "Cleaning $1" $(Q)$(RM) -r $1/.depend $(Q)$(RM) $(patsubst $1/%.ice,$1/%.php,$(wildcard $1/*.ice)) tests generate-srcs srcs all:: $(patsubst $1/%.ice,$1/%.php,$(wildcard $1/*.ice)) endef