xref: /freebsd/share/zoneinfo/Makefile (revision 02e9120893770924227138ba49df1edb3896112a)
1
2#
3# HOW TO UPDATE THE ZONEINFO DATA
4#
5# Import the new sources to the vendor branch:
6#
7# $ cd ~/freebsd/src
8# $ git worktree add ../tzdata vendor/tzdata
9# $ pushd ../tzdata
10# $ tar -xvf ../tzdata-latest.tar.gz
11#   (check with "git status" and "git diff" if it all makes sense)
12# $ git add -A
13# $ git commit -m "Import tzdata 20XXX"
14# $ git tag -a -m "Tag import of tzdata 20XXX" vendor/tzdata/tzdata20XXX
15# $ git push --follow-tags freebsd vendor/tzdata
16# $ popd
17#
18# Merge-from-vendor
19#
20# $ git subtree merge -P contrib/tzdata vendor/tzdata
21#   (write a meaningful commit message)
22# $ git push freebsd HEAD:main
23#
24# MFC
25#
26# $ git checkout -b freebsd/stable/12 stable-12
27# $ git cherry-pick -x [hash of merge commit to main] -m 1 --edit
28#   (write a meaningful commit message)
29# $ git push freebsd HEAD:stable/12
30#
31#
32# If there are changes to zone1970.tab, update the baseline file by running
33# `make baseline` in usr.sbin/tzsetup to check if tzsetup is able to parse new
34# contents (if not, report/fix tzsetup).  Check that update does not
35# introduce breaking/unexpected changes to continents/countries/zones,
36# and commit the updated baseline file.
37
38.include <src.opts.mk>
39
40PACKAGE=	zoneinfo
41CLEANDIRS+=	builddir
42CONTRIBDIR=	${SRCTOP}/contrib/tzdata/
43.PATH:		${CONTRIBDIR}
44
45.if defined(LEAPSECONDS)
46.warning Using backwards compatibility variable for LEAPSECONDS; please use WITH_ZONEINFO_LEAPSECONDS_SUPPORT instead
47MK_ZONEINFO_LEAPSECONDS_SUPPORT= yes
48.endif
49
50.if ${MK_ZONEINFO_LEAPSECONDS_SUPPORT} != "no"
51LEAPFILE=	-L ${CONTRIBDIR}leapseconds
52.else
53LEAPFILE=
54.endif
55
56TZFILES=	africa antarctica asia australasia etcetera europe \
57		factory northamerica southamerica
58TZFILES+=	backward
59
60TZFILES:=	${TZFILES:S/^/${CONTRIBDIR}/}
61
62TZBUILDDIR=	${.OBJDIR}/builddir
63TZBUILDSUBDIRS=	\
64		Africa \
65		America/Argentina \
66		America/Indiana \
67		America/Kentucky \
68		America/North_Dakota \
69		Antarctica \
70		Arctic \
71		Asia \
72		Atlantic \
73		Australia \
74		Etc \
75		Europe \
76		Indian \
77		Pacific
78TZBUILDSUBDIRS+= US Mexico Chile Canada Brazil
79
80.if !defined(_SKIP_BUILD)
81all: zonefiles
82.endif
83META_TARGETS+=	zonefiles install-zoneinfo
84
85#
86# Produce “fat” zoneinfo files for backward compatibility.
87#
88ZICFLAGS?=	-b fat
89
90.if ${MK_DIRDEPS_BUILD} == "yes"
91ZIC= ${STAGE_HOST_OBJTOP}/usr/sbin/zic
92# we do everything in a single visit
93install-zoneinfo: zonefiles
94.endif
95
96zonefiles: ${TDATA}
97	mkdir -p ${TZBUILDDIR}
98	(cd ${TZBUILDDIR}; mkdir -p ${TZBUILDSUBDIRS})
99	(umask 022; cd ${.CURDIR}; \
100	${ZIC:Uzic} -D -d ${TZBUILDDIR} ${ZICFLAGS} -m ${NOBINMODE} \
101	    ${LEAPFILE} ${TZFILES})
102	(cd ${TZBUILDDIR} && find * -type f | LC_ALL=C sort) > ${.TARGET}
103
104beforeinstall: install-zoneinfo
105install-zoneinfo:
106	mkdir -p ${DESTDIR}/usr/share/zoneinfo
107	(cd ${DESTDIR}/usr/share/zoneinfo;  mkdir -p ${TZBUILDSUBDIRS})
108	for f in `cat zonefiles`; do \
109		${INSTALL} ${TAG_ARGS} \
110		    -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
111		    ${TZBUILDDIR}/$${f} ${DESTDIR}/usr/share/zoneinfo/$${f}; \
112	done
113	${INSTALL} ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
114	    ${CONTRIBDIR}/zone.tab ${DESTDIR}/usr/share/zoneinfo/
115	${INSTALL} ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
116	    ${CONTRIBDIR}/zone1970.tab ${DESTDIR}/usr/share/zoneinfo/
117
118afterinstall:
119#
120# If the file /var/db/zoneinfo exists, and it is owned by root:wheel,
121# and the contents of it exists in /usr/share/zoneinfo, then reinstall
122# it.
123#
124	@if [ -f ${DESTDIR}/var/db/zoneinfo -a -O ${DESTDIR}/var/db/zoneinfo \
125	    -a -G ${DESTDIR}/var/db/zoneinfo ]; then \
126		zf=$$(cat ${DESTDIR}/var/db/zoneinfo); \
127		if [ -f ${DESTDIR}/usr/share/zoneinfo/$${zf} ]; then \
128			if [ ! -z "${DESTDIR}" ]; then \
129				optC="-C ${DESTDIR}"; \
130			fi; \
131			echo "Updating /etc/localtime"; \
132			tzsetup $${optC} -r; \
133		fi; \
134	else \
135		echo "Run tzsetup(8) manually to update /etc/localtime."; \
136	fi
137
138HAS_TESTS=
139SUBDIR.${MK_TESTS}+= tests
140
141.include <bsd.prog.mk>
142