Skip to content

Commit dbeb672

Browse files
committed
new doc
1 parent eb9bcf6 commit dbeb672

File tree

123 files changed

+15712
-234
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+15712
-234
lines changed

201509/20150907_03.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
## PostgreSQL src/Makefile.global中的小坑
2+
3+
### 作者
4+
digoal
5+
6+
### 日期
7+
2015-09-07
8+
9+
### 标签
10+
PostgreSQL , 编译 , makefile
11+
12+
----
13+
14+
## 背景
15+
在编译一个插件时发现PostgreSQL的src/Makefile.global可能有一些坑你会踩到,
16+
17+
我们来看看坑是什么?
18+
19+
src/Makefile.global
20+
21+
```
22+
datadir := ${datarootdir}
23+
ifeq "$(findstring pgsql, $(datadir))" ""
24+
ifeq "$(findstring postgres, $(datadir))" ""
25+
override datadir := $(datadir)/postgresql
26+
endif
27+
endif
28+
29+
sysconfdir := ${prefix}/etc
30+
ifeq "$(findstring pgsql, $(sysconfdir))" ""
31+
ifeq "$(findstring postgres, $(sysconfdir))" ""
32+
override sysconfdir := $(sysconfdir)/postgresql
33+
endif
34+
endif
35+
36+
libdir := ${exec_prefix}/lib
37+
38+
pkglibdir = $(libdir)
39+
ifeq "$(findstring pgsql, $(pkglibdir))" ""
40+
ifeq "$(findstring postgres, $(pkglibdir))" ""
41+
override pkglibdir := $(pkglibdir)/postgresql
42+
endif
43+
endif
44+
45+
includedir := ${prefix}/include
46+
47+
pkgincludedir = $(includedir)
48+
ifeq "$(findstring pgsql, $(pkgincludedir))" ""
49+
ifeq "$(findstring postgres, $(pkgincludedir))" ""
50+
override pkgincludedir := $(pkgincludedir)/postgresql
51+
endif
52+
endif
53+
54+
mandir := ${datarootdir}/man
55+
56+
docdir := ${datarootdir}/doc/${PACKAGE_TARNAME}
57+
ifeq "$(findstring pgsql, $(docdir))" ""
58+
ifeq "$(findstring postgres, $(docdir))" ""
59+
override docdir := $(docdir)/postgresql
60+
endif
61+
endif
62+
```
63+
64+
注意,当这些目录中没有出现pgsql, postgres时,自动会在原有目录下新增一个postgresql目录。
65+
66+
这点可能酿成大错,例如你的环境变量,或者代码中有这种强依赖的话,在更换主目录后就可能出现问题。
67+
68+
例如原来是/opt/pgsql/lib
69+
70+
更换主目录后,你的lib可能会放到/opt/pg/lib/postgresql这里去。
71+
72+
这个最容易出问题的在extension中。例如:
73+
74+
75+
src/contrib/pg_stat_statements/Makefile
76+
77+
```
78+
ifdef USE_PGXS
79+
PG_CONFIG = pg_config
80+
PGXS := $(shell $(PG_CONFIG) --pgxs)
81+
include $(PGXS)
82+
else
83+
subdir = contrib/pg_stat_statements
84+
top_builddir = ../..
85+
include $(top_builddir)/src/Makefile.global
86+
include $(top_srcdir)/contrib/contrib-global.mk
87+
endif
88+
```
89+
90+
<a rel="nofollow" href="http://info.flagcounter.com/h9V1" ><img src="http://s03.flagcounter.com/count/h9V1/bg_FFFFFF/txt_000000/border_CCCCCC/columns_2/maxflags_12/viewers_0/labels_0/pageviews_0/flags_0/" alt="Flag Counter" border="0" ></a>
91+

0 commit comments

Comments
 (0)