xref: /freebsd-13-stable/share/zoneinfo/Makefile (revision 3502f06c6686fbb8335872b8bb3b951b549d8b2f)
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.include <src.opts.mk>
33
34PACKAGE=	zoneinfo
35CLEANDIRS+=	builddir
36CONTRIBDIR=	${SRCTOP}/contrib/tzdata/
37.PATH:		${CONTRIBDIR}
38
39.if defined(LEAPSECONDS)
40.warning "Using backwards compatibility variable for LEAPSECONDS; please use WITH_ZONEINFO_LEAPSECONDS_SUPPORT instead"
41MK_ZONEINFO_LEAPSECONDS_SUPPORT= yes
42.endif
43
44.if ${MK_ZONEINFO_LEAPSECONDS_SUPPORT} != "no"
45LEAPFILE=	-L ${CONTRIBDIR}leapseconds
46.else
47LEAPFILE=
48.endif
49
50TZFILES=	africa antarctica asia australasia etcetera europe \
51		factory northamerica southamerica
52TZFILES+=	backward
53
54TZFILES:=	${TZFILES:S/^/${CONTRIBDIR}/}
55
56TZBUILDDIR=	${.OBJDIR}/builddir
57TZBUILDSUBDIRS=	\
58		Africa \
59		America/Argentina \
60		America/Indiana \
61		America/Kentucky \
62		America/North_Dakota \
63		Antarctica \
64		Arctic \
65		Asia \
66		Atlantic \
67		Australia \
68		Etc \
69		Europe \
70		Indian \
71		Pacific
72TZBUILDSUBDIRS+= US Mexico Chile Canada Brazil
73
74.if !defined(_SKIP_BUILD)
75all: zoneinfo
76.endif
77META_TARGETS+=	zoneinfo install-zoneinfo
78
79#
80# Produce “fat” zoneinfo files for backward compatibility.
81#
82ZICFLAGS?=	-b fat
83
84zoneinfo: ${TDATA}
85	mkdir -p ${TZBUILDDIR}
86	cd ${TZBUILDDIR}; mkdir -p ${TZBUILDSUBDIRS}
87	umask 022; cd ${.CURDIR}; \
88	zic -D -d ${TZBUILDDIR} ${ZICFLAGS} -m ${NOBINMODE} \
89	    ${LEAPFILE} ${TZFILES}
90	umask 022; cd ${TZBUILDDIR}; \
91	read -r version <${CONTRIBDIR}version && \
92	LC_ALL=C awk \
93	    -v DATAFORM='main' \
94	    -v PACKRATDATA='' \
95	    -v PACKRATLIST='' \
96	    -f ${CONTRIBDIR}ziguard.awk ${TZFILES} >${TZBUILDDIR}/main.zi; \
97	LC_ALL=C awk \
98	    -v dataform='main' \
99	    -v deps='zishrink.awk' \
100	    -v redo='posix_only' \
101	    -v version="$$version" \
102	    -f ${CONTRIBDIR}zishrink.awk \
103	main.zi >tzdata.zi; rm main.zi
104
105#
106# Sort TZS to ensure they are the same every build. find -s might
107# be a shorter way to express this, but it's non-portable. Any
108# differences between the two don't matter for this purpose.
109#
110.if make(*install*)
111TZS!= cd ${TZBUILDDIR} && find * -type f | LC_ALL=C sort
112.endif
113
114beforeinstall: install-zoneinfo
115install-zoneinfo:
116	mkdir -p ${DESTDIR}/usr/share/zoneinfo
117	cd ${DESTDIR}/usr/share/zoneinfo;  mkdir -p ${TZBUILDSUBDIRS}
118.for f in ${TZS}
119	${INSTALL} ${TAG_ARGS} \
120	    -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
121	    ${TZBUILDDIR}/${f} ${DESTDIR}/usr/share/zoneinfo/${f}
122.endfor
123	${INSTALL} ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
124	    ${CONTRIBDIR}/zone.tab ${DESTDIR}/usr/share/zoneinfo/
125	${INSTALL} ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
126	    ${CONTRIBDIR}/zone1970.tab ${DESTDIR}/usr/share/zoneinfo/
127	${INSTALL} ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
128	    ${CONTRIBDIR}/version ${DESTDIR}/usr/share/zoneinfo/
129
130afterinstall:
131#
132# If the file /var/db/zoneinfo exists, and it is owned by root:wheel,
133# and the contents of it exists in /usr/share/zoneinfo, then reinstall
134# it.
135#
136	@if [ -f ${DESTDIR}/var/db/zoneinfo -a -O ${DESTDIR}/var/db/zoneinfo \
137	    -a -G ${DESTDIR}/var/db/zoneinfo ]; then \
138		zf=$$(cat ${DESTDIR}/var/db/zoneinfo); \
139		if [ -f ${DESTDIR}/usr/share/zoneinfo/$${zf} ]; then \
140			if [ ! -z "${DESTDIR}" ]; then \
141				optC="-C ${DESTDIR}"; \
142			fi; \
143			echo "Updating /etc/localtime"; \
144			tzsetup $${optC} -r; \
145		fi; \
146	else \
147		echo "Run tzsetup(8) manually to update /etc/localtime."; \
148	fi
149
150HAS_TESTS=
151SUBDIR.${MK_TESTS}+= tests
152
153.include <bsd.prog.mk>
154