bug-make
[Top][All Lists]
Advanced

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

Function or variable to get the name of the current makefile.


From: mhaigh
Subject: Function or variable to get the name of the current makefile.
Date: Thu, 19 Sep 2002 16:18:27 -0700

Hello,
 
To the best of my knowledge, currently there's no way to determine the name of the makefile currently being read.  This information is useful to me, and I'd like to implement a 'thisfile' function that returns it.  The change would be minimal; basically I'd need to add func_thisfile() and ouput the reading_file->filenm string.  Also, a small change to lookup_function() is required so that we don't always assume that a function name has a whitespace or '\0' after it.
 
Would such a change be acceptable for inclusion in the next release?  Of course I will implement, thoroughly test, and document it.
 
In case you're wondering, I use the name of the makefile stub to generate a variable name prefix to avoid name collisions anywhere within a mountain of makefiles.  This can be used to implement a very simple non-recursive process.  For example (just off the top of my head):
 
%.o : %.c
    $(CC) $(if $($(call get_prefix,$(@D))_CFLAGS),$($(call get_prefix,$(@D))_CFLAGS),$(CFLAGS))
 
In other words, here if an included makefile stub has a variable $(call get_prefix $(dir $(thisfile)))_CFLAGS set, it will be used for files in the same directory; otherwise the default CFLAGS will be used.  There's probably other circumstances where $(thisfile) would come in handy, also.
 
Thanks,
 
Mark
 
 
Mark Haigh
Sr. Firmware Engineer
SonicWALL, Inc
m h a i g h @ s o n i c w a l l . c o m
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]