help-make
[Top][All Lists]
Advanced

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

Re: generate a File-ID??


From: Paul D. Smith
Subject: Re: generate a File-ID??
Date: Mon, 3 Jul 2006 17:06:40 -0400

%% Torsten Mohr <address@hidden> writes:

  tm> At the moment i think about adding a command line #define like:

  tm> obj/%.o : %.c
  tm>         $(CC) -DF_ID=F_ID_$(subst .,_,$<)

  tm> If then F_ID_main_c := 1 the compiler option should expand to
  tm> -DF_ID=1 for "main.c".

In that case I think you meant:

> obj/%.o : %.c
>         $(CC) -DF_ID=$(F_ID_$(subst .,_,$<))

  tm> Now the question, if there is a list of sources in SRC, can i
  tm> somehow automatically generate variables F_ID_main_c, F_ID_init_c
  tm> and so on?  I think of a clever combination of $(words),
  tm> $(wordlist), $(eval) and maybe others?

I really don't think this is a good idea.  If you generate it like this
then whenever you add a new file to the system all the existing files
will be renumbered, unless you're sure you always only ever add them at
the end of the list.

Also, what about files in different directories?  They'll have the same
ID#.  Or, do you plan to have a directory ID# as well?  Or maybe
restrict the build environment so that no filename can appear twice,
even in different directories (yuck...)


My advice is don't risk it, and write out the list of numbers by hand,
either in your makefile or in some .h file.

One advantage of doing it in the makefile is that you won't have to
rebuild the world every time you add a new file (and thus change the .h
file).

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