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