Port from Linux, Makefile not in top-level

From: Xavier Humbert <xavier_at_groumpf.org>
Date: Fri, 18 Jun 2021 16:19:45 UTC
Hi, I'm porting rudder-agent to FreeBSD, but I have a problem since the
main Makefile is not at the top level of the hierarchy, as shown below
(excerpt)

rudder-sources-6.2.7/
├── rudder-agent
│   ├── bin
│   ├── etc
│   ├── LICENSE
│   ├── man
│   ├── qa-test
│   ├── README.md
│   └── share
├── rudder-packages
│   └── rudder-agent
│       └── SOURCES
│           ├── Makefile
│           └── Makefile.orig
└── NO Makefile AT THIS LEVEL

The solution, at first glance seems to be simple : set
WRKSRC_SUBDIR=rudder-packages/${PORTNAME}/SOURCES
     (ie work/rudder-sources-6.2.7/rudder-packages/rudder-agent/SOURCES)

In fact, ${WRKSRC_SUBDIR}/Makefile takes care of the first-level
"rudder-agent", and files are correctly installed in the "stage" directory,
but a huge problem arises :
"make makepatch" and "make patch" ignore this first-level directory, and I
have files to patch here

What would be the solution ? If I leave alone WRKSRC_SUBDIR using a 
"do-build"
target in my Makefile :
│ do-build:
│    cd ${WRKSRC}/rudder-packages/rudder-agent/SOURCES && \
│      ${SETENV} ${MAKE_ENV} ${MAKE_CMD} install)
Nothing works, and make all complains about a top-level Makefile missing

TIA, hope I've been clear enough, feel free to ask more

Regards

Xavier

Here is my Makefile :
===============================================================================
PORTNAME=       rudder-agent
DISTVERSION=    6.2.7
CATEGORIES=     sysutils
DISTNAME=       rudder-sources-${DISTVERSION}
MASTER_SITES= https://repository.rudder.io/sources/${DISTVERSION}/
EXTRACT_SUFX=   .tar.bz2

MAINTAINER=     xavier@amdh.fr
COMMENT=        Agent for Rudder

USES=           perl5
USES=           gmake

LICENSE=        GPLv2+
LICENSE_FILE= 
${WRKDIR}/rudder-sources-${DISTVERSION}/rudder-packages/LICENSE

LIB_DEPENDS+=   libpcre.so:devel/pcre \
                 liblmdb.so:databases/lmdb \
                 libreadline.so:devel/readline \
                 libyaml.so:textproc/libyaml \
                 libxml2.so:textproc/libxml2 \
                 libaugeas.so:textproc/augeas

BUILD_DEPENDS+= hs-ShellCheck>=0.7.2:devel/hs-ShellCheck \
                 openssl>=1.1.1:security/openssl \
                 cfengine317>=3.17.0:sysutils/cfengine317 \
                 curl>7.76.1:ftp/curl \
                 jq>=1.6:textproc/jq \
p5-FusionInventory-Agent>=0:net-mgmt/p5-FusionInventory-Agent \
                 p5-File-Which>=1.2.7:sysutils/p5-File-Which \
                 p5-libwww>=6.54:www/p5-libwww \
                 p5-Net-IP>=1.26:net-mgmt/p5-Net-IP \
p5-Text-Template>=1.59:textproc/p5-Text-Template \
p5-UNIVERSAL-require>=0.18:devel/p5-UNIVERSAL-require \
                 p5-XML-TreePP>=0.43:textproc/p5-XML-TreePP \
                 p5-Parse-EDID>=1.0.7:textproc/p5-Parse-EDID \
                 p5-DateTime>=1.54:devel/p5-DateTime \
p5-DateTime-TimeZone>=2.47:devel/p5-DateTime-TimeZone \
                 p5-Net-SNMP>=6.0.1:net-mgmt/p5-Net-SNMP \
                 p5-Net-NBName>=0.26:net/p5-Net-NBName \
                 p5-Thread-Queue>=3.13:devel/p5-Thread-Queue

CC?=            gcc10
BINARY_ALIAS=   gcc=${CC}
MAKE_ENV=       USE_SYSTEM_PERL=yes
SHORT_NAME=     rudder
NO_ARCH=        yes
WRKSRC_SUBDIR=  rudder-packages/${PORTNAME}/SOURCES

post-patch:
     cd ${WRKSRC}/${PORTNAME}/man && make all

.include <bsd.port.mk>
===============================================================================

-- 
Xavier HUMBERT - Unix/Win/MacOSX Sysadmin/Network Senior Engineer
https://www.amdh.fr