bug-make
[Top][All Lists]
Advanced

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

Re: Makefile problems together with OSTYPE env variable


From: Paul D. Smith
Subject: Re: Makefile problems together with OSTYPE env variable
Date: Mon, 2 Sep 2002 23:21:51 -0400

%% Gernot Ziegler <address@hidden> writes:

  gz> Now my problem is rather ... simple: I wish to use $(OSTYPE) in my
  gz> Makefile, and the code I am using is The funny thing is that a
  gz> simple "make" on my Linux machine (Not on the IRIX, it works there
  gz> with GNU make) doesn't find this OSTYPE env variable, it reports
  gz> it to be empty

  gz> but as soon as I reset the variable with
  gz> address@hidden texmpeg]# export OSTYPE=linux-gnu

  gz> it works !!

  gz> That's a real weirdie, isn't it ? ;)

I don't know why you think it's weird: you have solved your own problem.

Shell builtin variables like OSTYPE are not exported by default.  They
are defined only in the shell.  So, any program the shell creates,
_including make_, cannot see that value just as it couldn't see any
other non-exported value.

Once you export it, then it becomes visible to subprocesses (BTW, you
don't have to reset the value, just use "export OSTYPE").


But, note that this variable is set by your shell (bash) and is a
shell-specific feature.  That means that if other people use different
shells (sh, csh, tcsh, ksh, etc.) and try to invoke your build
environment, it will fail.

I strongly recommend _against_ using this kind of environment-specific
value in your makefiles.  Try this, for a more portable solution:

  OSTYPE := $(shell uname -msr)

Or season the options to uname to taste.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.paulandlesley.org
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist




reply via email to

[Prev in Thread] Current Thread [Next in Thread]