makefile - GNU Make using $(eval ...) not working -
here makefile:
libdirs += ./librelease libdirs += ./sharedarcgis/depfileslinux64/libreleaselinux64/skia libdirs += ./sharedarcgis/depfileslinux64/libreleaselinux64/libtess libdirs += ./sharedarcgis/depfileslinux64/libreleaselinux64/sqlite statics = $(wildcard $(libdirs:=/*.a)) targeta = libruntimecorejava.a targetd = libruntimecorejava.so targetd1 = $(targetd).1 targetd2 = $(targetd).1.0 targetd3 = $(targetd).1.0.0 ar = ar cqs ar_extract = ar -x link = g++ symlink = ln -f -s ldflags = -shared -wl,-soname,libruntimecorejava.so extract = : $(targetd) $(targeta) $(targetd) : clean mkdir -p ./obj ./librelease $(foreach lib, $(statics), cp $(lib) ./obj;) $(eval extract := $(wildcard ./obj/*.a)) echo $(extract) $(foreach lib, $(extract), $(ar_extract) $(lib);) $(foreach lib, $(extract), rm -f $(lib);) #$(cxx) $(ldflags) $(objs) #$(symlink) $(targetd) $(targetd1) #$(symlink) $(targetd) $(targetd2) #$(symlink) $(targetd) $(targetd3) $(targeta) : $(eval objs:=$(wildcard ./obj/*.o)) echo $(objs) #$(ar) $(targeta) $(objs) clean : rm -rf ./ob
here output:
[matt6809@hogganz400 arcgis2]$ ls -l ./obj total 23332 -rw-rw-r-- 1 matt6809 matt6809 191324 mar 7 09:18 libcommon.a -rw-rw-r-- 1 matt6809 matt6809 8427134 mar 7 09:18 libgeometryxlib.a -rw-rw-r-- 1 matt6809 matt6809 88580 mar 7 09:18 liblibtess.a -rw-rw-r-- 1 matt6809 matt6809 3401554 mar 7 09:18 libmapping.a -rw-rw-r-- 1 matt6809 matt6809 3558746 mar 7 09:18 libpe_s.a -rw-rw-r-- 1 matt6809 matt6809 412634 mar 7 09:18 libpe++_s.a -rw-rw-r-- 1 matt6809 matt6809 597808 mar 7 09:18 libsg_s.a -rw-rw-r-- 1 matt6809 matt6809 3523726 mar 7 09:18 libskia.a -rw-rw-r-- 1 matt6809 matt6809 730064 mar 7 09:18 libsqlite.a -rw-rw-r-- 1 matt6809 matt6809 814234 mar 7 09:18 libsymboldictionary.a -rw-rw-r-- 1 matt6809 matt6809 2128742 mar 7 09:18 libsymbolxlib.a [matt6809@hogganz400 arcgis2]$ make rm -rf ./obj mkdir -p ./obj ./librelease cp ./librelease/libcommon.a ./obj; cp ./librelease/libgeometryxlib.a ./obj; cp ./librelease/libmapping.a ./obj; cp ./librelease/libpe_s.a ./obj; cp ./librelease/libpe++_s.a ./obj; cp ./librelease/libsg_s.a ./obj; cp ./librelease/libsymboldictionary.a ./obj; cp ./librelease/libsymbolxlib.a ./obj; cp ./sharedarcgis/depfileslinux64/libreleaselinux64/skia/libskia.a ./obj; cp ./sharedarcgis/depfileslinux64/libreleaselinux64/libtess/liblibtess.a ./obj; cp ./sharedarcgis/depfileslinux64/libreleaselinux64/sqlite/libsqlite.a ./obj; echo #g++ -shared -wl,-soname,libruntimecorejava.so #ln -f -s libruntimecorejava.so libruntimecorejava.so.1 #ln -f -s libruntimecorejava.so libruntimecorejava.so.1.0 #ln -f -s libruntimecorejava.so libruntimecorejava.so.1.0.0 echo #ar cqs libruntimecorejava.a
why extract empty? output show libs copied on .obj file.
each command line in rule considered 'recipe', , each recipe invoke new instance of shell run. thus, when set value extract in 1 recipe, , try read in another, reading 2 different shell instances, , value not carry between them. 1 way around join commands single recipe so:
$(targetd) : clean mkdir -p ./obj ./librelease; \ lib in $(statics) do; cp $$lib ./obj; done; \ extract=`ls ./obj/*.a`; echo $$extract; \ lib in $$extract do; $(ar_extract) $$lib done; \ lib in $$extract do; rm -f $$lib; done; \
thus, when set extract, available commands within recipe.
see http://www.gnu.org/software/make/manual/make.html#recipes more info
Comments
Post a Comment