help-make
[Top][All Lists]
Advanced

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

Re: Help with make files


From: Paul D. Smith
Subject: Re: Help with make files
Date: Thu, 3 Feb 2005 21:17:33 -0500

%% Peter Holmes <address@hidden> writes:

  ph> I have a situation like this. I need some constants that can be
  ph> included by c files and makefiles. So I am thinking of having a .h
  ph> file declare these constants.  I need the Make file to pick up the
  ph> constants from this .h file.

What do you mean by "constants"?  Make only knows about make variables.
You mean, you want to have some C #defines, like:

    #define FOO     10

then translate that into a make variable setting, like:

    FOO = 10

?


You could do it something like this:

    include c_constants.mk

    c_constants.mk: c_constants.h
            sed -n 's/ *# *define *\([^ ]*\) *\(.*\)/\1 = \2/p' < $< > $@

This won't work if you're using TABs in your C header file: updates to
support TABs as well as spaces are left as an exercise for the reader :-).

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