[Top][All Lists]

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

Re: Gnu make-isms

From: Paul D. Smith
Subject: Re: Gnu make-isms
Date: Wed, 3 Dec 2003 11:22:43 -0500

%% Angus Leeming <address@hidden> writes:

  al> this might sound like a strange thing to ask on this list, but I'd
  al> like to remove some gnu make-isms from the Makefiles I'm
  al> maintaining.

Good luck with that :-/.

Before you go any further, though, sit down and decide what your real
goal here is: what versions of make do you want to be portable to?

If the answer is "all of them", stop what you're doing right there, go
out and download and invest in getting autoconf and automake set up for
your project.  It'll be much simpler in the long run than trying to
write a completely portable makefile.  The POSIX definition of make, for
example, doesn't even provide an "include" directive of any sort.

You can go "halfway" and try to have your makefiles portable between GNU
make and SysV make; that's at least worth considering.  Even so, it will
be annoying.

  al> All well and good. However, I am stumped with what to do with this:

  al> %.C: %.h %.ui
  al>         $(UIC) $(UICFLAGS) -impl $^ -o $@

  al> Fixing the top line is easy --- same as above. However, the second 
  al> rule is more complex and I'm stuck.

There is no way in make suffix rule syntax to emulate the above rule

  al> 2. The .C file also depends on the .h file -> '.ui.C: $*.h' ???

No, this is not valid syntax.  Automatic variables like $* are available
only within the command script, not in the prerequisites list.

  al> 3. '$^' in the build rule. The line above expands to:
  al> /usr/local/kde/qt/bin/uic -tr qt_ -impl QMathDialogBase.h 
  al> ../../../../../src/frontends/qt2/ui/QMathDialogBase.ui -o 
  al> QMathDialogBase.C
  al> so, somehow '$^' is expanded to 'QMathDialogBase.h 
  al> ../../../../../src/frontends/qt2/ui/QMathDialogBase.ui'
  al> Ie, it is probably equivalent to somethng like '$*.h $<' but I haven't 
  al> got this to work yet.

The $^ variable is not available in standard make (although I thought
SysV make had it... but maybe not).

$< is not what you want: that's the first prerequisite only, not all of

>From the above I also assume you're using VPATH: you couldn't get that
result given that pattern rule if you weren't.

VPATH is not part of standard make, and the SysV implementation of VPATH
is brain-damaged.  You'll probably not be able to use VPATH in a
portable makefile.

If you weren't using VPATH I'd say you have to do this:

         $(UIC) $(UICFLAGS) -impl $*.h $*.ui -o $@

but, since you are using VPATH that won't work.

 Paul D. Smith <address@hidden>          Find some GNU make tips at:            
 "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]