summaryrefslogtreecommitdiff
path: root/databases/postgresql/Makefile
blob: 33676ecde79cbd14aeb0549a2498beb14441bd53 (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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# $NetBSD: Makefile,v 1.37 1999/08/24 14:18:53 tron Exp $
# FreeBSD Id: Makefile,v 1.22 1997/12/24 01:21:37 alex Exp
#

DISTNAME=		postgresql-6.4.2
WRKSRC=			${WRKDIR}/${DISTNAME}/src
CATEGORIES=		databases
MASTER_SITES=		ftp://ftp.PostgreSQL.org/pub/ \
			ftp://ftp.sunsite.auc.dk/mirrors/www.postgresql.org/pub/ \
			ftp://ftp.jaist.ac.jp/pub/dbms/postgres95/

MAINTAINER=		packages@netbsd.org
HOMEPAGE=		http://www.PostgreSQL.ORG/

BUILD_DEPENDS+=		${LOCALBASE}/bin/bison:../../devel/bison
DEPENDS+=		tk-8.0.5:../../x11/tk80 \
			tcl-8.0.5:../../lang/tcl80 \
			addnerd-1.6:../../sysutils/addnerd

# Needs ELF clue, mips has no TAS implementation
NOT_FOR_PLATFORM=	*-*-alpha *-*-mips

PLIST_SRC=		${WRKDIR}/PLIST.tmp
REQ_FILE=		${WRKDIR}/REQ

PGUSER?=		pgsql
PGGROUP?=		ingres

USE_GMAKE=
MAKEFILE=		GNUmakefile
HAS_CONFIGURE=		yes
CONFIGURE_ARGS= 	--prefix=${PREFIX}/${PGUSER} \
			--enable-locale \
			--with-tcl \
			--with-tclconfig="${LOCALBASE}/lib/tcl8.0 ${LOCALBASE}/lib/tk8.0" \
			--with-includes="${LOCALBASE}/include ${LOCALBASE}/include/tcl8.0 ${LOCALBASE}/include/tk8.0" \
			--with-libs=${PREFIX}/lib \
			--with-template=`${ECHO} ${OPSYS} | ${TR} '[A-Z]' '[a-z]'`

INSTALL_TARGET=		install install-man

BUILD_DEFS+=		PGGROUP PGUSER

.include "../../mk/bsd.prefs.mk"

pre-extract:
	@(case "X${PGUSER}" in						\
	Xbin|Xetc|Xinclude|Xinfo|Xlib|Xlibdata|Xlibexec|Xman|Xsbin|Xshare)\
		gooduser=no;						\
		;;							\
	*)								\
		gooduser=yes;						\
		;;							\
	esac;								\
	if [ $$gooduser = "no" ]; then					\
		${ECHO} "You have choosen PGUSER=${PGUSER} which will";	\
		${ECHO} "cause trouble, because postgres would get";	\
		${ECHO} "installed to ${PREFIX}/${PGUSER}. So please";	\
		${ECHO} "set PGUSER to something more reasonable";	\
		${ECHO} "like pgsql.";					\
		${ECHO} "";						\
		${FALSE};						\
	fi)

post-build:
	@ ${ECHO} "------------------------------------------------------------"
	@ ${ECHO} "Dump existing databases, before installing new db version !!"
	@ ${ECHO} "Detailed instructions, see INSTALL file under ${WRKDIR}...  "
	@ ${ECHO} "------------------------------------------------------------"

pre-install:
	${RM} -rf ${PREFIX}/${PGUSER}
	@${SED}  \
		-e 's|@PGUSER@|${PGUSER}|g' \
		-e 's|@PGGROUP@|${PGGROUP}|g' \
		-e 's|@PREFIX@|${PREFIX}|g' \
		-e 's|@LOCALBASE@|${LOCALBASE}|g' \
		<${PKGDIR}/REQ > ${REQ_FILE}
	@${SED}  \
		-e 's|@PGUSER@|${PGUSER}|g' \
		<${PKGDIR}/PLIST > ${PLIST_SRC}
	${SH} ${REQ_FILE} ${PKGNAME} INSTALL

post-install:
	@ if [ ! -f ${PREFIX}/${PGUSER}/.profile ]; then \
		${ECHO} "PATH=\$${PATH}:${PREFIX}/${PGUSER}/bin" \
			> ${PREFIX}/${PGUSER}/.profile; \
		${ECHO} "MANPATH=\$${MANPATH}:${PREFIX}/${PGUSER}/man" \
			>> ${PREFIX}/${PGUSER}/.profile; \
		${ECHO} "PGLIB=${PREFIX}/${PGUSER}/lib" \
			>> ${PREFIX}/${PGUSER}/.profile; \
		${ECHO} "# note: PGDATA overwrites the -D startup option" \
			>> ${PREFIX}/${PGUSER}/.profile; \
		${ECHO} "PGDATA=${PREFIX}/${PGUSER}/data" \
			>> ${PREFIX}/${PGUSER}/.profile; \
		${ECHO} "DISPLAY=:0" \
			>> ${PREFIX}/${PGUSER}/.profile; \
		${ECHO} "export PATH MANPATH PGLIB PGDATA DISPLAY" \
			>> ${PREFIX}/${PGUSER}/.profile; \
		${ECHO} "# if you want to make regression tests use this TZ" \
			>> ${PREFIX}/${PGUSER}/.profile; \
		${ECHO} "#TZ=PST8PDT" \
			>> ${PREFIX}/${PGUSER}/.profile; \
		${ECHO} "#export TZ" \
			>> ${PREFIX}/${PGUSER}/.profile; \
	fi
	@/usr/sbin/chown -R ${PGUSER}:${PGGROUP} ${PREFIX}/${PGUSER}
	@${ECHO} 'Initializing PostgreSQL Databases - this may take a few minutes...'
	${LDCONFIG} ${PREFIX}/${PGUSER}/lib || ${TRUE}
	@${ECHO} '${SETENV} PATH=${PREFIX}/${PGUSER}/bin:$$PATH ${PREFIX}/${PGUSER}/bin/initdb --pglib=${PREFIX}/${PGUSER}/lib --pgdata=${PREFIX}/${PGUSER}/data' | su -l ${PGUSER}
	@${SED} -e "s=!!PREFIX!!=${PREFIX}=g" -e "s=!!PGUSER!!=${PGUSER}=g" \
		< ${FILESDIR}/pgsql.sh.tmpl > ${PREFIX}/etc/rc.d/pgsql.sh
	@/bin/chmod 554 ${PREFIX}/etc/rc.d/pgsql.sh
	@/usr/sbin/chown root:${PGGROUP} ${PREFIX}/etc/rc.d/pgsql.sh
	@${INSTALL} -c -o ${PGUSER} -g ${PGGROUP} -m 444 \
		${FILESDIR}/post-install-notes ${PREFIX}/${PGUSER}
	-${MKDIR} ${PREFIX}/share/doc/pgsql
	${CP} -R ${WRKDIR}/${DISTNAME}/doc/* ${PREFIX}/share/doc/pgsql
	${RM} -rf ${PREFIX}/share/doc/pgsql/src/CVS \
		${PREFIX}/share/doc/pgsql/src/graphics/CVS \
		${PREFIX}/share/doc/pgsql/src/sgml/ref/CVS \
		${PREFIX}/share/doc/pgsql/src/sgml/CVS \
		${PREFIX}/share/doc/pgsql/CVS
.if !defined(BATCH)
	@${CAT} ${FILESDIR}/post-install-notes
.endif
	@case `${GREP} -c '^${PREFIX}/${PGUSER}/lib$$' /etc/ld.so.conf` in	\
	0)									\
		${ECHO} "************** WARNING ********************";		\
		${ECHO} "Please add ${PREFIX}/${PGUSER}/lib to /etc/ld.so.conf";\
		${ECHO} "so that this package is usable after any reboot";	\
		${ECHO} "************** WARNING ********************";		\
		;;								\
	esac

.include "../../mk/bsd.pkg.mk"