slang-users mailing list

[2014 Date Index] [2014 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: [slang-users] SLprep_set_eval_hook() usage


Gisle Vanem <gvanem@xxxxxxxx> wrote:
> I'm trying to extend my small S-Lang powered preprocessed makefile
> (modelled after mkmake.c in ./src) to return the Windows SDK-version
> my input file is targeting.

As you know, mkmake.c is very simple.  It simply takes keywords from the
command line and adds them to the preprocessor to be used in
constructs such as:

   #ifdef KEYWORD
     bla bla bla
   #else
     foo bar
   #endif

> My idea was to map values from GetVersionEx() into '-D_WIN32_WINNT=0x??'
> values (assuming the SDK match the OS-ver). How do I do this best?
>
> I tried using the 'SLprep_set_eval_hook()' function and in my makefile:
>   @if $WinDir
>   @if (CFLAGS = -D_WIN32_WINNT=0x??)
>   @endif

By "@if (CFLAGS = -D_WIN32_WINNT=0x??)", are you checking to see if
CFLAGS is equal to "-D_WIN32_WINNT=0x??"?

Is CFLAGS an environment variable, or is it set in the makefile?  If
it is set in the makefile, then the preprocessor knows nothing about
it.  If set in the environment, then the preprocessor can make use of
it as described in the comments of slprep.c:

 * #if$ENV TOKEN1 TOKEN2 ...
 *	- True if the contents of enviroment variable ENV match
 *	  any of TOKEN1 TOKEN2 ...
 *
 * #ifn$ENV TOKEN1 TOKEN2 ...
 * #if !$ENV TOKEN1 TOKEN2 ...
 *	- True if the contents of enviroment variable ENV do not match
 *	  any of TOKEN1 TOKEN2 ...
 *
 *	NB: For $ENV, the tokens may contain wildcard characters:
 *		'?' - match any single character
 *		'*' - match any number of characters

> And see that my hook is called with 
>   '(CFLAGS = -D_WIN32_WINNT=0x??)\n'
>
> Is the only way for hook to be called if the line starts with '@if ('?

Yes, the hook will get called for one of the following forms:

   #if (expression)
   #ifeval expression
   #if !(expression)
   #elif (expression)
   #elifeval expression
   #elif !(expression)

> If so, do I simply copy the '-DCFLAGS = _WIN32_WINNT=0x0x501'
> back into the 'expr' buffer? The docs on this very dim IMHO.

I do not know what you mean.  The slang preprocessor functions do the
working of placing expressions from the file into the buffer.

Perhaps, off-list, you should send me an example makefile that you
would like to preprocess.  This will give me a better idea what you
are trying to do.

Thanks,
--John

_______________________________________________
For list information, visit <http://jedsoft.org/slang/mailinglists.html>.


[2014 date index] [2014 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]