[makefile] multi line function calling

whired123

Member
Joined
Nov 15, 2021
Messages
151
Reaction score
10
Credits
1,097
Code:
+ tree . /tmp/abc
.
└── makefile
/tmp/abc
├── file1
└── file2

+ cat makefile 
define my_function
    ls -1 /tmp/abc/$(1) /tmp/abc/$(2)
endef

default:
    # SINGLE LINE: OK
    $(call my_function,file1,file2)

    # MULTI LINE: ERROR
    $(call my_function, \
        "file1", \
        file2 \
    )

+ make
# SINGLE LINE: OK
ls -1 /tmp/abc/file1 /tmp/abc/file2
/tmp/abc/file1
/tmp/abc/file2
# MULTI LINE: ERROR
ls -1 /tmp/abc/ "file1" /tmp/abc/ file2 
ls: cannot access 'file1': No such file or directory
ls: cannot access 'file2': No such file or directory
/tmp/abc/:
file1
file2

/tmp/abc/:
file1
file2
make: *** [makefile:9: default] Error 2

Synthesis

Code:
# SINGLE LINE: OK
ls -1 /tmp/abc/file1 /tmp/abc/file2
/tmp/abc/file1
/tmp/abc/file2
# MULTI LINE: ERROR
ls -1 /tmp/abc/ "file1" /tmp/abc/ file2 
ls: cannot access 'file1': No such file or directory
ls: cannot access 'file2': No such file or directory

Why?
 


Sorry for the delay.
I don't remember how now, but I think I solved the problem.
Perhaps it was enough to remove the space before the backslashes.
 


Follow Linux.org

Staff online

Members online


Latest posts

Top