< Previous by Date Date Index Next by Date >
< Previous in Thread Thread Index Next in Thread >

Re: [reSIProcate] Makefile woes


On Wed, 2005-03-02 at 08:09 -0800, Fischl jason wrote:
> Scott, 
> 
> Do you have a suggestion for how to resolve this issue in the Makefile itself?

I'd solve it using the autoconf framework.  

In a .m4 file (or directly in your configure.ac), create a macro like:

================
AC_DEFUN([CHECK_GPERF],
[  
   AC_ARG_ENABLE(gperf,
                [  --enable-gperf        enable profile generation with gperf 
(yes)], 
                [], 
                [ enable_gperf=yes]
   )
   if test "x$enable_gperf" = "xyes"
   then
     AC_MSG_CHECKING([for gperf])
     AC_PATH_PROG(GPERF, gperf, no)
     if test "$GPERF" = "no"
     then 
       enable_gperf=no
       AC_MSG_WARN([not found - gperf disabled])
     else
       AC_SUBST(GPERF)
     fi
   fi
   AM_CONDITIONAL(USE_GPERF, test x$enable_gperf = xyes)
])
================
and invoke it in configure.ac:

CHECK_GPERF

Then in the Makefile.am, take MethodHash.cxx out of your list of sources
and use the USE_GPERF to conditionalize creation of it:

if USE_GPERF

SRC += MethodHash.cxx

SUFFIXES += .gperf .cxx
GPERFOPTS = -D --enum -E -L C++ -t -k '*' --compare-strncmp
#GPERFVER="GNU gperf 2.7.2"

# rule for case sensitive sorts of hash
MethodHash.cxx: MethodHash.gperf
        @GPERF@ $(GPERFOPTS) -Z `echo MethodHash | sed -e 's/.*\///'` $< >  $@

# rule for insensitive clods
#${SRC}: ${@:%.cxx=%.gperf} -- more portable?
%.cxx: %.gperf
        gperf $(GPERFOPTS) -Z `echo $* | sed -e 's/.*\///'` $< | \
        sed -e 's/str\[\([0-9][0-9]*\)\]/tolower(str[\1])/g' | \
        sed -e 's/^\([  ]*\)if *(\*\([a-z][a-z]*\) *== *\*\([a-z][a-z]*\) *\&\& 
*!strncmp *(\([^)]*\)).*/\1if (tolower(*\2) == *\3 \&\& !strncasecmp( \4 ))/g' 
| \
        sed -e 's/\*str ==/tolower(*str) ==/' | \
        sed -e 's/\!strncmp/\!strncasecmp/'  > $@

endif

      

There's a more elaborate macro to test for gperf versions at:

https://oops.kerneljanitors.org/repos/synaptic/trunk/macros/gperf-check.m4


-- 
Scott Lawrence
Consulting Engineer
Pingtel Corp.
http://www.pingtel.com/
+1.781.938.5306 x162