【发布时间】:2011-06-03 09:50:51
【问题描述】:
我正在为 Snow Leopard 安装(使用 MacPorts 安装 Postgres)编译几个 Postgres 扩展。这通常需要与 make 命令一起传递两个变量,例如:
sudo make install USE_PGXS=1 PGUSER=postgres
至少可以说,我的 C 有点生疏了,我在 Google 上四处搜索无济于事,希望找到一种不需要传递上述两个变量的方法。
我似乎做对了一些事情...我当前的 ~/.makerc 文件包含以下内容:
$ cat ~/.makerc
USE_PGXS=1
PGUSER=postgres
这解决了运行make installcheck 时的问题,但是在没有sudo 的情况下运行它经常意味着在实际制作过程中出现权限问题,并且当我运行sudo make installcheck 时不会读取.makerc。我以 root 身份登录并在 /var/root 中放置了指向上述文件的符号链接,但无济于事。
可以说,我可以诉诸以 root 身份登录的所有这些操作。但是,我很想知道我是否可能忽略了某些东西。运行sudo make而不是make时有没有办法使用.makerc文件?
编辑:评论日志,在最初的建议之后:
DB:~/pgdevel/kmeans-postgresql $ export USE_PGXS=1
DB:~/pgdevel/kmeans-postgresql $ export PGUSER=postrgess
这失败了,因为它使 makefile 假定 kmeans-postgresql 位于 postgres/contrib 中(这是 USE_PGXS 的意义所在,并且将其放置在 postgres/contrib 中也失败了,因为它是使用 MacPorts 安装的):
DB:~/pgdevel/kmeans-postgresql $ sudo make
Makefile:34: ../../src/Makefile.global: No such file or directory
Makefile:35: /contrib/contrib-global.mk: No such file or directory
make: *** No rule to make target `/contrib/contrib-global.mk'. Stop.
这成功了(即使没有导出):
DB:~/pgdevel/kmeans-postgresql $ make
sed 's,MODULE_PATHNAME,$libdir/kmeans,g' kmeans.sql.in >kmeans.sql
cp kmeans.sql kmeans--1.0.0.sql
/usr/bin/gcc-4.2 -pipe -O2 -arch x86_64 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wformat-security -fno-strict-aliasing -fwrapv -I. -I. -I/opt/local/include/postgresql91/server -I/opt/local/include/postgresql91/internal -I/opt/local/include -I/opt/local/include/ossp -I/opt/local/include/libxml2 -I/opt/local/include -c -o kmeans.o kmeans.c
[some warnings...]
/usr/bin/gcc-4.2 -pipe -O2 -arch x86_64 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wformat-security -fno-strict-aliasing -fwrapv -L/opt/local/lib/postgresql91 -L/opt/local/lib -arch x86_64 -L/opt/local/lib -L/opt/local/lib -Wl,-dead_strip_dylibs -bundle -bundle_loader /opt/local/lib/postgresql91/bin/postgres -o kmeans.so kmeans.o
rm kmeans.o
PS:我正在重新添加 OSX 和 PostgreSQL 标签,因为虽然不是严格与 PostgreSQL 相关,但我希望 MacOSX 上的另一个 PostgreSQL 用户可能知道解决方法。
【问题讨论】:
-
你从哪里得到
.makerc?是 GNU Make 还是别的什么? -
试错,真的。我在谷歌搜索结果中看到了它,所以尝试了一下。 GCC 版本是 i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5664)
-
我在 GNU Make 文档中找不到它,所以它可能不存在 :)
-
似乎如此。我刚刚发布了答案,确实不需要这样的文件......
-
需要设置类似变量的扩展被破坏。向他们发送错误报告。
标签: macos postgresql makefile sudo