Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use parenthesis in dependency in Makefile

Following is my Makefile:

.PHONY: all

all: /Users/wu/qqaa/homepage\ 1\ 2\ 3/icons\ (a-b)
        @tar cjvf 1.tar.bz2 --exclude=*~ /Users/wu/qqaa/homepage\ 1\ 2\ 3/icons\ \(a-b\)

It didn't work. The problem is the parenthesis in dependency. Adding \ before ( and ) also didn't work. The error is this:

make: *** No rule to make target `/Users/wu/qqaa/homepage 1 2 3/icons (a-b)', needed by `all'. Stop

The directory /Users/wu/qqaa/homepage 1 2 3/icons (a-b) does exist. It seemed that parenthesis couldn't be used in dependency. Is it correct? Or do I miss something?

Sound that colon also couldn't be used in dependency.

I wrote a bash shell script to backup my system. I used make and tar to backup. Using make is to only update the newer files and tar the directory. The problem is that the names of many files have colon or parenthesis and they have special meaning in Makefile. It results in the above problem.

I really appreciate any help. Thank you.

like image 656
warem Avatar asked Nov 10 '11 08:11

warem


1 Answers

The problem is that parentheses mark archive members and seem to be unescapeable. The usual tricks are backslash-escape and escaping by using a variable:

.PHONY : all
leftparen:=(
rightparen:=)
all: /Users/wu/qqaa/homepage\ 1\ 2\ 3/icons\ $(leftparen)a-b$(rightparen)
        @tar cjvf 1.tar.bz2 --exclude=*~ "$@"

And since both don't work in this case, you'll probably have to live with this limitation or file a bug against GNU make.

like image 178
thiton Avatar answered Sep 22 '22 19:09

thiton