Hi!
(I realize that the case I will describe is very uncommon or even weird.)
I'm having trouble writing a makefile the only purpose of which is installing programs (not compiling or making them in any way). I have a dozen shell-scripts that I found difficult to manage (update and install in /usr/local/bin) without some automation. In fact, almost all scripts have to be installed in the same way: we just need to copy them to the directory of choice. But not only I want to be able to install all scripts in bulk (
Here's the makefile I came up with:
But as you may expect, when I run it, I got:
The trick is that in case of pure shell scripts we don't have to 'make' anything, just install. But I want to be able to make this operation by typing
dependency ${src} is interpreted as name of target (which we use as an alias) and this causes dependency loop.
In short, the only thing I have to do now is to tell make to treat dependency ${src} as _filename_. I could not find a way to do it so far.
Is it possible?
Thanks.
(I realize that the case I will describe is very uncommon or even weird.)
I'm having trouble writing a makefile the only purpose of which is installing programs (not compiling or making them in any way). I have a dozen shell-scripts that I found difficult to manage (update and install in /usr/local/bin) without some automation. In fact, almost all scripts have to be installed in the same way: we just need to copy them to the directory of choice. But not only I want to be able to install all scripts in bulk (
make), but also to install specific scripts only ( make script1 script2). Obviously, I'm using bmake.Here's the makefile I came up with:
Makefile:
SRCS= script1 script2 script3
PREFIX= /tmp/usr/local
.for src in ${SRCS}
# Here I want dependency ${src} to be treated as _filename_, not _target_ name.
# |
# v
${PREFIX}/bin/${src}: ${src}
@install -v ${src} ${PREFIX}/bin
.PHONY: ${src}
${src}: ${PREFIX}/bin/${src}
.endfor
But as you may expect, when I run it, I got:
Code:
$ make script1
make: Graph cycles through script1
`script1' not remade because of errors.
The trick is that in case of pure shell scripts we don't have to 'make' anything, just install. But I want to be able to make this operation by typing
make script1, i.e. I have to use 'script1' (filename) as target name as well. And also I don't want installation to be done in case the latest version is already installed. So the only choice is to have two targets: one for the destination file ( ${PREFIX}/bin/${src}) and second - as 'alias' for the first, to be able to run make script1. But error occurs because on this line
Makefile:
${PREFIX}/bin/${src}: ${src}
In short, the only thing I have to do now is to tell make to treat dependency ${src} as _filename_. I could not find a way to do it so far.
Is it possible?
Thanks.