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