[comp.unix.questions] unix commands in makefiles

jjk@astro.UMD.EDU (Jim Klavetter) (02/17/90)

Running under sunos 4.0.3, I have the following in my makefile:

__________________________________________________________________
DEST          = $(HOME)/astrobin/`arch`
...
install:        $(PROGRAM)
	@echo Installing $(PROGRAM) in $(DEST)
	@install -s -g wheel $(PROGRAM) $(DEST)
__________________________________________________________________

And this works as expected when I type "make install":  I get my
program installed in /a/jjk/astrobin/sun3 (if on a sun3).  Note that
this works if the program is made and I only want to install.

However, with the following fragment in place:

__________________________________________________________________
LIBS          = $(HOME)/astro/astro.a \
                $(HOME)/util/util.a \
                $(HOME)/iraf/lib/`arch`/iraf.a \
                /iraf/local/bin.$(FLOAT_OPTION)/libimfort.a \
                /iraf/local/bin.$(FLOAT_OPTION)/libsys.a \
                /iraf/local/bin.$(FLOAT_OPTION)/libvops.a \
                /iraf/local/unix/bin.mc68020/libos.a \
                /usr/lib/libF77.a /usr/lib/libI77.a \
                /usr/lib/libm.a
...
__________________________________________________________________

I get the following error message when I try to make my program:

make: Fatal error: Don't know how to make target `/a/jjk/iraf/lib/`arch`/iraf.a'

Obviously, the `arch` works as expected in the DEST definition, but is
not getting read properly in the LIBS definition.  Can someone please
help me with this?

Thanks

Jim Klavetter
jjk@astro.umd.edu
Astronomy Program
University of Maryland
College Park, MD  20742

matthew@sunpix.East.Sun.COM ( Sun Visualization Products) (02/19/90)

In article <6141@umd5.umd.edu> jjk@astro.UMD.EDU writes:
}
}Running under sunos 4.0.3, I have the following in my makefile:
}
}__________________________________________________________________
}DEST          = $(HOME)/astrobin/`arch`
}__________________________________________________________________
}
}__________________________________________________________________
}LIBS          = $(HOME)/astro/astro.a \
}                $(HOME)/iraf/lib/`arch`/iraf.a \
}__________________________________________________________________
}
}I get the following error message when I try to make my program:
}
}make: Fatal error: Don't know how to make target `/a/jjk/iraf/lib/`arch`/iraf.a'
}
}Obviously, the `arch` works as expected in the DEST definition, but is
}not getting read properly in the LIBS definition.  Can someone please
}help me with this?
}
}Thanks
}
}Jim Klavetter

      Judging by the error message, I assume you were using `$(LIBS)' in a 
dependency list.  Thats were your problem is.  When you were using back-quotes
in the `DEST' macro, the text of that macro got passed to a shell and the 
shell did the command substitution.  Dependency lists are handled by make(1)
itself, and make does not know about command substitutions.

      To get around this problem, try making a new macro called ARCH. ARCH
can be set one of two ways.  

1) If you set an enviromental variable ARCH to the value of `arch` in your 
current working shell, it will propagate to a pre-defined macro in the makefile. 

2) Add the following macro definition to your makefile.  It uses a pre-defined
macro "$(TARGET_ARCH)" and strips off the preceding dash.

	ARCH = $(TARGET_ARCH:-%=%)


-- 
Matthew Lee Stier                            |
Sun Microsystems ---  RTP, NC  27709-3447    |     "Wisconsin   Escapee"
uucp:  sun!mstier or mcnc!rti!sunpix!matthew |
phone: (919) 469-8300 fax: (919) 460-8355    |