I had to do something similar for Symbian OS. Here's how I did it: let's say you want to check if the file "file_strange.h" exists, and you want to include some headers or a link to some libraries depending on the existence of this file.
first create a small batch file to verify the existence of this file.
autoconf is good, but more killing for many small projects.
---------- check.bat
@echo off IF EXIST [\epoc32\include\domain\middleware\file_strange] GOTO NEW_API GOTO OLD_API GOTO :EOF :NEW_API echo.
---------- check.bat ends
then i created a gnumake file
---------- checkmedialist.mk
do_nothing : @rem do_nothing MAKMAKE : check.bat BLD : do_nothing CLEAN : do_nothing LIB : do_nothing CLEANLIB : do_nothing RESOURCE : do_nothing FREEZE : do_nothing SAVESPACE : do_nothing RELEASABLES : do_nothing FINAL : do_nothing
---------- check.mk ends
include the check.mk file in your bld.inf file, it MUST be in front of your MMP files
PRJ_MMPFILES gnumakefile checkmedialist.mk
Now, at compile time, file_strange_supported.h will have the appropriate flag. you can use this flag in your cpp files or even in mmp file for example in mmp
#include "../inc/file_strange_supported.h" #ifdef NEW_API_SUPPORTED LIBRARY newapi.lib #else LIBRARY oldapi.lib #endif
and in .cpp
#include "../inc/file_strange_supported.h" #ifdef NEW_API_SUPPORTED CStrangeApi* api = Api::NewLC(); #else
Ahmad Mushtaq Jul 02 '09 at 11:38 2009-07-02 11:38
source share