1
votes

I try to write a makefile, and I'm stuck.

In this project, make is supposed do generate/update a .zip file, named after the directory containing the makefile.

MyWorkingDirectory/ -> MyWorkingDirectory.zip

Somebody gave me some code, here, but it fails with /bin/sh: -c: ligne 0: syntax error near unexpected token "("

CIBLE:= $(shell  basename  "`pwd`".zip)
SRC=blabla
OBJ=blabla
all: $(CIBLE)

$(CIBLE): $(OBJ)
   rm $@ 2>/dev/null;zip -j $@ $^

I have GNU make 4.2.1

Thank you !

2
"it fails" is not a problem report we can do anything with. - MadScientist
Sorry. Make fails, with this error : /bin/sh: -c: ligne 0: syntax error near unexpected token "(" - Sergei Leduc
There must be more to your environment than you are mentioning here, or else the makefile above is different in some important way from the one you're actually using. That makefile works fine for me. What operating system are you using? - MadScientist
I'm going to guess your default shell is not bash. - alexis
It is bash ! But I fixed it. First line wasn't the problem. I'll explain in the first post. Thank you ! - Sergei Leduc

2 Answers

0
votes

You can get the name of the current directory also with:

CIBLE := $(notdir $(abspath .))

This circumvents the shell, which may be the problem in your case.

0
votes

The first line wasn't the problem...

In makefile, I quoted all $@

rm "$@" 2>/dev/null;zip -j "$@" $^

And I make sure that there are no parenthesis in the name of my CIBLE. Parenthesis were the issue, I think.

Thank you all.