Blame timezone/Makefile

Packit 6c4009
# Copyright (C) 1998-2018 Free Software Foundation, Inc.
Packit 6c4009
# This file is part of the GNU C Library.
Packit 6c4009
Packit 6c4009
# The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
# modify it under the terms of the GNU Lesser General Public
Packit 6c4009
# License as published by the Free Software Foundation; either
Packit 6c4009
# version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
# The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
# but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
# Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
# You should have received a copy of the GNU Lesser General Public
Packit 6c4009
# License along with the GNU C Library; if not, see
Packit 6c4009
# <http://www.gnu.org/licenses/>.
Packit 6c4009
Packit 6c4009
#
Packit 6c4009
#	Makefile for timezone information
Packit 6c4009
#
Packit 6c4009
subdir	:= timezone
Packit 6c4009
Packit 6c4009
include ../Makeconfig
Packit 6c4009
Packit 6c4009
others	:= zdump zic
Packit 6c4009
tests	:= test-tz tst-timezone tst-tzset
Packit 6c4009
Packit 6c4009
generated-dirs += testdata
Packit 6c4009
Packit 6c4009
generated += tzselect
Packit 6c4009
Packit 6c4009
testdata = $(objpfx)testdata
Packit 6c4009
Packit 6c4009
ifeq ($(enable-timezone-tools),yes)
Packit 6c4009
install-sbin := zic zdump
Packit 6c4009
install-bin-script = tzselect
Packit 6c4009
endif
Packit 6c4009
Packit 6c4009
ifeq ($(run-built-tests),yes)
Packit 6c4009
# List zones generated by separate commands running zic on the host.
Packit 6c4009
# Each such zic run counts as a separate test.
Packit 6c4009
test-zones := America/New_York Etc/UTC UTC Europe/Berlin \
Packit 6c4009
	      Australia/Melbourne America/Sao_Paulo Asia/Tokyo \
Packit 6c4009
	      $(posixrules-file)
Packit 6c4009
tests-special += $(addprefix $(testdata)/, $(test-zones))
Packit 6c4009
endif
Packit 6c4009
Packit 6c4009
include ../Rules
Packit 6c4009
Packit 6c4009
Packit 6c4009
$(objpfx)zic.o $(objpfx)zdump.o: $(objpfx)version.h
Packit 6c4009
Packit 6c4009
$(objpfx)version.h: $(common-objpfx)config.make
Packit 6c4009
	echo 'static char const TZVERSION[]="$(version)";' \
Packit 6c4009
	    > $@.new
Packit 6c4009
	mv -f $@.new $@
Packit 6c4009
Packit 6c4009
tz-cflags = -DTZDIR='"$(zonedir)"' \
Packit 6c4009
	    -DTZDEFAULT='"$(localtime-file)"' \
Packit 6c4009
	    -DTZDEFRULES='"$(posixrules-file)"' \
Packit 6c4009
	    -DTM_GMTOFF=tm_gmtoff -DTM_ZONE=tm_zone \
Packit 6c4009
	    -DHAVE_GETTEXT -DUSE_LTZ=0 -D_ISOMAC -DTZ_DOMAIN='"libc"' \
Packit 6c4009
	    -include $(common-objpfx)config.h -Wno-maybe-uninitialized
Packit 6c4009
Packit 6c4009
# The -Wno-unused-variable flag is used to prevent GCC 6
Packit 6c4009
# from warning about time_t_min and time_t_max which are
Packit 6c4009
# defined in private.h but not used.
Packit 6c4009
CFLAGS-zdump.c += $(tz-cflags)
Packit 6c4009
CFLAGS-zic.c += $(tz-cflags) -Wno-unused-variable
Packit 6c4009
Packit 6c4009
# We have to make sure the data for testing the tz functions is available.
Packit 6c4009
# Don't add leapseconds here since test-tz made checks that work only without
Packit 6c4009
# leapseconds.
Packit 6c4009
define build-testdata
Packit 6c4009
$(built-program-cmd) -d $(testdata) -y ./yearistype $<; \
Packit 6c4009
$(evaluate-test)
Packit 6c4009
endef
Packit 6c4009
Packit 6c4009
$(objpfx)test-tz.out: $(addprefix $(testdata)/, America/New_York Etc/UTC UTC)
Packit 6c4009
$(objpfx)tst-timezone.out: $(addprefix $(testdata)/, \
Packit 6c4009
				       Europe/Berlin Universal \
Packit 6c4009
				       Australia/Melbourne \
Packit 6c4009
				       America/New_York \
Packit 6c4009
				       America/Sao_Paulo Asia/Tokyo \
Packit 6c4009
				       Europe/London)
Packit 6c4009
$(objpfx)tst-tzset.out: $(addprefix $(testdata)/XT, 1 2 3 4)
Packit 6c4009
Packit 6c4009
test-tz-ENV = TZDIR=$(testdata)
Packit 6c4009
tst-timezone-ENV = TZDIR=$(testdata)
Packit 6c4009
tst-tzset-ENV = TZDIR=$(testdata)
Packit 6c4009
Packit 6c4009
# Note this must come second in the deps list for $(built-program-cmd) to work.
Packit 6c4009
zic-deps = $(objpfx)zic $(leapseconds) yearistype
Packit 6c4009
Packit 6c4009
$(testdata)/America/New_York: northamerica $(zic-deps)
Packit 6c4009
	$(build-testdata)
Packit 6c4009
$(testdata)/$(posixrules-file): $(testdata)/America/New_York
Packit 6c4009
	$(make-link); $(evaluate-test)
Packit 6c4009
$(testdata)/Etc/UTC: etcetera $(zic-deps)
Packit 6c4009
	$(build-testdata)
Packit 6c4009
# Use a pattern rule to indicate the command produces both targets at once.
Packit 6c4009
# Two separate targets built separately can collide if in parallel.
Packit 6c4009
%/UTC %/Universal: simplebackw $(zic-deps) %/Etc/UTC
Packit 6c4009
	$(build-testdata)
Packit 6c4009
	{ test -r $(@D)/Universal.test-result \
Packit 6c4009
	&& cp $(@D)/Universal.test-result $(@D)/UTC.test-result \
Packit 6c4009
	&& sed -i 's/Universal/UTC/' $(@D)/UTC.test-result ; exit 0; }
Packit 6c4009
	{ test -r $(@D)/UTC.test-result \
Packit 6c4009
	&& cp $(@D)/UTC.test-result $(@D)/Universal.test-result \
Packit 6c4009
	&& sed -i 's/UTC/Universal/' $(@D)/Universal.test-result ; exit 0; }
Packit 6c4009
$(testdata)/%/Berlin $(testdata)/%/London: europe $(zic-deps)
Packit 6c4009
	$(build-testdata)
Packit 6c4009
$(testdata)/Australia/Melbourne: australasia $(zic-deps)
Packit 6c4009
	$(build-testdata)
Packit 6c4009
$(testdata)/America/Sao_Paulo: southamerica $(zic-deps)
Packit 6c4009
	$(build-testdata)
Packit 6c4009
$(testdata)/Asia/Tokyo: asia $(zic-deps)
Packit 6c4009
	$(build-testdata)
Packit 6c4009
Packit 6c4009
$(testdata)/XT%: testdata/XT%
Packit 6c4009
	$(make-target-directory)
Packit 6c4009
	cp $< $@
Packit 6c4009
Packit 6c4009
$(objpfx)tzselect: tzselect.ksh $(common-objpfx)config.make
Packit 6c4009
	sed -e 's|/bin/bash|$(BASH)|' \
Packit 6c4009
	    -e 's|TZDIR=[^}]*|TZDIR=$(zonedir)|' \
Packit 6c4009
	    -e '/TZVERSION=/s|see_Makefile|"$(version)"|' \
Packit 6c4009
	    -e '/PKGVERSION=/s|=.*|="$(PKGVERSION)"|' \
Packit 6c4009
	    -e '/REPORT_BUGS_TO=/s|=.*|="$(REPORT_BUGS_TO)"|' \
Packit 6c4009
	    < $< > $@.new
Packit 6c4009
	chmod 555 $@.new
Packit 6c4009
	mv -f $@.new $@