One way can be as follows:

## pre-define your library directories based on the output of the "getconf" 
output format
LIB_32 := /stage2/lib/dbus-1.0/include
LIB_64 := /stage2/lib64/dbus-1.0/include

# then compute the architecture of the machine running gmake
CFLAGS := -I$(LIB_$(strip $(shell getconf LONG_BIT)))

### now you are all set for using the CFLAGS in your build code.
## you may want to incorporate some amount of error checking
# when the `getconf' command delivers output different than either 32 or 64.

# another method could be to invoke the "uname -m" command.



> Date: Mon, 3 Aug 2015 18:56:38 +0200
> From: bas...@starynkevitch.net
> To: spk...@yahoo.com
> Subject: Re: Conditional include directories
> CC: help-make@gnu.org
> 
> On Mon, Aug 03, 2015 at 04:38:37PM +0000, Mike Gran wrote:
>> 
>> Hello all,
>> 
>> In a standalone project makefile I want to add a -I directory
>> parameter to a CFLAGS variable.
>> 
>> On a 32-bit box, I need to add it as
>> -I/stage2/lib/dbus-1.0/include
>> 
>> One a 64-bit box, I need to add it as
>> -I/stage2/lib64/dbus-1.0/include 
>> 
>> There are a bunch of ways to do this, I guess. 
> 
> 
> A possible way might be to use pkg-config. Your Dbus library might be
> registered in some pkg-config *.pc file.
> 
> http://www.freedesktop.org/wiki/Software/pkg-config/
> 
> A way of using it in your Makefile:
> http://stackoverflow.com/questions/20145132/makefiles-how-can-i-use-them/20146082#20146082
> 
> Regards
> -- 
> Basile Starynkevitch http://starynkevitch.net/Basile/
> France basile at starynkevitch dot net
> 
> _______________________________________________
> Help-make mailing list
> Help-make@gnu.org
> https://lists.gnu.org/mailman/listinfo/help-make
                                          
_______________________________________________
Help-make mailing list
Help-make@gnu.org
https://lists.gnu.org/mailman/listinfo/help-make

Reply via email to