xref: /netbsd-src/external/public-domain/tz/share/zoneinfo/Makefile (revision 7a15adb9edfae822c708c629d6235283b3914605)
1#	$NetBSD: Makefile,v 1.5 2024/06/02 00:21:12 kre Exp $
2
3.include <bsd.own.mk>
4.include "../../Makefile.inc"
5
6.PATH: ${TZDISTDIR}
7
8# If you want something other than Eastern United States time as a template
9# for handling POSIX-style time zone environment variables,
10# change the line below (after finding the zone you want in the
11# time zone files, or adding it to a time zone file).
12# (When a POSIX-style environment variable is handled, the rules in the
13# template file are used to determine "spring forward" and "fall back" days and
14# times; the environment variable itself specifies UT offsets of standard and
15# summer time.)
16# Alternately, if you discover you've got the wrong time zone, you can just
17#	zic -p rightzone
18# to correct things.
19# Use the command
20#	make zonenames
21# to get a list of the values you can use for POSIXRULES.
22# If you want POSIX compatibility, use "America/New_York".
23
24POSIXRULES=	America/New_York
25
26# "Compiled" time zone information is placed in the "TZDIR" directory
27# (and subdirectories).
28# Use an absolute path name for TZDIR unless you're just testing the software.
29# Note: ${DESTDIR} is prepended to this for the actual copy.
30
31TZDIR=	/usr/share/zoneinfo
32
33# If you always want time values interpreted as "seconds since the epoch
34# (not counting leap seconds)", use
35#	REDO=		posix_only
36# below.  If you always want right time values interpreted as "seconds since
37# the epoch" (counting leap seconds)", use
38#	REDO=		right_only
39# below.  If you want both sets of data available, with leap seconds not
40# counted normally, use
41#	REDO=		posix_right
42# below.  If you want both sets of data available, with leap seconds counted
43# normally, use
44#	REDO=		right_posix
45# below.
46
47REDO=		posix_only
48
49PRIMARY_YDATA=	africa antarctica asia australasia \
50		europe northamerica southamerica
51YDATA=		$(PRIMARY_YDATA) etcetera backward
52NDATA=		factory
53TDATA=		$(YDATA) $(NDATA)
54ZONETABLES=	zone1970.tab zone.tab
55TABDATA=	iso3166.tab leapseconds leap-seconds.list $(ZONETABLES)
56DATA=		$(YDATA) $(NDATA) $(TABDATA)
57
58TZBUILDDIR=	${.OBJDIR}/builddir
59
60.PHONY:	posix_only
61posix_only: ${TDATA}
62	${_MKTARGET_CREATE}
63	mkdir -p ${TZBUILDDIR}
64	cd ${TZDISTDIR} && \
65	    ${TOOL_ZIC} -d ${TZBUILDDIR} -L /dev/null ${TDATA}
66
67.PHONY:	right_only
68right_only: leapseconds ${TDATA}
69	${_MKTARGET_CREATE}
70	mkdir -p ${TZBUILDDIR}
71	cd ${TZDISTDIR} && \
72	    ${TOOL_ZIC} -d ${TZBUILDDIR} -L leapseconds ${TDATA}
73
74.PHONY:	other_two
75other_two: leapseconds ${TDATA}
76	${_MKTARGET_CREATE}
77	mkdir -p ${TZBUILDDIR}
78	cd ${TZDISTDIR} && \
79	    ${TOOL_ZIC} -d ${TZBUILDDIR}/posix -L /dev/null ${TDATA}
80	cd ${TZDISTDIR} && \
81	    ${TOOL_ZIC} -d ${TZBUILDDIR}/right -L leapseconds ${TDATA}
82
83.PHONY:	posix_right
84posix_right: posix_only other_two
85
86.PHONY:	right_posix
87right_posix: right_only other_two
88
89.if ${MKUNPRIVED} == "no"
90TOOL_PAX.unpriv=-pe
91.else
92TOOL_PAX.unpriv=
93.endif
94
95.if ${MKSHARE} != "no"
96afterinstall: ${DATA} ${REDO} ${TABDATA}
97	${_MKMSG_CREATE} ${POSIXRULES}
98	mkdir -p ${TZBUILDDIR}
99	cd ${TZDISTDIR} && \
100	    ${TOOL_ZIC} -d ${TZBUILDDIR} -p ${POSIXRULES}
101	cd ${TZBUILDDIR} && \
102	    find . -type f -print | xargs ${TOOL_STAT} -qf '%d,%i %N' | sort \
103	| while read devino tzfile; do \
104		destfile=${DESTDIR}${TZDIR}/$${tzfile#./}; \
105		destdir=$$(dirname $${destfile}); \
106		if [ ! -d "$$destdir" ]; then \
107			${_MKSHMSG_INSTALL} $$destdir; \
108			${_MKSHECHO} ${INSTALL_DIR} -o ${BINOWN} -g ${BINGRP} \
109			$$destdir; \
110			${INSTALL_DIR} -o ${BINOWN} -g ${BINGRP} $$destdir; \
111		fi; \
112		if [ "$$devino" = "$$lastdevino" ]; then \
113			if  ldevino=$$(${TOOL_STAT} -qf '%d %i' $$lastfile) && \
114			    tdevino=$$(${TOOL_STAT} -qf '%d %i' $$destfile) && \
115			    [ "$$ldevino" = "$$tdevino" ]; then \
116				continue; \
117			fi; \
118			${_MKSHMSG_INSTALL} $$destfile; \
119			${_MKSHECHO} ${INSTALL_LINK} -o ${BINOWN} -g ${BINGRP} \
120			    -m ${NONBINMODE} $$lastfile $$destfile; \
121			${INSTALL_LINK} -o ${BINOWN} -g ${BINGRP} \
122			    -m ${NONBINMODE} $$lastfile $$destfile; \
123		else \
124			lastdevino=$$devino; \
125			lastfile=$$destfile; \
126			cmp -s $$tzfile $$destfile >/dev/null 2>&1 && continue;\
127			${_MKSHMSG_INSTALL} $$destfile; \
128			${_MKSHECHO} ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} \
129			    -m ${NONBINMODE} $$tzfile $$destfile; \
130			${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} \
131			    -m ${NONBINMODE} $$tzfile $$destfile; \
132		fi; \
133	done
134	for f in ${TABDATA}; do \
135		${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m ${NONBINMODE} \
136			${TZDISTDIR}/$$f ${DESTDIR}${TZDIR}; \
137	done
138	${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m ${NONBINMODE} \
139		${TZDISTDIR}/TZDATA_VERSION ${DESTDIR}${TZDIR}/TZDATA_VERSION
140.else	# ${MKSHARE} == "no"
141afterinstall:
142.endif	# ${MKSHARE} == "no"
143
144clean:
145	-rm -rf ${TZBUILDDIR}
146
147.include <bsd.prog.mk>
148