IntelMacにDarwinPortsでrubyをインストール

こんなのでた。

--->  Fetching zlib
--->  Attempting to fetch zlib-1.2.3.tar.bz2 from http://www.zlib.net/
--->  Verifying checksum(s) for zlib
--->  Extracting zlib
--->  Configuring zlib
--->  Building zlib with target all
--->  Staging zlib into destroot
--->  Packaging tgz archive for zlib 1.2.3_0
--->  Installing zlib 1.2.3_0
--->  Activating zlib 1.2.3_0
Error: Target com.apple.activate returned: Image error: /opt/local/include/zconf.h already exists and does not belong to a registered port.  Unable to activate port zlib.
Error: The following dependencies failed to build: zlib
Error: /opt/local/bin/port: Status 1 encountered during processing.

しょうがないので、

sudo port -dv  install ruby

とやると、

Error: Target com.apple.build returned: shell command "cd "/opt/local/var/db/dports/build/_opt_local_var_db_dports_sources_rsync.rsync.darwinports.org_dpupdate_dports_devel_openssl/work/openssl-0.9.8b" && make all CC=/usr/bin/gcc-4.0" returned error 2
Command output: /usr/bin/libtool: internal link edit command failed
making all in engines...
make[1]: Nothing to be done for `all'.
making all in apps...
rm -f openssl
shlib_target=; if [ -n "libcrypto.0.9.8.dylib libssl.0.9.8.dylib" ]; then ?
      shlib_target="darwin-shared"; ?
fi; ?
if [ "${shlib_target}" = "darwin-shared" ] ; then ?
LIBRARIES="../libssl.a  ../libcrypto.a" ; ?
else ?
LIBRARIES="-L.. -lssl  -L.. -lcrypto" ; ?
fi; ?
make -f ../Makefile.shared -e ?
      APPNAME=openssl OBJECTS="openssl.o verify.o asn1pars.o req.o dgst.o dh.o dhparam.o enc.o passwd.o gendh.o errstr.o ca.o pkcs7.o crl2p7.o crl.o rsa.o rsautl.o dsa.o dsaparam.o ec.o ecparam.o x509.o genrsa.o gendsa.o s_server.o s_client.o speed.o s_time.o apps.o s_cb.o s_socket.o app_rand.o version.o sess_id.o ciphers.o nseq.o pkcs12.o pkcs8.o spkac.o smime.o rand.o engine.o ocsp.o prime.o" ?
      LIBDEPS=" $LIBRARIES -L/opt/local/lib  -lz" ?
      link_app.${shlib_target}
( :; LIBDEPS="${LIBDEPS:-../libssl.a  ../libcrypto.a -L/opt/local/lib  -lz}"; LDCMD="${LDCMD:-/usr/bin/gcc-4.0}"; LDFLAGS="${LDFLAGS:--fPIC -fno-common -DOPENSSL_PIC -DZLIB -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -O3 -fomit-frame-pointer -fno-common}"; LIBPATH=`for x in $LIBDEPS; do if echo $x | grep '^ *-L' > /dev/null 2>&1; then echo $x | sed -e 's/^ *-L//'; fi; done | uniq`; LIBPATH=`echo $LIBPATH | sed -e 's/ /:/g'`; LD_LIBRARY_PATH=$LIBPATH:$LD_LIBRARY_PATH ${LDCMD} ${LDFLAGS} -o ${APPNAME:=openssl} openssl.o verify.o asn1pars.o req.o dgst.o d
h.o dhparam.o enc.o passwd.o gendh.o errstr.o ca.o pkcs7.o crl2p7.o crl.o rsa.o rsautl.o dsa.o dsaparam.o ec.o ecparam.o x509.o genrsa.o gendsa.o s_server.o s_client.o speed.o s_time.o apps.o s_cb.o s_socket.o app_rand.o version.o sess_id.o ciphers.o nseq.o pkcs12.o pkcs8.o spkac.o smime.o rand.o engine.o ocsp.o prime.o ${LIBDEPS} )
<strong>/usr/bin/ld: warning /opt/local/lib/libz.dylib cputype (18, architecture ppc) does not match cputype (7) for specified -arch flag: i386 (file not loaded)
/usr/bin/ld: Undefined symbols:</strong>
_deflate
_deflateEnd
_deflateInit_
_inflate
_inflateEnd
_inflateInit_
collect2: ld returned 1 exit status
make[2]: *** [link_app.darwin] Error 1
make[1]: *** [openssl] Error 2
make: *** [build_apps] Error 1

Warning: the following items did not execute (for openssl): com.apple.activate com.apple.build com.apple.destroot com.apple.archive com.apple.install
Error: /opt/local/bin/port: Status 1 encountered during processing.

こんなのが出てきた。
要するに、/opt/local/lib/libz.dylibがppc用になっていて、i386用になっていないのが原因らしい。

ググッタところ、調査方法と対処方があったので、それに従ってまずは確認。

satie:~ hisaboh$ file /opt/local/lib/libz.dylib
/opt/local/lib/libz.dylib: symbolic link to `libz.1.2.2.dylib'
satie:~ hisaboh$ file /opt/local/lib/libz.1.2.2.dylib
/opt/local/lib/libz.1.2.2.dylib: Mach-O dynamically linked shared library ppc

ということで間違いなくppc用になっているのが原因。
ソースコード版のDarwinPortsを入れればいいようなので、まずは既存のDarwinPortsをアンインストール
http://wiki.opendarwin.org/index.php/DarwinPorts:FAQ#How_do_I_remove_or_uninstall_DarwinPorts.3F

satie:~ hisaboh$ sudo rm -rf /opt/local/ /Library/Tcl/darwinports1.0


/Applications/DarwinPortsと/Library/StartupItems/DarwinPortsStartupはなかった。

ソースコード版を入れようかと思ったが、そもそもどこからDarwinPortsをインストールしたか覚えていなかったので、一度だけ、dmgを試してみようかと。
http://darwinports.opendarwin.org/getdp/からDarwinPorts-1.2.1-10.4.dmbをダウンロードしてインストール。

satie:~ hisaboh$ sudo port selfupdate
satie:~ hisaboh$ sudo port install ruby

したら無事成功。

ソースコード版を入れる必要はなかった。