🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.unix.programmer
3 messages
3 total messages Started by Steve Simmons Fri, 15 Feb 2002 19:04
A simple make rule looks hard....
#3754
Author: Steve Simmons
Date: Fri, 15 Feb 2002 19:04
28 lines
1811 bytes
I'm trying to write a make rule that uses the suffix of the source in
the actions.  To give an example, one could write a rule set to install
man pages like so:

.1.man:
	cp $< /usr/local/man/man1/$<

.2.man:
	cp $< /usr/local/man/man2/$<

.3.man:
	cp $< /usr/local/man/man3/$<

and so on for all the variants.  What I'd prefer to do is a single
rule which uses the suffix of the source.

.1.man .2.man .3.man:
	cp $< /usr/local/man/man$(S)/$<

where $(S) is the suffix 1, 2, 3, etc.  Damned if I can find a
way to get the suffix as any of gnu makes canned variables.

Yes, I realize this contrived example would do the wrong thing if
I have both a foo.1 and a foo.3.
--
`Have you noticed that, when we were young, we were told that "everybody
else is doing it" was a really stupid reason to do something, but now it's
the standard reason for picking a particular software package?' -- Barry Gehm
Re: A simple make rule looks hard....
#3755
Author: Eli Zaretskii
Date: Sat, 16 Feb 2002 06:45
11 lines
1392 bytes
Steve Simmons wrote:
> 
> .1.man .2.man .3.man:
>         cp $< /usr/local/man/man$(S)/$<
> 
> where $(S) is the suffix 1, 2, 3, etc.  Damned if I can find a
> way to get the suffix as any of gnu makes canned variables.

Did you miss the description of the $(suffix) built-in function in the
manual?  AFAICS, something like $(subst .,,$(suffix $<)) should do what you
want.  (Warning: untested!)
Re: A simple make rule looks hard....
#3756
Author: Koushik Banerjee
Date: Mon, 18 Feb 2002 09:21
41 lines
2345 bytes

Eli Zaretskii wrote:

> Steve Simmons wrote:
> >
> > .1.man .2.man .3.man:
> >         cp $< /usr/local/man/man$(S)/$<
> >
> > where $(S) is the suffix 1, 2, 3, etc.  Damned if I can find a
> > way to get the suffix as any of gnu makes canned variables.
>
> Did you miss the description of the $(suffix) built-in function in the
> manual?  AFAICS, something like $(subst .,,$(suffix $<)) should do what you
> want.  (Warning: untested!)

I tried to do it some other way( I really didnot try , but just tried to make
sure it looked fine), the following way
==========
MAN_DIR=/usr/local/man
BLAFILES= .1.man .2.man .3.man
TARGET:=${BLAFILES:.%.bla=$(MAN_DIR)/man%}

all:   $(TARGET)

$(MAN_DIR)/man% : .%.man
  @cp $< $@/$<
===========

  Here the copy rule will be executed once TARGET is being made from all. Just
give it a try, and let me know if it works. And since the dependency is on the
man files, it will be executed everytime the man file changes. Do let me know
if it works.

--
cheerio,
       Koushik.

//
// << The idea expressed above are solely mine, and doesnot represent >>
// << that of my employer and/or any person implicitly/explicitly    >>
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads