xref: /freebsd/share/zoneinfo/Makefile (revision 22cf89c938886d14f5796fc49f9f020c23ea8eaf)
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: zoneinfo
82.endif
83META_TARGETS+=	zoneinfo 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.endif
93
94zoneinfo: ${TDATA}
95	mkdir -p ${TZBUILDDIR}
96	cd ${TZBUILDDIR}; mkdir -p ${TZBUILDSUBDIRS}
97	umask 022; cd ${.CURDIR}; \
98	${ZIC:Uzic} -D -d ${TZBUILDDIR} ${ZICFLAGS} -m ${NOBINMODE} \
99	    ${LEAPFILE} ${TZFILES}
100
101#
102# Sort TZS to ensure they are the same every build. find -s might
103# be a shorter way to express this, but it's non-portable. Any
104# differences between the two don't matter for this purpose.
105#
106.if make(*install*)
107TZS!= cd ${TZBUILDDIR} && find * -type f | LC_ALL=C sort
108.endif
109
110beforeinstall: install-zoneinfo
111install-zoneinfo:
112	mkdir -p ${DESTDIR}/usr/share/zoneinfo
113	cd ${DESTDIR}/usr/share/zoneinfo;  mkdir -p ${TZBUILDSUBDIRS}
114.for f in ${TZS}
115	${INSTALL} ${TAG_ARGS} \
116	    -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
117	    ${TZBUILDDIR}/${f} ${DESTDIR}/usr/share/zoneinfo/${f}
118.endfor
119	${INSTALL} ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
120	    ${CONTRIBDIR}/zone.tab ${DESTDIR}/usr/share/zoneinfo/
121	${INSTALL} ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
122	    ${CONTRIBDIR}/zone1970.tab ${DESTDIR}/usr/share/zoneinfo/
123
124afterinstall:
125#
126# If the file /var/db/zoneinfo exists, and it is owned by root:wheel,
127# and the contents of it exists in /usr/share/zoneinfo, then reinstall
128# it.
129#
130	@if [ -f ${DESTDIR}/var/db/zoneinfo -a -O ${DESTDIR}/var/db/zoneinfo \
131	    -a -G ${DESTDIR}/var/db/zoneinfo ]; then \
132		zf=$$(cat ${DESTDIR}/var/db/zoneinfo); \
133		if [ -f ${DESTDIR}/usr/share/zoneinfo/$${zf} ]; then \
134			if [ ! -z "${DESTDIR}" ]; then \
135				optC="-C ${DESTDIR}"; \
136			fi; \
137			echo "Updating /etc/localtime"; \
138			tzsetup $${optC} -r; \
139		fi; \
140	else \
141		echo "Run tzsetup(8) manually to update /etc/localtime."; \
142	fi
143
144HAS_TESTS=
145SUBDIR.${MK_TESTS}+= tests
146
147.include <bsd.prog.mk>
148