%% Peter Holmes <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]>          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


_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make

Reply via email to