On 2021/11/14 17:07, Clemens Gößnitzer wrote:
> I am currently working on porting the scotch library[1] to OpenBSD.  It 
> compiles
> fine.  However, I am facing some troubles ports-wise.  I cannot make the port
> pick up the libraries and headers and install them in the correct location.
> 
> The port is built in ${WORKSRC}/src, and it puts the libraries and headers in
> ${WORKSRC}/{lib,include}, respectively.  How do I teach the port to pick up 
> this
> location?
> 
> I am also not so sure about the patch:  It just installs a new Makefile.  I 
> will
> upstream this once the port gets accepted.
> 
> Thanks.
> 
> [1] https://www.labri.fr/perso/pelegrin/scotch/

The attached version gets you further. Not enough yet, the libraries
will need to be built with correct versioned filenames, for some clues
see https://www.openbsd.org/faq/ports/specialtopics.html#SharedLibs

comments inline in a diff:

> diff --git math/scotch/Makefile math/scotch/Makefile
> index 06eed7c..ba6b354 100644
> --- math/scotch/Makefile
> +++ math/scotch/Makefile
> @@ -1,12 +1,10 @@
>  # $OpenBSD$
>  
> -# dependency for OpenFOAM
> -ONLY_FOR_ARCHS =     amd64
> -

Ports shouldn't be restricted for artificial reasons, if a port can be
built on an arch then it should be allowed to build. ONLY_FOR_ARCHS
is normally used in cases where the source code will not build on a
particular arch unless it has specific support for that arch, and in
that case it's set to working archs - it's also sometimes used if we
know that a required dependency only works on a restricted set of archs.

>  COMMENT =            decomposition library for parallel numerical 
> applications
>  
> -V =                  v6.1.2
> -DISTNAME =           scotch-${V}
> +V =                  6.1.2
> +DISTNAME =           scotch-v${V}
> +PKGNAME =            scotch-${V}

the previous PKGNAME scotch-v6.1.2 doesn't match the allowed format,
must be -6.1.2

>  SHARED_LIBS =                esmumps                 0.0
>  SHARED_LIBS +=               ptscotch                0.0
> @@ -30,20 +28,22 @@ PERMIT_PACKAGE =  Yes
>  # XXX ToDo "make port-lib-depends-check" can help
>  #WANTLIB =           ???
>  
> -MASTER_SITES =               
> https://gitlab.inria.fr/scotch/scotch/-/archive/${V}/
> +MASTER_SITES =               
> https://gitlab.inria.fr/scotch/scotch/-/archive/v${V}/
> -BUILD_DEPENDS =              devel/openmpi

this is a LIB_DEPENDS not just a BUILD_DEPENDS

>  
> -SEPARATE_BUILD =     Yes

> -USE_GMAKE =          Yes
> +WRKSRC =             ${WRKDIST}/src
>  
> -WRKBUILD =           ${WRKSRC}/src

SEPARATE_BUILD is for "out of source tree" builds, typically where you
cd to a build directory that does not contain the source files, and run
a configure tool with a full path to the source directory, and it then
generates build files. That's not what happens here, it just needs to
be pointed to the correct dir in WRKSRC

> +LIB_DEPENDS =                devel/openmpi
> +
> +USE_GMAKE =          Yes
>  ALL_TARGET =         scotch ptscotch esmumps
>  
> -pre-build:
> -     cp ${WRKBUILD}/Make.inc/Makefile.inc.x86-64_pc_openbsd 
> ${WRKBUILD}/Makefile.inc
> +MAKE_ENV =           prefix="${WRKINST}${PREFIX}" \
> +                     mandir="${WRKINST}${PREFIX}/man" \

This (and removing the custom install target) is what fixes the install
issue. It's preferred to use upstream install infrastructure unless it needs
to be so heavily patched that it's a complete rewrite. That way changes in
future updates are less likely to be missed. The issue was that upstream's
makefiles use lower-case "prefix" so the variable set by default by ports
(PREFIX) doesn't work.

> +                     CCS="${CC}" \
> +                     CCD="${CC}" \

compiler command names should be under control of the ports tree rather
than hardcoded in makefiles, e.g. the ports tree user should be able to type
"CC=egcc make" to compile with gcc.

> +                     MAKE="${MAKE_PROGRAM}"

similar to above re compilers

>  
> -install:
> -     cp ${WRKSRC}/lib/* ${LOCALBASE}/lib
> -     cp ${WRKSRC}/include/* ${LOCALBASE}/include
> +post-patch:
>Makefile +     ln -fs Make.inc/Makefile.inc.x86-64_pc_openbsd 
>${WRKSRC}/Makefile.inc

symlink rather than copying just to make things a bit less confusing
with "make update-patches"

>  
>  .include <bsd.port.mk>
> diff --git 
> math/scotch/patches/patch-src_Make_inc_Makefile_inc_x86-64_pc_openbsd 
> math/scotch/patches/patch-src_Make_inc_Makefile_inc_x86-64_pc_openbsd
> index 8397e1c..b262bcc 100644
> --- math/scotch/patches/patch-src_Make_inc_Makefile_inc_x86-64_pc_openbsd
> +++ math/scotch/patches/patch-src_Make_inc_Makefile_inc_x86-64_pc_openbsd
> @@ -8,13 +8,13 @@ Index: src/Make.inc/Makefile.inc.x86-64_pc_openbsd
>  +LIB         = .so
>  +OBJ         = .o
>  +
> -+MAKE                = gmake
> ++MAKE                ?= gmake
>  +AR          = ar
>  +ARFLAGS             = -ruv
>  +CAT         = cat
> -+CCS         = cc
> -+CCP         = mpicc
> -+CCD         = cc
> ++CCS         ?= cc
> ++CCP         ?= mpicc
> ++CCD         ?= cc

Normally when there is a single makefile we could just override these
in MAKE_FLAGS (which takes higher priority than "VAR=contents" in a
makefile). But in this case there are subsidiary make instances
and the flags aren't passed on the command line for those, so we
rely on passing via the environment, so they need to use ?=

>  +CFLAGS              += -I/usr/local/include -fPIC -DCOMMON_FILE_COMPRESS_GZ 
> -DCOMMON_PTHREAD -DCOMMON_RANDOM_FIXED_SEED -DSCOTCH_RENAME 
> -DSCOTCH_RENAME_PARSER -DSCOTCH_PTHREAD -Drestrict=__restrict -DIDXSIZE64
>  +CLIBFLAGS   =
>  +LDFLAGS             += -lz -lm -lpthread
> diff --git math/scotch/pkg/PLIST math/scotch/pkg/PLIST
> index eb6f335..f4e2418 100644
> --- math/scotch/pkg/PLIST
> +++ math/scotch/pkg/PLIST
> @@ -1 +1,73 @@
>  @comment $OpenBSD: PLIST,v$
> +@bin bin/acpl
> +@bin bin/amk_ccc
> +@bin bin/amk_fft2
> +@bin bin/amk_grf
> +@bin bin/amk_hy
> +@bin bin/amk_m2
> +@bin bin/amk_p2
> +@bin bin/atst
> +@bin bin/dggath
> +@bin bin/dgmap
> +@bin bin/dgord
> +@bin bin/dgpart
> +@bin bin/dgscat
> +@bin bin/dgtst
> +@bin bin/gbase
> +@bin bin/gcv
> +@bin bin/gdump
> +@bin bin/gmap
> +@bin bin/gmk_hy
> +@bin bin/gmk_m2
> +@bin bin/gmk_m3
> +@bin bin/gmk_msh
> +@bin bin/gmk_ub2
> +@bin bin/gmtst
> +@bin bin/gord
> +@bin bin/gotst
> +@bin bin/gout
> +@bin bin/gpart
> +@bin bin/gscat
> +@bin bin/gtst
> +@bin bin/mcv
> +@bin bin/mmk_m2
> +@bin bin/mmk_m3
> +@bin bin/mord
> +@bin bin/mtst
> +include/esmumps.h
> +include/ptscotch.h
> +include/ptscotchf.h
> +include/scotch.h
> +include/scotchf.h
> +lib/libesmumps.so
> +lib/libptscotch.so
> +lib/libptscotcherr.so
> +lib/libptscotcherrexit.so
> +lib/libptscotchparmetis.so
> +lib/libscotch.so
> +lib/libscotcherr.so
> +lib/libscotcherrexit.so
> +lib/libscotchmetis.so
> +@man man/man1/acpl.1
> +@man man/man1/amk_ccc.1
> +@man man/man1/amk_grf.1
> +@man man/man1/atst.1
> +@man man/man1/dgmap.1
> +@man man/man1/dgord.1
> +@man man/man1/dgscat.1
> +@man man/man1/dgtst.1
> +@man man/man1/gbase.1
> +@man man/man1/gcv.1
> +@man man/man1/gdump.1
> +@man man/man1/gmap.1
> +@man man/man1/gmk_hy.1
> +@man man/man1/gmk_msh.1
> +@man man/man1/gmtst.1
> +@man man/man1/gord.1
> +@man man/man1/gotst.1
> +@man man/man1/gout.1
> +@man man/man1/gtst.1
> +@man man/man1/mcv.1
> +@man man/man1/mmk_m2.1
> +@man man/man1/mord.1
> +@man man/man1/mtst.1
> 

Attachment: scotch.tgz
Description: application/tar-gz

Reply via email to