xref: /PHP-8.4/ext/phar/Makefile.frag (revision 9fcc1bca)
1$(srcdir)/phar_path_check.c: $(srcdir)/phar_path_check.re
2	@(cd $(top_srcdir); \
3	if test -f ./php_phar.h; then \
4		$(RE2C) $(RE2C_FLAGS) -b -o phar_path_check.c phar_path_check.re; \
5	else \
6		$(RE2C) $(RE2C_FLAGS) -b -o ext/phar/phar_path_check.c ext/phar/phar_path_check.re; \
7	fi)
8
9pharcmd: $(builddir)/phar.php $(builddir)/phar.phar
10
11PHP_PHARCMD_SETTINGS = -n -d 'open_basedir=' -d 'output_buffering=0' -d 'memory_limit=-1' -d phar.readonly=0
12PHP_PHARCMD_EXECUTABLE = ` \
13	if test -x "$(top_builddir)/$(SAPI_CLI_PATH)"; then \
14		$(top_srcdir)/build/shtool echo -n -- "$(top_builddir)/$(SAPI_CLI_PATH) -n"; \
15		if test "x$(PHP_MODULES)" != "x"; then \
16		$(top_srcdir)/build/shtool echo -n -- " -d extension_dir=$(top_builddir)/modules"; \
17		for i in bz2 zlib phar; do \
18			if test -f "$(top_builddir)/modules/$$i.la"; then \
19				. $(top_builddir)/modules/$$i.la; $(top_srcdir)/build/shtool echo -n -- " -d extension=$$dlname"; \
20			fi; \
21		done; \
22		fi; \
23	else \
24		$(top_srcdir)/build/shtool echo -n -- "$(PHP_EXECUTABLE)"; \
25	fi;`
26PHP_PHARCMD_BANG = `$(top_srcdir)/build/shtool echo -n -- "$(INSTALL_ROOT)$(bindir)/$(program_prefix)php$(program_suffix)$(EXEEXT)";`
27
28$(builddir)/phar/phar.inc: $(srcdir)/phar/phar.inc
29	-@test -d $(builddir)/phar || mkdir $(builddir)/phar
30	-@test -f $(builddir)/phar/phar.inc || cp $(srcdir)/phar/phar.inc $(builddir)/phar/phar.inc
31
32TEST_PHP_EXECUTABLE = $(shell $(PHP_EXECUTABLE) -v 2>&1)
33TEST_PHP_EXECUTABLE_RES = $(shell echo "$(TEST_PHP_EXECUTABLE)" | grep -c 'Exec format error')
34
35$(builddir)/phar.php: $(srcdir)/build_precommand.php $(srcdir)/phar/*.inc $(srcdir)/phar/*.php $(SAPI_CLI_PATH)
36	-@(echo "Generating phar.php"; \
37	if [ "$(TEST_PHP_EXECUTABLE_RES)" != 1 ]; then \
38		$(PHP_PHARCMD_EXECUTABLE) $(PHP_PHARCMD_SETTINGS) $(srcdir)/build_precommand.php > $(builddir)/phar.php; \
39	else \
40		echo "Skipping phar.php generating during cross compilation"; \
41	fi)
42
43$(builddir)/phar.phar: $(builddir)/phar.php $(builddir)/phar/phar.inc $(srcdir)/phar/*.inc $(srcdir)/phar/*.php $(SAPI_CLI_PATH)
44	-@(echo "Generating phar.phar"; \
45	if [ "$(TEST_PHP_EXECUTABLE_RES)" != 1 ]; then \
46		rm -f $(builddir)/phar.phar; \
47		rm -f $(srcdir)/phar.phar; \
48		$(PHP_PHARCMD_EXECUTABLE) $(PHP_PHARCMD_SETTINGS) $(builddir)/phar.php pack -f $(builddir)/phar.phar -a pharcommand -c auto -p 0 -s $(srcdir)/phar/phar.php -h sha1 -b "$(PHP_PHARCMD_BANG)"  $(srcdir)/phar/; \
49		chmod +x $(builddir)/phar.phar; \
50	else \
51		echo "Skipping phar.phar generating during cross compilation"; \
52	fi)
53
54install-pharcmd: pharcmd
55	@(if [ "$(TEST_PHP_EXECUTABLE_RES)" != 1 ]; then \
56		$(mkinstalldirs) $(INSTALL_ROOT)$(bindir); \
57		$(INSTALL) $(builddir)/phar.phar $(INSTALL_ROOT)$(bindir)/$(program_prefix)phar$(program_suffix).phar; \
58		rm -f $(INSTALL_ROOT)$(bindir)/$(program_prefix)phar$(program_suffix); \
59		$(LN_S) -f $(program_prefix)phar$(program_suffix).phar $(INSTALL_ROOT)$(bindir)/$(program_prefix)phar$(program_suffix); \
60		$(mkinstalldirs) $(INSTALL_ROOT)$(mandir)/man1; \
61		$(INSTALL_DATA) $(builddir)/phar.1 $(INSTALL_ROOT)$(mandir)/man1/$(program_prefix)phar$(program_suffix).1; \
62		$(INSTALL_DATA) $(builddir)/phar.phar.1 $(INSTALL_ROOT)$(mandir)/man1/$(program_prefix)phar$(program_suffix).phar.1; \
63	else \
64		echo "Skipping install-pharcmd during cross compilation"; \
65	fi)
66