How to do a conditional statement in makefile -


i'm trying use commandline var choose toolkit use compile. when in command line use line like:

make all-arm our_toolkit=1 

and, in every makefile implied, put include

include arm_compiler.inc 

then, in every makefile,

all: settoolkit $(otheroperations) 

and contents of arm_compiler logic choose compiler:

settoolkit:  ifdef our_toolkit     toolkit=1 endif ifdef customer_toolkit     toolkit=2 endif  ifeq ($(toolkit), 1)     $(info "=========our toolkit selected======================")     rm=/bin/rm -f     cc= arm-linux-c++ -fpic     cxx= arm-linux-c++ -fpic     link= arm-linux-c++ -shared -wl     ar= ar cq     ranlib= ranlib     strip=arm-linux-strip       # para que se utilicen las herramientas y librerias del cross compiler     path:=$(path):/path/to/our/toolkit     ld_libray_path:=$(ld_libray_path):/path/to/our/toolkit           endif  ifeq ($(toolkit), 2)     $(info "================customer toolkit selected====================")     rm=/bin/rm -f     cc= arm-none-linux-gnueabi-c++ -fpic     cxx= arm-none-linux-gnueabi-c++ -fpic     link= arm-none-linux-gnueabi-c++ -shared -wl     ar= ar cq     ranlib= ranlib     strip= arm-none-linux-gnueabi-strip       # para que se utilicen las herramientas y librerias del cross compiler     path:=$(path):/path/to/other/toolkit     ld_libray_path:=$(ld_libray_path):/path/to/other/toolkit endif 

thanks of 0a0d, discovered toolkit value empty. i've changed code little. problem make throws error

../makefile-includes/arm-compiler.inc:10: *** commands commence before first target 

at line:

ifeq ($(toolkit), 1) 

anyone has idea? thanks

variants of question come lot.

each command executes in own subshell; variable set in 1 command cannot used in another.

but can set variables outside rules: remove of leading tabs conditional statements above. work except path , ld_library_path. neither of these is, in opinion, make should mess with, there ways effect want. handle path this:

ifeq ($(toolkit), 1)   toolkitpath = /path/to/our/toolkit endif ...  sometarget:     $(toolkitpath)/sometool somearg 

or this:

all:     export path=$$path:$(toolkitpath) ; $(make) $(otheroperations) 

and shouldn't use ld_library_path @ all.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -