From 9dae1a3562ba3f8d28b1fd0b5415d546cf5fc400 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Sun, 3 Jul 2005 18:54:28 +0000 Subject: [PATCH] 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. --- configure | 14 +++++++++++++- configure.in | 11 +++++++++++ doc/src/sgml/installation.sgml | 17 +++++++++++++++++ src/Makefile.global.in | 1 + src/timezone/Makefile | 15 ++++++++++++--- 5 files changed, 54 insertions(+), 4 deletions(-) diff --git a/configure b/configure index ed8faf10be..217c133b40 100755 --- a/configure +++ b/configure @@ -314,7 +314,7 @@ ac_includes_default="\ # include #endif" -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' +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' ac_subst_files='' # Initialize some variables set by options. @@ -3305,6 +3305,17 @@ _ACEOF +# +# Native compiler +# + +if test -z "$CC_FOR_BUILD"; then + CC_FOR_BUILD=$CC +fi + + + + # # Set up TAS assembly code if needed; the template file has now had its # chance to request this. @@ -22892,6 +22903,7 @@ s,@EXEEXT@,$EXEEXT,;t t s,@OBJEXT@,$OBJEXT,;t t s,@CPP@,$CPP,;t t s,@GCC@,$GCC,;t t +s,@CC_FOR_BUILD@,$CC_FOR_BUILD,;t t s,@TAS@,$TAS,;t t s,@autodepend@,$autodepend,;t t s,@INCLUDES@,$INCLUDES,;t t diff --git a/configure.in b/configure.in index 9999db5cb6..328ddb846f 100644 --- a/configure.in +++ b/configure.in @@ -303,6 +303,17 @@ AC_DEFINE_UNQUOTED(PG_VERSION_STR, [A string containing the version number, platform, and C compiler]) +# +# Native compiler +# + +if test -z "$CC_FOR_BUILD"; then + CC_FOR_BUILD=$CC +fi + +AC_SUBST(CC_FOR_BUILD) + + # # Set up TAS assembly code if needed; the template file has now had its # chance to request this. diff --git a/doc/src/sgml/installation.sgml b/doc/src/sgml/installation.sgml index 62752893e4..6cf73f9a14 100644 --- a/doc/src/sgml/installation.sgml +++ b/doc/src/sgml/installation.sgml @@ -993,6 +993,23 @@ su - postgres ./configure CC=/opt/bin/gcc CFLAGS='-O2 -pipe' + + + If you are cross-compilingcross + compilation (compiling on one architecture + with the intent to run on a different architecture), special care + needs to be taken. First of all, specify the host architecture + (the architecture PostgreSQL will run on) using the option + . The variables CC, + CFLAGS, etc. should refer to the build tools for the + host architecture. During the build process, the time-zone + database for PostgreSQL is created and a special tool to do that + is compiled and run during the build process. This tool needs to + be compiled using a native compiler. Specify this compiler using + the variable CC_FOR_BUILD. Cross compilation + requires expert knowledge and the support for this process in the + PostgreSQL tree should be considered somewhat experimental. + diff --git a/src/Makefile.global.in b/src/Makefile.global.in index 56773b3a8e..266a57655f 100644 --- a/src/Makefile.global.in +++ b/src/Makefile.global.in @@ -182,6 +182,7 @@ endif endif # not PGXS CC = @CC@ +CC_FOR_BUILD = @CC_FOR_BUILD@ GCC = @GCC@ CFLAGS = @CFLAGS@ diff --git a/src/timezone/Makefile b/src/timezone/Makefile index 934b565d90..a1430e827d 100644 --- a/src/timezone/Makefile +++ b/src/timezone/Makefile @@ -18,7 +18,7 @@ override CPPFLAGS := $(CPPFLAGS) OBJS= localtime.o strftime.o pgtz.o # files needed to build zic utility program -ZICOBJS= zic.o ialloc.o scheck.o localtime.o +ZICOBJS= zic.o ialloc.o scheck.o localtime-zic.o # timezone data files TZDATA := africa antarctica asia australasia europe northamerica southamerica \ @@ -30,8 +30,17 @@ all: SUBSYS.o submake-libpgport zic SUBSYS.o: $(OBJS) $(LD) $(LDREL) $(LDOUT) SUBSYS.o $(OBJS) +# In case of cross-compilation, zic needs to be built with a native +# compiler because it is run during the build, not on the final +# system. + +localtime-zic.c: localtime.c + $(LN_S) $< $@ + +$(ZICOBJS): CC=$(CC_FOR_BUILD) + zic: $(ZICOBJS) - $(CC) $(CFLAGS) $(ZICOBJS) $(LDFLAGS) $(LIBS) -o $@$(X) + $(CC_FOR_BUILD) $(CFLAGS) $(ZICOBJS) -o $@$(X) install: all installdirs ./zic -d $(DESTDIR)$(datadir)/timezone $(TZDATAFILES) @@ -40,4 +49,4 @@ installdirs: $(mkinstalldirs) $(DESTDIR)$(datadir) clean distclean maintainer-clean: - rm -f SUBSYS.o zic$(X) $(OBJS) $(ZICOBJS) + rm -f SUBSYS.o zic zic$(X) $(OBJS) $(ZICOBJS) localtime-zic.c -- 2.39.5