Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 85884cb

Browse files
committed
Support cross compilation by compiling "zic" with a native compiler. This
relies on the output of zic being platform independent, but that is currently the case.
1 parent cc9bcbc commit 85884cb

File tree

5 files changed

+58
-8
lines changed

5 files changed

+58
-8
lines changed

configure

+13-1
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ ac_includes_default="\
314314
# include <unistd.h>
315315
#endif"
316316

317-
ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS configure_args build build_cpu build_vendor build_os host host_cpu host_vendor host_os PORTNAME docdir enable_nls WANTED_LANGUAGES default_port enable_shared enable_rpath enable_debug CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP GCC TAS autodepend INCLUDES enable_thread_safety with_tcl with_perl with_python with_krb5 krb_srvtab with_pam with_bonjour with_openssl EGREP ELF_SYS LDFLAGS_SL AWK FLEX FLEXFLAGS LN_S LD with_gnu_ld ld_R_works RANLIB ac_ct_RANLIB LORDER TAR STRIP ac_ct_STRIP STRIP_STATIC_LIB STRIP_SHARED_LIB YACC YFLAGS PERL perl_archlibexp perl_privlibexp perl_useshrplib perl_embed_ldflags PYTHON python_version python_configdir python_includespec python_libdir python_libspec python_additional_libs HAVE_IPV6 LIBOBJS acx_pthread_config PTHREAD_CC PTHREAD_LIBS PTHREAD_CFLAGS HAVE_POSIX_SIGNALS MSGFMT MSGMERGE XGETTEXT localedir TCLSH TCL_CONFIG_SH TCL_INCLUDE_SPEC TCL_LIB_FILE TCL_LIBS TCL_LIB_SPEC TCL_SHARED_BUILD TCL_SHLIB_LD_LIBS NSGMLS JADE have_docbook DOCBOOKSTYLE COLLATEINDEX SGMLSPL vpath_build LTLIBOBJS'
317+
ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS configure_args build build_cpu build_vendor build_os host host_cpu host_vendor host_os PORTNAME docdir enable_nls WANTED_LANGUAGES default_port enable_shared enable_rpath enable_debug CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP GCC CC_FOR_BUILD TAS autodepend INCLUDES enable_thread_safety with_tcl with_perl with_python with_krb5 krb_srvtab with_pam with_bonjour with_openssl EGREP ELF_SYS LDFLAGS_SL AWK FLEX FLEXFLAGS LN_S LD with_gnu_ld ld_R_works RANLIB ac_ct_RANLIB LORDER TAR STRIP ac_ct_STRIP STRIP_STATIC_LIB STRIP_SHARED_LIB YACC YFLAGS PERL perl_archlibexp perl_privlibexp perl_useshrplib perl_embed_ldflags PYTHON python_version python_configdir python_includespec python_libdir python_libspec python_additional_libs HAVE_IPV6 LIBOBJS acx_pthread_config PTHREAD_CC PTHREAD_LIBS PTHREAD_CFLAGS HAVE_POSIX_SIGNALS MSGFMT MSGMERGE XGETTEXT localedir TCLSH TCL_CONFIG_SH TCL_INCLUDE_SPEC TCL_LIB_FILE TCL_LIBS TCL_LIB_SPEC TCL_SHARED_BUILD TCL_SHLIB_LD_LIBS NSGMLS JADE have_docbook DOCBOOKSTYLE COLLATEINDEX SGMLSPL vpath_build LTLIBOBJS'
318318
ac_subst_files=''
319319

320320
# Initialize some variables set by options.
@@ -3305,6 +3305,17 @@ _ACEOF
33053305

33063306

33073307

3308+
#
3309+
# Native compiler
3310+
#
3311+
3312+
if test -z "$CC_FOR_BUILD"; then
3313+
CC_FOR_BUILD=$CC
3314+
fi
3315+
3316+
3317+
3318+
33083319
#
33093320
# Set up TAS assembly code if needed; the template file has now had its
33103321
# chance to request this.
@@ -22892,6 +22903,7 @@ s,@EXEEXT@,$EXEEXT,;t t
2289222903
s,@OBJEXT@,$OBJEXT,;t t
2289322904
s,@CPP@,$CPP,;t t
2289422905
s,@GCC@,$GCC,;t t
22906+
s,@CC_FOR_BUILD@,$CC_FOR_BUILD,;t t
2289522907
s,@TAS@,$TAS,;t t
2289622908
s,@autodepend@,$autodepend,;t t
2289722909
s,@INCLUDES@,$INCLUDES,;t t

configure.in

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dnl Process this file with autoconf to produce a configure script.
2-
dnl $PostgreSQL: pgsql/configure.in,v 1.414 2005/07/01 18:17:30 petere Exp $
2+
dnl $PostgreSQL: pgsql/configure.in,v 1.415 2005/07/03 18:54:26 petere Exp $
33
dnl
44
dnl Developers, please strive to achieve this order:
55
dnl
@@ -303,6 +303,17 @@ AC_DEFINE_UNQUOTED(PG_VERSION_STR,
303303
[A string containing the version number, platform, and C compiler])
304304

305305

306+
#
307+
# Native compiler
308+
#
309+
310+
if test -z "$CC_FOR_BUILD"; then
311+
CC_FOR_BUILD=$CC
312+
fi
313+
314+
AC_SUBST(CC_FOR_BUILD)
315+
316+
306317
#
307318
# Set up TAS assembly code if needed; the template file has now had its
308319
# chance to request this.

doc/src/sgml/installation.sgml

+18-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/installation.sgml,v 1.238 2005/06/27 02:04:23 neilc Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/installation.sgml,v 1.239 2005/07/03 18:54:27 petere Exp $ -->
22

33
<chapter id="installation">
44
<title><![%standalone-include[<productname>PostgreSQL</>]]>
@@ -993,6 +993,23 @@ su - postgres
993993
<userinput>./configure CC=/opt/bin/gcc CFLAGS='-O2 -pipe'</>
994994
</screen>
995995
</para>
996+
997+
<para>
998+
If you are cross-compiling<indexterm><primary>cross
999+
compilation</primary></indexterm> (compiling on one architecture
1000+
with the intent to run on a different architecture), special care
1001+
needs to be taken. First of all, specify the host architecture
1002+
(the architecture PostgreSQL will run on) using the option
1003+
<option>--host</option>. The variables <envar>CC</>,
1004+
<envar>CFLAGS</>, etc. should refer to the build tools for the
1005+
host architecture. During the build process, the time-zone
1006+
database for PostgreSQL is created and a special tool to do that
1007+
is compiled and run during the build process. This tool needs to
1008+
be compiled using a native compiler. Specify this compiler using
1009+
the variable <envar>CC_FOR_BUILD</envar>. Cross compilation
1010+
requires expert knowledge and the support for this process in the
1011+
PostgreSQL tree should be considered somewhat experimental.
1012+
</para>
9961013
</step>
9971014

9981015
<step>

src/Makefile.global.in

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*-makefile-*-
2-
# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.214 2005/05/17 18:26:22 tgl Exp $
2+
# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.215 2005/07/03 18:54:28 petere Exp $
33

44
#------------------------------------------------------------------------------
55
# All PostgreSQL makefiles include this file and use the variables it sets,
@@ -182,6 +182,7 @@ endif
182182
endif # not PGXS
183183

184184
CC = @CC@
185+
CC_FOR_BUILD = @CC_FOR_BUILD@
185186
GCC = @GCC@
186187
CFLAGS = @CFLAGS@
187188

src/timezone/Makefile

+13-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Makefile for the timezone library
55

66
# IDENTIFICATION
7-
# $PostgreSQL: pgsql/src/timezone/Makefile,v 1.17 2004/12/31 19:01:54 tgl Exp $
7+
# $PostgreSQL: pgsql/src/timezone/Makefile,v 1.18 2005/07/03 18:54:28 petere Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -18,7 +18,7 @@ override CPPFLAGS := $(CPPFLAGS)
1818
OBJS= localtime.o strftime.o pgtz.o
1919

2020
# files needed to build zic utility program
21-
ZICOBJS= zic.o ialloc.o scheck.o localtime.o
21+
ZICOBJS= zic.o ialloc.o scheck.o localtime-zic.o
2222

2323
# timezone data files
2424
TZDATA := africa antarctica asia australasia europe northamerica southamerica \
@@ -30,8 +30,17 @@ all: SUBSYS.o submake-libpgport zic
3030
SUBSYS.o: $(OBJS)
3131
$(LD) $(LDREL) $(LDOUT) SUBSYS.o $(OBJS)
3232

33+
# In case of cross-compilation, zic needs to be built with a native
34+
# compiler because it is run during the build, not on the final
35+
# system.
36+
37+
localtime-zic.c: localtime.c
38+
$(LN_S) $< $@
39+
40+
$(ZICOBJS): CC=$(CC_FOR_BUILD)
41+
3342
zic: $(ZICOBJS)
34-
$(CC) $(CFLAGS) $(ZICOBJS) $(LDFLAGS) $(LIBS) -o $@$(X)
43+
$(CC_FOR_BUILD) $(CFLAGS) $(ZICOBJS) -o $@$(X)
3544

3645
install: all installdirs
3746
./zic -d $(DESTDIR)$(datadir)/timezone $(TZDATAFILES)
@@ -40,4 +49,4 @@ installdirs:
4049
$(mkinstalldirs) $(DESTDIR)$(datadir)
4150

4251
clean distclean maintainer-clean:
43-
rm -f SUBSYS.o zic$(X) $(OBJS) $(ZICOBJS)
52+
rm -f SUBSYS.o zic zic$(X) $(OBJS) $(ZICOBJS) localtime-zic.c

0 commit comments

Comments
 (0)