esl / erlang_ale

Erlang Actor Library for Embedded -- An embedded framework from Erlang Solutions
Apache License 2.0
207 stars 65 forks source link

Make file #8

Closed stuart-thackray closed 10 years ago

stuart-thackray commented 10 years ago

Hi,

I realise I am using a different OS than others, I am using pidora, which a is a lot easier out of the box than any other. It is not debian so used yum and even made erlang from scratch (few hours compliling :( )

My problem occurred when the make tried to compile any of the c drivers that required erl_interface or ei.

I eventually solved this after a day or two by changing the ELOC and LDFLAGs variables to the following.

EILOC:=/usr/lib/erlang/lib/erl_interface-3.7.9/include LDFLAGS=-Lpriv -L/usr/lib/erlang/usr/lib -L/usr/lib/erlang/lib/erl_interface-3.7.9/lib

I suspect, but not great with make files or code the following two alterations would work, if there is a not a better way.

EILOC:=$(shell find /usr/local/lib/erlang /usr/lib/erlang -name ei.h -printf '%h\n' 2> /dev/null | head -1) LDFLAGS=-Lpriv -L/usr/lib/erlang/usr/lib -L$(find /usr/local/lib/erlang /usr/lib/erlang -name '*ei.a' -printf '%h\n' 2> /dev/null | head -1)

Hopefully we can make a change that would make anyone else's install easier.

Thanks, Stuart

stuart-thackray commented 10 years ago

Please see pull request https://github.com/esl/erlang_ale/pull/9 i have tested on pidora and it works.

lehoff commented 10 years ago

Hi Stuart,

Could you try this one out as well? erl -eval 'io:format("~s", [code:lib_dir(erl_interface, include)])' -s init stop -noshell

I don't have a working Raspberry-Pi right now - will try to play with it tomorrow after work.

Cheers, Torben

notifications@github.com writes:

Please see pull request https://github.com/esl/erlang_ale/pull/9 i have tested on rasbian and it works.


Reply to this email directly or view it on GitHub: https://github.com/esl/erlang_ale/issues/8#issuecomment-35900339

Torben Hoffmann CTO Erlang Solutions Ltd. Tel: +45 25 14 05 38 http://www.erlang-solutions.com

stuart-thackray commented 10 years ago

Hi Torben,

I can't remember if I might have changed erlang versions again, but this is what i get

erl -eval 'io:format("~s", [code:lib_dir(erl_interface, include)])' -s init stop -noshell /usr/local/lib/erlang/lib/erl_interface-3.7.15/include

Please note that include was already fine with regards to c includes, the problem was due to the library linkages, if this is the right wording.

Regards, Stuart

lehoff commented 10 years ago

Sorry - my mistake. It should have been

erl -eval 'io:format("~s", [code:lib_dir(erl_interface, lib)])' -s init stop -noshell

The reason I want to use this over find is that it asks the Erlang runtime where it would pick up things and that is more reliable than find.

stuart-thackray commented 10 years ago

/usr/local/lib/erlang/lib/erl_interface-3.7.15

just to point out this is cause manually installed R16B03-1, but your point is valid, I think this is the way we should determine erlang version and location of C libraries.

lehoff commented 10 years ago

I have double checked the documentation of code:lib_dir/2 and as long as the location of libei.a et al is in the lib dir the "erl -eval ..." call will suffice for us.

Could you please make a new pull request with this change? And please add a gist of the build log as I cannot get my R-Pi to work right now, so I will have to base my acceptance of this on your log file.

stuart-thackray commented 10 years ago

Here is the pull request https://github.com/esl/erlang_ale/pull/10 it worked perfectly.

I can't seem to fix the formatting of the build log, but I think you will get the gist.

make[1]: Leaving directory /home/stuart/myrepo/erlang_ale/deps/meck' make[1]: Entering directory/home/stuart/myrepo/erlang_ale/deps/pihwm' make[1]: *\ No targets specified and no makefile found. Stop. make[1]: Leaving directory /home/stuart/myrepo/erlang_ale/deps/pihwm' make[1]: Entering directory/home/stuart/myrepo/erlang_ale/deps/erlang_portutil' gcc -c -o portutil.o portutil.c -Wall -std=c99 -I/usr/local/lib/erlang/lib/erl_interface-3.7.15/include make[1]: Leaving directory `/home/stuart/myrepo/erlang_ale/deps/erlang_portutil' mkdir -p priv ebin gcc -I/usr/local/include -I/usr/local/lib/erlang/lib/erl_interface-3.7.15/include -I/usr/lib/erlang/usr/include/ -Ideps/erlang_portutil -Ideps/pihwm/lib -c -o priv/portutil.o deps/erlang_portutil/portutil.c gcc -I/usr/local/include -I/usr/local/lib/erlang/lib/erl_interface-3.7.15/include -I/usr/lib/erlang/usr/include/ -Ideps/erlang_portutil -Ideps/pihwm/lib -c -o priv/pihwm.o deps/pihwm/lib/pihwm.c gcc -I/usr/local/include -I/usr/local/lib/erlang/lib/erl_interface-3.7.15/include -I/usr/lib/erlang/usr/include/ -Ideps/erlang_portutil -Ideps/pihwm/lib -c -o priv/pi_gpio.o -lpthread deps/pihwm/lib/pi_gpio.c gcc -I/usr/local/include -I/usr/local/lib/erlang/lib/erl_interface-3.7.15/include -I/usr/lib/erlang/usr/include/ -Ideps/erlang_portutil -Ideps/pihwm/lib -c -o priv/pi_i2c.o deps/pihwm/lib/pi_i2c.c gcc -I/usr/local/include -I/usr/local/lib/erlang/lib/erl_interface-3.7.15/include -I/usr/lib/erlang/usr/include/ -Ideps/erlang_portutil -Ideps/pihwm/lib -c -o priv/pi_spi.o deps/pihwm/lib/pi_spi.c gcc -I/usr/local/include -I/usr/local/lib/erlang/lib/erl_interface-3.7.15/include -I/usr/lib/erlang/usr/include/ -Ideps/erlang_portutil -Ideps/pihwm/lib -c -o priv/pi_pwm.o deps/pihwm/lib/pi_pwm.c erlc -o ./ebin src/port_lib.erl gcc -Lpriv -L/usr/lib/erlang/usr/lib -L/usr/local/lib/erlang/lib/erl_interface-3.7.15/lib -I/usr/local/include -I/usr/local/lib/erlang/lib/erl_interface-3.7.15/include -I/usr/lib/erlang/usr/include/ -Ideps/erlang_portutil -Ideps/pihwm/lib -o priv/gpio_port \ priv/portutil.o priv/pihwm.o priv/pi_gpio.o c_src/gpio_port.c \ -lpthread -lerl_interface -lei erlc -o ./ebin src/gpio.erl

we need to re-compile bits of pihwm here because NIFs require -fPIC

gcc -Lpriv -L/usr/lib/erlang/usr/lib -L/usr/local/lib/erlang/lib/erl_interface-3.7.15/lib -I/usr/local/include -I/usr/local/lib/erlang/lib/erl_interface-3.7.15/include -I/usr/lib/erlang/usr/include/ -Ideps/erlang_portutil -Ideps/pihwm/lib -o priv/pwm_nif.so -fPIC -shared \ deps/pihwm/lib/pihwm.c deps/pihwm/lib/pi_gpio.c c_src/pwm_nif.c \ -lpthread erlc -o ./ebin src/pwm.erl src/pwm.erl:63: Warning: variable 'Devname' is unused gcc -Lpriv -L/usr/lib/erlang/usr/lib -L/usr/local/lib/erlang/lib/erl_interface-3.7.15/lib -I/usr/local/include -I/usr/local/lib/erlang/lib/erl_interface-3.7.15/include -I/usr/lib/erlang/usr/include/ -Ideps/erlang_portutil -Ideps/pihwm/lib -o priv/i2c_lib \ priv/portutil.o priv/pihwm.o priv/pi_i2c.o c_src/i2c_ei.c \ -lpthread -lerl_interface -lei erlc -o ./ebin src/i2c.erl gcc -Lpriv -L/usr/lib/erlang/usr/lib -L/usr/local/lib/erlang/lib/erl_interface-3.7.15/lib -I/usr/local/include -I/usr/local/lib/erlang/lib/erl_interface-3.7.15/include -I/usr/lib/erlang/usr/include/ -Ideps/erlang_portutil -Ideps/pihwm/lib -o priv/spi_lib \ priv/portutil.o priv/pihwm.o priv/pi_spi.o c_src/spi_ei.c \ -lpthread -lerl_interface -lei erlc -o ./ebin src/spi.erl