user3313834
user3313834

Reputation: 7837

split lines in Makefile functions

I define function in my Makefile (here clone_or_pull) it's working well

I would like to know what is the correct way to slip lines in the function body, to get 80cols lines.

Here is my Makefile

#
# Development workflow
#
define clone_or_pull
        ([ -d $(1) ] && ((cd $(1) && git fetch && git rebase) || printf '\e[91mCould not rebase git repo $(1)\e[0m\n')) || git clone [email protected]:group1/$(1).git
endef

clone_or_pull_dependencies:
        $(call clone_or_pull,zf_nlp)
        $(call clone_or_pull,nlp_api)

I call it with:

$ make clone_or_pull_dependencies

Upvotes: 0

Views: 84

Answers (1)

user3313834
user3313834

Reputation: 7837

As said by @igagis \ at the end made the trick. BTW it then else make it more clear.

define clone_or_pull
  if test -d $(1) ;                                                    \
  then                                                                 \
    cd $(1) && git fetch && git rebase ;                               \
  else                                                                 \
    printf '\e[91mCould not rebase git repo $(1); Cloning it\e[0m\n' ; \
    git clone [email protected]:group1/$(1).git ;           \
  fi
  @printf '\e[92m Update of $(1) Done\e[0m\n'
endef

Upvotes: 1

Related Questions