Re: Need help with a makefile

From: Jonathan Adams <jfadams1963_at_proton.me>
Date: Wed, 07 Feb 2024 16:00:43 UTC
On Wednesday, February 7th, 2024 at 4:21 AM, David Christensen <dpchrist@holgerdanske.com> wrote:
> 

> I also had problems attempting to write one Makefile that worked with
> both BSD make(1) and GNU make(1) (e.g. Linux). My solution was to
> choose GNU make(1) for the programming language, install gmake(1) on
> BSD, rename Makefile to GNUmakefile, and write a BSDmakefile that
> forwards invocations to gmake(1):
> 

> $ cat BSDmakefile
> PHONY : update
> update :
> @gmake -s $@
> 

> DEFAULT :
> @gmake -s $@

Hi David. Thanks for sharing your experience. This is an interesting solution; gives me a few ideas..
> ("update" is the default target in GNUmakefile.)

Hm, ok.

> The following invocations work on either platform:
> 

> $ make
> 

> $ make update
> 

> $ make TARGET

Seems that a very simple and straight-forward approach would be to use GNUmake and have separate targets for BSD and Linux. (??)

> RTFM BSD make(1) on my machine does not document BSDmakefile (?)

I also noticed that. I did also notice this caveat in make(1):

 "Other make dialects
   Other make dialects (GNU make, SVR4 make, POSIX make, etc.) do not
   support most of the features of make as described in this manual."

- Jonathan
____________________________________________
"Before Turing, things were done to numbers.
After Turing, numbers began doing things"
- George Dyson