1#	$NetBSD: Makefile,v 1.43 2009/04/10 16:16:12 apb Exp $
2
3.include <bsd.own.mk>
4
5# Change the line below for your time zone (after finding the zone you want in
6# the time zone files, or adding it to a time zone file).
7# Alternately, if you discover you've got the wrong time zone, you can just
8#	zic -l rightzone
9
10# If you want something other than Eastern United States time as a template
11# for handling POSIX-style time zone environment variables,
12# change the line below (after finding the zone you want in the
13# time zone files, or adding it to a time zone file).
14# Alternately, if you discover you've got the wrong time zone, you can just
15#	zic -p rightzone
16
17POSIXRULES=	US/Pacific
18
19# Use an absolute path name for TZDIR unless you're just testing the software.
20# Note: ${DESTDIR} is prepended to this for the actual copy.
21
22TZDIR=	/usr/share/zoneinfo
23
24# If you always want time values interpreted as "seconds since the epoch
25# (not counting leap seconds)", use
26# 	REDO=		posix_only
27# below.  If you always want right time values interpreted as "seconds since
28# the epoch" (counting leap seconds)", use
29#	REDO=		right_only
30# below.  If you want both sets of data available, with leap seconds not
31# counted normally, use
32#	REDO=		posix_right
33# below.  If you want both sets of data available, with leap seconds counted
34# normally, use
35#	REDO=		right_posix
36# below.
37
38REDO=		posix_only
39
40# Since "." may not be in PATH...
41YEARISTYPE=	"${HOST_SH} ${.CURDIR}/yearistype.sh"
42
43YDATA=		africa antarctica asia australasia \
44		europe northamerica southamerica pacificnew etcetera factory \
45		backward
46NDATA=		systemv
47SDATA=		solar87 solar88 solar89
48TDATA=		$(YDATA) $(NDATA) $(SDATA)
49ZONETABLES=	zone1970.tab zone.tab
50TABDATA=	iso3166.tab leapseconds $(ZONETABLES)
51DATA=		$(YDATA) $(NDATA) $(TABDATA) # yearistype.sh
52USNO=		usno1988 usno1989
53
54TZBUILDDIR=	${.OBJDIR}/builddir
55
56.PHONY:	posix_only
57posix_only: ${TDATA}
58	${_MKTARGET_CREATE}
59	mkdir -p ${TZBUILDDIR}
60	cd ${.CURDIR} && \
61	    ${TOOL_ZIC} -y ${YEARISTYPE} -d ${TZBUILDDIR} -L /dev/null ${TDATA}
62
63.PHONY:	right_only
64right_only: leapseconds ${TDATA}
65	${_MKTARGET_CREATE}
66	mkdir -p ${TZBUILDDIR}
67	cd ${.CURDIR} && \
68	    ${TOOL_ZIC} -y ${YEARISTYPE} -d ${TZBUILDDIR} -L leapseconds ${TDATA}
69
70.PHONY:	other_two
71other_two: leapseconds ${TDATA}
72	${_MKTARGET_CREATE}
73	mkdir -p ${TZBUILDDIR}
74	cd ${.CURDIR} && \
75	    ${TOOL_ZIC} -y ${YEARISTYPE} -d ${TZBUILDDIR}/posix -L /dev/null ${TDATA}
76	cd ${.CURDIR} && \
77	    ${TOOL_ZIC} -y ${YEARISTYPE} -d ${TZBUILDDIR}/right -L leapseconds ${TDATA}
78
79.PHONY:	posix_right
80posix_right: posix_only other_two
81
82.PHONY:	right_posix
83right_posix: right_only other_two
84
85.if ${MKUNPRIVED} == "no"
86TOOL_PAX.unpriv=-pe
87.else
88TOOL_PAX.unpriv=
89.endif
90
91.if ${MKSHARE} != "no"
92afterinstall: ${DATA} ${REDO} ${TABDATA}
93	${_MKMSG_CREATE} ${POSIXRULES}
94	mkdir -p ${TZBUILDDIR}
95	cd ${.CURDIR} && \
96	    ${TOOL_ZIC} -y ${YEARISTYPE} -d ${TZBUILDDIR} -p ${POSIXRULES}
97	cd ${TZBUILDDIR} && \
98	    find . -type f -print | xargs ${TOOL_STAT} -qf '%d,%i %N' | sort \
99	| while read devino tzfile; do \
100		destfile=${DESTDIR}${TZDIR}/$${tzfile#./}; \
101		if [ "$$devino" = "$$lastdevino" ]; then \
102			if  ldevino=`${TOOL_STAT} -qf '%d %i' $$lastfile` && \
103			    tdevino=`${TOOL_STAT} -qf '%d %i' $$destfile` && \
104			    [ "$$ldevino" = "$$tdevino" ]; then \
105				continue; \
106			fi; \
107			${_MKSHMSG_INSTALL} $$destfile; \
108			${_MKSHECHO} ${INSTALL_LINK} -o ${BINOWN} -g ${BINGRP} \
109			    -m ${NONBINMODE} $$lastfile $$destfile; \
110			${INSTALL_LINK} -o ${BINOWN} -g ${BINGRP} \
111			    -m ${NONBINMODE} $$lastfile $$destfile; \
112		else \
113			lastdevino=$$devino; \
114			lastfile=$$destfile; \
115			cmp -s $$tzfile $$destfile >/dev/null 2>&1 && continue;\
116			${_MKSHMSG_INSTALL} $$destfile; \
117			${_MKSHECHO} ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} \
118			    -m ${NONBINMODE} $$tzfile $$destfile; \
119			${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} \
120			    -m ${NONBINMODE} $$tzfile $$destfile; \
121		fi; \
122	done
123	for f in ${TABDATA}; do \
124		${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m ${NONBINMODE} \
125			${.CURDIR}/$$f ${DESTDIR}${TZDIR}; \
126	done
127.else	# ${MKSHARE} == "no"
128afterinstall:
129.endif	# ${MKSHARE} == "no"
130
131clean:
132	-rm -rf ${TZBUILDDIR}
133
134.include <bsd.prog.mk>
135