How to use brackets depending on Makefile

Below is my Makefile:

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

This did not work. The problem is in parentheses depending. Adding \ to ( and ) also did not help. The error is this:

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

Directory / Users / wu / qqaa / homepage 1 2 3 / icons (ab) exists. It seemed that parentheses could not be used depending. Is it correct? Or am I missing something?

The sound that the colon also cannot be used depends on.

I wrote a bash shell script to backup my system. I used make and tar for backup. Using make is updating only new files and tar directories. The problem is that many file names have a colon or brackets, and they have special meaning in the Makefile. This leads to the above problem.

I really appreciate any help. Thanks.

+4
source share
2 answers

The problem is that parentheses mark archive elements and seem inconspicuous. Common tricks - backslash - escape and escape using a variable:

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

And since both do not work in this case, you will probably have to live with this restriction or file a GNU make error message.

+3
source

For me, I had this problem with the Makefile that I used on Windows. The compiler is a 32-bit version of MinGW64-W32.

gcc --version shows: gcc (i686-posix-sjlj-rev0, Built by MinGW-W64 project) 5.1.0

make --version shows: GNU Make 3.81

I wrote a Makefile that was supposed to include modified directories (i.e. include directories for a 32-bit compiler are different from include directories for a 64-bit compiler). I needed to include something like: -IC:/Program Files (x86)/mingw-w64/gtk+-3.6.4_win32/include/gtk-3.0

For instance. I had the same problem when I tried to compile the compiler was wrong (on line 0 or something. My solution was simple. I just had to use double quotes, for example:

-I"C:/Program Files (x86)/mingw-w64/gtk+-3.6.4_win32/include/gtk-3.0"

The use of double quotes. This allowed me to successfully compile my program.

Note. Usually on Linux for a directory with spaces we need something like:

-I"C:/Program\ Files\ (x86)/mingw-w64/gtk+-3.6.4_win32/include/gtk-3.0"

with \ in front of the space. In the Makefile, if I use \ for spaces, with a double quote, the program does not compile. I believe the Makefile thinks that \ is actually part of the directory name when I use double quotes.

For your code, try something like:

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

If this does not work, try something like:

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

In any case, good luck.

0
source

Source: https://habr.com/ru/post/1380532/


All Articles