Annotation of pkgsrc/mk/java-vm.mk, revision 1.103

1.103   ! ryoon       1: # $NetBSD: java-vm.mk,v 1.102 2015/06/02 20:37:01 ryoon Exp $
1.1       jlam        2: #
                      3: # This Makefile fragment handles Java dependencies and make variables,
                      4: # and is meant to be included by packages that require Java either at
1.48      rillig      5: # build-time or at run-time.
1.1       jlam        6: #
1.48      rillig      7: # User-settable variables:
1.1       jlam        8: #
1.48      rillig      9: # PKG_JVM_DEFAULT
                     10: #      The JVM that should be used if nothing particular is specified.
1.1       jlam       11: #
1.99      tnn        12: #      Possible values: kaffe openjdk7 openjdk8
1.102     ryoon      13: #              sun-jdk6 sun-jdk7 oracle-jdk8
1.48      rillig     14: #      Default value: (platform-dependent)
1.14      jlam       15: #
1.48      rillig     16: # Package-settable variables:
1.4       jlam       17: #
1.48      rillig     18: # USE_JAVA
1.71      obache     19: #      When set to "yes", a build-time dependency on the JDK and
                     20: #                         a run-time dependency on the JRE are added.
1.48      rillig     21: #      When set to "run", a run-time dependency on the JRE is added.
1.71      obache     22: #      When set to "build", a build-time dependency on the JRE is added.
1.1       jlam       23: #
1.71      obache     24: #      Possible values: yes run build
1.48      rillig     25: #      Default value: yes
                     26: #
                     27: # USE_JAVA2
                     28: #      When the package needs a Java 2 implementation, this variable
1.97      ryoon      29: #      should be set to "yes". It can also be set to "1.4", "1.5", "6".
                     30: #      "7" or "8" require an even more recent implementation.
1.48      rillig     31: #
1.96      tnn        32: #      Possible values: yes no 1.4 1.5 6 7 8
1.49      rillig     33: #      Default value: no
1.48      rillig     34: #
                     35: # PKG_JVMS_ACCEPTED
                     36: #      The list of JVMs that may be used as possible implementations.
                     37: #
                     38: # Variables set by this file:
                     39: #
1.58      rillig     40: # JAVA_BINPREFIX
                     41: #      The prefix for the Java binaries. The path to the real binaries
                     42: #      is constructed by appending -${program} to it.
                     43: #
                     44: #      Examples:
                     45: #      * ${JAVA_BINPREFIX}-java is the path to the Java interpreter.
                     46: #      * ${JAVA_BINPREFIX}-javac is the path to the Java compiler.
                     47: #
1.48      rillig     48: # PKG_JVM
                     49: #      The name of the selected Java implementation.
                     50: #
                     51: # PKG_JAVA_HOME
                     52: #      The directory where the JVM is installed.
1.1       jlam       53: #
                     54: 
                     55: .if !defined(JAVA_VM_MK)
                     56: JAVA_VM_MK=    # defined
                     57: 
1.58      rillig     58: _VARGROUPS+=           java
                     59: _USER_VARS.java=       PKG_JVM_DEFAULT
                     60: _PKG_VARS.java=                USE_JAVA USE_JAVA2 PKG_JVMS_ACCEPTED
                     61: _SYS_VARS.java=                PKG_JVM PKG_JAVA_HOME JAVA_BINPREFIX
                     62: 
1.1       jlam       63: .include "../../mk/bsd.prefs.mk"
                     64: 
1.3       jlam       65: USE_JAVA?=     yes
1.49      rillig     66: USE_JAVA2?=    no
1.1       jlam       67: 
                     68: PKG_JVM_DEFAULT?=      # empty
                     69: PKG_JVMS_ACCEPTED?=    ${_PKG_JVMS}
                     70: 
1.54      rillig     71: # This is a list of all of the JDKs that may be used.
1.3       jlam       72: #
1.102     ryoon      73: _PKG_JVMS.8=           openjdk8 oracle-jdk8
1.99      tnn        74: _PKG_JVMS.7=           ${_PKG_JVMS.8} openjdk7 sun-jdk7
1.76      wiz        75: _PKG_JVMS.6=           ${_PKG_JVMS.7} sun-jdk6 jdk16
1.73      wiz        76: _PKG_JVMS.1.5=         ${_PKG_JVMS.6} jdk15
1.74      obache     77: _PKG_JVMS.1.4=         ${_PKG_JVMS.1.5}
1.63      wiz        78: _PKG_JVMS.yes=         ${_PKG_JVMS.1.4} kaffe
1.74      obache     79: _PKG_JVMS.no=          ${_PKG_JVMS.yes}
1.49      rillig     80: _PKG_JVMS=             ${_PKG_JVMS.${USE_JAVA2}}
1.1       jlam       81: 
                     82: # To be deprecated: if PKG_JVM is explicitly set, then use it as the
                     83: # default JVM.  Note that this has lower precedence than PKG_JVM_DEFAULT.
                     84: #
                     85: .if defined(PKG_JVM)
                     86: .  if !empty(PKG_JVM)
                     87: _PKG_JVM_DEFAULT:=     ${PKG_JVM}
                     88: .  endif
                     89: .endif
                     90: 
                     91: # Set the default JVM for this platform.
                     92: #
                     93: .if !empty(PKG_JVM_DEFAULT)
                     94: _PKG_JVM_DEFAULT=      ${PKG_JVM_DEFAULT}
                     95: .endif
                     96: .if !defined(_PKG_JVM_DEFAULT)
1.98      tnn        97: .  if   !empty(MACHINE_PLATFORM:MNetBSD-[56789].*-i386) || \
                     98:         !empty(MACHINE_PLATFORM:MNetBSD-[56789].*-x86_64)
1.103   ! ryoon      99: _PKG_JVM_DEFAULT?=     openjdk8
1.101     szptvlfn  100: .  elif !empty(MACHINE_PLATFORM:MNetBSD-[789].*-sparc64) || \
1.100     tnn       101:        !empty(MACHINE_PLATFORM:MNetBSD-[789].*-earmv[67]hf)
1.98      tnn       102: _PKG_JVM_DEFAULT?=     openjdk8
1.68      abs       103: .  elif !empty(MACHINE_PLATFORM:MNetBSD-*-i386) || \
1.98      tnn       104:         !empty(MACHINE_PLATFORM:MLinux-*-i[3456]86) || \
                    105:         !empty(MACHINE_PLATFORM:MLinux-*-x86_64)
1.73      wiz       106: _PKG_JVM_DEFAULT?=     sun-jdk6
1.1       jlam      107: .  elif !empty(MACHINE_PLATFORM:MDarwin-*-*)
1.73      wiz       108: _PKG_JVM_DEFAULT?=     sun-jdk6
1.92      jperkin   109: .  elif !empty(MACHINE_PLATFORM:MSunOS-5.11-i386) || \
                    110:         !empty(MACHINE_PLATFORM:MSunOS-5.11-x86_64)
1.91      jperkin   111: _PKG_JVM_DEFAULT?=     openjdk7
1.87      marino    112: .  elif !empty(MACHINE_PLATFORM:MDragonFly-*-*)
                    113: _PKG_JVM_DEFAULT?=     openjdk7
1.1       jlam      114: .  else
                    115: _PKG_JVM_DEFAULT?=     kaffe
                    116: .  endif
                    117: .endif
                    118: 
                    119: # These lists are copied from the JVM package Makefiles.
1.34      tv        120: _ONLY_FOR_PLATFORMS.kaffe= \
1.84      dholland  121:        *-*-alpha *-*-arm *-*-arm32 *-*-i386 *-*-m68k \
1.96      tnn       122:        *-*-mipsel* *-*-sparc *-*-powerpc
1.86      dholland  123: # exclude *-*-x86_64 from kaffe list as it apparently doesn't work
1.55      tv        124: _ONLY_FOR_PLATFORMS.sun-jdk6= \
1.81      yyamano   125:        Darwin-9.*-i386 Darwin-9.*-x86_64 \
                    126:        Darwin-10.*-i386 Darwin-10.*-x86_64 \
                    127:        Darwin-11.*-i386 Darwin-11.*-x86_64 \
1.55      tv        128:        DragonFly-*-i386 \
                    129:        FreeBSD-6.*-i386 \
                    130:        Linux-*-i[3-6]86 \
1.78      abs       131:        Linux-*-x86_64 \
1.67      christos  132:        NetBSD-*-i386 NetBSD-*-x86_64 \
1.94      tron      133:        SunOS-5.10-i386 \
1.93      tron      134:        SunOS-5.10-sparc \
1.94      tron      135:        SunOS-5.10-x86_64 \
1.89      jperkin   136:        SunOS-5.11-i386 \
                    137:        SunOS-5.11-x86_64
1.70      wiz       138: _ONLY_FOR_PLATFORMS.openjdk7= \
1.83      marino    139:        DragonFly-*-* \
1.96      tnn       140:        NetBSD-[5-9]*-i386 \
1.91      jperkin   141:        NetBSD-[5-9]*-x86_64 \
1.98      tnn       142:        NetBSD-[7-9]*-sparc64 \
1.100     tnn       143:        NetBSD-[7-9]*-earmv[67]hf \
1.96      tnn       144:        SunOS-*-i386 \
                    145:        SunOS-*-x86_64
                    146: _ONLY_FOR_PLATFORMS.openjdk8= \
                    147:        DragonFly-*-* \
                    148:        NetBSD-[5-9]*-i386 \
                    149:        NetBSD-[5-9]*-x86_64 \
1.98      tnn       150:        NetBSD-[7-9]*-sparc64 \
1.100     tnn       151:        NetBSD-[7-9]*-earmv[67]hf \
1.96      tnn       152:        SunOS-*-i386 \
                    153:        SunOS-*-x86_64
1.90      ryoon     154: _ONLY_FOR_PLATFORMS.sun-jdk7= \
                    155:        Darwin-9.*-i386 Darwin-9.*-x86_64 \
1.95      tron      156:        Darwin-[1-9][0-9].*-i386 Darwin-[1-9][0-9].*-x86_64 \
1.90      ryoon     157:        DragonFly-*-i386 \
                    158:        FreeBSD-6.*-i386 \
                    159:        Linux-*-i[3-6]86 \
                    160:        Linux-*-x86_64 \
                    161:        NetBSD-[6-9]*-i386 NetBSD-[6-9]*-x86_64 \
                    162:        SunOS-5.11-i386 \
                    163:        SunOS-5.11-x86_64
1.102     ryoon     164: _ONLY_FOR_PLATFORMS.oracle-jdk8= \
                    165:        Darwin-9.*-i386 Darwin-9.*-x86_64 \
                    166:        Darwin-[1-9][0-9].*-i386 Darwin-[1-9][0-9].*-x86_64 \
                    167:        DragonFly-*-i386 \
                    168:        FreeBSD-6.*-i386 \
                    169:        Linux-*-i[3-6]86 \
                    170:        Linux-*-x86_64 \
                    171:        NetBSD-[6-9]*-i386 NetBSD-[6-9]*-x86_64 \
                    172:        SunOS-5.11-x86_64
1.1       jlam      173: 
1.88      sbd       174: # Set ONLY_FOR_PLATFORM based on accepted JVMs
                    175: .for _jvm_ in ${PKG_JVMS_ACCEPTED}
                    176: ONLY_FOR_PLATFORM+=    ${_ONLY_FOR_PLATFORMS.${_jvm_}}
                    177: .endfor
                    178: 
1.1       jlam      179: # Set the accepted JVMs for this platform.
                    180: .for _jvm_ in ${_PKG_JVMS}
                    181: .  for _pattern_ in ${_ONLY_FOR_PLATFORMS.${_jvm_}}
                    182: .    if !empty(MACHINE_PLATFORM:M${_pattern_})
                    183: _PKG_JVMS_ACCEPTED+=   ${PKG_JVMS_ACCEPTED:M${_jvm_}}
                    184: .    endif
                    185: .  endfor
                    186: .endfor
                    187: 
1.34      tv        188: _JAVA_PKGBASE.kaffe=           kaffe
1.70      wiz       189: _JAVA_PKGBASE.openjdk7=                openjdk7
1.96      tnn       190: _JAVA_PKGBASE.openjdk8=                openjdk8
1.55      tv        191: _JAVA_PKGBASE.sun-jdk6=                sun-jre6
1.90      ryoon     192: _JAVA_PKGBASE.sun-jdk7=                sun-jre7
1.102     ryoon     193: _JAVA_PKGBASE.oracle-jdk8=     oracle-jre8
1.1       jlam      194: 
1.58      rillig    195: # The following is copied from the respective JVM Makefiles.
                    196: _JAVA_NAME.kaffe=              kaffe
1.70      wiz       197: _JAVA_NAME.openjdk7=           openjdk7
1.96      tnn       198: _JAVA_NAME.openjdk8=           openjdk8
1.58      rillig    199: _JAVA_NAME.sun-jdk6=           sun6
1.90      ryoon     200: _JAVA_NAME.sun-jdk7=           sun7
1.102     ryoon     201: _JAVA_NAME.oracle-jdk8=                oracle8
1.58      rillig    202: 
1.1       jlam      203: # Mark the acceptable JVMs and check which JVM packages are installed.
                    204: .for _jvm_ in ${_PKG_JVMS_ACCEPTED}
                    205: _PKG_JVM_OK.${_jvm_}=  yes
                    206: _PKG_JVM_INSTALLED.${_jvm_}!= \
                    207:        if ${PKG_INFO} -qe ${_JAVA_PKGBASE.${_jvm_}}; then              \
                    208:                ${ECHO} yes;                                            \
                    209:        else                                                            \
                    210:                ${ECHO} no;                                             \
                    211:        fi
                    212: .endfor
                    213: 
                    214: # Use one of the installed JVMs,...
                    215: #
                    216: .if !defined(_PKG_JVM)
                    217: .  for _jvm_ in ${_PKG_JVMS_ACCEPTED}
                    218: .    if !empty(_PKG_JVM_INSTALLED.${_jvm_}:M[yY][eE][sS])
                    219: _PKG_JVM?=     ${_jvm_}
                    220: .    else
                    221: _PKG_JVM_FIRSTACCEPTED?= ${_jvm_}
                    222: .    endif
                    223: .  endfor
                    224: #
                    225: # ...otherwise, prefer the default one if it's accepted,...
                    226: #
                    227: .  if defined(_PKG_JVM_OK.${_PKG_JVM_DEFAULT}) && \
                    228:       !empty(_PKG_JVM_OK.${_PKG_JVM_DEFAULT}:M[yY][eE][sS])
                    229: _PKG_JVM=      ${_PKG_JVM_DEFAULT}
                    230: .  endif
                    231: .endif
                    232: #
                    233: # ...otherwise, just use the first accepted JVM.
                    234: #
                    235: .if !defined(_PKG_JVM)
                    236: .  if defined(_PKG_JVM_FIRSTACCEPTED)
                    237: _PKG_JVM=      ${_PKG_JVM_FIRSTACCEPTED}
                    238: .  endif
                    239: .endif
                    240: #
                    241: # If there are no acceptable JVMs, then generate an error.
                    242: #
                    243: .if !defined(_PKG_JVM)
                    244: # force an error
1.53      rillig    245: PKG_FAIL_REASON=       "no acceptable JVM found"
1.8       dmcmahil  246: _PKG_JVM=              "none"
1.1       jlam      247: .endif
                    248: 
1.45      reed      249: BUILDLINK_API_DEPENDS.kaffe?=          kaffe>=1.1.4
1.70      wiz       250: BUILDLINK_API_DEPENDS.openjdk7?=       openjdk7-[0-9]*
1.96      tnn       251: BUILDLINK_API_DEPENDS.openjdk8?=       openjdk8-[0-9]*
1.68      abs       252: BUILDLINK_API_DEPENDS.sun-jdk6?=       sun-jdk6-[0-9]*
                    253: BUILDLINK_API_DEPENDS.sun-jre6?=       sun-jre6-[0-9]*
1.90      ryoon     254: BUILDLINK_API_DEPENDS.sun-jdk7?=       sun-jdk7-[0-9]*
                    255: BUILDLINK_API_DEPENDS.sun-jre7?=       sun-jre7-[0-9]*
1.102     ryoon     256: BUILDLINK_API_DEPENDS.oracle-jdk8?=    oracle-jdk8-[0-9]*
                    257: BUILDLINK_API_DEPENDS.oracle-jre8?=    oracle-jre8-[0-9]*
1.30      wiz       258: 
1.34      tv        259: _JRE.kaffe=            kaffe
1.70      wiz       260: _JRE.openjdk7=         openjdk7
1.96      tnn       261: _JRE.openjdk8=         openjdk8
1.55      tv        262: _JRE.sun-jdk6=         sun-jre6
1.90      ryoon     263: _JRE.sun-jdk7=         sun-jre7
1.102     ryoon     264: _JRE.oracle-jdk8=      oracle-jre8
1.7       jlam      265: 
1.5       abs       266: _JAVA_BASE_CLASSES=    classes.zip
                    267: 
1.98      tnn       268: .if ${_PKG_JVM} == "kaffe"
1.34      tv        269: _JDK_PKGSRCDIR=                ../../lang/kaffe
                    270: _JRE_PKGSRCDIR=                ${_JDK_PKGSRCDIR}
                    271: _JAVA_HOME_DEFAULT=    ${LOCALBASE}/java/kaffe
1.70      wiz       272: .elif ${_PKG_JVM} == "openjdk7"
                    273: _JDK_PKGSRCDIR=                ../../lang/openjdk7
                    274: _JRE_PKGSRCDIR=                ${_JDK_PKGSRCDIR}
                    275: _JAVA_HOME_DEFAULT=    ${LOCALBASE}/java/openjdk7
1.96      tnn       276: .elif ${_PKG_JVM} == "openjdk8"
                    277: _JDK_PKGSRCDIR=                ../../lang/openjdk8
                    278: _JRE_PKGSRCDIR=                ${_JDK_PKGSRCDIR}
                    279: _JAVA_HOME_DEFAULT=    ${LOCALBASE}/java/openjdk8
1.55      tv        280: .elif ${_PKG_JVM} == "sun-jdk6"
                    281: _JDK_PKGSRCDIR=                ../../lang/sun-jdk6
                    282: _JRE_PKGSRCDIR=                ../../lang/sun-jre6
                    283: _JAVA_HOME_DEFAULT=    ${LOCALBASE}/java/sun-6
                    284: UNLIMIT_RESOURCES+=    datasize
1.90      ryoon     285: .elif ${_PKG_JVM} == "sun-jdk7"
                    286: _JDK_PKGSRCDIR=                ../../lang/sun-jdk7
                    287: _JRE_PKGSRCDIR=                ../../lang/sun-jre7
                    288: _JAVA_HOME_DEFAULT=    ${LOCALBASE}/java/sun-7
                    289: UNLIMIT_RESOURCES+=    datasize
1.102     ryoon     290: .elif ${_PKG_JVM} == "oracle-jdk8"
                    291: _JDK_PKGSRCDIR=                ../../lang/oracle-jdk8
                    292: _JRE_PKGSRCDIR=                ../../lang/oracle-jre8
                    293: _JAVA_HOME_DEFAULT=    ${LOCALBASE}/java/oracle-8
                    294: UNLIMIT_RESOURCES+=    datasize
1.1       jlam      295: .endif
                    296: 
1.27      tron      297: .if defined(_JAVA_HOME_DEFAULT)
                    298: _JAVA_HOME=            ${_JAVA_HOME_DEFAULT}
                    299: .else
1.1       jlam      300: EVAL_PREFIX+=          _JAVA_HOME=${_JAVA_PKGBASE.${_PKG_JVM}}
1.27      tron      301: .endif
1.1       jlam      302: 
1.71      obache    303: # If we are not using Java for building, then we need a run-time dependency on
                    304: # the JRE, otherwise, build-time dependency on the JRE.
1.10      dmcmahil  305: .if defined(_JRE_PKGSRCDIR)
1.39      tv        306: .  if exists(${_JRE_PKGSRCDIR}/buildlink3.mk)
1.71      obache    307: .    if !empty(USE_JAVA:M[bB][uU][iI][lL][dD])
                    308: BUILDLINK_DEPMETHOD.${_JRE.${_PKG_JVM}}=       build
                    309: .    endif
1.39      tv        310: .    include "${_JRE_PKGSRCDIR}/buildlink3.mk"
1.24      xtraeme   311: .  endif
1.1       jlam      312: .endif
                    313: 
                    314: # If we are building Java software, then we need a build-time dependency on
                    315: # the JDK.
                    316: #
1.71      obache    317: .if !empty(USE_JAVA:M[yE][eE][sS])
1.24      xtraeme   318: .  if defined(_JDK_PKGSRCDIR)
1.39      tv        319: .    if exists(${_JDK_PKGSRCDIR}/buildlink3.mk)
                    320: .      include "${_JDK_PKGSRCDIR}/buildlink3.mk"
1.11      dmcmahil  321: .    endif
1.1       jlam      322: .  endif
                    323: .endif
                    324: 
                    325: PKG_JVM:=              ${_PKG_JVM}
                    326: .if defined(BUILDLINK_JAVA_PREFIX.${_PKG_JVM})
                    327: PKG_JAVA_HOME?=                ${BUILDLINK_JAVA_PREFIX.${_PKG_JVM}}
                    328: .else
                    329: PKG_JAVA_HOME?=                ${_JAVA_HOME}
                    330: .endif
1.37      tv        331: .if !defined(CLASSPATH)
                    332: CLASSPATH_cmd=         ${ECHO} `for p in                                       \
                    333:                                ${PKG_JAVA_HOME}/lib/${_JAVA_BASE_CLASSES}      \
                    334:                                ${PKG_JAVA_HOME}/lib/tools.jar; do              \
                    335:                        ${TEST} ! -f $$p || ${ECHO} $$p; done`                  \
                    336:                        . | ${TR} ' ' :
                    337: CLASSPATH?=            ${CLASSPATH_cmd:sh}
                    338: .endif
                    339: 
1.38      tv        340: ALL_ENV+=              CLASSPATH=${CLASSPATH:Q}
                    341: ALL_ENV+=              JAVA_HOME=${PKG_JAVA_HOME}
1.58      rillig    342: BUILD_DEFS+=           ${_USER_VARS.java}
                    343: BUILD_DEFS_EFFECTS+=   ${_SYS_VARS.java}
1.43      rillig    344: MAKEFLAGS+=            PKG_JVM=${PKG_JVM:Q}
1.37      tv        345: PREPEND_PATH+=         ${PKG_JAVA_HOME}/bin
1.58      rillig    346: JAVA_BINPREFIX=                ${LOCALBASE}/bin/${_JAVA_NAME.${_PKG_JVM}}
1.1       jlam      347: 
1.60      jlam      348: PLIST_SUBST+=          PKG_JAVA_HOME=${PKG_JAVA_HOME:Q}
                    349: FILES_SUBST+=          PKG_JAVA_HOME=${PKG_JAVA_HOME:Q}
                    350: 
1.1       jlam      351: .endif # JAVA_VM_MK

CVSweb <webmaster@jp.NetBSD.org>