foreach & silencer in a makefile target - foreach

I am using a foreach in a makefile for a particular target.
my_Target:
$(foreach x,$(MY_TARGET_DIRS), #echo " BUILD $(x)";$(Q)$(MAKE) --directory=$(x) LIB_DIR=$(MY_LIB_DIR) $(MY_TARGET_RULES); )
This is intended call the makefiles contained every specified directory of MY_TARGET_DIRS, after a string has been printed to tell which build is ongoing.
The Q variable is defined as follows:
# Silent per default, 'make V=1' shows all compiler calls.
ifneq ($(V),1)
Q := #
endif
So that the make command is verbose if V=1 is defined.
For V=1 the output log is:
make my_Target V=1
BUILD /dir1
make[1]: Entering directory `/dir1'
make[1]: Nothing to be done for `elf'.
make[1]: Nothing to be done for `bin'.
make[1]: Leaving directory `/dir1'
/bin/sh: #echo: command not found
make[1]: Entering directory `/dir2'
make[1]: Nothing to be done for `elf'.
make[1]: Nothing to be done for `bin'.
make[1]: Leaving directory `/dir2'
While if I do not define V=1, the output log is:
make my_Target
BUILD /dir1
/bin/sh: #make: command not found
/bin/sh: #echo: command not found
/bin/sh: #make: command not found
make: *** [my_Target] Error 127
How can I get the behavior I desire correctly?
Bye!

Put the # ($(Q)) at the beginning of the recipe:
my_Target:
$(Q)$(foreach x,$(MY_TARGET_DIRS), echo " BUILD $(x)";$(MAKE) --directory=$(x) LIB_DIR=$(MY_LIB_DIR) $(MY_TARGET_RULES); )
Notice that the foreach will ouptut a single recipe line, and the # will apply to all of it. An alternative, if you want to get more fancy is to create a rule for each of the target dirs:
MY_TARGET_DIRS_TARGS=$(MY_TARGET_DIRS:%=%/.phony)
my_Target: $(MY_TARGET_DIRS_TARG)
$(MY_TARGET_DIRS_TARGS):
#echo " BUILD $(x)"
$(Q)(MAKE) --directory=$(x) LIB_DIR=$(MY_LIB_DIR) $(MY_TARGET_RULES);
.PHONY: $(MY_TARGET_DIRS_TARGS)

Related

compile libffi on openwrt fatal error: sys/xattr.h: No such file or directory

when i build libffi on a SDK forwarded by linkit smart 7688,the error comes out,and i couldnt find any help by search.
libattr/attr_copy_fd.c:25:24: fatal error: sys/xattr.h: No such file or directory
Config-build.in:12603:warning: defaults for choice values not supported
Config-build.in:12619:warning: defaults for choice values not supported
Config-build.in:14019:warning: defaults for choice values not supported
Config-build.in:14499:warning: defaults for choice values not supported
warning: (boost-libs-all) selects boost-coroutine2 which has unmet direct dependencies (PACKAGE_boost && !GCC_VERSION_4_8)
warning: (boost-libs-all) selects boost-coroutine2 which has unmet direct dependencies (PACKAGE_boost && !GCC_VERSION_4_8)
\#
\# configuration written to .config
\#
make[1]: Entering directory '/home/color/mt7688'
make[2]: Entering directory '/home/color/mt7688/feeds/packages/libs/glib2'
make[2]: Leaving directory '/home/color/mt7688/feeds/packages/libs/glib2'
make[1]: Leaving directory '/home/color/mt7688'
Config-build.in:12603:warning: defaults for choice values not supported
Config-build.in:12619:warning: defaults for choice values not supported
Config-build.in:14019:warning: defaults for choice values not supported
Config-build.in:14499:warning: defaults for choice values not supported
warning: (boost-libs-all) selects boost-coroutine2 which has unmet direct dependencies (PACKAGE_boost && !GCC_VERSION_4_8)
warning: (boost-libs-all) selects boost-coroutine2 which has unmet direct dependencies (PACKAGE_boost && !GCC_VERSION_4_8)
\#
\# configuration written to .config
\#
make[1]: Entering directory '/home/color/mt7688'
make[2]: Entering directory '/home/color/mt7688/feeds/packages/utils/attr'
CFLAGS="-Os -pipe -mno-branch-likely -mips32r2 -mtune=24kec -mdsp -fno-caller-saves -fhonour-copts -Wno-error=unused-but-set-variable -msoft-float -I/home/color/mt7688/staging_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/usr/include -I/home/color/mt7688/staging_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/include -I/home/color/mt7688/staging_dir/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/usr/include -I/home/color/mt7688/staging_dir/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/include " CXXFLAGS="-Os -pipe -mno-branch-likely -mips32r2 -mtune=24kec -mdsp -fno-caller-saves -fhonour-copts -Wno-error=unused-but-set-variable -msoft-float -I/home/color/mt7688/staging_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/usr/include -I/home/color/mt7688/staging_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/include -I/home/color/mt7688/staging_dir/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/usr/include -I/home/color/mt7688/staging_dir/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/include " LDFLAGS="-L/home/color/mt7688/staging_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/usr/lib -L/home/color/mt7688/staging_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/lib -L/home/color/mt7688/staging_dir/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/usr/lib -L/home/color/mt7688/staging_dir/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/lib " make -j1 -C /home/color/mt7688/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/attr-20170915/. AR="mipsel-openwrt-linux-uclibc-gcc-ar" AS="ccache_cc -c -Os -pipe -mno-branch-likely -mips32r2 -mtune=24kec -mdsp -fno-caller-saves -fhonour-copts -Wno-error=unused-but-set-variable -msoft-float" LD=mipsel-openwrt-linux-uclibc-ld NM="mipsel-openwrt-linux-uclibc-gcc-nm" CC="ccache_cc" GCC="ccache_cc" CXX="ccache_cxx" RANLIB="mipsel-openwrt-linux-uclibc-gcc-ranlib" STRIP=mipsel-openwrt-linux-uclibc-strip OBJCOPY=mipsel-openwrt-linux-uclibc-objcopy OBJDUMP=mipsel-openwrt-linux-uclibc-objdump SIZE=mipsel-openwrt-linux-uclibc-size CROSS="mipsel-openwrt-linux-uclibc-" ARCH="mipsel" ;
make[3]: Entering directory '/home/color/mt7688/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/attr-20170915'
CC libattr/libattr_la-attr_copy_fd.lo
****libattr/attr_copy_fd.c:25:24: fatal error: sys/xattr.h: No such file or directory
\# include <sys/xattr.h>
\^****
compilation terminated.
Makefile:929: recipe for target 'libattr/libattr_la-attr_copy_fd.lo' failed
make[3]: * [libattr/libattr_la-attr_copy_fd.lo] Error 1
make[3]: Leaving directory '/home/color/mt7688/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/attr-20170915'
Makefile:93: recipe for target '/home/color/mt7688/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/attr-20170915/.built' failed
make[2]: * [/home/color/mt7688/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/attr-20170915/.built] Error 2
make[2]: Leaving directory '/home/color/mt7688/feeds/packages/utils/attr'
package/Makefile:191: recipe for target 'package/feeds/packages/attr/compile' failed
make[1]: * [package/feeds/packages/attr/compile] Error 2
make[1]: Leaving directory '/home/color/mt7688'
/home/color/mt7688/include/toplevel.mk:174: recipe for target 'package/feeds/packages/glib2/compile' failed
make: * [package/feeds/packages/glib2/compile] Error 2
It seems the library you are looking for is not included in OpenWrt SDK by default.
Being this way you should look for it and add it manually. In my case I have the libraries inside the folder $ROOT_DIR/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/include, so you should find and add mannualy xattr.h and move it to $ROOT_DIR/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/include/sys.

My package in OpenWRT does not compile

I have downloaded OpenWRT source from git and build it. I created a simple helloworld package with the required Makefile in package/helloworld directory and build it. But it does not seem to be doing anything. Following is the log:
sonal#sonal-ThinkPad:~/openwrt$ make V=99 package/helloworld/compile
WARNING: your configuration is out of sync. Please run make menuconfig, oldconfig or defconfig!
make[1]: Entering directory '/home/sonal/openwrt'
make[2]: Entering directory '/home/sonal/openwrt/package/libs/toolchain'
if [ -f /home/sonal/openwrt/staging_dir/target-mips_34kc_uClibc-0.9.33.2/pkginfo/toolchain.default.install.clean ]; then rm -f /home/sonal/openwrt/staging_dir/target-mips_34kc_uClibc-0.9.33.2/pkginfo/toolchain.default.install /home/sonal/openwrt/staging_dir/target-mips_34kc_uClibc-0.9.33.2/pkginfo/toolchain.default.install.clean; fi; echo "libc" >> /home/sonal/openwrt/staging_dir/target-mips_34kc_uClibc-0.9.33.2/pkginfo/toolchain.default.install
if [ -f /home/sonal/openwrt/staging_dir/target-mips_34kc_uClibc-0.9.33.2/pkginfo/toolchain.default.install.clean ]; then rm -f /home/sonal/openwrt/staging_dir/target-mips_34kc_uClibc-0.9.33.2/pkginfo/toolchain.default.install /home/sonal/openwrt/staging_dir/target-mips_34kc_uClibc-0.9.33.2/pkginfo/toolchain.default.install.clean; fi; echo "libgcc" >> /home/sonal/openwrt/staging_dir/target-mips_34kc_uClibc-0.9.33.2/pkginfo/toolchain.default.install
make[2]: Leaving directory '/home/sonal/openwrt/package/libs/toolchain'
make[2]: Entering directory '/home/sonal/openwrt/package/helloworld'
make[2]: Leaving directory '/home/sonal/openwrt/package/helloworld'
make[1]: Leaving directory '/home/sonal/openwrt'`enter code here`
Thanks
Sonal
http://wiki.prplfoundation.org/wiki/Creating_an_OpenWrt_package_for_a_web_page
This above link will guide you how to build own package. I had also made own luci pages with above link. It will guide you from scratch.
If you want to create only hello world page then no need to create package, you just make new directory name as files in '/home/sonal/openwrt/'
and then go to files directory and make new directory as www in '/home/sonal/openwrt/files/'. No custom packages requires for it.

Failing to run hello-world example on sky tmote

I'm trying to run the hello-world example in contiki on a sky tmote. I'm using ubuntu and followed this tutorial: http://www.contiki-os.org/start.html#hardware
The first time I executed:
make TARGET=sky hello-world.upload
it worked fine but I got an error when executing:
make TARGET=sky login
../../tools/sky/serialdump-linux -b115200
make: execvp: ../../tools/sky/serialdump-linux: Permission denied
make: *** [login] Error 127
And now from now on every time I execute
make TARGET=sky hello-world.upload
I get the output from the tutorial (the note)
make z1-reset z1-upload
make[1]: Entering directory `/home/user/contiki/examples/hello-world'
make -k -j 20 z1-reset-sequence
make[2]: Entering directory `/home/user/contiki/examples/hello-world'
Done
make[2]: Leaving directory `/home/user/contiki/examples/hello-world'
make -j 20 z1-upload-sequence
make[2]: Entering directory `/home/user/contiki/examples/hello-world'
Done
make[2]: Leaving directory `/home/user/contiki/examples/hello-world'
make[1]: Leaving directory `/home/user/contiki/examples/hello-world'
rm hello-world.ihex
Before I once tried the instantcontiki with the VMPlayer and when this occured I just had to reconnect the sky mote again via a button in the VMPlayer, but since I'm not using it anymore I don't know what to do.
Also I couldn't figure out how to solve the Error 127 from above.
Greetings,
Jan
PS: I'm new to linux
Here is a solution which worked at me:
Find out at which USB is your tmote connected, e.g. USB0 and than just run:
sudo chmod 666 /dev/ttyUSB0
this phrase permission denied indicates that you are not the owner, ie. you are not the root
use sudo su,
give your password for the root
and repeat the code.
you will not find the error

Troubles with wkhtmltopdf

Good day!, I hope someone has the answer to this question. I'm having troubles when trying to "convert" an html to pdf from a rails application, I've followed these steps: http://www.snikt.net/blog/2012/04/26/wicked-pdf/ with no luck, when I click the link it only changes the url from "http://localhost:3000/users/3" to "http://localhost:3000/users.3" with a blank page.
Then I read that you must configure a few things first, so I follow these steps: http://code.google.com/p/wkhtmltopdf/wiki/compilation, everything looks good until I reach the part with the "make && make install", here are the results:
cd src/lib/ && make -f Makefile
make[1]: Entering directory /home/username/wkhtmltopdf/src/lib'
make[1]: Nothing to be done forfirst'.
make[1]: Leaving directory /home/username/wkhtmltopdf/src/lib'
cd src/pdf/ && make -f Makefile
make[1]: Entering directory/home/username/wkhtmltopdf/src/pdf'
make[1]: Nothing to be done for first'.
make[1]: Leaving directory/home/username/wkhtmltopdf/src/pdf'
cd src/image/ && make -f Makefile
make[1]: Entering directory /home/username/wkhtmltopdf/src/image'
make[1]: Nothing to be done forfirst'.
make[1]: Leaving directory /home/username/wkhtmltopdf/src/image'
cd src/lib/ && make -f Makefile install
make[1]: Entering directory/home/username/wkhtmltopdf/src/lib'
mkdir: cannot create directory /include': Permission denied
make[1]: *** [install_headers] Error 1
make[1]: Leaving directory/home/username/wkhtmltopdf/src/lib'
make: * [sub-src-lib-install_subtargets-ordered] Error 2
As a note the command "wkhtmltopdf some_url my_pdf.pdf" does work, the issue is when trying to "convert" an html, from a rails application, to pdf.
I appreciate every single tip you can give because I'm trully lost. I'm sorry if it's a dumb question and for all the troubles, and thank you for your time.
Ok, just go through all of that, following this tutorial: http://blog.tcs.de/install-wkhtmltopdf-on-ubuntu-server/
Thank you guys for your time.

Failure when trying to cross-compile Erlang R13B04 for ARM

I am trying to cross-compile Erlang and running into a weird bug. The commands used are
make clean
./otp_build configure --host=arm-none-linux-gnueabi --build=i686-pc-linux-gnu
--prefix=/opt/erlang erl_xcomp_sysroot=~/sbctools/arm-2007q3 --disable-hipe
--disable-threads --disable-smp --disable-megaco-flex-scanner-lineno
--disable-megaco-reentrant-flex-scanner --disable-dynamic-ssl-lib
--without-termcap --without-javac --without-ssl
./otp_build boot
Their output can be seen at http://gist.github.com/576199 (it's too big to paste here), but the error which ends the process is
/home/aromanov/sbctools/arm-2007q3/bin/../lib/gcc/arm-none-linux-gnueabi/4.2.1/../../../../arm-none-linux-gnueabi/bin/ld: /home/aromanov/otp_src/erts/emulator/zlib/obj/arm-none-linux-gnueabi/opt/libz.a(adler32.o): Relocations in generic ELF (EM: 3)
/home/aromanov/sbctools/arm-2007q3/bin/../lib/gcc/arm-none-linux-gnueabi/4.2.1/../../../../arm-none-linux-gnueabi/bin/ld: /home/aromanov/otp_src/erts/emulator/zlib/obj/arm-none-linux-gnueabi/opt/libz.a(adler32.o): Relocations in generic ELF (EM: 3)
/home/aromanov/sbctools/arm-2007q3/bin/../lib/gcc/arm-none-linux-gnueabi/4.2.1/../../../../arm-none-linux-gnueabi/bin/ld: /home/aromanov/otp_src/erts/emulator/zlib/obj/arm-none-linux-gnueabi/opt/libz.a(adler32.o): Relocations in generic ELF (EM: 3)
/home/aromanov/sbctools/arm-2007q3/bin/../lib/gcc/arm-none-linux-gnueabi/4.2.1/../../../../arm-none-linux-gnueabi/bin/ld: /home/aromanov/otp_src/erts/emulator/zlib/obj/arm-none-linux-gnueabi/opt/libz.a(adler32.o): Relocations in generic ELF (EM: 3)
/home/aromanov/sbctools/arm-2007q3/bin/../lib/gcc/arm-none-linux-gnueabi/4.2.1/../../../../arm-none-linux-gnueabi/bin/ld: /home/aromanov/otp_src/erts/emulator/zlib/obj/arm-none-linux-gnueabi/opt/libz.a(adler32.o): Relocations in generic ELF (EM: 3)
/home/aromanov/otp_src/erts/emulator/zlib/obj/arm-none-linux-gnueabi/opt/libz.a: could not read symbols: File in wrong format
collect2: ld returned 1 exit status
make[3]: *** [/home/aromanov/otp_src/bin/arm-none-linux-gnueabi/beam] Error 1
make[3]: Leaving directory `/home/aromanov/otp_src/erts/emulator'
make[2]: *** [opt] Error 2
make[2]: Leaving directory `/home/aromanov/otp_src/erts/emulator'
make[1]: *** [opt] Error 2
make[1]: Leaving directory `/home/aromanov/otp_src/erts'
make: *** [emulator] Error 2
Indeed, viewing ~/otp_src/erts/emulator/zlib/obj/arm-none-linux-gnueabi/opt/libz.a shows it's compiled for Intel 30386. But why? And how can I avoid it?
EDIT: ~/sbctools/arm-2007q3/bin is the first directory in the PATH. Do I perhaps need to add other toolchain directories as well?
make[4]: Entering directory /home/aromanov/otp_src/erts/emulator/zlib'
make -f arm-none-linux-gnueabi/Makefile TYPE=opt
make[5]: Entering directory/home/aromanov/otp_src/erts/emulator/zlib'
make[5]: Nothing to be done for all'.
make[5]: Leaving directory/home/aromanov/otp_src/erts/emulator/zlib'
make[4]: Leaving directory `/home/aromanov/otp_src/erts/emulator/zlib'
Looks like you've built zlib part before... when it was not correctly configured.
Try make clean or make distclean and then recompile.

Resources