xref: /PHP-8.3/ext/phar/Makefile.frag (revision 4fcb3e0d)
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) --no-generation-date -b -o phar_path_check.c phar_path_check.re; \
5	else \
6		$(RE2C) $(RE2C_FLAGS) --no-generation-date -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
32
33TEST_PHP_EXECUTABLE = $(shell $(PHP_EXECUTABLE) -v 2>&1)
34TEST_PHP_EXECUTABLE_RES = $(shell echo "$(TEST_PHP_EXECUTABLE)" | grep -c 'Exec format error')
35
36$(builddir)/phar.php: $(srcdir)/build_precommand.php $(srcdir)/phar/*.inc $(srcdir)/phar/*.php $(SAPI_CLI_PATH)
37	-@(echo "Generating phar.php"; \
38	if [ "$(TEST_PHP_EXECUTABLE_RES)" != 1 ]; then \
39		$(PHP_PHARCMD_EXECUTABLE) $(PHP_PHARCMD_SETTINGS) $(srcdir)/build_precommand.php > $(builddir)/phar.php; \
40	else \
41		echo "Skipping phar.php generating during cross compilation"; \
42	fi)
43
44$(builddir)/phar.phar: $(builddir)/phar.php $(builddir)/phar/phar.inc $(srcdir)/phar/*.inc $(srcdir)/phar/*.php $(SAPI_CLI_PATH)
45	-@(echo "Generating phar.phar"; \
46	if [ "$(TEST_PHP_EXECUTABLE_RES)" != 1 ]; then \
47		rm -f $(builddir)/phar.phar; \
48		rm -f $(srcdir)/phar.phar; \
49		$(PHP_PHARCMD_EXECUTABLE) $(PHP_PHARCMD_SETTINGS) $(builddir)/phar.php pack -f $(builddir)/phar.phar -a pharcommand -c auto -x \\.svn -p 0 -s $(srcdir)/phar/phar.php -h sha1 -b "$(PHP_PHARCMD_BANG)"  $(srcdir)/phar/; \
50		chmod +x $(builddir)/phar.phar; \
51	else \
52		echo "Skipping phar.phar generating during cross compilation"; \
53	fi)
54
55install-pharcmd: pharcmd
56	@(if [ "$(TEST_PHP_EXECUTABLE_RES)" != 1 ]; then \
57		$(mkinstalldirs) $(INSTALL_ROOT)$(bindir); \
58		$(INSTALL) $(builddir)/phar.phar $(INSTALL_ROOT)$(bindir)/$(program_prefix)phar$(program_suffix).phar; \
59		rm -f $(INSTALL_ROOT)$(bindir)/$(program_prefix)phar$(program_suffix); \
60		$(LN_S) -f $(program_prefix)phar$(program_suffix).phar $(INSTALL_ROOT)$(bindir)/$(program_prefix)phar$(program_suffix); \
61		$(mkinstalldirs) $(INSTALL_ROOT)$(mandir)/man1; \
62		$(INSTALL_DATA) $(builddir)/phar.1 $(INSTALL_ROOT)$(mandir)/man1/$(program_prefix)phar$(program_suffix).1; \
63		$(INSTALL_DATA) $(builddir)/phar.phar.1 $(INSTALL_ROOT)$(mandir)/man1/$(program_prefix)phar$(program_suffix).phar.1; \
64	else \
65		echo "Skipping install-pharcmd during cross compilation"; \
66	fi)
67