xref: /netbsd-src/lib/libc/time/Makefile (revision d25ffa98a4bfca1fe272f3c182496ec9934faac7)
1# <pre>
2# @(#)Makefile	8.8
3# This file is in the public domain, so clarified as of
4# 2009-05-17 by Arthur David Olson.
5
6# Change the line below for your time zone (after finding the zone you want in
7# the time zone files, or adding it to a time zone file).
8# Alternately, if you discover you've got the wrong time zone, you can just
9#	zic -l rightzone
10# to correct things.
11# Use the command
12#	make zonenames
13# to get a list of the values you can use for LOCALTIME.
14
15LOCALTIME=	Factory
16
17# If you want something other than Eastern United States time as a template
18# for handling POSIX-style time zone environment variables,
19# change the line below (after finding the zone you want in the
20# time zone files, or adding it to a time zone file).
21# (When a POSIX-style environment variable is handled, the rules in the
22# template file are used to determine "spring forward" and "fall back" days and
23# times; the environment variable itself specifies UTC offsets of standard and
24# summer time.)
25# Alternately, if you discover you've got the wrong time zone, you can just
26#	zic -p rightzone
27# to correct things.
28# Use the command
29#	make zonenames
30# to get a list of the values you can use for POSIXRULES.
31# If you want POSIX compatibility, use "America/New_York".
32
33POSIXRULES=	America/New_York
34
35# Also see TZDEFRULESTRING below, which takes effect only
36# if the time zone files cannot be accessed.
37
38# Everything gets put in subdirectories of. . .
39
40TOPDIR=		/usr/local
41
42# "Compiled" time zone information is placed in the "TZDIR" directory
43# (and subdirectories).
44# Use an absolute path name for TZDIR unless you're just testing the software.
45
46TZDIR=		$(TOPDIR)/etc/zoneinfo
47
48# The "tzselect", "zic", and "zdump" commands get installed in. . .
49
50ETCDIR=		$(TOPDIR)/etc
51
52# If you "make INSTALL", the "date" command gets installed in. . .
53
54BINDIR=		$(TOPDIR)/bin
55
56# Manual pages go in subdirectories of. . .
57
58MANDIR=		$(TOPDIR)/man
59
60# Library functions are put in an archive in LIBDIR.
61
62LIBDIR=		$(TOPDIR)/lib
63TZLIB=		$(LIBDIR)/libtz.a
64
65# If you always want time values interpreted as "seconds since the epoch
66# (not counting leap seconds)", use
67#	REDO=		posix_only
68# below.  If you always want right time values interpreted as "seconds since
69# the epoch" (counting leap seconds)", use
70#	REDO=		right_only
71# below.  If you want both sets of data available, with leap seconds not
72# counted normally, use
73#	REDO=		posix_right
74# below.  If you want both sets of data available, with leap seconds counted
75# normally, use
76#	REDO=		right_posix
77# below.
78# POSIX mandates that leap seconds not be counted; for compatibility with it,
79# use either "posix_only" or "posix_right".
80
81REDO=		posix_right
82
83# Since "." may not be in PATH...
84
85YEARISTYPE=	./yearistype
86
87# Non-default libraries needed to link.
88# Add -lintl if you want to use `gettext' on Solaris.
89LDLIBS=
90
91# Add the following to the end of the "CFLAGS=" line as needed.
92#  -DHAVE_ADJTIME=0 if `adjtime' does not exist (SVR0?)
93#  -DHAVE_GETTEXT=1 if `gettext' works (GNU, Linux, Solaris); also see LDLIBS
94#  -DHAVE_INCOMPATIBLE_CTIME_R=1 if your system's time.h declares
95#	ctime_r and asctime_r incompatibly with the POSIX standard (Solaris 8).
96#  -DHAVE_SETTIMEOFDAY=0 if settimeofday does not exist (SVR0?)
97#  -DHAVE_SETTIMEOFDAY=1 if settimeofday has just 1 arg (SVR4)
98#  -DHAVE_SETTIMEOFDAY=2 if settimeofday uses 2nd arg (4.3BSD)
99#  -DHAVE_SETTIMEOFDAY=3 if settimeofday ignores 2nd arg (4.4BSD)
100#  -DHAVE_STDINT_H=1 if you have a pre-C99 compiler with "stdint.h"
101#  -DHAVE_SYMLINK=0 if your system lacks the symlink function
102#  -DHAVE_SYS_STAT_H=0 if your compiler lacks a "sys/stat.h"
103#  -DHAVE_SYS_WAIT_H=0 if your compiler lacks a "sys/wait.h"
104#  -DLOCALE_HOME=\"path\" if locales are in "path", not "/usr/lib/locale"
105#  -DHAVE_UNISTD_H=0 if your compiler lacks a "unistd.h" (Microsoft C++ 7?)
106#  -DHAVE_UTMPX_H=1 if your compiler has a "utmpx.h"
107#  -DTZDEFRULESTRING=\",date/time,date/time\" to default to the specified
108#	DST transitions if the time zone files cannot be accessed
109#  -DTZ_DOMAIN=\"foo\" to use "foo" for gettext domain name; default is "tz"
110#  -TTZ_DOMAINDIR=\"/path\" to use "/path" for gettext directory;
111#	the default is system-supplied, typically "/usr/lib/locale"
112#  $(GCC_DEBUG_FLAGS) if you are using GCC and want lots of checking
113#  -DNO_RUN_TIME_WARNINGS_ABOUT_YEAR_2000_PROBLEMS_THANK_YOU=1
114#	if you do not want run time warnings about formats that may cause
115#	year 2000 grief
116#  -DZIC_MAX_ABBR_LEN_WO_WARN=3
117#	(or some other number) to set the maximum time zone abbreviation length
118#	that zic will accept without a warning (the default is 6)
119GCC_DEBUG_FLAGS = -Dlint -g -O -fno-common \
120	-Wall -Wcast-qual -Wconversion -Wmissing-prototypes \
121	-Wnested-externs -Wpointer-arith -Wshadow \
122	-Wtraditional # -Wstrict-prototypes -Wwrite-strings
123#
124# If you want to use System V compatibility code, add
125#	-DUSG_COMPAT
126# to the end of the "CFLAGS=" line.  This arrange for "timezone" and "daylight"
127# variables to be kept up-to-date by the time conversion functions.  Neither
128# "timezone" nor "daylight" is described in X3J11's work.
129#
130# If your system has a "GMT offset" field in its "struct tm"s
131# (or if you decide to add such a field in your system's "time.h" file),
132# add the name to a define such as
133#	-DTM_GMTOFF=tm_gmtoff
134# or
135#	-DTM_GMTOFF=_tm_gmtoff
136# to the end of the "CFLAGS=" line.
137# Neither tm_gmtoff nor _tm_gmtoff is described in X3J11's work;
138# in its work, use of "tm_gmtoff" is described as non-conforming.
139# Both Linux and BSD have done the equivalent of defining TM_GMTOFF in
140# their recent releases.
141#
142# If your system has a "zone abbreviation" field in its "struct tm"s
143# (or if you decide to add such a field in your system's "time.h" file),
144# add the name to a define such as
145#	-DTM_ZONE=tm_zone
146# or
147#	-DTM_ZONE=_tm_zone
148# to the end of the "CFLAGS=" line.
149# Neither tm_zone nor _tm_zone is described in X3J11's work;
150# in its work, use of "tm_zone" is described as non-conforming.
151# Both UCB and Sun have done the equivalent of defining TM_ZONE in
152# their recent releases.
153#
154# If you want functions that were inspired by early versions of X3J11's work,
155# add
156#	-DSTD_INSPIRED
157# to the end of the "CFLAGS=" line.  This arranges for the functions
158# "tzsetwall", "offtime", "timelocal", "timegm", "timeoff",
159# "posix2time", and "time2posix" to be added to the time conversion library.
160# "tzsetwall" is like "tzset" except that it arranges for local wall clock
161# time (rather than the time specified in the TZ environment variable)
162# to be used.
163# "offtime" is like "gmtime" except that it accepts a second (long) argument
164# that gives an offset to add to the time_t when converting it.
165# "timelocal" is equivalent to "mktime".
166# "timegm" is like "timelocal" except that it turns a struct tm into
167# a time_t using UTC (rather than local time as "timelocal" does).
168# "timeoff" is like "timegm" except that it accepts a second (long) argument
169# that gives an offset to use when converting to a time_t.
170# "posix2time" and "time2posix" are described in an included manual page.
171# X3J11's work does not describe any of these functions.
172# Sun has provided "tzsetwall", "timelocal", and "timegm" in SunOS 4.0.
173# These functions may well disappear in future releases of the time
174# conversion package.
175#
176# If you want Source Code Control System ID's left out of object modules, add
177#	-DNOID
178# to the end of the "CFLAGS=" line.
179#
180# If you'll never want to handle solar-time-based time zones, add
181#	-DNOSOLAR
182# to the end of the "CFLAGS=" line
183# (and comment out the "SDATA=" line below).
184# This reduces (slightly) the run-time data-space requirements of
185# the time conversion functions; it may reduce the acceptability of your system
186# to folks in oil- and cash-rich places.
187#
188# If you want to allocate state structures in localtime, add
189#	-DALL_STATE
190# to the end of the "CFLAGS=" line.  Storage is obtained by calling malloc.
191#
192# If you want an "altzone" variable (a la System V Release 3.1), add
193#	-DALTZONE
194# to the end of the "CFLAGS=" line.
195# This variable is not described in X3J11's work.
196#
197# If you want a "gtime" function (a la MACH), add
198#	-DCMUCS
199# to the end of the "CFLAGS=" line
200# This function is not described in X3J11's work.
201#
202# NIST-PCTS:151-2, Version 1.4, (1993-12-03) is a test suite put
203# out by the National Institute of Standards and Technology
204# which claims to test C and Posix conformance.  If you want to pass PCTS, add
205#	-DPCTS
206# to the end of the "CFLAGS=" line.
207#
208# If you want strict compliance with XPG4 as of 1994-04-09, add
209#	-DXPG4_1994_04_09
210# to the end of the "CFLAGS=" line.  This causes "strftime" to always return
211# 53 as a week number (rather than 52 or 53) for those days in January that
212# before the first Monday in January when a "%V" format is used and January 1
213# falls on a Friday, Saturday, or Sunday.
214
215CFLAGS=
216
217# If you want zic's -s option used when installing, uncomment the next line
218# ZFLAGS=	-s
219
220zic=		./zic
221ZIC=		$(zic) $(ZFLAGS)
222
223# The name of a Posix-compliant `awk' on your system.
224AWK=		nawk
225
226# The path where SGML DTDs are kept.
227SGML_SEARCH_PATH= $(TOPDIR)/share/doc/sgml-lib/REC-html401-19991224/
228
229# The catalog file(s) to use when validating.
230SGML_CATALOG_FILES= HTML4.cat
231
232# The name, arguments and environment of a program to validate your web pages.
233# See <http://www.jclark.com/sp/> for a validator, and
234# <http://validator.w3.org/source/> for a validation library.
235VALIDATE = nsgmls
236VALIDATE_FLAGS = -s -B -wall -wno-unused-param
237VALIDATE_ENV = \
238  SGML_CATALOG_FILES=$(SGML_CATALOG_FILES) \
239  SGML_SEARCH_PATH=$(SGML_SEARCH_PATH) \
240  SP_CHARSET_FIXED=YES \
241  SP_ENCODING=UTF-8
242
243###############################################################################
244
245cc=		cc
246CC=		$(cc) -DTZDIR=\"$(TZDIR)\"
247
248TZCSRCS=	zic.c localtime.c asctime.c scheck.c ialloc.c
249TZCOBJS=	zic.o localtime.o asctime.o scheck.o ialloc.o
250TZDSRCS=	zdump.c localtime.c ialloc.c
251TZDOBJS=	zdump.o localtime.o ialloc.o
252DATESRCS=	date.c localtime.c strftime.c asctime.c
253DATEOBJS=	date.o localtime.o strftime.o asctime.o
254LIBSRCS=	localtime.c asctime.c difftime.c
255LIBOBJS=	localtime.o asctime.o difftime.o
256HEADERS=	tzfile.h private.h
257NONLIBSRCS=	zic.c zdump.c scheck.c ialloc.c
258NEWUCBSRCS=	date.c strftime.c
259SOURCES=	$(HEADERS) $(LIBSRCS) $(NONLIBSRCS) $(NEWUCBSRCS) tzselect.ksh
260MANS=		newctime.3 newstrftime.3 newtzset.3 time2posix.3 \
261			tzfile.5 tzselect.8 zic.8 zdump.8
262DOCS=		README Theory $(MANS) date.1 Makefile
263PRIMARY_YDATA=	africa antarctica asia australasia \
264		europe northamerica southamerica
265YDATA=		$(PRIMARY_YDATA) pacificnew etcetera factory backward
266NDATA=		systemv
267SDATA=		solar87 solar88 solar89
268TDATA=		$(YDATA) $(NDATA) $(SDATA)
269TABDATA=	iso3166.tab zone.tab
270DATA=		$(YDATA) $(NDATA) $(SDATA) $(TABDATA) leapseconds yearistype.sh
271WEB_PAGES=	tz-art.htm tz-link.htm
272MISC=		usno1988 usno1989 usno1989a usno1995 usno1997 usno1998 \
273			itca.jpg $(WEB_PAGES) checktab.awk workman.sh \
274			zoneinfo2tdf.pl
275ENCHILADA=	$(DOCS) $(SOURCES) $(DATA) $(MISC)
276
277# And for the benefit of csh users on systems that assume the user
278# shell should be used to handle commands in Makefiles. . .
279
280SHELL=		/bin/sh
281
282all:		tzselect zic zdump $(LIBOBJS)
283
284ALL:		all date
285
286install:	all $(DATA) $(REDO) $(TZLIB) $(MANS) $(TABDATA)
287		$(ZIC) -y $(YEARISTYPE) \
288			-d $(TZDIR) -l $(LOCALTIME) -p $(POSIXRULES)
289		-rm -f $(TZDIR)/iso3166.tab $(TZDIR)/zone.tab
290		cp iso3166.tab zone.tab $(TZDIR)/.
291		-mkdir $(TOPDIR) $(ETCDIR)
292		cp tzselect zic zdump $(ETCDIR)/.
293		-mkdir $(TOPDIR) $(MANDIR) \
294			$(MANDIR)/man3 $(MANDIR)/man5 $(MANDIR)/man8
295		-rm -f $(MANDIR)/man3/newctime.3 \
296			$(MANDIR)/man3/newtzset.3 \
297			$(MANDIR)/man5/tzfile.5 \
298			$(MANDIR)/man8/tzselect.8 \
299			$(MANDIR)/man8/zdump.8 \
300			$(MANDIR)/man8/zic.8
301		cp newctime.3 newtzset.3 $(MANDIR)/man3/.
302		cp tzfile.5 $(MANDIR)/man5/.
303		cp tzselect.8 zdump.8 zic.8 $(MANDIR)/man8/.
304
305INSTALL:	ALL install date.1
306		-mkdir $(TOPDIR) $(BINDIR)
307		cp date $(BINDIR)/.
308		-mkdir $(TOPDIR) $(MANDIR) $(MANDIR)/man1
309		-rm -f $(MANDIR)/man1/date.1
310		cp date.1 $(MANDIR)/man1/.
311
312zdump:		$(TZDOBJS)
313		$(CC) $(CFLAGS) $(LFLAGS) $(TZDOBJS) $(LDLIBS) -o $@
314
315zic:		$(TZCOBJS) yearistype
316		$(CC) $(CFLAGS) $(LFLAGS) $(TZCOBJS) $(LDLIBS) -o $@
317
318yearistype:	yearistype.sh
319		cp yearistype.sh yearistype
320		chmod +x yearistype
321
322posix_only:	zic $(TDATA)
323		$(ZIC) -y $(YEARISTYPE) -d $(TZDIR) -L /dev/null $(TDATA)
324
325right_only:	zic leapseconds $(TDATA)
326		$(ZIC) -y $(YEARISTYPE) -d $(TZDIR) -L leapseconds $(TDATA)
327
328# In earlier versions of this makefile, the other two directories were
329# subdirectories of $(TZDIR).  However, this led to configuration errors.
330# For example, with posix_right under the earlier scheme,
331# TZ='right/Australia/Adelaide' got you localtime with leap seconds,
332# but gmtime without leap seconds, which led to problems with applications
333# like sendmail that subtract gmtime from localtime.
334# Therefore, the other two directories are now siblings of $(TZDIR).
335# You must replace all of $(TZDIR) to switch from not using leap seconds
336# to using them, or vice versa.
337other_two:	zic leapseconds $(TDATA)
338		$(ZIC) -y $(YEARISTYPE) -d $(TZDIR)-posix -L /dev/null $(TDATA)
339		$(ZIC) -y $(YEARISTYPE) \
340			-d $(TZDIR)-leaps -L leapseconds $(TDATA)
341
342posix_right:	posix_only other_two
343
344right_posix:	right_only other_two
345
346zones:		$(REDO)
347
348$(TZLIB):	$(LIBOBJS)
349		-mkdir $(TOPDIR) $(LIBDIR)
350		ar ru $@ $(LIBOBJS)
351		if [ -x /usr/ucb/ranlib -o -x /usr/bin/ranlib ] ; \
352			then ranlib $@ ; fi
353
354date:		$(DATEOBJS)
355		$(CC) $(CFLAGS) date.o localtime.o asctime.o strftime.o \
356			$(LDLIBS) -lc -o $@
357
358tzselect:	tzselect.ksh
359		sed \
360			-e 's|AWK=[^}]*|AWK=$(AWK)|g' \
361			-e 's|TZDIR=[^}]*|TZDIR=$(TZDIR)|' \
362			<$? >$@
363		chmod +x $@
364
365check:		check_tables check_web
366
367check_tables:	checktab.awk $(PRIMARY_YDATA)
368		$(AWK) -f checktab.awk $(PRIMARY_YDATA)
369
370check_web:	$(WEB_PAGES)
371		$(VALIDATE_ENV) $(VALIDATE) $(VALIDATE_FLAGS) $(WEB_PAGES)
372
373clean:
374		rm -f core *.o *.out tzselect zdump zic yearistype date
375
376maintainer-clean: clean
377		@echo 'This command is intended for maintainers to use; it'
378		@echo 'deletes files that may need special tools to rebuild.'
379		rm -f *.[1-8].txt tzcode.tar.gz tzdata.tar.gz
380
381names:
382		@echo $(ENCHILADA)
383
384# The zics below ensure that each data file can stand on its own.
385# We also do an all-files run to catch links to links.
386
387public:		$(ENCHILADA)
388		make maintainer-clean
389		make "CFLAGS=$(GCC_DEBUG_FLAGS)"
390		-mkdir /tmp/,tzpublic
391		-for i in $(TDATA) ; do zic -v -d /tmp/,tzpublic $$i 2>&1 | grep -v "starting year" ; done
392		for i in $(TDATA) ; do zic -d /tmp/,tzpublic $$i || exit; done
393		zic -v -d /tmp/,tzpublic $(TDATA) || exit
394		rm -f -r /tmp/,tzpublic
395		for i in *.[1-8] ; do sh workman.sh $$i > $$i.txt || exit; done
396		$(AWK) -f checktab.awk $(PRIMARY_YDATA)
397		tar cf - $(DOCS) $(SOURCES) $(MISC) *.[1-8].txt | gzip -9 > tzcode.tar.gz
398		tar cf - $(DATA) | gzip -9 > tzdata.tar.gz
399
400typecheck:
401		make clean
402		for i in "long long" unsigned double; \
403		do \
404			make CFLAGS="-DTYPECHECK -D_TIME_T \"-Dtime_t=$$i\"" ; \
405			./zdump -v Europe/Rome ; \
406			make clean ; \
407		done
408
409zonenames:	$(TDATA)
410		@$(AWK) '/^Zone/ { print $$2 } /^Link/ { print $$3 }' $(TDATA)
411
412asctime.o:	private.h tzfile.h
413date.o:		private.h
414difftime.o:	private.h
415ialloc.o:	private.h
416localtime.o:	private.h tzfile.h
417scheck.o:	private.h
418strftime.o:	tzfile.h
419zic.o:		private.h tzfile.h
420
421.KEEP_STATE:
422