Submitted By: Joe Ciccone <jciccone@linuxfromscratch.org>
Date: 2005-07-20
Initial Package Version: 2.4
Origin: Joe Ciccone
Upstream Status: Unknown
Description: Allows the timezone data to be installed when cross-compiling
             by building and using zic-host.

diff -Naur glibc-2.4.orig/timezone/Makefile glibc-2.4/timezone/Makefile
--- glibc-2.4.orig/timezone/Makefile	2005-04-15 16:09:08.000000000 -0400
+++ glibc-2.4/timezone/Makefile	2006-06-18 11:55:46.000000000 -0400
@@ -28,6 +28,9 @@
 extra-objs := scheck.o ialloc.o
 
 others	:= zdump zic
+ifneq ($(cross-compiling),no)
+others	+= zic-host
+endif
 tests	:= test-tz tst-timezone
 
 tzbases := africa antarctica asia australasia europe northamerica \
@@ -49,6 +52,7 @@
 include ../Makeconfig	# Get objpfx defined so we can use it below.
 
 CPPFLAGS-zic = -DNOT_IN_libc
+CPPFLAGS-zic-host = -DNOT_IN_libc
 
 # z.* use this variable.
 define nl
@@ -69,13 +73,10 @@
 					 $(addprefix $(inst_zonedir)/, \
 						     $(posixrules-file)))
 
-ifeq ($(cross-compiling),no)
-# Don't try to install the zoneinfo files since we can't run zic.
 install-others = $(addprefix $(inst_zonedir)/,$(zonenames) \
 					      $(zonenames:%=posix/%) \
 					      $(zonenames:%=right/%)) \
 		 $(installed-localtime-file) $(installed-posixrules-file)
-endif
 
 ifeq ($(have-ksh),yes)
 install-others += $(inst_zonedir)/iso3166.tab $(inst_zonedir)/zone.tab
@@ -85,7 +86,6 @@
 
 include ../Rules
 
-
 $(tzfiles:%=$(objpfx)z.%): $(objpfx)z.%: % Makefile
 # Kludge alert: we use an implicit rule (in what we are generating here)
 # because that is the only way to tell Make that the one command builds all
@@ -124,11 +124,14 @@
 echo-zonenames:
 	@echo 'Known zones: $(zonenames)'
 
-
 # We have to use `-d $(inst_zonedir)' to explictly tell zic where to
 # place the output files although $(zonedir) is compiled in.  But the
 # user might have set $(install_root) on the command line of `make install'.
+ifeq ($(cross-compiling),no)
 zic-cmd = $(built-program-cmd) -d $(inst_zonedir)
+else
+zic-cmd = $(common-objpfx)/timezone/zic-host -d $(inst_zonedir)
+endif
 tzcompile = $(zic-cmd)$(target-zone-flavor) -L $(word 3,$^) \
 	    -y $(dir $(word 4,$^))$(notdir $(word 4,$^)) $<
 
@@ -158,6 +161,14 @@
 	$(zic-cmd) -p $(posixrules)
 endif
 
+zic-host.c scheck-host.c ialloc-host.c: $($@:%-host=%)
+	ln -sf $(@:%-host.c=%.c) $@
+
+zic-host-CFLAGS = -O $(CFLAGS-zic.c) \
+	$(firstword $(filter /%,scheck-host.c $(shell pwd)/scheck-host.c)) \
+	$(firstword $(filter /%,ialloc-host.c $(shell pwd)/ialloc-host.c)) 
+$(objpfx)zic-host: zic-host.c scheck-host.c ialloc-host.c
+	$(native-compile)
 
 $(objpfx)zic: $(objpfx)scheck.o $(objpfx)ialloc.o
 
