Hallo zusammen,
ich bin vor kurzem auf die Idee gekommen, meinen alten iPod Touch 2G zum kleinen, lokalen Webserver zu konfigurieren (bitte hinterfragt den Sinn nicht, es ist sozusagen just4fun).
Dabei hab ich in Cydia (iPod ist gejailbreaked) lighttpd, php und mysql gefunden und installiert. Allerdings ist PHP ohne mysql kompiliert und da ich kein mysql Modul für PHP auf iPod/iPhone gefunden habe, wollte ich mir PHP selber kompilieren. Zuerst hab ich versucht, das auf dem iPod abzuwickeln, nach einer Weile ist ./configure sogar durchgelaufen, beim kompilieren ist der iPod allerdings abgestürzt (war wohl doch zu viel Arbeit, was ein Wunder^^). Also wollte ich PHP auf meinem ArchLinux System cross-compilen. Dazu hab ich mir dieses Toolchain heruntergeladen:
http://pjtrix.com/iphone/presentations/OSCON2009/iphone-toolchain-linux.tgz
Die Dateien (außer dem Include Ordner) hab ich nach /usr/local entpackt. Darauf hab ich mir vom iPod via SSH die Librarys unter /usr/lib und die Header unter /var/stash.*/Include.* rüberkopiert und nach /usr/local/ipod/usr/lib bzw. include entpackt. Außerdem hab ich noch die beim Toolchain mitgelieferten Header nach /usr/local/ipod/usr/local/include entpackt.
Darauf hab ich php folgendermaßen konfiguriert:
export CPPFLAGS='--sysroot /usr/local/ipod'
export CXXFLAGS='--sysroot /usr/local/ipod'
./configure '--build=x86_64-unknown-linux-gnu' '--host=arm-apple-darwin9' \
'--target=arm-apple-darwin9' '--enable-static=no' '--enable-shared=yes' \
'--prefix=/usr' '--localstatedir=/var/cache/php' '--with-mysql' '--without-pdo-sqlite' \
'--without-sqlite3' '--without-iconv' '--disable-all' '--enable-fastcgi'
Das lief dann auch problemlos durch, erst make hat Probleme gemacht. Zuerst lies sich php_date.c nicht kompilieren, dass konnte ich aber mit dem hier:
https://bugs.php.net/bug.php?id=53188 genannten XtOffsetOf lösen.
Jetzt gibt es aber das Problem, dass sich der Kompiliervorgang bei
/bin/sh /home/iuser/Downloads/php/libtool --silent --preserve-dup-deps --mode=compile arm-apple-darwin9-gcc -Iext/standard/ -I/home/iuser/Downloads/php/ext/standard/ -DPHP_ATOM_INC -I/home/iuser/Downloads/php/include -I/home/iuser/Downloads/php/main -I/home/iuser/Downloads/php -I/home/iuser/Downloads/php/ext/date/lib -I/home/iuser/Downloads/php/ext/ereg/regex -I/home/iuser/Downloads/php/TSRM -I/home/iuser/Downloads/php/Zend --sysroot /usr/local/ipod -no-cpp-precomp -g -O2 -c /home/iuser/Downloads/php/ext/standard/dns.c -o ext/standard/dns.lo
beendet. Zuerst konnte es nameser8_compat.h nicht finden, welche von nameser.h eingebunden wurde. Das lies sich aber lösen, da in /usr/local/ipod/usr/include/arpa außer der nameser.h auch noch eine nameser_compat.h liegt, also hab ich das include der nameser.h einfach in nameser_compat.h abgeändert.
Dann konnte resolv.h resolv8_compat.h nicht finden. Da hab ich mir dann unter
http://www.opensource.apple.com/source/Libinfo/Libinfo-330/dns.subproj/resolv8_compat.h?txt die resolv8_compat.h heruntergeladen und in der resolv.h noch
#define NS_MAXDNAME 1025 hinzugefügt, weil sonst wieder in der resolv8_compat.h gemeckert wurde.
Jetzt erhalte ich allerdings immer noch einen Fehler in php/ext/standard/dns.c, den ich auch durch das hinzufügen von
#define res_9_init res_init
#define res_9_search res_search
#define res_9_expand res_expand
#define res_9_dn_skipname __dn_skipname
#define res_9_dn_expand dn_expand
in dns.c nicht lösen konnte (stand auch bei dem XtOffsetOf-Link dabei).
Der Fehler:
/home/iuser/Downloads/php/ext/standard/dns.c: In function ‘zif_dns_check_record’:
/home/iuser/Downloads/php/ext/standard/dns.c:356: error: ‘ns_t_mx’ undeclared (first use in this function)
/home/iuser/Downloads/php/ext/standard/dns.c:356: error: (Each undeclared identifier is reported only once
/home/iuser/Downloads/php/ext/standard/dns.c:356: error: for each function it appears in.)
/home/iuser/Downloads/php/ext/standard/dns.c:376: error: ‘ns_t_a’ undeclared (first use in this function)
/home/iuser/Downloads/php/ext/standard/dns.c:409: error: ‘ns_c_in’ undeclared (first use in this function)
/home/iuser/Downloads/php/ext/standard/dns.c: In function ‘php_parserr’:
/home/iuser/Downloads/php/ext/standard/dns.c:444: error: ‘ns_t_any’ undeclared (first use in this function)
/home/iuser/Downloads/php/ext/standard/dns.c: In function ‘zif_dns_get_record’:
/home/iuser/Downloads/php/ext/standard/dns.c:862: error: ‘ns_c_in’ undeclared (first use in this function)
/home/iuser/Downloads/php/ext/standard/dns.c:869: error: ‘NS_HFIXEDSZ’ undeclared (first use in this function)
/home/iuser/Downloads/php/ext/standard/dns.c:886: error: ‘NS_QFIXEDSZ’ undeclared (first use in this function)
/home/iuser/Downloads/php/ext/standard/dns.c: In function ‘zif_dns_get_mx’:
/home/iuser/Downloads/php/ext/standard/dns.c:979: error: ‘ns_c_in’ undeclared (first use in this function)
/home/iuser/Downloads/php/ext/standard/dns.c:987: error: ‘NS_HFIXEDSZ’ undeclared (first use in this function)
/home/iuser/Downloads/php/ext/standard/dns.c:989: error: ‘NS_QFIXEDSZ’ undeclared (first use in this function)
/home/iuser/Downloads/php/ext/standard/dns.c:1003: error: ‘NS_INT16SZ’ undeclared (first use in this function)
/home/iuser/Downloads/php/ext/standard/dns.c:1003: error: ‘NS_INT32SZ’ undeclared (first use in this function)
make: *** [ext/standard/dns.lo] Fehler 1
Und jetzt komme ich einfach nicht mehr weiter. Mit google hab ich nichts mehr dazu gefunden.
Vielleicht kann mir einer von euch weiterhelfen? Irgendwie muss es ja möglich sein PHP für iOS zu kompilieren, sonst wäre es nich im Cydia Store, auch wenn dort eine ältere Version verwendet wird. Sollte ich es vielleicht auch mal mit der versuchen?
Vielen Dank im Voraus!
Edit: Ach ja, ich hatte noch das hier gefunden:
https://www.ohloh.net/p/php4iphone aber da finde ich keinen Download von, die google code seite scheint nicht mehr zu existieren.
Edit2: Hab nach noch mal ein bisschen nach den einzelnen Bezeichnern gegooglet, die nicht gefunden wurden und hab folgendes der dns.c hinzugefügt:
#define ns_t_invalid 0
#define ns_t_a 1
#define ns_t_ns 2
#define ns_t_cname 5
#define ns_t_ptr 12
#define ns_t_mx 15
#define ns_t_txt 16
#define ns_t_aaaa 28
#define ns_t_any 255
#define ns_t_spf 99
#define ns_t_invalid 0
#define NETDB_SUCCESS 0
#define HOST_NOT_FOUND 1
#define TRY_AGAIN 2
#define NO_RECOVERY 3
#define NO_DATA 4
#define ns_c_in 1
#define NS_HFIXEDSZ 12
#define NS_QFIXEDSZ 4
#define NS_INT16SZ 2
#define NS_INT32SZ 4
Danach ist der Kompiliervorgang schon um einiges weiter gekommen, bricht jetzt aber bei folgendem ab:
arm-apple-darwin9-gcc -g -O2 ext/date/php_date.o ext/date/lib/astro.o ext/date/lib/dow.o ext/date/lib/parse_date.o ext/date/lib/parse_tz.o ext/date/lib/timelib.o ext/date/lib/tm2unixtime.o ext/date/lib/unixtime2tm.o ext/date/lib/parse_iso_intervals.o ext/date/lib/interval.o ext/ereg/ereg.o ext/ereg/regex/regcomp.o ext/ereg/regex/regexec.o ext/ereg/regex/regerror.o ext/ereg/regex/regfree.o ext/pcre/pcrelib/pcre_chartables.o ext/pcre/pcrelib/pcre_ucd.o ext/pcre/pcrelib/pcre_compile.o ext/pcre/pcrelib/pcre_config.o ext/pcre/pcrelib/pcre_exec.o ext/pcre/pcrelib/pcre_fullinfo.o ext/pcre/pcrelib/pcre_get.o ext/pcre/pcrelib/pcre_globals.o ext/pcre/pcrelib/pcre_info.o ext/pcre/pcrelib/pcre_maketables.o ext/pcre/pcrelib/pcre_newline.o ext/pcre/pcrelib/pcre_ord2utf8.o ext/pcre/pcrelib/pcre_refcount.o ext/pcre/pcrelib/pcre_study.o ext/pcre/pcrelib/pcre_tables.o ext/pcre/pcrelib/pcre_try_flipped.o ext/pcre/pcrelib/pcre_valid_utf8.o ext/pcre/pcrelib/pcre_version.o ext/pcre/pcrelib/pcre_xclass.o ext/pcre/php_pcre.o ext/mysql/php_mysql.o ext/reflection/php_reflection.o ext/spl/php_spl.o ext/spl/spl_functions.o ext/spl/spl_engine.o ext/spl/spl_iterators.o ext/spl/spl_array.o ext/spl/spl_directory.o ext/spl/spl_exceptions.o ext/spl/spl_observer.o ext/spl/spl_dllist.o ext/spl/spl_heap.o ext/spl/spl_fixedarray.o ext/standard/crypt_freesec.o ext/standard/crypt_blowfish.o ext/standard/crypt_sha512.o ext/standard/crypt_sha256.o ext/standard/php_crypt_r.o ext/standard/array.o ext/standard/base64.o ext/standard/basic_functions.o ext/standard/browscap.o ext/standard/crc32.o ext/standard/crypt.o ext/standard/cyr_convert.o ext/standard/datetime.o ext/standard/dir.o ext/standard/dl.o ext/standard/dns.o ext/standard/exec.o ext/standard/file.o ext/standard/filestat.o ext/standard/flock_compat.o ext/standard/formatted_print.o ext/standard/fsock.o ext/standard/head.o ext/standard/html.o ext/standard/image.o ext/standard/info.o ext/standard/iptc.o ext/standard/lcg.o ext/standard/link.o ext/standard/mail.o ext/standard/math.o ext/standard/md5.o ext/standard/metaphone.o ext/standard/microtime.o ext/standard/pack.o ext/standard/pageinfo.o ext/standard/quot_print.o ext/standard/rand.o ext/standard/soundex.o ext/standard/string.o ext/standard/scanf.o ext/standard/syslog.o ext/standard/type.o ext/standard/uniqid.o ext/standard/url.o ext/standard/var.o ext/standard/versioning.o ext/standard/assert.o ext/standard/strnatcmp.o ext/standard/levenshtein.o ext/standard/incomplete_class.o ext/standard/url_scanner_ex.o ext/standard/ftp_fopen_wrapper.o ext/standard/http_fopen_wrapper.o ext/standard/php_fopen_wrapper.o ext/standard/credits.o ext/standard/css.o ext/standard/var_unserializer.o ext/standard/ftok.o ext/standard/sha1.o ext/standard/user_filters.o ext/standard/uuencode.o ext/standard/filters.o ext/standard/proc_open.o ext/standard/streamsfuncs.o ext/standard/http.o ext/mysqlnd/mysqlnd.o ext/mysqlnd/mysqlnd_alloc.o ext/mysqlnd/mysqlnd_bt.o ext/mysqlnd/mysqlnd_charset.o ext/mysqlnd/mysqlnd_wireprotocol.o ext/mysqlnd/mysqlnd_loaddata.o ext/mysqlnd/mysqlnd_reverse_api.o ext/mysqlnd/mysqlnd_net.o ext/mysqlnd/mysqlnd_statistics.o ext/mysqlnd/mysqlnd_driver.o ext/mysqlnd/mysqlnd_ext_plugin.o ext/mysqlnd/mysqlnd_auth.o ext/mysqlnd/mysqlnd_result.o ext/mysqlnd/mysqlnd_result_meta.o ext/mysqlnd/mysqlnd_debug.o ext/mysqlnd/mysqlnd_block_alloc.o ext/mysqlnd/mysqlnd_plugin.o ext/mysqlnd/php_mysqlnd.o ext/mysqlnd/mysqlnd_ps.o ext/mysqlnd/mysqlnd_ps_codec.o TSRM/TSRM.o TSRM/tsrm_strtok_r.o TSRM/tsrm_virtual_cwd.o main/main.o main/snprintf.o main/spprintf.o main/php_sprintf.o main/fopen_wrappers.o main/alloca.o main/php_scandir.o main/php_ini.o main/SAPI.o main/rfc1867.o main/php_content_types.o main/strlcpy.o main/strlcat.o main/mergesort.o main/reentrancy.o main/php_variables.o main/php_ticks.o main/network.o main/php_open_temporary_file.o main/php_logos.o main/output.o main/getopt.o main/streams/streams.o main/streams/cast.o main/streams/memory.o main/streams/filter.o main/streams/plain_wrapper.o main/streams/userspace.o main/streams/transports.o main/streams/xp_socket.o main/streams/mmap.o main/streams/glob_wrapper.o Zend/zend_language_parser.o Zend/zend_language_scanner.o Zend/zend_ini_parser.o Zend/zend_ini_scanner.o Zend/zend_alloc.o Zend/zend_compile.o Zend/zend_constants.o Zend/zend_dynamic_array.o Zend/zend_dtrace.o Zend/zend_execute_API.o Zend/zend_highlight.o Zend/zend_llist.o Zend/zend_opcode.o Zend/zend_operators.o Zend/zend_ptr_stack.o Zend/zend_stack.o Zend/zend_variables.o Zend/zend.o Zend/zend_API.o Zend/zend_extensions.o Zend/zend_hash.o Zend/zend_list.o Zend/zend_indent.o Zend/zend_builtin_functions.o Zend/zend_sprintf.o Zend/zend_ini.o Zend/zend_qsort.o Zend/zend_multibyte.o Zend/zend_ts_hash.o Zend/zend_stream.o Zend/zend_iterators.o Zend/zend_interfaces.o Zend/zend_exceptions.o Zend/zend_strtod.o Zend/zend_gc.o Zend/zend_closures.o Zend/zend_float.o Zend/zend_string.o Zend/zend_signal.o Zend/zend_objects.o Zend/zend_object_handlers.o Zend/zend_objects_API.o Zend/zend_default_classes.o Zend/zend_execute.o main/internal_functions_cli.o sapi/cli/php_cli.o sapi/cli/php_http_parser.o sapi/cli/php_cli_server.o -o sapi/cli/php
/usr/local/bin/arm-apple-darwin9-ld: Undefined symbols:
_NS_GET16
_NS_GET32
___dn_skipname
collect2: ld returned 1 exit status
make: *** [sapi/cli/php] Fehler 1
Edit3: Ich bin gerade leicht irritiert, weil eigentlich sind die ganzen defines, die ich in dns.c manuell hinzugefügt hab, schon in arpa/nameser.h vorhanden, welche auch von dns.c eingebunden sein sollte. In der nameser.h sind auch NS_GET16 und NS_GET32 definiert. nameser.h ist unter dns.c so eingebunden:
#if HAVE_ARPA_NAMESER_H
#ifdef DARWIN
# define BIND_8_COMPAT 1
#endif
#include <arpa/nameser.h>
#endif
Selbst wenn #if und #ifdef auskommentiere, so das nameser.h auf jeden Fall eingebunden werden soll, funktioniert das ganze nicht.
Ich hab sogar unter nameser.h das #ifndef _NAMESER_9_H_ auskommentiert, das hat aber auch gar nichts geändert, nicht mal ein zusätzlicher compile error, weil irgendetwas doppelt definiert wurde...