Makefile 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. # Copyright (C) 1998-2026 Free Software Foundation, Inc.
  2. # This file is part of the GNU C Library.
  3. # The GNU C Library is free software; you can redistribute it and/or
  4. # modify it under the terms of the GNU Lesser General Public
  5. # License as published by the Free Software Foundation; either
  6. # version 2.1 of the License, or (at your option) any later version.
  7. # The GNU C Library is distributed in the hope that it will be useful,
  8. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. # Lesser General Public License for more details.
  11. # You should have received a copy of the GNU Lesser General Public
  12. # License along with the GNU C Library; if not, see
  13. # <https://www.gnu.org/licenses/>.
  14. #
  15. # Makefile for timezone information
  16. #
  17. subdir := timezone
  18. include ../Makeconfig
  19. others := zdump zic
  20. tests := test-tz tst-timezone tst-tzset tst-bz28707 tst-bz29951
  21. generated-dirs += testdata
  22. generated += tzselect
  23. testdata = $(objpfx)testdata
  24. ifeq ($(enable-timezone-tools),yes)
  25. install-sbin := zic
  26. install-bin := zdump
  27. install-bin-script = tzselect
  28. endif
  29. ifeq ($(run-built-tests),yes)
  30. # List zones generated by separate commands running zic on the host.
  31. # Each such zic run counts as a separate test.
  32. test-zones := America/New_York Etc/UTC UTC Europe/Berlin \
  33. Australia/Melbourne America/Sao_Paulo Asia/Tokyo \
  34. $(posixrules-file)
  35. tests-special += $(addprefix $(testdata)/, $(test-zones))
  36. endif
  37. include ../Rules
  38. $(objpfx)zic.o: $(objpfx)tzdir.h
  39. # In glibc this file is an empty placeholder,
  40. # as tz-cflags defines TZDEFAULT and TZDIR.
  41. $(objpfx)tzdir.h:
  42. > $@
  43. $(objpfx)zic.o $(objpfx)zdump.o: $(objpfx)version.h
  44. $(objpfx)version.h: $(common-objpfx)config.make
  45. echo 'static char const TZVERSION[]="$(version)";' \
  46. > $@.new
  47. mv -f $@.new $@
  48. tz-cflags = -DTZDIR='"$(zonedir)"' \
  49. -DTZDEFAULT='"$(localtime-file)"' \
  50. -DTZDEFRULES='"$(posixrules-file)"' \
  51. -DTM_GMTOFF=tm_gmtoff -DTM_ZONE=tm_zone \
  52. -DHAVE_GETTEXT -DUSE_LTZ=0 -D_ISOMAC -DTZ_DOMAIN='"libc"' \
  53. -include $(common-objpfx)config.h $(config-cflags-wno-maybe-uninitialized)
  54. # The -Wno-unused-variable flag is used to prevent GCC 6
  55. # from warning about time_t_min and time_t_max which are
  56. # defined in private.h but not used.
  57. # $(config-cflags-wno-discarded-qualifiers) is because zic is not prepared for C23
  58. # -qualifier-generic strchr.
  59. CFLAGS-zdump.c += $(tz-cflags)
  60. CFLAGS-zic.c += $(tz-cflags) -Wno-unused-variable $(config-cflags-wno-discarded-qualifiers)
  61. # We have to make sure the data for testing the tz functions is available.
  62. # Don't add leapseconds here since test-tz made checks that work only without
  63. # leapseconds.
  64. define build-testdata
  65. $(built-program-cmd) -d $(testdata) -y ./yearistype $<; \
  66. $(evaluate-test)
  67. endef
  68. $(objpfx)test-tz.out: $(addprefix $(testdata)/, America/New_York Etc/UTC UTC)
  69. $(objpfx)tst-timezone.out: $(addprefix $(testdata)/, \
  70. Europe/Berlin Universal \
  71. Australia/Melbourne \
  72. America/New_York \
  73. America/Sao_Paulo Asia/Tokyo \
  74. Europe/London)
  75. $(objpfx)tst-tzset.out: $(addprefix $(testdata)/XT, 1 2 3 4)
  76. $(objpfx)tst-bz28707.out: $(testdata)/XT5
  77. $(objpfx)tst-bz29951.out: $(testdata)/XT6
  78. test-tz-ENV = TZDIR=$(testdata)
  79. tst-timezone-ENV = TZDIR=$(testdata)
  80. tst-tzset-ENV = TZDIR=$(testdata)
  81. tst-bz28707-ENV = TZDIR=$(testdata)
  82. tst-bz29951-ENV = TZDIR=$(testdata)
  83. # Note this must come second in the deps list for $(built-program-cmd) to work.
  84. zic-deps = $(objpfx)zic $(leapseconds) yearistype
  85. $(testdata)/America/New_York: northamerica $(zic-deps)
  86. $(build-testdata)
  87. $(testdata)/$(posixrules-file): $(testdata)/America/New_York
  88. $(make-link); $(evaluate-test)
  89. $(testdata)/Etc/UTC: etcetera $(zic-deps)
  90. $(build-testdata)
  91. # Use a pattern rule to indicate the command produces both targets at once.
  92. # Two separate targets built separately can collide if in parallel.
  93. %/UTC %/Universal: simplebackw $(zic-deps) %/Etc/UTC
  94. $(build-testdata)
  95. { test -r $(@D)/Universal.test-result \
  96. && cp $(@D)/Universal.test-result $(@D)/UTC.test-result \
  97. && sed -i 's/Universal/UTC/' $(@D)/UTC.test-result ; exit 0; }
  98. { test -r $(@D)/UTC.test-result \
  99. && cp $(@D)/UTC.test-result $(@D)/Universal.test-result \
  100. && sed -i 's/UTC/Universal/' $(@D)/Universal.test-result ; exit 0; }
  101. $(testdata)/%/Berlin $(testdata)/%/London: europe $(zic-deps)
  102. $(build-testdata)
  103. $(testdata)/Australia/Melbourne: australasia $(zic-deps)
  104. $(build-testdata)
  105. $(testdata)/America/Sao_Paulo: southamerica $(zic-deps)
  106. $(build-testdata)
  107. $(testdata)/Asia/Tokyo: asia $(zic-deps)
  108. $(build-testdata)
  109. $(testdata)/XT%: testdata/XT%
  110. $(make-target-directory)
  111. cp $< $@
  112. $(testdata)/XT5: testdata/gen-XT5.sh
  113. $(make-target-directory)
  114. $(SHELL) $< > $@.tmp
  115. mv $@.tmp $@
  116. $(objpfx)tzselect: tzselect.ksh $(common-objpfx)config.make
  117. sed -e 's|TZDIR=[^}]*|TZDIR=$(zonedir)|' \
  118. -e '/TZVERSION=/s|see_Makefile|"$(version)"|' \
  119. -e '/PKGVERSION=/s|=.*|="$(PKGVERSION)"|' \
  120. -e '/REPORT_BUGS_TO=/s|=.*|="$(REPORT_BUGS_TO)"|' \
  121. < $< > $@.new
  122. chmod 555 $@.new
  123. mv -f $@.new $@