Here we go
Thttpd + php5 on mips
My sourcery install went into /opt/Sourcery_G++ Lite/
I'm using /usr/local/mips as target dir for my bins/libs/whatever.
Needed: zlib-1.2.3, thttpd-2.21b, php5 (read below..)
Zlib:
I started with zlib-1.2.3, which was fairly easy. It throws an error in the end that you'll need to add to the ' maker.sh' in order to create the final product :)
I prefer a per-program sh script i call 'maker.sh' that contains all exports and commands needed to compile the final thing. Below is maker.sh for zlib:
Lucky for us, the entire command is on the screen with the missing part plainly (in)visible... We'll just ar that manually thank you:
/opt/Sourcery_G++_Lite/bin/mips-linux-gnu-ar rc libz.a adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o zutil.o inflate.o infback.o inftrees.o inffast.o
Then make install, and zlib goes into /usr/local/mips.
thttpd:
At first i thought: We need to configure it first, then configure php5 --with-thttpd so that it modifies the makefile/makefile.in for us.. But that's not how it works.. read on..
Php5
This was a pain in the ass. I took the latest php (5.3.0 at time of writing) and struggled with it to get it to a stage where it fails with :
And it's also spitting out lots of "cc1: warning: include location "/usr/include" is unsafe for cross-compilation" warnings..
After a while i went back to version 5.2.10 and that compiles fine. Here's maker.sh:
Back to thttpd..
With our makefile patched, we can now build it. But.. failure!
So, i copied the whole ext folder into the thttpd-2.21b folder and tried again. This time it went a bit further.
Make clean and make also did not work. Configuring again also not.. I ran out of options, but google told me the order was supposed to be:
1. Extract thttpd
2. Configure, make, and make-install php
3. Compile thttpd..
Which in turn gave me another bunch of errors i've never seen before :)
I then googled some more, modified my little maker script after seeing better examples of --host and --target options, and started fresh with a clean thttp and php5 source..
And i modifed maker.sh for thttpd as well:
And that works as expected! No errors, just a warning about tmpnam:
Offcourse, it's time to revisit php 5.3.0 now and check how that goes..
And, --disable-all is a bit crude for php.. we'll probably need some extra stuff later on, but at least we've got a working compiled thttpd :)
(update: 5.3.1 is still a no-go :( it compiles error-less untill the end, and gives the same error as before..)
Enabling more stuff in php
since we have them, we might as well use them. Add the following to the php configure-command, (after extracting a nice clean thttpd again):
Thttpd again
Seems make-install somehow stops working if you use the php stuff.
After configuring you can just edit ./Makefile and change the prefix to whatever you need, and run make-install..
My sourcery install went into /opt/Sourcery_G++ Lite/
I'm using /usr/local/mips as target dir for my bins/libs/whatever.
Needed: zlib-1.2.3, thttpd-2.21b, php5 (read below..)
Zlib:
I started with zlib-1.2.3, which was fairly easy. It throws an error in the end that you'll need to add to the ' maker.sh' in order to create the final product :)
I prefer a per-program sh script i call 'maker.sh' that contains all exports and commands needed to compile the final thing. Below is maker.sh for zlib:
export CFLAGS="-EL "Make will spit out some errors:
export CC="/opt/Sourcery_G++_Lite/bin/mips-linux-gnu-gcc"
export CXX="/opt/Sourcery_G++_Lite/bin/mips-linux-gnu-g++"
export PATH=/opt/Sourcery_G++_Lite/bin:$PATH
export RANLIB="/opt/Sourcery_G++_Lite//bin/mips-linux-gnu-ranlib"
export AR="/opt/Sourcery_G++_Lite/bin/mips-linux-gnu-ar"
export AS="/opt/Sourcery_G++_Lite/bin/mips-linux-gnu-as"
export LD="/opt/Sourcery_G++_Lite/bin/mips-linux-gnu-ld"
export STRIP=/opt/Sourcery_G++_Lite/mips-linux-gnu/bin/strip
CFLAGS="-EL " ./configure --prefix=/usr/local/mips
/opt/Sourcery_G++_Lite/bin/mips-linux-gnu-ar libz.a adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o zutil.o inflate.o infback.o inftrees.o inffast.o
/opt/Sourcery_G++_Lite/bin/mips-linux-gnu-ar: illegal option -- z
..
..
..
make: *** [libz.a] Error 1
Lucky for us, the entire command is on the screen with the missing part plainly (in)visible... We'll just ar that manually thank you:
/opt/Sourcery_G++_Lite/bin/mips-linux-gnu-ar rc libz.a adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o zutil.o inflate.o infback.o inftrees.o inffast.o
Then make install, and zlib goes into /usr/local/mips.
thttpd:
At first i thought: We need to configure it first, then configure php5 --with-thttpd so that it modifies the makefile/makefile.in for us.. But that's not how it works.. read on..
Php5
This was a pain in the ass. I took the latest php (5.3.0 at time of writing) and struggled with it to get it to a stage where it fails with :
main/php_ini.o: In function `php_load_php_extension_cb':
php_ini.c:(.text+0x1154): undefined reference to `php_load_extension'
php_ini.c:(.text+0x1158): undefined reference to `php_load_extension'
And it's also spitting out lots of "cc1: warning: include location "/usr/include" is unsafe for cross-compilation" warnings..
After a while i went back to version 5.2.10 and that compiles fine. Here's maker.sh:
export CFLAGS="-EL "It still gives me those warnings about unsafe for cross-compilation, but seems to work.. You need to make install for it to patch thttpd makefile. Still didn't like the warnings though.. read on..
export CC="/opt/Sourcery_G++_Lite/bin/mips-linux-gnu-gcc"
export CXX="/opt/Sourcery_G++_Lite/bin/mips-linux-gnu-g++"
export PATH=/opt/Sourcery_G++_Lite/bin:$PATH
export RANLIB="/opt/Sourcery_G++_Lite//bin/mips-linux-gnu-ranlib"
export AR="/opt/Sourcery_G++_Lite/bin/mips-linux-gnu-ar"
export AS="/opt/Sourcery_G++_Lite/bin/mips-linux-gnu-as"
export LD="/opt/Sourcery_G++_Lite/bin/mips-linux-gnu-ld"
export STRIP=/opt/Sourcery_G++_Lite/mips-linux-gnu/bin/strip
./configure --disable-shared --prefix=/usr/local/mips --target=mips-linux-gnu --with-ssl=/usr/local/mips --with-z
lib=/usr/local/mips --with-libxml-dir=/usr/local/mips --with-openssl=/usr/local/mips --with-thttpd=../thttpd-2.21
b --without-pear
make
make install
Back to thttpd..
With our makefile patched, we can now build it. But.. failure!
libhttpd.c:655:40: error: ext/standard/php_smart_str.h: No such file or directory
So, i copied the whole ext folder into the thttpd-2.21b folder and tried again. This time it went a bit further.
libhttpd.o: In function `httpd_complete_request':
libhttpd.c:(.text+0x58a0): undefined reference to `thttpd_closed_conn'
libhttpd.c:(.text+0x58a4): undefined reference to `thttpd_closed_conn'
Make clean and make also did not work. Configuring again also not.. I ran out of options, but google told me the order was supposed to be:
1. Extract thttpd
2. Configure, make, and make-install php
3. Compile thttpd..
Which in turn gave me another bunch of errors i've never seen before :)
/tmp/cckR8fMf.s: Assembler messages:
/tmp/cckR8fMf.s:681: Error: unrecognized opcode `rorw $8,$20'
/tmp/cckR8fMf.s:681: Error: unrecognized opcode `rorl $16,$20'
/tmp/cckR8fMf.s:681: Error: unrecognized opcode `rorw $8,$20'
make: *** [libhttpd.o] Error 1
I then googled some more, modified my little maker script after seeing better examples of --host and --target options, and started fresh with a clean thttp and php5 source..
export CFLAGS="-EL "
export CC="/opt/Sourcery_G++_Lite/bin/mips-linux-gnu-gcc"
export CXX="/opt/Sourcery_G++_Lite/bin/mips-linux-gnu-g++"
./configure --host=i386-linux-gnu --target=mips --prefix=/usr/local/mips --disable-short-tags --without-mysql --without-pear --disable-all --disable-short-tags --with-thttpd=../thttpd-2.21b
And i modifed maker.sh for thttpd as well:
export CFLAGS="-EL "
export CC="/opt/Sourcery_G++_Lite/bin/mips-linux-gnu-gcc -EL"
export CXX="/opt/Sourcery_G++_Lite/bin/mips-linux-gnu-g++"
CFLAGS="-EL" ./configure --host=i386-linux-gnu --target=mips --prefix=/usr/local/mips --with-zlib=/usr/local/mips
make
And that works as expected! No errors, just a warning about tmpnam:
htpasswd.o: In function `main':Now i had my very own thttpd+php5 to run on my mips board!
htpasswd.c:(.text+0x4a0): warning: the use of `tmpnam' is dangerous, better use `mkstemp'
make[1]: Leaving directory `/home/target/build/thttpd-2.21b/extras'
Offcourse, it's time to revisit php 5.3.0 now and check how that goes..
And, --disable-all is a bit crude for php.. we'll probably need some extra stuff later on, but at least we've got a working compiled thttpd :)
(update: 5.3.1 is still a no-go :( it compiles error-less untill the end, and gives the same error as before..)
Enabling more stuff in php
since we have them, we might as well use them. Add the following to the php configure-command, (after extracting a nice clean thttpd again):
--with-libxml-dir=/usr/local/mips --with-openssl-dir=/usr/local/mips --with-zlib-dir=/usr/local/mips
Thttpd again
Seems make-install somehow stops working if you use the php stuff.
After configuring you can just edit ./Makefile and change the prefix to whatever you need, and run make-install..
# Top level hierarchy.Voila! Thttpd+php5 cross-compiled :) Hope it's of use to someone!
prefix = /usr/local/mips
exec_prefix = ${prefix}
# Pathname of directory to install the binary.
BINDIR = ${exec_prefix}/sbin
# Pathname of directory to install the man page.
MANDIR = ${prefix}/man
# Pathname of directory to install the CGI programs.
WEBDIR = $(prefix)/www
Labels: cross-compiling, mips, php, thttpd

1 reacties:
I also met the issue of compiling php 5.3.0 you mentioned above. (undefined reference to `php_load_extension') I have solved the issue by exporting "CFLAGS=-DHAVE_LIBDL" before ./configure for php 5.3.0, FYI.
Een reactie posten
Aanmelden bij Reacties posten [Atom]
<< Homepage