Re: How to override port Makefile to point to local directory?

From: Chris <portmaster_at_bsdforge.com>
Date: Tue, 17 May 2022 00:46:01 UTC
On 2022-05-15 23:08, Pat Maddox wrote:
> On 15 May 2022, at 22:28, Pat Maddox wrote:
> 
>> On 15 May 2022, at 20:49, Chris wrote:
>> 
>>> On 2022-05-15 20:29, Pat Maddox wrote:
>>>> I am writing software that I would eventually like to install on FreeBSD. 
>>>> I'm
>>>> currently stuck trying to write a Makefile that will point to my local 
>>>> git dir, so
>>>> I can build and install it while I'm developing. All of the finished 
>>>> Makefiles
>>>> reference tar packages, which makes sense. But when I'm actively 
>>>> developing, I
>>>> don't want to commit the code, push it, have it built, update the 
>>>> makefile with
>>>> the commit, and make.
>>>> 
>>>> Does anyone know of a way to override options to a port's Makefile to 
>>>> point to a
>>>> local directory on disk? I want to run "sudo make install" and "make 
>>>> package" from
>>>> my development directory, using the same Makefile that would be in the 
>>>> ports tree.
>>> You can perform make out of tree build/installs w/o issue. The ports 
>>> infrastructure
>>> will post a couple of warnings. But nothing to stop you from development. 
>>> I do it out
>>> of ~/DEV/<category>/port-im-developing all the time.
>>> 
>>> HTH
>>> 
>>> Chris
>>>> 
>>>> Pat
>> 
>> Cool, how do I do that?
>> 
>> Here’s the Makefile in my project directory: 
>> https://gist.github.com/patmaddox/d5d8a0e0df656072749bf18f7f634ae9
>> 
>> When I run `make install`, it downloads the zip from GitHub. That makes 
>> sense, because that’s what it’s configured to do, and I haven’t passed in 
>> any options to find the source elsewhere.
>> 
>> I don’t know how to tell make not to fetch & extract, because I already 
>> have the source locally.
>> 
>> Pat
> 
> Well I wrote a script that generates the folder structure and zip that make
> expects, and moves it into place:
> https://gist.github.com/patmaddox/d5d8a0e0df656072749bf18f7f634ae9#file-build-sh
> 
> I figure there’s gotta be some sort of `make SRCDIR=. install` to bypass 
> fetch &
> extract, but this will do for now.
OK I haven't tested your (proposed) port. But your Makefile is fine as it is.
You WILL, however require a distinfo && likely a pkg-plist BEFORE you attempt 
your
development target. You'll also need to add your port to the Makefile within 
your
chosen category.
For example. You already have a recent copy of /usr/ports within your dev env 
(jail(8)
or whatever). Within your home directory (within your jail or whatever) you 
have
DEV/<category>/you-port-name
You can test your development env by cd'ing to ~/DEV/<category>/you-port-name 
&&
performing make -DBATCH <some-make-target>
If the ports env only returns a couple WARN(s) but continues build to 
completion. You're
essentially good-to-go. HOWEVER, if the ports framework sends ERROR(s). It 
ends there. It
will likely be caused by the missing entry within your chosen category. So 
open the
/usr/ports/category/Makefile within your dev env and add your port (NOTE: 
their in
alphabetical order). Then try again. TBH most all of this can be figured out 
by becoming
familiar with the Porters Handbook[1]. ;-)

HTH

Chris

1) https://docs.freebsd.org/en/books/porters-handbook/
> 
> Pat