[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: makefile not taking aliases into account



Michael Marsh wrote:
On 5/8/05, Kamaraju Kusumanchi <kk288@cornell.edu> wrote:

Hi
   Using Debian sid. I have an alias in my .bashrc say something like

alias x="y"

This command is executing fine on a bash shell (ie I can use x). But
when I use x in a makefile, it is not getting expanded to y. Is this a
future? How can I overcome this limitation?


Unless you've told it otherwise, make isn't using bash, it's using sh.
 While sh is probably a symlink to bash, when invoked as "sh" it
doesn't read your .bashrc (nor the system default).  You can change
this behavior with the SHELL variable in your makefile:

SHELL := /bin/bash


Thanks. I will try that.

In general, though, it's better to set everything that you need in the
makefile, since relying on your aliases makes your makefile highly
non-portable.  I usually do something like (using your example):

X := y

and then using $(X) instead of the alias x in commands.


Actually for me the reason for sourcing the .bashrc is for portability! This is my situation. Consider two machines A and B. I use gfortran compiler on these machines with the same makefile. I have latest gcc-snapshot on machine A and a bit older gcc-snapshot on machine B. The latest gcc-snapshot package names the gfortran executable as gfortran-20050507-1 while the older gcc-snapshot calls it gfortran. This makes the makefile non-portable (as it relies on compiler set to gfortran) across A and B. So I decided to put an alias for gfortran in the .bashrc of machine A, so that gfortran will in turn call gfortran-20050507-1. Is there any other portable solution way for this situation?

Thanks for the reply again.
raju



Reply to: