Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 19 Jan 2002 10:55:30 -0800 (PST)
From:      Kevin Walsh <walsh@cs.duke.edu>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   misc/34062: bsd.kmod.mk fails due to bug in make with .PATH and exists() function
Message-ID:  <200201191855.g0JItUh29643@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         34062
>Category:       misc
>Synopsis:       bsd.kmod.mk fails due to bug in make with .PATH and exists() function
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Jan 19 11:00:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Kevin Walsh
>Release:        4.3-RELEASE
>Organization:
Duke University
>Environment:
FreeBSD rack27.cs.duke.edu 4.4-RELEASE FreeBSD 4.4-RELEASE #0: Fri Nov  2 16:21:54 EST 2001     priya@rack26.cs.duke.edu:/usr/research/playground/priya/fbsd/4.4-RELEASE/compile/DUMMY  i386

>Description:
When attempting to compile the 4.4-RELEASE kernel modules ('make modules' from the compile/DUMMY directory) make fails with the error:
===> libmchain
"/usr/share/mk/bsd.kmod.mk", line 10: "can't find kernel source tree"
*** Error code 1

A tour of libmchain/Makefile and the bsd.kmod.mk file reveals the following bug.
If a path (in this case /blah/blah/../../kern) is specified in the .PATH (as it is in libmchain/Makefile), then the .exists() function will fail when searching for the exact same path if a trailing '/' is left on (in this case, bsd.kmod.mk searches for /blah/blah/../../kern/).

This bug is too obvious and problematic to be real. I ran into it on my very first FreeBSD compile ever (and in multiple places, too!)
>How-To-Repeat:
Do 'make modules'.
Or run 'make' in a directory with the following Makefile:
# Makefile -- this will break the FreeBSD make (pmake???) and
# illustrates what is wrong with the kernel makefiles

_FOO=/usr/local/bin/

# this one works fine
.if exists(${_FOO})
.else
.error "first try -- _FOO does not exist: ${_FOO}"
.endif

# this also works fine
.PATH: /usr/local
.if exists(${_FOO})
.else
.error "second try -- _FOO does not exist: ${_FOO}"
.endif

# this one fails
.PATH: /usr/local/bin
.if exists(${_FOO})
.else
.error "third try -- _FOO does not exist: ${_FOO}"
.endif

all:

>Fix:
Workaround 1: fix all of the makefiles to never search for a directory with a trailing '/' character.
Workaround 2: fix all of the module makefiles to never include '../../kern'.

Fix: Change the function Dir_FindFile(name,path) in usr.bin/make/dir.c
so that (1) there is a check to see if 'name' is absolute BEFORE failing, and/or (2) trailing slashes are recognized and handled appropriately.
>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200201191855.g0JItUh29643>