relatively simple make question

Robert Hartman rhartman at thestepchild.sgi.com
Fri May 17 05:33:01 AEST 1991


In article <621 at elroy> davidk at dsinet (David Karr) writes:
>I have a Make question.  This should be simple, but it is giving me pain.
>
>I have a macro definition called "SRCS".  It is a list of C shell source files.
> ... For every file in the "SRCS"
>list, I want to create a hard link with the ".csh" removed.

It would be better to define a suffix rule for this.  The following makefile
does what you want:

	SCRIPTS = gork flork

	all: $(SCRIPTS)

	.SUFFIXES: .csh
	.csh:
		@echo ln $@ $<

The standard man page isn't too clear about how you go about defining
your own suffix rules (which they refer to as "inference" rules).  What
you must do to add a new suffix rule is to add the new suffixes to the
suffixes list by showing them as dependencies for the .SUFFIXES
target.  Then you must supply a target definition corresponding to the
concatenation of dependency and target suffixes.  The rule in this
target is applied to dependency files with an indicated suffix to
produce a target with another indicated suffix.

In this case, ".csh" is the dependency suffix, and the target suffix is
null.  Thus, the target name for the suffix rule is ".csh."  If I wanted
to produce a target with the suffix "foo," I'd write a rule like this:

	SCRIPTS = gorkfoo florkfoo

	all: $(SCRIPTS)

	.SUFFIXES: .csh foo
	.cshfoo:
        	@echo ln $@ $<


Order is important in the suffixes list.  But you can read the man page to
find out how to tweak the order of the suffixes list, now that you've seen
the basic idea.

-r



More information about the Comp.unix.shell mailing list