PostgreSQL 7.4 を Intel Mac にインストールする方法
理由あって PostgreSQL 7.4 を Mac OS X にインストールすることになった。早速、ダウンロードページから手に入る中で最新の 7.4.17 をダウンロードしてインストールしようとするも、エラーが出てコンパイルできない。
% ./configure
% make
...
gcc -no-cpp-precomp -O2 -fno-strict-aliasing -Wall -Wmissing-prototypes -Wmissing-declarations -I../../../../src/include -c -o xlog.o xlog.c
In file included from ../../../../src/include/storage/spin.h:50,
from xlog.c:35:
../../../../src/include/storage/s_lock.h:543:2: error: #error **PostgreSQL does not have native spinlock support on this platform. To continue the compilation, rerun configure using --disable-spinlocks. However, performance will be poor. Please report this to pgsql-bugs@postgresql.org.**
In file included from ../../../../src/include/storage/spin.h:50,
from xlog.c:35:
../../../../src/include/storage/s_lock.h:551: error: conflicting types for ‘slock_t’
../../../../src/include/pg_config_os.h:11: error: previous declaration of ‘slock_t’ was here
make[4]: *** [xlog.o] Error 1
make[3]: *** [transam-recursive] Error 2
make[2]: *** [access-recursive] Error 2
make[1]: *** [all] Error 2
make: *** [all] Error 2
ちなみに環境は以下の通り。
- PostgreSQL 7.4.17 (download)
- Mac OS X 10.4.10
- MacBook Intel Core 2 Duo
エラーメッセージには、
PostgreSQL does not have native spinlock support on this platform. To continue the compilation, rerun configure using –disable-spinlocks. However, performance will be poor. Please report this to pgsql-bugs@postgresql.org.
とあるので、言われたとおり --disable-spinlocks
オプションつきでコンパイルを試みる。
% make clean
% ./configure --disable-spinlocks
...
In file included from ../../../../src/include/storage/spin.h:50,
from xlog.c:35:
../../../../src/include/storage/s_lock.h:551: error: conflicting types for ‘slock_t’
../../../../src/include/pg_config_os.h:11: error: previous declaration of ‘slock_t’ was here
make[4]: *** [xlog.o] Error 1
make[3]: *** [transam-recursive] Error 2
make[2]: *** [access-recursive] Error 2
make[1]: *** [all] Error 2
make: *** [all] Error 2
やはり駄目だ。該当のエラーはなくなったけど、そのあとのエラーが直らない。
Google で検索してみると、同様に困っている人も何人かいるようだ。
しかし、解決策は書かれていない(最新版使えよ、ってのはあるけど…)。
しょうがないので、無理矢理コンパイルを通すことにした。
--- src/include/port/darwin.h.org 2007-07-24 17:15:54.000000000 +0900
+++ src/include/port/darwin.h 2007-07-24 17:15:58.000000000 +0900
@@ -1,8 +1,6 @@
#define __darwin__ 1
-#if defined(__ppc__)
#define HAS_TEST_AND_SET
-#endif
#if defined(__ppc__)
typedef unsigned int slock_t;
ざっとソースコードを眺めた感じ、Intel Mac のチェックが抜けているだけのように思えた(というか、読む気が失せて、そう思い込むことにした)ので、こんな適当な変更でコンパイルしてみる。
% make clean
% ./configure
% make
...
All of PostgreSQL successfully made. Ready to install.
psql
が動作することと、make check
がパスすることは確認ずみ。