Re: Need help with a makefile

From: Jonathan Adams <jfadams1963_at_proton.me>
Date: Wed, 07 Feb 2024 15:36:17 UTC
On Wednesday, February 7th, 2024 at 2:41 AM, grarpamp <grarpamp@gmail.com> wrote:

> On 2/6/24, Jonathan Adams jfadams1963@proton.me wrote:
> 

> > 5 │ UNAME := $(shell uname)
> > 7 │ ifeq ($(UNAME),FreeBSD) \
> > make: "/home/jfa/portable/src/makefile" line 7: Invalid line type
> > I'm working on 14.0-RELEASE-p4.
> 

> 

> Many makefile systems are incompatible.
> You could try to write compatible makefiles,
> or force the user to install whichever make or build system you're using,
> or ship a separate makefile.<os> for their platform,
> 

> whereby in this example the only tabs prefix the a1 section...
> 

> # env - UNAME='' U='bar' make -dA -r -f ./makefile.freebsd a1
> 

> if (!defined(UNAME) || empty(UNAME))
> note=was_either_unset_or_null
> UNAME!=uname
> elif ${UNAME} == "FreeBSD"
> note=was_FreeBSD
> CFLAGS+=-DBSD
> elif ${UNAME} == "foo"
> note=was_foo
> else
> info was something else
> endif
> a1: .NOTMAIN
> @echo "note: ${note}"
> @echo "uvar: ${UNAME}"
> @echo "cvar: ${CFLAGS}"
> @echo ----------
> uname -a
> echo $$(uname -K)
> echo $UNAME

  Thank you very much. My query has garnered some very useful responses. As I mentioned in my reply to Greg, this program doesn't have to compile on Linux. I'm trying to improve my C programming skills and knowledge. So, this is actually a personal project and exercise in C. As such, getting a solid grip on a cross-platform makefile solution is certainly a great exercise!

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