summaryrefslogtreecommitdiffstats
path: root/Makefile.am
blob: 23f6a6fa29e68ffcf783941b45a59c2856428363 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
pkgname = postgresql$(DISTSUFF)

SUBDIRS = . doc

bin_SCRIPTS = postgresql$(DISTSUFF)-setup

libexec_SCRIPTS = postgresql$(DISTSUFF)-ctl \
		  postgresql$(DISTSUFF)-check-db-dir

pkgsysconfdir = $(PKGCONFIG_DIR)
pkgsysconf_DATA = conf/postgresql$(DISTSUFF)

userunitsdir = /etc/systemd/system

systemdunitsdir = $(prefix)/lib/systemd/system
nodist_systemdunits_DATA = postgresql$(DISTSUFF).service postgresql$(DISTSUFF)@.service

nodist_pgdoc_DATA = README.rpm-dist

# Encouraged by autoconf documentation itself.  When we use config.status
# directly, e.g. libexecdir may result into '${exec_prefix}/libexec' -- but we
# need fully expanded strings there.
SED_RULES = \
	-e 's|@__FILE__[@]|$@|g' \
	-e 's|@bindir[@]|$(bindir)|g' \
	-e 's|@DISTSUFF[@]|$(DISTSUFF)|g' \
	-e 's|@docdir[@]|$(docdir)|g' \
	-e 's|@libdir[@]|$(libdir)|g' \
	-e 's|@libexecdir[@]|$(libexecdir)|g' \
	-e 's|@PG_CTL_BIN[@]|$(PG_CTL_BIN)|g' \
	-e 's|@PGDATADIR[@]|$(PGDATADIR)|g' \
	-e 's|@pgcontribdocdir[@]|$(pgcontribdocdir)|g' \
	-e 's|@pgdocdir[@]|$(pgdocdir)|g' \
	-e 's|@PGENGINE[@]|$(PGENGINE)|g' \
	-e 's|@pkgname[@]|$(pkgname)|g' \
	-e 's|@PGMAJORVERSION[@]|$(PGMAJORVERSION)|g' \
	-e 's|@PGVERSION[@]|$(PGVERSION)|g' \
	-e 's|@PKGCONFIG_DIR[@]|$(PKGCONFIG_DIR)|g' \
	-e 's|@POSTGRES_HOMEDIR[@]|$(POSTGRES_HOMEDIR)|g' \
	-e 's|@PREVMAJORVERSION[@]|$(PREVMAJORVERSION)|g' \
	-e 's|@PREVPGENGINE[@]|$(PREVPGENGINE)|g' \
	-e 's|@README_DIST[@]|$(README_DIST)|g' \
	-e 's|@SU[@]|$(SU)|g' \
	-e 's|@systemdunitsdir[@]|$(systemdunitsdir)|' \
	-e 's|@VERSION[@]|$(VERSION)|g'

SED_CALL = $(SED) $(SED_RULES)

edit = $(SED_CALL) $< > $@

c_s = $(top_srcdir)/config.status

c_s_gen = $(AM_V_GEN)$(edit)

c_s_script_gen = $(c_s_gen) && chmod +x $@

postgresql$(DISTSUFF)-ctl: postgresql-ctl.in $(c_s)
	$(c_s_script_gen)

postgresql$(DISTSUFF)-setup: postgresql-setup.in $(c_s)
	$(c_s_script_gen)

postgresql$(DISTSUFF)-check-db-dir: postgresql-check-db-dir.in $(c_s)
	$(c_s_script_gen)

conf/postgresql$(DISTSUFF): conf/postgresql.in $(c_s)
	$(c_s_gen)

# In ideal world, postgresql@.service would be hardlink to postgresql.service.
# That would require, however, the rhbz#1141824 resolved so we could install
# system-default drop-in file.  Make a "almost" duplicate files now.

postgresql$(DISTSUFF)@.service: postgresql.service.in $(c_s)
	$(AM_V_GEN)$(SED_CALL) \
	    -e '/@PGDATA_ENVIRONMENT[@]/d' \
	    $< > $@

postgresql$(DISTSUFF).service: postgresql.service.in $(c_s)
	$(AM_V_GEN)$(SED_CALL) \
	    -e 's|@PGDATA_ENVIRONMENT[@]|Environment=PGDATA=$(PGDATADIR)|' \
	    $< > $@

README.rpm-dist: README.rpm-dist.in $(c_s)
	$(c_s_gen)

EXTRA_DIST = *.in conf/*.in

CLEANFILES = $(bin_SCRIPTS) \
	     $(libexec_SCRIPTS) \
	     $(nodist_pgdoc_DATA) \
	     $(pkgsysconf_DATA) \
	     $(nodist_systemdunits_DATA)

install-data-hook:
	test `id -u` -eq 0 && systemctl daemon-reload