Subject: Make expression evaluation
To: 'current-users@NetBSD.ORG' <current-users@NetBSD.ORG>
From: Martin Husemann <martin@laurin.teuto.de>
List: current-users
Date: 02/01/1997 07:30:42
In a software package running both on NetBSD and FreeBSD there are
some subtle differences in Makefiles for the two systems. We need
"MAN" to contain a list of man pages, if "PROG" is not set, while
FreeBSD needs "MAN4" to be a list of section 4 man pages.
Also man pages describing kernel drivers have to give different
"SYNOPSIS" lines, so these pages need OS depended preproccessing.
The method I found is this:
---8<---
.if !defined(OSTYPE)
OSTYPE=`uname`
.endif
.if (${OSTYPE} == "NetBSD")
# NetBSD needs MAN to be defined
MAN = disdn.4 ipi.4 isdn.4 tel.4 itel.4 ity.4
.endif
--->8---
which doesn't work in NetBSD-current. (Don't know if it ever did.)
It's not easy to see, because this:
---8<---
.if !defined(OSTYPE)
OSTYPE=`uname`
.endif
all:
@echo "OSTYPE is $(OSTYPE)"
--->8---
will result in:
---8<---
[/tmp] martin@rumolt > make
OSTYPE is NetBSD
--->8---
But if you change @echo to echo you'll see what is wrong:
---8<---
[/tmp] martin@rumolt > make
echo "OSTYPE is `uname`"
OSTYPE is NetBSD
--->8---
A working way is the following:
---8<---
[/tmp] martin@rumolt > cat Makefile
.if !defined(OSTYPE)
OSTYPE=`uname`
.endif
all install foo bar:
@$(MAKE) -f Makefile.work OSTYPE=$(OSTYPE) $(.TARGET)
[/tmp] martin@rumolt > cat Makefile.work
.if !defined(OSTYPE)
@echo "Don't use this Makefile directly"
.endif
all:
echo "OSTYPE is $(OSTYPE)"
--->8---
This gives
---8<---
[/tmp] martin@rumolt > make
echo "OSTYPE is NetBSD"
OSTYPE is NetBSD
--->8---
Is there an easier solution? What is the prefered way to do this kind of things?
Martin