LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-26-2012, 02:32 AM   #1
Meson
Member
 
Registered: Oct 2007
Distribution: Arch x86_64
Posts: 606

Rep: Reputation: 67
make: use target in prerequisites


I want to do something like:

Code:
WRAPPERS   :=  script1 script2

$(WRAPPERS): %.sh.in
	sed 's/.../.../g' $^ > $@
Where % is supposed to match the entire target. I'm sure there's a way to do this. How?
 
Old 04-26-2012, 02:49 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,792

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
either
Code:
%: %.sh.in
   @-rm -rf $@
   sed 's/.../.../g' $^ > $@
or
Code:
script1: script1.sh.in
script2: script2.sh.in

$(WRAPPERS):
   @-rm -rf $@
   sed 's/.../.../g' $@.sh.in > $@
but you mixed
 
Old 04-26-2012, 08:22 AM   #3
Meson
Member
 
Registered: Oct 2007
Distribution: Arch x86_64
Posts: 606

Original Poster
Rep: Reputation: 67
This is what I was looking for:

Code:
WRAPPERS   :=  script1 script2

.SECONDEXPANSION:
$(WRAPPERS): $$@.sh.in
	sed 's/.../.../g' $^ > $@
Is there an even more concise way to do it without the secondary expansion?
 
Old 04-27-2012, 12:50 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,792

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
I gave you two other solutions. Have you tested them? Is there any problem with them?
 
Old 04-27-2012, 05:15 AM   #5
Meson
Member
 
Registered: Oct 2007
Distribution: Arch x86_64
Posts: 606

Original Poster
Rep: Reputation: 67
Yes, they require redundant information.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
MAKEFILE ERROR:' make: *** No rule to make target `MacroCompletudeExe', needed by all ssica Linux - Newbie 5 04-23-2012 10:56 AM
make: using targets, prerequisites from another Makefile Meson Programming 2 12-02-2011 12:53 PM
NS 2 compilation error: make: *** No rule to make target â??VERSIONâ??, needed by â??gen/ve Marz22 Linux - Newbie 8 11-21-2011 02:20 AM
Belkin Wirless G RTL8185L make[1]: *** No rule to make target `Makefile'. Stop. SilverRock Linux - Wireless Networking 2 02-11-2007 07:25 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:38 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration