help-make
[Top][All Lists]
Advanced

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

Re: posix standards? $(CURDIR) or $$PWD or $(shell pwd)?


From: Paul D. Smith
Subject: Re: posix standards? $(CURDIR) or $$PWD or $(shell pwd)?
Date: Fri, 11 Oct 2002 16:18:59 -0400

%% gk <address@hidden> writes:

  g> I am trying to write makefiles that are least dependent on a
  g> particular make.  The Gnu make manual says:

Let me prefix this message by saying that what you want to do is going
to be very frustrating, and you should only proceed if you have _VERY_
strong reasons you _MUST_ do this, such as external requirements.  The
POSIX definition of make is very anemic: it's so undemanding that it
doesn't even provide for an "include" feature, much less many other more
powerful capabilities.

It's far, far better for your sanity to forego the idea of writing
portable makefiles, and use a portable _make program_ instead.  GNU make
is available in source form and compiles on virtually every version of
UNIX, plus VMS, DOS, Windows, and Amiga.  Coming shortly (currently
available as patches) is a port to OS/2.

Failing that, you'll probably want to use automake or some other
makefile generating tool: writing POSIX compliant makefiles is tedious
enough that you won't want to do it by hand.

  g> The make programs in various other systems support a few features
  g> that are not implemented in GNU make. The POSIX.2 standard (IEEE
  g> Standard 1003.2-1992) which specifies make does not require any of
  g> these features.

  g> Does this imply that Gnu make is POSX.2 compliant and contains no
  g> non-POSIX features?

No.

Those two things ("is POSIX.2 compliant" and "contains no non-POSIX
features") are entirely orthogonal.

If you put the special target ".POSIX:" into your makefile, then GNU
make will be POSIX.2 compliant (except for bugs--note there are two
small inconsistencies with POSIX currently reported as open bugs--but
you'll likely not notice them).  That means that if you have a makefile
which conforms to the POSIX.2 standard for make, GNU make will process
it properly as defined by the standard.

That does _NOT_ mean that all non-POSIX capabilities in GNU make are
turned off; that is, if you specify POSIX and use a GNU extension it
will not give you an error.  There is no mode in GNU make which will do
this, and this is not required to be POSIX-compliant ("compliant"
doesn't mean "only works with compliant input", it means "always works
with compliant input").

  g> In particular, I would like to know which is better: $(CURDIR) or
  g> $$PWD or $(shell pwd)?  Is $(CURDIR) supported by all makes, or at
  g> least by POSIX?

No.  CURDIR is only supported by GNU make, I think, although other makes
may have variables with the same value but different names.  There is no
variable that contains the working directory in the POSIX definition of
make.

The $(shell ...) function is completely GNU make-specific of course;
POSIX does not define anything like a function.

The form $$PWD uses the shell variable $PWD; note that not all shells
implement this (although IIRC POSIX shells must).  Whether or not that
works, in other words, is up to your shell, not to make.

  g> Where can I find 'posix standard' for make? It appears to not be
  g> freely available.

It is not.  IEEE does not publish its standards freely.  However, a
newer version, the SingleUNIX spec, is available freely.  This is based
on POSIX but has some enhancements: note that GNU make probably does not
fully conform to this version (but the differences are only a few odd
enhancements here and there).

You can find the section on make here:

http://www.opengroup.org/onlinepubs/007904975/toc.htm

  g> It is apparently only a 40 page document: I have seen it on
  g> techstreet.com for the price of $51 hardcover; $107 for PDF
  g> version.

  g> Standard            Read about Tracking...
  g>                             IEEE Standards Interpretations for IEEE Std. 
  g> 1003.2-1992 : March
  g>                             1994 Edition
  g>                             Document Number: IEEE 1003.2-1992
  g>                             Institute of Electrical and Electronics 
Engineers
  g>                             01-Jan-1994
  g>                             ISBN: 155937411X
  g>                             40 pages

No, this is not even _close_ to what you are looking for.  This is just a
little booklet addition to POSIX.

The thing you are looking for is the IEEE Std 1003.2-1992 (revised as
IEEE Std 1003.1-1996 and again as IEEE Std 1003.1-2001), volume titled
_Shells and Utilities_ (there are multiple volumes of POSIX; make is
described in this one).

That one volume of the POSIX standard is 1,122 pages long including
table of contents, index, and appendices.

Of course the section describing make is only 20 pages or so long.

-- 
-------------------------------------------------------------------------------
 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]