Skip to content

Commit

Permalink
Mk/**java.mk: Convert bsd.java.mk to USES
Browse files Browse the repository at this point in the history
The following features have been added or changed:
- Instead of USE_JAVA use USES=java. This defaults to
  USES=java:build,run if NO_BUILD is undefined. Else it defaults to
  USES=java:run
- Instead of USE_ANT=yes use USES=java:ant which also implies
  USES=java:build
- Instead of JAVA_BUILD=yes use USES=java:build. Does not imply run or
  extract
- Instead of JAVA_EXTRACT=yes use USES=java:extract does not imply
  build or run
- Instead of JAVA_RUN=yes use USES=java:run does not imply extract or
  build
- Instead of USE_JAVA=<version> use USES=java and JAVA_VERSION=<version>

Approved by: mat (portmgr), glewis
Differential Revision:  https://reviews.freebsd.org/D48201
  • Loading branch information
5u623l20 committed Dec 31, 2024
1 parent fbd8f89 commit 0835676
Show file tree
Hide file tree
Showing 538 changed files with 978 additions and 1,365 deletions.
19 changes: 19 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,25 @@ in the release notes and/or placed into UPDATING.

All ports committers are allowed to commit to this file.

20241231:
AUTHOR: [email protected]

Convert bsd.java.mk to USES

The following features have been added or changed:
- Instead of USE_JAVA use USES=java. This defaults to
USES=java:build,run if NO_BUILD is undefined. Else it defaults to
USES=java:run
- Instead of USE_ANT=yes use USES=java:ant which also implies
USES=java:build
- Instead of JAVA_BUILD=yes use USES=java:build. Does not imply run or
extract
- Instead of JAVA_EXTRACT=yes use USES=java:extract does not imply
build or run
- Instead of JAVA_RUN=yes use USES=java:run does not imply extract or
build
- Instead of USE_JAVA=<version> use USES=java and JAVA_VERSION=<version>

20241231:
AUTHOR: [email protected]

Expand Down
167 changes: 92 additions & 75 deletions Mk/bsd.java.mk → Mk/Uses/java.mk
Original file line number Diff line number Diff line change
@@ -1,51 +1,42 @@
#-*- tab-width: 4; -*-
# ex:ts=4
# Provide support for Java (java)
# Feature: java
# Usage: USES=java or USES=java:args
#
# bsd.java.mk - Support for Java-based ports.
# Defaults to USES=java:build,run if no arguments are provided and NO_BUILD is
# undefined. If NO_BUILD is defined, USES=java:run is used.
#
# Valid ARGS: ant build extract
#
# ant - Should be defined when the port uses Apache Ant. Ant is thus
# considered to be the sub-make command. When no 'do-build'
# target is defined by the port, a default one will be set
# that simply runs Ant according to MAKE_ENV, MAKE_ARGS and
# ALL_TARGET. Read the documentation in bsd.port.mk for more
# information.
#
# build - Add the JDK port to the build dependencies
#
# extract - Add the JDK port to the extract dependencies
#
# run - Add the JDK port to the run dependencies
#
# For FreeBSD committers:
# Please send all suggested changes to the maintainer instead of committing
# them yourself.
#

.if !defined(Java_Include)

Java_Include= bsd.java.mk
Java_Include_MAINTAINER= [email protected]

#-------------------------------------------------------------------------------
# Variables that each port can define:
#
# USE_JAVA Should be defined to the remaining variables to have any
# effect
#
# JAVA_VERSION List of space-separated suitable java versions for the
# port. An optional "+" allows you to specify a range of
# versions. (allowed values: 8[+] 11[+] 17[+] 18[+] 19[+]
# 20[+] 21[+] 22[+] 23[+])
# port. An optional "+" allows you to specify a range of
# versions. (allowed values: 8[+] 11[+] 17[+] 18[+] 19[+]
# 20[+] 21[+] 22[+] 23[+])
#
# JAVA_OS List of space-separated suitable JDK port operating systems
# for the port. (allowed values: native linux)
# JAVA_OS List of space-separated suitable JDK port operating systems
# for the port. (allowed values: native linux)
#
# JAVA_VENDOR List of space-separated suitable JDK port vendors for the
# port. (allowed values: openjdk oracle)
#
# JAVA_BUILD When set, it means that the selected JDK port should be
# added to build dependencies for the port.
#
# JAVA_EXTRACT This variable works exactly the same as JAVA_BUILD but
# regarding extract dependencies.
#
# JAVA_RUN This variable works exactly the same as JAVA_BUILD but
# regarding run dependencies.
#
# USE_ANT Should be defined when the port uses Apache Ant. Ant is thus
# considered to be the sub-make command. When no 'do-build'
# target is defined by the port, a default one will be set
# that simply runs Ant according to MAKE_ENV, MAKE_ARGS and
# ALL_TARGET. Read the documentation in bsd.port.mk for more
# information.
# port. (allowed values: openjdk oracle)
#
#-------------------------------------------------------------------------------
# Variables defined for the port:
Expand Down Expand Up @@ -125,12 +116,62 @@ Java_Include_MAINTAINER= [email protected]
# Stage 4: Add any dependencies if necessary
# Stage 5: Define all settings for the port to use
#
# MAINTAINER: [email protected]

.if !defined(_INCLUDE_USES_JAVA_MK)

_INCLUDE_USES_JAVA_MK= yes

. if defined(USE_JAVA)
_JAVA_VALID_ARGS= ant build extract run
_JAVA_UNKNOWN_ARGS=
. for arg in ${java_ARGS}
. if empty(_JAVA_VALID_ARGS:M${arg})
_JAVA_UNKNOWN_ARGS+= ${arg}
. endif
. endfor
. if !empty(_JAVA_UNKNOWN_ARGS)
IGNORE= has unknown USES=java arguments: ${_JAVA_UNKNOWN_ARGS}
. endif
. if empty(java_ARGS)
. if defined(NO_BUILD)
java_ARGS= run
. else
java_ARGS= build,run
. endif
. endif

. if !defined(JAVA_VERSION) && empty(USE_JAVA:C/[0-9]*[\.]*[0-9]*[+]*//)
JAVA_VERSION=${USE_JAVA}
. if !empty(java_ARGS)
.undef _USE_JAVA_ANT
.undef _USE_JAVA_BUILD
.undef _USE_JAVA_EXTRACT
.undef _USE_JAVA_RUN
_JAVA_ARGS= ${java_ARGS:S/,/ /g}
. if ${_JAVA_ARGS:Mextract}
_USE_JAVA_EXTRACT= yes
_JAVA_ARGS:= ${_JAVA_ARGS:Nextract}
. endif
. if ${_JAVA_ARGS:Mant}
. if defined(NO_BUILD)
IGNORE= Makefile error: NO_BUILD and USES=java:ant cannot be set at the same time
. else
_USE_JAVA_ANT= yes
_USE_JAVA_BUILD= yes
_JAVA_ARGS:= ${_JAVA_ARGS:Nant}
. endif
. endif
. if ${_JAVA_ARGS:Mbuild}
. if defined(NO_BUILD)
IGNORE= Makefile error: NO_BUILD and USES=java:build cannot be set at the same time
. else
_USE_JAVA_BUILD= yes
_JAVA_ARGS:= ${_JAVA_ARGS:Nbuild}
. endif
. endif
. if ${_JAVA_ARGS:Mrun}
_USE_JAVA_RUN= yes
_JAVA_ARGS:= ${_JAVA_ARGS:Nrun}
. endif
. endif # !empty(java_ARGS)

#-------------------------------------------------------------------------------
# Stage 1: Define constants
Expand Down Expand Up @@ -221,7 +262,6 @@ _JDK_FILE=bin/javac
# suitable
#

# From here, the port is using bsd.java.mk v2.0

# Error checking: defined JAVA_{HOME,PORT,PORT_VERSION,PORT_VENDOR,PORT_OS}
. for variable in JAVA_HOME JAVA_PORT JAVA_PORT_VERSION JAVA_PORT_VENDOR JAVA_PORT_OS
Expand Down Expand Up @@ -267,16 +307,6 @@ check-makevars::
${FALSE})
. endif

# Set default values for JAVA_BUILD and JAVA_RUN
# When nothing is set, assume JAVA_BUILD=jdk and JAVA_RUN=jre
# (unless NO_BUILD is set)
. if !defined(JAVA_EXTRACT) && !defined(JAVA_BUILD) && !defined(JAVA_RUN)
. if !defined(NO_BUILD)
JAVA_BUILD= jdk
. endif
JAVA_RUN= jre
. endif

# JDK dependency setting
. undef _JAVA_PORTS_INSTALLED
. undef _JAVA_PORTS_POSSIBLE
Expand Down Expand Up @@ -371,46 +401,36 @@ JAVA_PORT_OS_DESCRIPTION:= ${JAVA_PORT_OS:S/^/\${_JAVA_OS_/:S/$/}/}
# Stage 4: Add any dependencies if necessary
#

# Ant Support: USE_ANT --> JAVA_BUILD=jdk
. if defined(USE_ANT)
JAVA_BUILD= jdk
. endif

# Add the JDK port to the dependencies
DEPEND_JAVA= ${JAVA}:${JAVA_PORT}
. if defined(JAVA_EXTRACT)
. if defined(_USE_JAVA_EXTRACT)
EXTRACT_DEPENDS+= ${DEPEND_JAVA}
. endif
. if defined(JAVA_BUILD)
. if defined(NO_BUILD)
check-makevars::
@${ECHO_CMD} "${PKGNAME}: Makefile error: JAVA_BUILD and NO_BUILD cannot be set at the same time.";
@${FALSE}
. endif
. if defined(_USE_JAVA_BUILD)
BUILD_DEPENDS+= ${DEPEND_JAVA}
. endif
. if defined(JAVA_RUN)
. if defined(_USE_JAVA_RUN)
RUN_DEPENDS+= ${DEPEND_JAVA}
. endif

# Ant support: default do-build target
. if defined(USE_ANT)
DESTDIRNAME?= -Dfreebsd.ports.destdir
. if defined(_USE_JAVA_ANT)
DESTDIRNAME= -Dfreebsd.ports.destdir
ANT?= ${LOCALBASE}/bin/ant
MAKE_ENV+= JAVA_HOME=${JAVA_HOME}
BUILD_DEPENDS+= ${ANT}:devel/apache-ant
ALL_TARGET?=
. if !target(do-build)
do-build:
@(cd ${BUILD_WRKSRC}; ${SETENVI} ${WRK_ENV} ${MAKE_ENV} \
${ANT} ${MAKE_ARGS} ${ALL_TARGET})
@(cd ${BUILD_WRKSRC}; ${SETENVI} ${WRK_ENV} ${MAKE_ENV} \
${ANT} ${MAKE_ARGS} ${ALL_TARGET})
. endif
. if !target(do-test) && defined(TEST_TARGET)
TEST_DEPENDS+= ${DEPEND_JAVA}
TEST_DEPENDS+= ${ANT}:devel/apache-ant
do-test:
@(cd ${TEST_WRKSRC}; ${SETENVI} ${WRK_ENV} ${MAKE_ENV} \
${ANT} ${MAKE_ARGS} ${TEST_TARGET})
@(cd ${TEST_WRKSRC}; ${SETENVI} ${WRK_ENV} ${MAKE_ENV} \
${ANT} ${MAKE_ARGS} ${TEST_TARGET})
. endif
. endif

Expand All @@ -422,13 +442,11 @@ do-test:
# Define the location of the Java compiler.

# Only define JAVAC if a JDK is needed
. undef JAVAC
#. undef JAVAC

# Then test if a JAVAC has to be set (JAVA_BUILD==jdk)
. if defined(JAVA_BUILD)
. if (${JAVA_BUILD:tu} == "JDK") && !defined(JAVAC)
. if defined(_USE_JAVA_BUILD) && !defined(JAVAC)
JAVAC?= ${JAVA_HOME}/bin/javac
. endif
. endif

# Define the location of some more executables.
Expand Down Expand Up @@ -460,9 +478,9 @@ java-debug:
@${ECHO_CMD} "JAVA_VERSION= ${JAVA_VERSION} (${_JAVA_VERSION})"
@${ECHO_CMD} "JAVA_OS= ${JAVA_OS} (${_JAVA_OS})"
@${ECHO_CMD} "JAVA_VENDOR= ${JAVA_VENDOR} (${_JAVA_VENDOR})"
@${ECHO_CMD} "JAVA_BUILD= ${JAVA_BUILD}"
@${ECHO_CMD} "JAVA_RUN= ${JAVA_RUN}"
@${ECHO_CMD} "JAVA_EXTRACT= ${JAVA_EXTRACT}"
@${ECHO_CMD} "JAVA_BUILD= ${_USE_JAVA_BUILD}"
@${ECHO_CMD} "JAVA_RUN= ${_USE_JAVA_RUN}"
@${ECHO_CMD} "JAVA_EXTRACT= ${_USE_JAVA_EXTRACT}"
@${ECHO_CMD} "JAVA_DEFAULT= ${JAVA_DEFAULT}"
@${ECHO_CMD}
@${ECHO_CMD} "# JDK port dependency selection process:"
Expand All @@ -483,5 +501,4 @@ java-debug:
@${ECHO_CMD} "JAVAC= ${JAVAC}"
@${ECHO_CMD} "JAVA_CLASSES= ${JAVA_CLASSES}"

. endif
.endif
11 changes: 0 additions & 11 deletions Mk/bsd.port.mk
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,6 @@ FreeBSD_MAINTAINER= [email protected]
##
# LDFLAGS_${ARCH} Append the ldflags to LDFLAGS only on the specified architecture
##
# USE_JAVA - If set, this port relies on the Java language.
# Implies inclusion of bsd.java.mk. (Also see
# that file for more information on USE_JAVA_*).
##
# USE_GECKO - If set, this port uses the Gecko/Mozilla product.
# See bsd.gecko.mk for more details.
Expand Down Expand Up @@ -1402,10 +1399,6 @@ PKGCOMPATDIR?= ${LOCALBASE}/lib/compat/pkg
.sinclude "${odir}/Mk/bsd.overlay.mk"
. endfor

. if defined(USE_JAVA)
.include "${PORTSDIR}/Mk/bsd.java.mk"
. endif

. if defined(USE_APACHE_BUILD)
USES+= apache:build,${USE_APACHE_BUILD:C/2([0-9])/2.\1/g}
. elif defined(USE_APACHE_RUN)
Expand Down Expand Up @@ -1925,10 +1918,6 @@ PKGPOSTDEINSTALL?= ${PKGDIR}/pkg-post-deinstall
.sinclude "${odir}/Mk/bsd.overlay.mk"
. endfor

. if defined(USE_JAVA)
.include "${PORTSDIR}/Mk/bsd.java.mk"
. endif

. if defined(USE_WX) || defined(USE_WX_NOT)
.include "${PORTSDIR}/Mk/bsd.wx.mk"
. endif
Expand Down
8 changes: 7 additions & 1 deletion Mk/bsd.sanity.mk
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ SANITY_UNSUPPORTED= USE_OPENAL USE_FAM USE_MAKESELF USE_ZIP USE_LHA USE_CMAKE \
USE_OPENLDAP WANT_OPENLDAP_VER USE_OCAML USE_OCAML_CAMLP4 USE_OCAML_WASH \
USE_OCAML_TK NO_OCAMLTK_BUILDDEPENDS NO_OCAMLTK_RUNDEPENDS \
USE_OCAMLFIND_PLIST USE_OCAML_FINDLIB USE_OCAML_LDCONFIG \
NO_OCAML_BUILDDEPENDS NO_OCAML_RUNDEPENDS
NO_OCAML_BUILDDEPENDS NO_OCAML_RUNDEPENDS USE_JAVA JAVA_BUILD \
JAVA_EXTRACT USE_ANT JAVA_RUN
SANITY_DEPRECATED= MLINKS \
USE_MYSQL WANT_MYSQL_VER \
PYDISTUTILS_INSTALLNOSINGLE
Expand Down Expand Up @@ -321,6 +322,11 @@ NO_OCAMLTK_BUILDDEPENDS_ALT= USES=ocaml:tkrun
NO_OCAMLTK_RUNDEPENDS_ALT= USES=ocaml:tkbuild
NO_OCAML_BUILDDEPENDS_ALT= USES=ocaml:run
NO_OCAML_RUNDEPENDS_ALT= USES=ocaml:build
USE_ANT_ALT= USES=java:ant
USE_JAVA_ALT= USES=java
JAVA_EXTRACT_ALT= USES=java:extract
JAVA_BUILD_ALT= USES=java:build
JAVA_RUN_ALT= USES=java:run

.for a in ${SANITY_DEPRECATED}
. if defined(${a})
Expand Down
3 changes: 1 addition & 2 deletions archivers/apache-commons-compress/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ WWW= https://commons.apache.org/proper/commons-compress/

LICENSE= APACHE20

USE_JAVA= yes
JAVA_VERSION= 8+
USES= java

WRKSRC= ${WRKDIR}/${PORTNAME}-${PORTVERSION}
NO_BUILD= yes
Expand Down
2 changes: 1 addition & 1 deletion archivers/javatar/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ WWW= http://www.trustice.com/java/tar/
LICENSE= PD
LICENSE_FILE= ${WRKSRC}/doc/LICENSE

USE_JAVA= yes
USES= java

NO_BUILD= yes

Expand Down
4 changes: 1 addition & 3 deletions archivers/snappy-java/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ LICENSE= APACHE20
BUILD_DEPENDS= cmake:devel/cmake-core \
sbt:devel/sbt

USES= gmake
USES= gmake java:build

USE_GITHUB= yes
GH_ACCOUNT= xerial
Expand All @@ -36,8 +36,6 @@ GH_TUPLE= google:snappy:${DISTVERSION:R}:google \
google:googletest:b796f7d:google_googletest/google_googletest \
kiyo-masui:bitshuffle:${BITSHUFFLE_V}:masui

USE_JAVA= yes
JAVA_BUILD= jre # prevent JAVA_RUN via bsd.java.mk
USE_LDCONFIG= yes
MAKE_ARGS+= CXX="${CXX}"
TEST_TARGET= test
Expand Down
2 changes: 1 addition & 1 deletion astro/gpsprune/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ NO_WRKSUBDIR= yes
NO_BUILD= yes
NO_ARCH= yes

USE_JAVA= yes
USES= java
JAVA_VERSION= 11+

SUB_FILES= gpsprune.sh
Expand Down
3 changes: 1 addition & 2 deletions astro/josm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ PORTSCOUT= ignore:1

NO_WRKSUBDIR= yes

USES= zip:infozip
USE_JAVA= yes
USES= java zip:infozip
JAVA_VERSION= 11+

NO_BUILD= yes
Expand Down
Loading

0 comments on commit 0835676

Please sign in to comment.