Re: Need help with a makefile

From: David Christensen <dpchrist_at_holgerdanske.com>
Date: Wed, 07 Feb 2024 09:21:00 UTC
On 2/6/24 19:21, Jonathan Adams wrote:
> Hi all,
>    I'm having a heck of a time getting my makefile conditional statements to not cause `make` to have fits. Could sure use some help on this. This is a makefile that works great _without_ the conditions, and my program compiles and runs on FBSD and Linux.
> ...


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 $@


("update" is the default target in GNUmakefile.)


The following invocations work on either platform:

$ make

$ make update

$ make TARGET


RTFM GNU make(1) documents GNUmakefile.


RTFM BSD make(1) on my machine does not document BSDmakefile (?), but it 
works.


David