# need help with Makefile

- Thread: https://externals.io/message/43741
- Original archive: https://news-web.php.net/php.internals/43741
- Started by Greg Beaver on 2009-04-19T22:56:46+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #43741 — Greg Beaver — 2009-04-19T22:56:46+00:00

URL: https://externals.io/message/43741#43741

Hi,

I never do Makefile stuff, so I need someone who can tell me why this 
blasted piece of scripting doesn't work:

@if test "a$(program_prefix)" != "a"; then \
    PEAR_PREFIX = " -dp php_prefix=$(program_prefix)"; \
fi
@if test "a$(program_suffix)" != "a"; then \
    PEAR_SUFFIX = " -ds php_suffix=$(program_suffix)"; \
fi

install-pear-installer: $(SAPI_CLI_PATH)
    @$(top_builddir)/sapi/cli/php $(PEAR_INSTALL_FLAGS) 
$(builddir)/install-pear-nozlib.phar -d "$(peardir)" -b "$(bindir)" 
$(PEAR_PREFIX) $(PEAR_SUFFIX)


What I am trying to do is to pass in those options ONLY if 
--program_prefix or --program_suffix were specified in the configure line.

Any working solution is appreciated.

Thanks,
Greg

---

## #43742 — sean finney — 2009-04-20T06:11:28+00:00

URL: https://externals.io/message/43741#43742 · In reply to: #43741

hi greg,


> blasted piece of scripting doesn't work:
>
> @if test "a$(program_prefix)" != "a"; then \
>    PEAR_PREFIX = " -dp php_prefix=$(program_prefix)"; \
> fi
> @if test "a$(program_suffix)" != "a"; then \
>    PEAR_SUFFIX = " -ds php_suffix=$(program_suffix)"; \
> fi

1) you can't put arbitrary shell commands in the body of a makefile: it has
to be part of the rule for a target.
2) you need to remove spaces around the "=" assignment for it to be valid shell
   (or iow you can't mix shell and makefile syntax like that)

>
> install-pear-installer: $(SAPI_CLI_PATH)
>    @$(top_builddir)/sapi/cli/php $(PEAR_INSTALL_FLAGS)  
> $(builddir)/install-pear-nozlib.phar -d "$(peardir)" -b "$(bindir)"  
> $(PEAR_PREFIX) $(PEAR_SUFFIX)
>
>
> What I am trying to do is to pass in those options ONLY if  
> --program_prefix or --program_suffix were specified in the configure 
> line.
>
> Any working solution is appreciated.

here's one way using makefile syntax (not sure if this works with other
than gnu makefiles though)

ifneq(,$(program_prefix))
  PEAR_PREFIX = " -dp php_prefix=$(program_prefix)"; \
endif
ifneq(,$(program_suffix))
  PEAR_SUFFIX = " -ds php_suffix=$(program_suffix)"; \
endif

> install-pear-installer: $(SAPI_CLI_PATH)
>    @$(top_builddir)/sapi/cli/php $(PEAR_INSTALL_FLAGS)  
> $(builddir)/install-pear-nozlib.phar -d "$(peardir)" -b "$(bindir)"  
> $(PEAR_PREFIX) $(PEAR_SUFFIX)

suggestion two, maybe more portable?:

export PEAR_SUFFIX
export PEAR_PREFIX

install-pear-installer: $(SAPI_CLI_PATH)
   @$(top_builddir)/sapi/cli/php $(PEAR_INSTALL_FLAGS) $(builddir)/install-pear-nozlib.phar -d "$(peardir)" -b "$(bindir)"  $${PEAR_PREFIX:- -ds php_prefix=$(program_prefix)} $${PEAR_SUFFIX:- -ds php_suffix=$(program_suffix)}

though that mnight have interesting results if program_suffix has a '}' in it...


hth,
	sean
