xref: /PHP-8.2/build/Makefile.global (revision d57a7767)
1mkinstalldirs = $(top_srcdir)/build/shtool mkdir -p
2INSTALL = $(top_srcdir)/build/shtool install -c
3INSTALL_DATA = $(INSTALL) -m 644
4
5DEFS = -I$(top_builddir)/include -I$(top_builddir)/main -I$(top_srcdir)
6COMMON_FLAGS = $(DEFS) $(INCLUDES) $(EXTRA_INCLUDES) $(CPPFLAGS) $(PHP_FRAMEWORKPATH)
7
8all: $(all_targets)
9	@echo
10	@echo "Build complete."
11	@echo "Don't forget to run 'make test'."
12	@echo
13
14build-modules: $(PHP_MODULES) $(PHP_ZEND_EX)
15
16build-binaries: $(PHP_BINARIES)
17
18libphp.la: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS)
19	$(LIBTOOL) --tag=CC --mode=link $(CC) $(LIBPHP_CFLAGS) $(CFLAGS) $(EXTRA_CFLAGS) -rpath $(phptempdir) $(EXTRA_LDFLAGS) $(LDFLAGS) $(PHP_RPATHS) $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@
20	-@$(LIBTOOL) --silent --tag=CC --mode=install cp $@ $(phptempdir)/$@ >/dev/null 2>&1
21
22libs/libphp.bundle: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS)
23	$(CC) $(MH_BUNDLE_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(PHP_GLOBAL_OBJS:.lo=.o) $(PHP_SAPI_OBJS:.lo=.o) $(PHP_FRAMEWORKS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@ && cp $@ libs/libphp.so
24
25install: $(all_targets) $(install_targets)
26
27install-sapi: $(OVERALL_TARGET)
28	@echo "Installing PHP SAPI module:       $(PHP_SAPI)"
29	-@$(mkinstalldirs) $(INSTALL_ROOT)$(bindir)
30	-@if test ! -r $(phptempdir)/libphp.$(SHLIB_DL_SUFFIX_NAME); then \
31		for i in 0.0.0 0.0 0; do \
32			if test -r $(phptempdir)/libphp.$(SHLIB_DL_SUFFIX_NAME).$$i; then \
33				$(LN_S) $(phptempdir)/libphp.$(SHLIB_DL_SUFFIX_NAME).$$i $(phptempdir)/libphp.$(SHLIB_DL_SUFFIX_NAME); \
34				break; \
35			fi; \
36		done; \
37	fi
38	@$(INSTALL_IT)
39
40install-binaries: build-binaries $(install_binary_targets)
41
42install-modules: build-modules
43	@test -d modules && \
44	$(mkinstalldirs) $(INSTALL_ROOT)$(EXTENSION_DIR)
45	@echo "Installing shared extensions:     $(INSTALL_ROOT)$(EXTENSION_DIR)/"
46	@rm -f modules/*.la >/dev/null 2>&1
47	@$(INSTALL) modules/* $(INSTALL_ROOT)$(EXTENSION_DIR)
48
49install-headers:
50	-@if test "$(INSTALL_HEADERS)"; then \
51		for i in `echo $(INSTALL_HEADERS)`; do \
52			i=`$(top_srcdir)/build/shtool path -d $$i`; \
53			paths="$$paths $(INSTALL_ROOT)$(phpincludedir)/$$i"; \
54		done; \
55		$(mkinstalldirs) $$paths && \
56		echo "Installing header files:          $(INSTALL_ROOT)$(phpincludedir)/" && \
57		for i in `echo $(INSTALL_HEADERS)`; do \
58			if test "$(PHP_PECL_EXTENSION)"; then \
59				src=`echo $$i | $(SED) -e "s#ext/$(PHP_PECL_EXTENSION)/##g"`; \
60			else \
61				src=$$i; \
62			fi; \
63			if test -f "$(top_srcdir)/$$src"; then \
64				$(INSTALL_DATA) $(top_srcdir)/$$src $(INSTALL_ROOT)$(phpincludedir)/$$i; \
65			elif test -f "$(top_builddir)/$$src"; then \
66				$(INSTALL_DATA) $(top_builddir)/$$src $(INSTALL_ROOT)$(phpincludedir)/$$i; \
67			else \
68				(cd $(top_srcdir)/$$src && $(INSTALL_DATA) *.h $(INSTALL_ROOT)$(phpincludedir)/$$i; \
69				cd $(top_builddir)/$$src && $(INSTALL_DATA) *.h $(INSTALL_ROOT)$(phpincludedir)/$$i) 2>/dev/null || true; \
70			fi \
71		done; \
72	fi
73
74PHP_TEST_SETTINGS = -d 'open_basedir=' -d 'output_buffering=0' -d 'memory_limit=-1'
75PHP_TEST_SHARED_EXTENSIONS =  ` \
76	if test "x$(PHP_MODULES)" != "x"; then \
77		for i in $(PHP_MODULES)""; do \
78			. $$i; \
79			if test "x$$dlname" != "xdl_test.so"; then \
80				$(top_srcdir)/build/shtool echo -n -- " -d extension=$$dlname"; \
81			fi; \
82		done; \
83	fi; \
84	if test "x$(PHP_ZEND_EX)" != "x"; then \
85		for i in $(PHP_ZEND_EX)""; do \
86			. $$i; $(top_srcdir)/build/shtool echo -n -- " -d zend_extension=$(top_builddir)/modules/$$dlname"; \
87		done; \
88	fi`
89PHP_DEPRECATED_DIRECTIVES_REGEX = '^(magic_quotes_(gpc|runtime|sybase)?|(zend_)?extension(_debug)?(_ts)?)[\t\ ]*='
90
91test: all
92	@if test ! -z "$(PHP_EXECUTABLE)" && test -x "$(PHP_EXECUTABLE)"; then \
93		INI_FILE=`$(PHP_EXECUTABLE) -d 'display_errors=stderr' -r 'echo php_ini_loaded_file();' 2> /dev/null`; \
94		if test "$$INI_FILE"; then \
95			$(EGREP) -h -v $(PHP_DEPRECATED_DIRECTIVES_REGEX) "$$INI_FILE" > $(top_builddir)/tmp-php.ini; \
96		else \
97			echo > $(top_builddir)/tmp-php.ini; \
98		fi; \
99		INI_SCANNED_PATH=`$(PHP_EXECUTABLE) -d 'display_errors=stderr' -r '$$a = explode(",\n", trim(php_ini_scanned_files())); echo $$a[0];' 2> /dev/null`; \
100		if test "$$INI_SCANNED_PATH"; then \
101			INI_SCANNED_PATH=`$(top_srcdir)/build/shtool path -d $$INI_SCANNED_PATH`; \
102			$(EGREP) -h -v $(PHP_DEPRECATED_DIRECTIVES_REGEX) "$$INI_SCANNED_PATH"/*.ini >> $(top_builddir)/tmp-php.ini; \
103		fi; \
104		TEST_PHP_EXECUTABLE=$(PHP_EXECUTABLE) \
105		TEST_PHP_SRCDIR=$(top_srcdir) \
106		CC="$(CC)" \
107			$(PHP_EXECUTABLE) -n -c $(top_builddir)/tmp-php.ini $(PHP_TEST_SETTINGS) $(top_srcdir)/run-tests.php -n -c $(top_builddir)/tmp-php.ini -d extension_dir=$(top_builddir)/modules/ $(PHP_TEST_SHARED_EXTENSIONS) $(TESTS); \
108		TEST_RESULT_EXIT_CODE=$$?; \
109		rm $(top_builddir)/tmp-php.ini; \
110		exit $$TEST_RESULT_EXIT_CODE; \
111	else \
112		echo "ERROR: Cannot run tests without CLI sapi."; \
113	fi
114
115clean:
116	find . -name \*.gcno -o -name \*.gcda | xargs rm -f
117	find . -name \*.lo -o -name \*.o -o -name \*.dep | xargs rm -f
118	find . -name \*.la -o -name \*.a | xargs rm -f
119	find . -name \*.so | xargs rm -f
120	find . -name .libs -a -type d|xargs rm -rf
121	rm -f libphp.la $(SAPI_CLI_PATH) $(SAPI_CGI_PATH) $(SAPI_LITESPEED_PATH) $(SAPI_FPM_PATH) $(OVERALL_TARGET) modules/* libs/*
122	rm -f ext/opcache/jit/zend_jit_x86.c
123	rm -f ext/opcache/jit/zend_jit_arm64.c
124	rm -f ext/opcache/minilua
125
126distclean: clean
127	rm -f Makefile config.cache config.log config.status Makefile.objects Makefile.fragments libtool main/php_config.h main/internal_functions_cli.c main/internal_functions.c Zend/zend_dtrace_gen.h Zend/zend_dtrace_gen.h.bak Zend/zend_config.h
128	rm -f main/build-defs.h scripts/phpize
129	rm -f ext/date/lib/timelib_config.h ext/mbstring/libmbfl/config.h ext/oci8/oci8_dtrace_gen.h ext/oci8/oci8_dtrace_gen.h.bak
130	rm -f scripts/man1/phpize.1 scripts/php-config scripts/man1/php-config.1 sapi/cli/php.1 sapi/cgi/php-cgi.1 sapi/phpdbg/phpdbg.1 ext/phar/phar.1 ext/phar/phar.phar.1
131	rm -f sapi/fpm/php-fpm.conf sapi/fpm/init.d.php-fpm sapi/fpm/php-fpm.service sapi/fpm/php-fpm.8 sapi/fpm/status.html
132	rm -f ext/phar/phar.phar ext/phar/phar.php
133	if test "$(srcdir)" != "$(builddir)"; then \
134	  rm -f ext/phar/phar/phar.inc; \
135	fi
136	$(EGREP) define'.*include/php' $(top_srcdir)/configure | $(SED) 's/.*>//'|xargs rm -f
137
138prof-gen:
139	CCACHE_DISABLE=1 $(MAKE) PROF_FLAGS=-fprofile-generate all
140	find . -name \*.gcda | xargs rm -f
141
142prof-clean:
143	find . -name \*.lo -o -name \*.o | xargs rm -f
144	find . -name \*.la -o -name \*.a | xargs rm -f
145	find . -name \*.so | xargs rm -f
146	rm -f libphp.la $(SAPI_CLI_PATH) $(SAPI_CGI_PATH) $(SAPI_LITESPEED_PATH) $(SAPI_FPM_PATH) $(OVERALL_TARGET) modules/* libs/*
147
148prof-use:
149	CCACHE_DISABLE=1 $(MAKE) PROF_FLAGS=-fprofile-use all
150
151%_arginfo.h: %.stub.php
152	@if test -e "$(top_srcdir)/build/gen_stub.php"; then \
153		if test ! -z "$(PHP)"; then \
154			echo Parse $< to generate $@;\
155			$(PHP) $(top_srcdir)/build/gen_stub.php $<; \
156		elif test ! -z "$(PHP_EXECUTABLE)" && test -x "$(PHP_EXECUTABLE)"; then \
157			echo Parse $< to generate $@;\
158			$(PHP_EXECUTABLE) $(top_srcdir)/build/gen_stub.php $<; \
159		fi; \
160	fi;
161
162.PHONY: all clean install distclean test prof-gen prof-clean prof-use
163.NOEXPORT:
164