common/autoconf/platform.m4
changeset 13697 5262b00bc10c
parent 13132 bd88bb8dd3af
child 14111 2a82ecb35fc7
equal deleted inserted replaced
13694:ffe6bce5a521 13697:5262b00bc10c
    21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    22 # or visit www.oracle.com if you need additional information or have any
    22 # or visit www.oracle.com if you need additional information or have any
    23 # questions.
    23 # questions.
    24 #
    24 #
    25 
    25 
    26 AC_DEFUN([PLATFORM_EXTRACT_TARGET_AND_BUILD_AND_LEGACY_VARS],
    26 # Support macro for PLATFORM_EXTRACT_TARGET_AND_BUILD.
    27 [
    27 # Converts autoconf style CPU name to OpenJDK style, into
    28     # Expects $host_os $host_cpu $build_os and $build_cpu
    28 # VAR_CPU, VAR_CPU_ARCH, VAR_CPU_BITS and VAR_CPU_ENDIAN.
    29     # and $with_target_bits to have been setup!
       
    30     #
       
    31     # Translate the standard triplet(quadruplet) definition
       
    32     # of the target/build system into
       
    33     # OPENJDK_TARGET_OS=aix,bsd,hpux,linux,macosx,solaris,windows
       
    34     # OPENJDK_TARGET_OS_FAMILY=bsd,gnu,sysv,win32,wince
       
    35     # OPENJDK_TARGET_OS_API=posix,winapi
       
    36     # 
       
    37     # OPENJDK_TARGET_CPU=ia32,x64,sparc,sparcv9,arm,arm64,ppc,ppc64
       
    38     # OPENJDK_TARGET_CPU_ARCH=x86,sparc,pcc,arm
       
    39     # OPENJDK_TARGET_CPU_BITS=32,64
       
    40     # OPENJDK_TARGET_CPU_ENDIAN=big,little
       
    41     #
       
    42     # The same values are setup for BUILD_...
       
    43     # 
       
    44     # And the legacy variables, for controlling the old makefiles.
       
    45     # LEGACY_OPENJDK_TARGET_CPU1=i586,amd64/x86_64,sparc,sparcv9,arm,arm64...
       
    46     # LEGACY_OPENJDK_TARGET_CPU2=i386,amd64,sparc,sparcv9,arm,arm64...
       
    47     # LEGACY_OPENJDK_TARGET_CPU3=sparcv9,amd64 (but only on solaris)
       
    48     # LEGACY_OPENJDK_TARGET_OS_API=solaris,windows
       
    49     #
       
    50     # We also copy the autoconf trip/quadruplet
       
    51     # verbatim to OPENJDK_TARGET_SYSTEM (from the autoconf "host") and OPENJDK_BUILD_SYSTEM
       
    52     OPENJDK_TARGET_SYSTEM="$host"
       
    53     OPENJDK_BUILD_SYSTEM="$build"
       
    54     AC_SUBST(OPENJDK_TARGET_SYSTEM)
       
    55     AC_SUBST(OPENJDK_BUILD_SYSTEM)
       
    56     
       
    57     PLATFORM_EXTRACT_VARS_FROM_OS_TO(OPENJDK_TARGET,$host_os)
       
    58     PLATFORM_EXTRACT_VARS_FROM_CPU_TO(OPENJDK_TARGET,$host_cpu)
       
    59 
       
    60     PLATFORM_EXTRACT_VARS_FROM_OS_TO(OPENJDK_BUILD,$build_os)
       
    61     PLATFORM_EXTRACT_VARS_FROM_CPU_TO(OPENJDK_BUILD,$build_cpu)
       
    62 
       
    63     if test "x$OPENJDK_TARGET_OS" != xsolaris; then
       
    64         LEGACY_OPENJDK_TARGET_CPU3=""
       
    65         LEGACY_OPENJDK_BUILD_CPU3=""
       
    66     fi
       
    67 
       
    68     # On MacOSX and MacOSX only, we have a different name for the x64 CPU in ARCH (LEGACY_OPENJDK_TARGET_CPU1) ...
       
    69     if test "x$OPENJDK_TARGET_OS" = xmacosx && test "x$OPENJDK_TARGET_CPU" = xx64; then
       
    70         LEGACY_OPENJDK_TARGET_CPU1="x86_64"
       
    71     fi
       
    72 
       
    73     PLATFORM_SET_RELEASE_FILE_OS_VALUES
       
    74 ])
       
    75 
       
    76 AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_OS_TO],
       
    77 [
       
    78     PLATFORM_EXTRACT_VARS_FROM_OS($2)
       
    79     $1_OS="$VAR_OS"
       
    80     $1_OS_FAMILY="$VAR_OS_FAMILY"
       
    81     $1_OS_API="$VAR_OS_API"
       
    82 
       
    83     AC_SUBST($1_OS)
       
    84     AC_SUBST($1_OS_FAMILY)
       
    85     AC_SUBST($1_OS_API)
       
    86 
       
    87     if test "x$$1_OS_API" = xposix; then
       
    88         LEGACY_$1_OS_API="solaris"
       
    89     fi
       
    90     if test "x$$1_OS_API" = xwinapi; then
       
    91         LEGACY_$1_OS_API="windows"
       
    92     fi
       
    93     AC_SUBST(LEGACY_$1_OS_API)    
       
    94 ])
       
    95 
       
    96 AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_CPU_TO],
       
    97 [
       
    98     PLATFORM_EXTRACT_VARS_FROM_CPU($2)
       
    99     $1_CPU="$VAR_CPU"
       
   100     $1_CPU_ARCH="$VAR_CPU_ARCH"
       
   101     $1_CPU_BITS="$VAR_CPU_BITS"
       
   102     $1_CPU_ENDIAN="$VAR_CPU_ENDIAN"
       
   103 
       
   104     AC_SUBST($1_CPU)
       
   105     AC_SUBST($1_CPU_ARCH)
       
   106     AC_SUBST($1_CPU_BITS)
       
   107     AC_SUBST($1_CPU_ENDIAN)
       
   108     
       
   109     # Also store the legacy naming of the cpu.
       
   110     # Ie i586 and amd64 instead of ia32 and x64
       
   111     LEGACY_$1_CPU1="$VAR_LEGACY_CPU"
       
   112     AC_SUBST(LEGACY_$1_CPU1)
       
   113 
       
   114     # And the second legacy naming of the cpu.
       
   115     # Ie i386 and amd64 instead of ia32 and x64.
       
   116     LEGACY_$1_CPU2="$LEGACY_$1_CPU1"
       
   117     if test "x$LEGACY_$1_CPU1" = xi586; then 
       
   118         LEGACY_$1_CPU2=i386
       
   119     fi
       
   120     AC_SUBST(LEGACY_$1_CPU2)
       
   121 
       
   122     # And the third legacy naming of the cpu.
       
   123     # Ie only amd64 or sparcv9, used for the ISA_DIR on Solaris.
       
   124     LEGACY_$1_CPU3=""
       
   125     if test "x$$1_CPU" = xx64; then 
       
   126         LEGACY_$1_CPU3=amd64
       
   127     fi
       
   128     if test "x$$1_CPU" = xsparcv9; then 
       
   129         LEGACY_$1_CPU3=sparcv9
       
   130     fi
       
   131     AC_SUBST(LEGACY_$1_CPU3)
       
   132 ])
       
   133 
       
   134 AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_CPU],
    29 AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_CPU],
   135 [
    30 [
   136   # First argument is the cpu name from the trip/quad
    31   # First argument is the cpu name from the trip/quad
   137   case "$1" in
    32   case "$1" in
   138     x86_64)
    33     x86_64)
   139       VAR_CPU=x64
    34       VAR_CPU=x86_64
   140       VAR_CPU_ARCH=x86
    35       VAR_CPU_ARCH=x86
   141       VAR_CPU_BITS=64
    36       VAR_CPU_BITS=64
   142       VAR_CPU_ENDIAN=little
    37       VAR_CPU_ENDIAN=little
   143       VAR_LEGACY_CPU=amd64
       
   144       ;;
    38       ;;
   145     i?86)
    39     i?86)
   146       VAR_CPU=ia32
    40       VAR_CPU=x86
   147       VAR_CPU_ARCH=x86
    41       VAR_CPU_ARCH=x86
   148       VAR_CPU_BITS=32
    42       VAR_CPU_BITS=32
   149       VAR_CPU_ENDIAN=little
    43       VAR_CPU_ENDIAN=little
   150       VAR_LEGACY_CPU=i586
       
   151       ;;
       
   152     alpha*)
       
   153       VAR_CPU=alpha
       
   154       VAR_CPU_ARCH=alpha
       
   155       VAR_CPU_BITS=64
       
   156       VAR_CPU_ENDIAN=big
       
   157       VAR_LEGACY_CPU=alpha
       
   158       ;;
    44       ;;
   159     arm*)
    45     arm*)
   160       VAR_CPU=arm
    46       VAR_CPU=arm
   161       VAR_CPU_ARCH=arm
    47       VAR_CPU_ARCH=arm
   162       VAR_CPU_BITS=32
    48       VAR_CPU_BITS=32
   163       VAR_CPU_ENDIAN=little
    49       VAR_CPU_ENDIAN=little
   164       VAR_LEGACY_CPU=arm
    50       ;;
   165       ;;
       
   166     mips)
       
   167       VAR_CPU=mips
       
   168       VAR_CPU_ARCH=mips
       
   169       VAR_CPU_BITS=woot
       
   170       VAR_CPU_ENDIAN=woot
       
   171       VAR_LEGACY_CPU=mips
       
   172        ;;
       
   173     mipsel)
       
   174       VAR_CPU=mipsel
       
   175       VAR_CPU_ARCH=mips
       
   176       VAR_CPU_BITS=woot
       
   177       VAR_CPU_ENDIAN=woot
       
   178       VAR_LEGACY_CPU=mipsel
       
   179        ;;
       
   180     powerpc)
    51     powerpc)
   181       VAR_CPU=ppc
    52       VAR_CPU=ppc
   182       VAR_CPU_ARCH=ppc
    53       VAR_CPU_ARCH=ppc
   183       VAR_CPU_BITS=32
    54       VAR_CPU_BITS=32
   184       VAR_CPU_ENDIAN=big
    55       VAR_CPU_ENDIAN=big
   185       VAR_LEGACY_CPU=ppc
       
   186        ;;
    56        ;;
   187     powerpc64)
    57     powerpc64)
   188       VAR_CPU=ppc64
    58       VAR_CPU=ppc64
   189       VAR_CPU_ARCH=ppc
    59       VAR_CPU_ARCH=ppc
   190       VAR_CPU_BITS=64
    60       VAR_CPU_BITS=64
   191       VAR_CPU_ENDIAN=big
    61       VAR_CPU_ENDIAN=big
   192       VAR_LEGACY_CPU=ppc64
       
   193        ;;
    62        ;;
   194     sparc)
    63     sparc)
   195       VAR_CPU=sparc
    64       VAR_CPU=sparc
   196       VAR_CPU_ARCH=sparc
    65       VAR_CPU_ARCH=sparc
   197       VAR_CPU_BITS=32
    66       VAR_CPU_BITS=32
   198       VAR_CPU_ENDIAN=big
    67       VAR_CPU_ENDIAN=big
   199       VAR_LEGACY_CPU=sparc
       
   200        ;;
    68        ;;
   201     sparc64)
    69     sparcv9)
   202       VAR_CPU=sparcv9
    70       VAR_CPU=sparcv9
   203       VAR_CPU_ARCH=sparc
    71       VAR_CPU_ARCH=sparc
   204       VAR_CPU_BITS=64
    72       VAR_CPU_BITS=64
   205       VAR_CPU_ENDIAN=big
    73       VAR_CPU_ENDIAN=big
   206       VAR_LEGACY_CPU=sparcv9
       
   207        ;;
       
   208     s390)
       
   209       VAR_CPU=s390
       
   210       VAR_CPU_ARCH=s390
       
   211       VAR_CPU_BITS=32
       
   212       VAR_CPU_ENDIAN=woot
       
   213       VAR_LEGACY_CPU=s390
       
   214       VAR_LEGACY_CPU=s390
       
   215        ;;
       
   216     s390x)
       
   217       VAR_CPU=s390x
       
   218       VAR_CPU_ARCH=s390
       
   219       VAR_CPU_BITS=64
       
   220       VAR_CPU_ENDIAN=woot
       
   221       VAR_LEGACY_CPU=s390x
       
   222        ;;
    74        ;;
   223     *)
    75     *)
   224       AC_MSG_ERROR([unsupported cpu $1])
    76       AC_MSG_ERROR([unsupported cpu $1])
   225       ;;
    77       ;;
   226   esac
    78   esac
   227 
    79 ])
   228   # Workaround cygwin not knowing about 64 bit.
    80 
   229   if test "x$VAR_OS" = "xwindows"; then
    81 # Support macro for PLATFORM_EXTRACT_TARGET_AND_BUILD.
   230       if test "x$PROCESSOR_IDENTIFIER" != "x"; then
    82 # Converts autoconf style OS name to OpenJDK style, into
   231           PROC_ARCH=`echo $PROCESSOR_IDENTIFIER | $CUT -f1 -d' '`
    83 # VAR_OS and VAR_OS_API.
   232           case "$PROC_ARCH" in
       
   233             intel64|Intel64|INTEL64|em64t|EM64T|amd64|AMD64|8664|x86_64)
       
   234               VAR_CPU=x64
       
   235               VAR_CPU_BITS=64
       
   236               VAR_LEGACY_CPU=amd64
       
   237               ;;
       
   238           esac
       
   239       fi
       
   240   fi
       
   241 
       
   242   # on solaris x86...default seems to be 32-bit
       
   243   if test "x$VAR_OS" = "xsolaris" && \
       
   244      test "x$with_target_bits" = "x" && \
       
   245      test "x$VAR_CPU_ARCH" = "xx86"
       
   246   then
       
   247       with_target_bits=32
       
   248   fi
       
   249 
       
   250   if test "x$VAR_CPU_ARCH" = "xx86"; then
       
   251       if test "x$with_target_bits" = "x64"; then
       
   252           VAR_CPU=x64
       
   253           VAR_CPU_BITS=64
       
   254           VAR_LEGACY_CPU=amd64
       
   255       fi
       
   256       if test "x$with_target_bits" = "x32"; then
       
   257           VAR_CPU=ia32
       
   258           VAR_CPU_BITS=32
       
   259           VAR_LEGACY_CPU=i586
       
   260       fi
       
   261   fi 
       
   262 
       
   263   if test "x$VAR_CPU_ARCH" = "xsparc"; then
       
   264       if test "x$with_target_bits" = "x64"; then
       
   265           VAR_CPU=sparcv9
       
   266           VAR_CPU_BITS=64
       
   267           VAR_LEGACY_CPU=sparcv9
       
   268       fi
       
   269   fi 
       
   270 ])
       
   271 
       
   272 AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_OS],
    84 AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_OS],
   273 [
    85 [
   274   case "$1" in
    86   case "$1" in
   275     *linux*)
    87     *linux*)
   276       VAR_OS=linux
    88       VAR_OS=linux
   277       VAR_OS_API=posix
    89       VAR_OS_API=posix
   278       VAR_OS_FAMILY=gnu
       
   279       ;;
    90       ;;
   280     *solaris*)
    91     *solaris*)
   281       VAR_OS=solaris
    92       VAR_OS=solaris
   282       VAR_OS_API=posix
    93       VAR_OS_API=posix
   283       VAR_OS_FAMILY=sysv
       
   284       ;;
    94       ;;
   285     *darwin*)
    95     *darwin*)
   286       VAR_OS=macosx
    96       VAR_OS=macosx
   287       VAR_OS_API=posix
    97       VAR_OS_API=posix
   288       VAR_OS_FAMILY=bsd
       
   289       ;;
    98       ;;
   290     *bsd*)
    99     *bsd*)
   291       VAR_OS=bsd
   100       VAR_OS=bsd
   292       VAR_OS_API=posix
   101       VAR_OS_API=posix
   293       VAR_OS_FAMILY=bsd
       
   294       ;;
   102       ;;
   295     *cygwin*|*windows*)
   103     *cygwin*|*windows*)
   296       VAR_OS=windows
   104       VAR_OS=windows
   297       VAR_OS_API=winapi
   105       VAR_OS_API=winapi
   298       VAR_OS_FAMILY=windows
       
   299       ;;
   106       ;;
   300     *)
   107     *)
   301       AC_MSG_ERROR([unsupported operating system $1])
   108       AC_MSG_ERROR([unsupported operating system $1])
   302       ;;
   109       ;;
   303   esac
   110   esac
       
   111 ])
       
   112 
       
   113 # Expects $host_os $host_cpu $build_os and $build_cpu
       
   114 # and $with_target_bits to have been setup!
       
   115 #
       
   116 # Translate the standard triplet(quadruplet) definition
       
   117 # of the target/build system into OPENJDK_TARGET_OS, OPENJDK_TARGET_CPU,
       
   118 # OPENJDK_BUILD_OS, etc.
       
   119 AC_DEFUN([PLATFORM_EXTRACT_TARGET_AND_BUILD],
       
   120 [
       
   121     # Copy the autoconf trip/quadruplet verbatim to OPENJDK_TARGET_AUTOCONF_NAME
       
   122     # (from the autoconf "host") and OPENJDK_BUILD_AUTOCONF_NAME
       
   123     # Note that we might later on rewrite e.g. OPENJDK_TARGET_CPU due to reduced build,
       
   124     # but this will not change the value of OPENJDK_TARGET_AUTOCONF_NAME.     
       
   125     OPENJDK_TARGET_AUTOCONF_NAME="$host"
       
   126     OPENJDK_BUILD_AUTOCONF_NAME="$build"
       
   127     AC_SUBST(OPENJDK_TARGET_AUTOCONF_NAME)
       
   128     AC_SUBST(OPENJDK_BUILD_AUTOCONF_NAME)
       
   129 
       
   130     # Convert the autoconf OS/CPU value to our own data, into the VAR_OS/CPU variables.
       
   131     PLATFORM_EXTRACT_VARS_FROM_OS($host_os)
       
   132     PLATFORM_EXTRACT_VARS_FROM_CPU($host_cpu)
       
   133     # ... and setup our own variables. (Do this explicitely to facilitate searching)
       
   134     OPENJDK_TARGET_OS="$VAR_OS"
       
   135     OPENJDK_TARGET_OS_API="$VAR_OS_API"
       
   136     OPENJDK_TARGET_CPU="$VAR_CPU"
       
   137     OPENJDK_TARGET_CPU_ARCH="$VAR_CPU_ARCH"
       
   138     OPENJDK_TARGET_CPU_BITS="$VAR_CPU_BITS"
       
   139     OPENJDK_TARGET_CPU_ENDIAN="$VAR_CPU_ENDIAN"
       
   140     AC_SUBST(OPENJDK_TARGET_OS)
       
   141     AC_SUBST(OPENJDK_TARGET_OS_API)
       
   142     AC_SUBST(OPENJDK_TARGET_CPU)
       
   143     AC_SUBST(OPENJDK_TARGET_CPU_ARCH)
       
   144     AC_SUBST(OPENJDK_TARGET_CPU_BITS)
       
   145     AC_SUBST(OPENJDK_TARGET_CPU_ENDIAN)
       
   146 
       
   147     # Convert the autoconf OS/CPU value to our own data, into the VAR_OS/CPU variables.
       
   148     PLATFORM_EXTRACT_VARS_FROM_OS($build_os)
       
   149     PLATFORM_EXTRACT_VARS_FROM_CPU($build_cpu)
       
   150     # ..and setup our own variables. (Do this explicitely to facilitate searching)
       
   151     OPENJDK_BUILD_OS="$VAR_OS"
       
   152     OPENJDK_BUILD_OS_API="$VAR_OS_API"
       
   153     OPENJDK_BUILD_CPU="$VAR_CPU"
       
   154     OPENJDK_BUILD_CPU_ARCH="$VAR_CPU_ARCH"
       
   155     OPENJDK_BUILD_CPU_BITS="$VAR_CPU_BITS"
       
   156     OPENJDK_BUILD_CPU_ENDIAN="$VAR_CPU_ENDIAN"
       
   157     AC_SUBST(OPENJDK_BUILD_OS)
       
   158     AC_SUBST(OPENJDK_BUILD_OS_API)
       
   159     AC_SUBST(OPENJDK_BUILD_CPU)
       
   160     AC_SUBST(OPENJDK_BUILD_CPU_ARCH)
       
   161     AC_SUBST(OPENJDK_BUILD_CPU_BITS)
       
   162     AC_SUBST(OPENJDK_BUILD_CPU_ENDIAN)
       
   163 ])
       
   164 
       
   165 # Check if a reduced build (32-bit on 64-bit platforms) is requested, and modify behaviour
       
   166 # accordingly. Must be done after setting up build and target system, but before
       
   167 # doing anything else with these values.
       
   168 AC_DEFUN([PLATFORM_SETUP_TARGET_CPU_BITS],
       
   169 [
       
   170   AC_ARG_WITH(target-bits, [AS_HELP_STRING([--with-target-bits],
       
   171      [build 32-bit or 64-bit binaries (for platforms that support it), e.g. --with-target-bits=32 @<:@guessed@:>@])])
       
   172 
       
   173   # We have three types of compiles:
       
   174   # native  == normal compilation, target system == build system
       
   175   # cross   == traditional cross compilation, target system != build system; special toolchain needed
       
   176   # reduced == using native compilers, but with special flags (e.g. -m32) to produce 32-bit builds on 64-bit machines
       
   177   #
       
   178   if test "x$OPENJDK_BUILD_AUTOCONF_NAME" != "x$OPENJDK_TARGET_AUTOCONF_NAME"; then
       
   179     # We're doing a proper cross-compilation
       
   180     COMPILE_TYPE="cross"
       
   181   else
       
   182     COMPILE_TYPE="native"
       
   183   fi
       
   184 
       
   185   if test "x$with_target_bits" != x; then
       
   186     if test "x$COMPILE_TYPE" = "xcross"; then
       
   187       AC_MSG_ERROR([It is not possible to combine --with-target-bits=X and proper cross-compilation. Choose either.])
       
   188     fi
       
   189 
       
   190     if test "x$with_target_bits" = x32 && test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
       
   191       # A reduced build is requested
       
   192       COMPILE_TYPE="reduced"
       
   193       OPENJDK_TARGET_CPU_BITS=32
       
   194       if test "x$OPENJDK_TARGET_CPU_ARCH" = "xx86"; then
       
   195         OPENJDK_TARGET_CPU=x86
       
   196       elif test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then
       
   197         OPENJDK_TARGET_CPU=sparc
       
   198       else
       
   199         AC_MSG_ERROR([Reduced build (--with-target-bits=32) is only supported on x86_64 and sparcv9])
       
   200       fi 
       
   201     elif test "x$with_target_bits" = x64 && test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
       
   202       AC_MSG_ERROR([It is not possible to use --with-target-bits=64 on a 32 bit system. Use proper cross-compilation instead.])
       
   203     elif test "x$with_target_bits" = "x$OPENJDK_TARGET_CPU_BITS"; then
       
   204       AC_MSG_NOTICE([--with-target-bits are set to build platform address size; argument has no meaning])
       
   205     else
       
   206       AC_MSG_ERROR([--with-target-bits can only be 32 or 64, you specified $with_target_bits!])
       
   207     fi
       
   208   fi
       
   209   AC_SUBST(COMPILE_TYPE)
       
   210 
       
   211 AC_MSG_CHECKING([for compilation type])
       
   212 AC_MSG_RESULT([$COMPILE_TYPE])
       
   213 ])
       
   214 
       
   215     # Setup the legacy variables, for controlling the old makefiles.
       
   216     #
       
   217 AC_DEFUN([PLATFORM_SETUP_LEGACY_VARS],
       
   218 [
       
   219     # Also store the legacy naming of the cpu.
       
   220     # Ie i586 and amd64 instead of x86 and x86_64
       
   221     OPENJDK_TARGET_CPU_LEGACY="$OPENJDK_TARGET_CPU"
       
   222     if test "x$OPENJDK_TARGET_CPU" = xx86; then 
       
   223       OPENJDK_TARGET_CPU_LEGACY="i586"
       
   224     elif test "x$OPENJDK_TARGET_OS" != xmacosx && test "x$OPENJDK_TARGET_CPU" = xx86_64; then 
       
   225       # On all platforms except MacOSX replace x86_64 with amd64.
       
   226       OPENJDK_TARGET_CPU_LEGACY="amd64"
       
   227     fi
       
   228     AC_SUBST(OPENJDK_TARGET_CPU_LEGACY)
       
   229 
       
   230     # And the second legacy naming of the cpu.
       
   231     # Ie i386 and amd64 instead of x86 and x86_64.
       
   232     OPENJDK_TARGET_CPU_LEGACY_LIB="$OPENJDK_TARGET_CPU"
       
   233     if test "x$OPENJDK_TARGET_CPU" = xx86; then 
       
   234       OPENJDK_TARGET_CPU_LEGACY_LIB="i386"
       
   235     elif test "x$OPENJDK_TARGET_CPU" = xx86_64; then 
       
   236       OPENJDK_TARGET_CPU_LEGACY_LIB="amd64"
       
   237     fi
       
   238     AC_SUBST(OPENJDK_TARGET_CPU_LEGACY_LIB)
       
   239 
       
   240     # This is the name of the cpu (but using i386 and amd64 instead of
       
   241     # x86 and x86_64, respectively), preceeded by a /, to be used when
       
   242     # locating libraries. On macosx, it's empty, though.
       
   243     OPENJDK_TARGET_CPU_LIBDIR="/$OPENJDK_TARGET_CPU_LEGACY_LIB"
       
   244     if test "x$OPENJDK_TARGET_OS" = xmacosx; then
       
   245         OPENJDK_TARGET_CPU_LIBDIR=""
       
   246     fi
       
   247     AC_SUBST(OPENJDK_TARGET_CPU_LIBDIR)
       
   248 
       
   249     # OPENJDK_TARGET_CPU_ISADIR is normally empty. On 64-bit Solaris systems, it is set to
       
   250     # /amd64 or /sparcv9. This string is appended to some library paths, like this:
       
   251     # /usr/lib${OPENJDK_TARGET_CPU_ISADIR}/libexample.so
       
   252     OPENJDK_TARGET_CPU_ISADIR=""
       
   253     if test "x$OPENJDK_TARGET_OS" = xsolaris; then
       
   254       if test "x$OPENJDK_TARGET_CPU" = xx86_64; then 
       
   255           OPENJDK_TARGET_CPU_ISADIR="/amd64"
       
   256       elif test "x$OPENJDK_TARGET_CPU" = xsparcv9; then 
       
   257           OPENJDK_TARGET_CPU_ISADIR="/sparcv9"
       
   258       fi
       
   259     fi
       
   260     AC_SUBST(OPENJDK_TARGET_CPU_ISADIR)
       
   261 
       
   262     # Setup OPENJDK_TARGET_CPU_OSARCH, which is used to set the os.arch Java system property
       
   263     OPENJDK_TARGET_CPU_OSARCH="$OPENJDK_TARGET_CPU"
       
   264     if test "x$OPENJDK_TARGET_OS" = xlinux && test "x$OPENJDK_TARGET_CPU" = xx86; then
       
   265       # On linux only, we replace x86 with i386.
       
   266       OPENJDK_TARGET_CPU_OSARCH="i386"
       
   267     elif test "x$OPENJDK_TARGET_OS" != xmacosx && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
       
   268       # On all platforms except macosx, we replace x86_64 with amd64.
       
   269       OPENJDK_TARGET_CPU_OSARCH="amd64"
       
   270     fi
       
   271     AC_SUBST(OPENJDK_TARGET_CPU_OSARCH)
       
   272 
       
   273     OPENJDK_TARGET_CPU_JLI="$OPENJDK_TARGET_CPU"
       
   274     if test "x$OPENJDK_TARGET_CPU" = xx86; then 
       
   275       OPENJDK_TARGET_CPU_JLI="i386"
       
   276     elif test "x$OPENJDK_TARGET_OS" != xmacosx && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
       
   277       # On all platforms except macosx, we replace x86_64 with amd64.
       
   278       OPENJDK_TARGET_CPU_JLI="amd64"
       
   279     fi
       
   280     # Now setup the -D flags for building libjli.
       
   281     OPENJDK_TARGET_CPU_JLI_CFLAGS="-DLIBARCHNAME='\"$OPENJDK_TARGET_CPU_JLI\"'"
       
   282     if test "x$OPENJDK_TARGET_OS" = xsolaris; then
       
   283       if test "x$OPENJDK_TARGET_CPU_ARCH" = xsparc; then
       
   284         OPENJDK_TARGET_CPU_JLI_CFLAGS="$OPENJDK_TARGET_CPU_JLI_CFLAGS -DLIBARCH32NAME='\"sparc\"' -DLIBARCH64NAME='\"sparcv9\"'"
       
   285       elif test "x$OPENJDK_TARGET_CPU_ARCH" = xx86; then 
       
   286         OPENJDK_TARGET_CPU_JLI_CFLAGS="$OPENJDK_TARGET_CPU_JLI_CFLAGS -DLIBARCH32NAME='\"i386\"' -DLIBARCH64NAME='\"amd64\"'"
       
   287       fi
       
   288     fi
       
   289     AC_SUBST(OPENJDK_TARGET_CPU_JLI_CFLAGS)
       
   290 
       
   291     # Setup OPENJDK_TARGET_OS_API_DIR, used in source paths.
       
   292     if test "x$OPENJDK_TARGET_OS_API" = xposix; then
       
   293         OPENJDK_TARGET_OS_API_DIR="solaris"
       
   294     fi
       
   295     if test "x$OPENJDK_TARGET_OS_API" = xwinapi; then
       
   296         OPENJDK_TARGET_OS_API_DIR="windows"
       
   297     fi
       
   298     AC_SUBST(OPENJDK_TARGET_OS_API_DIR)
       
   299 
       
   300     if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
       
   301         A_LP64="LP64:="
       
   302         ADD_LP64="-D_LP64=1"
       
   303     fi
       
   304     AC_SUBST(LP64,$A_LP64)
       
   305 
       
   306     if test "x$COMPILE_TYPE" = "xcross"; then
       
   307       # FIXME: ... or should this include reduced builds..?
       
   308       DEFINE_CROSS_COMPILE_ARCH="CROSS_COMPILE_ARCH:=$OPENJDK_TARGET_CPU_LEGACY"
       
   309     else
       
   310       DEFINE_CROSS_COMPILE_ARCH=""
       
   311     fi
       
   312     AC_SUBST(DEFINE_CROSS_COMPILE_ARCH)
   304 ])
   313 ])
   305 
   314 
   306 AC_DEFUN([PLATFORM_SET_RELEASE_FILE_OS_VALUES],
   315 AC_DEFUN([PLATFORM_SET_RELEASE_FILE_OS_VALUES],
   307 [
   316 [
   308     if test "x$OPENJDK_TARGET_OS" = "xsolaris"; then
   317     if test "x$OPENJDK_TARGET_OS" = "xsolaris"; then
   313        REQUIRED_OS_NAME=Linux
   322        REQUIRED_OS_NAME=Linux
   314        REQUIRED_OS_VERSION=2.6
   323        REQUIRED_OS_VERSION=2.6
   315     fi
   324     fi
   316     if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
   325     if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
   317         REQUIRED_OS_NAME=Windows
   326         REQUIRED_OS_NAME=Windows
   318         REQUIRED_OS_VERSION=5.1
   327         if test "x$OPENJDK_TARGET_CPU_BITS" = "x64"; then
       
   328             REQUIRED_OS_VERSION=5.2
       
   329         else
       
   330             REQUIRED_OS_VERSION=5.1
       
   331         fi
   319     fi
   332     fi
   320     if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
   333     if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
   321         REQUIRED_OS_NAME=Darwin
   334         REQUIRED_OS_NAME=Darwin
   322         REQUIRED_OS_VERSION=11.2
   335         REQUIRED_OS_VERSION=11.2
   323     fi
   336     fi
   336 # to use the configure naming style.
   349 # to use the configure naming style.
   337 AC_CANONICAL_BUILD
   350 AC_CANONICAL_BUILD
   338 AC_CANONICAL_HOST
   351 AC_CANONICAL_HOST
   339 AC_CANONICAL_TARGET
   352 AC_CANONICAL_TARGET
   340 
   353 
   341 AC_ARG_WITH(target-bits, [AS_HELP_STRING([--with-target-bits],
   354 PLATFORM_EXTRACT_TARGET_AND_BUILD
   342    [build 32-bit or 64-bit binaries (for platforms that support it), e.g. --with-target-bits=32 @<:@guessed@:>@])])
   355 PLATFORM_SETUP_TARGET_CPU_BITS
   343 
   356 PLATFORM_SET_RELEASE_FILE_OS_VALUES
   344 if test "x$with_target_bits" != x && \
   357 PLATFORM_SETUP_LEGACY_VARS
   345    test "x$with_target_bits" != x32 && \
       
   346    test "x$with_target_bits" != x64 ; then
       
   347     AC_MSG_ERROR([--with-target-bits can only be 32 or 64, you specified $with_target_bits!])
       
   348 fi
       
   349 # Translate the standard cpu-vendor-kernel-os quadruplets into
       
   350 # the new TARGET_.... and BUILD_... and the legacy names used by
       
   351 # the openjdk build.
       
   352 # It uses $host_os $host_cpu $build_os $build_cpu and $with_target_bits
       
   353 PLATFORM_EXTRACT_TARGET_AND_BUILD_AND_LEGACY_VARS
       
   354 
       
   355 # The LEGACY_OPENJDK_TARGET_CPU3 is the setting for ISA_DIR.
       
   356 if test "x$LEGACY_OPENJDK_TARGET_CPU3" != x; then
       
   357    LEGACY_OPENJDK_TARGET_CPU3="/${LEGACY_OPENJDK_TARGET_CPU3}"
       
   358 fi
       
   359 
       
   360 # Now the following vars are defined.
       
   361 # OPENJDK_TARGET_OS=aix,bsd,hpux,linux,macosx,solaris,windows
       
   362 # OPENJDK_TARGET_OS_FAMILY=bsd,gnu,sysv,win32,wince
       
   363 # OPENJDK_TARGET_OS_API=posix,winapi
       
   364 #
       
   365 # OPENJDK_TARGET_CPU=ia32,x64,sparc,sparcv9,arm,arm64,ppc,ppc64
       
   366 # OPENJDK_TARGET_CPU_ARCH=x86,sparc,pcc,arm
       
   367 # OPENJDK_TARGET_CPU_BITS=32,64
       
   368 # OPENJDK_TARGET_CPU_ENDIAN=big,little
       
   369 #
       
   370 # There is also a:
       
   371 # LEGACY_OPENJDK_TARGET_CPU1=i586,amd64,....  # used to set the old var ARCH
       
   372 # LEGACY_OPENJDK_TARGET_CPU2=i386,amd64,.... # used to set the old var LIBARCH
       
   373 # LEGACY_OPENJDK_TARGET_CPU3=only sparcv9,amd64 # used to set the ISA_DIR on Solaris
       
   374 # There was also a BUILDARCH that had i486,amd64,... but we do not use that
       
   375 # in the new build.
       
   376 # LEGACY_OPENJDK_TARGET_OS_API=solaris,windows # used to select source roots
       
   377 ])
   358 ])
   378 
   359 
   379 AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_BUILD_OS_VERSION],
   360 AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_BUILD_OS_VERSION],
   380 [
   361 [
   381 ###############################################################################
   362 ###############################################################################
   389 AC_SUBST(OS_VERSION_MAJOR)
   370 AC_SUBST(OS_VERSION_MAJOR)
   390 AC_SUBST(OS_VERSION_MINOR)
   371 AC_SUBST(OS_VERSION_MINOR)
   391 AC_SUBST(OS_VERSION_MICRO)
   372 AC_SUBST(OS_VERSION_MICRO)
   392 ])
   373 ])
   393 
   374 
   394 AC_DEFUN_ONCE([PLATFORM_TEST_OPENJDK_TARGET_BITS],
   375 # Support macro for PLATFORM_SETUP_OPENJDK_TARGET_BITS.
       
   376 # Add -mX to various FLAGS variables.
       
   377 AC_DEFUN([PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS],
       
   378 [
       
   379   # keep track of c/cxx flags that we added outselves...
       
   380   #   to prevent emitting warning...
       
   381   ADDED_CFLAGS=" -m${OPENJDK_TARGET_CPU_BITS}"
       
   382   ADDED_CXXFLAGS=" -m${OPENJDK_TARGET_CPU_BITS}"
       
   383   ADDED_LDFLAGS=" -m${OPENJDK_TARGET_CPU_BITS}"
       
   384 
       
   385   CFLAGS="${CFLAGS}${ADDED_CFLAGS}"
       
   386   CXXFLAGS="${CXXFLAGS}${ADDED_CXXFLAGS}"
       
   387   LDFLAGS="${LDFLAGS}${ADDED_LDFLAGS}"
       
   388 
       
   389   CFLAGS_JDK="${CFLAGS_JDK}${ADDED_CFLAGS}"
       
   390   CXXFLAGS_JDK="${CXXFLAGS_JDK}${ADDED_CXXFLAGS}"
       
   391   LDFLAGS_JDK="${LDFLAGS_JDK}${ADDED_LDFLAGS}"
       
   392 ])
       
   393 
       
   394 AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_TARGET_BITS],
   395 [
   395 [
   396 ###############################################################################
   396 ###############################################################################
   397 #
   397 #
   398 # Now we check if libjvm.so will use 32 or 64 bit pointers for the C/C++ code.
   398 # Now we check if libjvm.so will use 32 or 64 bit pointers for the C/C++ code.
   399 # (The JVM can use 32 or 64 bit Java pointers but that decision
   399 # (The JVM can use 32 or 64 bit Java pointers but that decision
   400 # is made at runtime.)
   400 # is made at runtime.)
   401 #
   401 #
   402 AC_LANG_PUSH(C++)
   402 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
   403 OLD_CXXFLAGS="$CXXFLAGS"
   403   # Always specify -m flags on Solaris
   404 if test "x$OPENJDK_TARGET_OS" != xwindows && test "x$with_target_bits" != x; then
   404   PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS
   405 	CXXFLAGS="-m${with_target_bits} $CXXFLAGS"
   405 elif test "x$COMPILE_TYPE" = xreduced; then
       
   406   if test "x$OPENJDK_TARGET_OS" != xwindows; then
       
   407     # Specify -m if running reduced on other Posix platforms
       
   408     PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS
       
   409   fi
   406 fi
   410 fi
       
   411 
       
   412 # Make compilation sanity check
       
   413 AC_CHECK_HEADERS([stdio.h], , [
       
   414   AC_MSG_NOTICE([Failed to compile stdio.h. This likely implies missing compile dependencies.])
       
   415   if test "x$COMPILE_TYPE" = xreduced; then
       
   416     AC_MSG_NOTICE([You are doing a reduced build. Check that you have 32-bit libraries installed.])
       
   417   elif test "x$COMPILE_TYPE" = xcross; then
       
   418     AC_MSG_NOTICE([You are doing a cross-compilation. Check that you have all target platform libraries installed.])
       
   419   fi
       
   420   AC_MSG_ERROR([Cannot continue.])
       
   421 ])
       
   422 
   407 AC_CHECK_SIZEOF([int *], [1111])
   423 AC_CHECK_SIZEOF([int *], [1111])
   408 CXXFLAGS="$OLD_CXXFLAGS"
   424 
   409 AC_LANG_POP(C++)
   425 if test "x$SIZEOF_INT_P" != "x$ac_cv_sizeof_int_p"; then
   410 
   426   # Workaround autoconf bug, see http://lists.gnu.org/archive/html/autoconf/2010-07/msg00004.html
   411 # keep track of c/cxx flags that we added outselves...
   427   SIZEOF_INT_P="$ac_cv_sizeof_int_p"
   412 #   to prevent emitting warning...
   428 fi
   413 ADDED_CFLAGS=
   429 
   414 ADDED_CXXFLAGS=
   430 if test "x$SIZEOF_INT_P" = x; then 
   415 ADDED_LDFLAGS=
   431     # The test failed, lets stick to the assumed value.
   416 
   432     AC_MSG_WARN([The number of bits in the target could not be determined, using $OPENJDK_TARGET_CPU_BITS.])
   417 if test "x$ac_cv_sizeof_int_p" = x0; then 
       
   418     # The test failed, lets pick the assumed value.
       
   419     ARCH_DATA_MODEL=$OPENJDK_TARGET_CPU_BITS
       
   420 else
   433 else
   421     ARCH_DATA_MODEL=`expr 8 \* $ac_cv_sizeof_int_p`
   434     TESTED_TARGET_CPU_BITS=`expr 8 \* $SIZEOF_INT_P`
   422 
   435 
   423     if test "x$OPENJDK_TARGET_OS" != xwindows && test "x$with_target_bits" != x; then
   436     if test "x$TESTED_TARGET_CPU_BITS" != "x$OPENJDK_TARGET_CPU_BITS"; then
   424        ADDED_CFLAGS=" -m${with_target_bits}"
   437         AC_MSG_ERROR([The tested number of bits in the target ($TESTED_TARGET_CPU_BITS) differs from the number of bits expected to be found in the target ($OPENJDK_TARGET_CPU_BITS)])
   425        ADDED_CXXFLAGS=" -m${with_target_bits}"
       
   426        ADDED_LDFLAGS=" -m${with_target_bits}"
       
   427 
       
   428        CFLAGS="${CFLAGS}${ADDED_CFLAGS}"
       
   429        CXXFLAGS="${CXXFLAGS}${ADDED_CXXFLAGS}"
       
   430        LDFLAGS="${LDFLAGS}${ADDED_LDFLAGS}"
       
   431 
       
   432        CFLAGS_JDK="${CFLAGS_JDK}${ADDED_CFLAGS}"
       
   433        CXXFLAGS_JDK="${CXXFLAGS_JDK}${ADDED_CXXFLAGS}"
       
   434        LDFLAGS_JDK="${LDFLAGS_JDK}${ADDED_LDFLAGS}"
       
   435     fi
   438     fi
   436 fi
   439 fi
   437 
   440 
   438 if test "x$ARCH_DATA_MODEL" = x64; then
       
   439     A_LP64="LP64:="
       
   440     ADD_LP64="-D_LP64=1"
       
   441 fi
       
   442 AC_MSG_CHECKING([for target address size])
   441 AC_MSG_CHECKING([for target address size])
   443 AC_MSG_RESULT([$ARCH_DATA_MODEL bits])
   442 AC_MSG_RESULT([$OPENJDK_TARGET_CPU_BITS bits])
   444 AC_SUBST(LP64,$A_LP64)
       
   445 AC_SUBST(ARCH_DATA_MODEL)
       
   446 
       
   447 if test "x$ARCH_DATA_MODEL" != "x$OPENJDK_TARGET_CPU_BITS"; then
       
   448     AC_MSG_ERROR([The tested number of bits in the target ($ARCH_DATA_MODEL) differs from the number of bits expected to be found in the target ($OPENJDK_TARGET_CPU_BITS)])
       
   449 fi
       
   450 
       
   451 #
       
   452 # NOTE: check for -mstackrealign needs to be below potential addition of -m32
       
   453 #
       
   454 if test "x$OPENJDK_TARGET_CPU_BITS" = x32 && test "x$OPENJDK_TARGET_OS" = xmacosx; then
       
   455     # On 32-bit MacOSX the OS requires C-entry points to be 16 byte aligned.
       
   456     # While waiting for a better solution, the current workaround is to use -mstackrealign.
       
   457     CFLAGS="$CFLAGS -mstackrealign"
       
   458     AC_MSG_CHECKING([if 32-bit compiler supports -mstackrealign])
       
   459     AC_LINK_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])],
       
   460                    [
       
   461 		        AC_MSG_RESULT([yes])
       
   462                    ],
       
   463 	           [
       
   464 		        AC_MSG_RESULT([no])
       
   465 	                AC_MSG_ERROR([The selected compiler $CXX does not support -mstackrealign! Try to put another compiler in the path.])
       
   466 	           ])
       
   467 fi
       
   468 ])
   443 ])
   469 
   444 
   470 AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_TARGET_ENDIANNESS],
   445 AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_TARGET_ENDIANNESS],
   471 [
   446 [
   472 ###############################################################################
   447 ###############################################################################
   476 AC_C_BIGENDIAN([ENDIAN="big"],[ENDIAN="little"],[ENDIAN="unknown"],[ENDIAN="universal_endianness"])
   451 AC_C_BIGENDIAN([ENDIAN="big"],[ENDIAN="little"],[ENDIAN="unknown"],[ENDIAN="universal_endianness"])
   477 
   452 
   478 if test "x$ENDIAN" = xuniversal_endianness; then
   453 if test "x$ENDIAN" = xuniversal_endianness; then
   479     AC_MSG_ERROR([Building with both big and little endianness is not supported])
   454     AC_MSG_ERROR([Building with both big and little endianness is not supported])
   480 fi
   455 fi
   481 if test "x$ENDIAN" = xunknown; then
   456 if test "x$ENDIAN" != "x$OPENJDK_TARGET_CPU_ENDIAN"; then
   482     ENDIAN="$OPENJDK_TARGET_CPU_ENDIAN"
   457     AC_MSG_ERROR([The tested endian in the target ($ENDIAN) differs from the endian expected to be found in the target ($OPENJDK_TARGET_CPU_ENDIAN)])
   483 fi
   458 fi
   484 if test "x$ENDIAN" != "x$OPENJDK_TARGET_CPU_ENDIAN"; then
   459 ])
   485     AC_MSG_WARN([The tested endian in the target ($ENDIAN) differs from the endian expected to be found in the target ($OPENJDK_TARGET_CPU_ENDIAN)])
       
   486     ENDIAN="$OPENJDK_TARGET_CPU_ENDIAN"
       
   487 fi
       
   488 AC_SUBST(ENDIAN)
       
   489 ])
       
   490 
       
   491 AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_TARGET_ISADIR],
       
   492 [
       
   493 ###############################################################################
       
   494 #
       
   495 # Could someone enlighten this configure script with a comment about libCrun?
       
   496 #
       
   497 #
       
   498 ])