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