#1149803 bmake ships bogus /usr/share/bmake/mk-netbsd/Makefile

Package:
bmake
Source:
bmake
Description:
NetBSD make
Submitter:
Thorsten Glaser
Date:
2026-10-03 09:11:04 UTC
Severity:
normal
#1149803#5
Date:
2026-06-08 20:55:36 UTC
From:
To:
This *might* be related to #1078772, but is not the same; for one,
that bugreport was under qemu-user while this one is on bare metal.

Reproducer: an otherwise empty directory with two files:

$ cat BSDmakefile
PROG=   facopy
SRCS=   poc.c
NOMAN=  Yes

.include <bsd.prog.mk>
$ cat poc.c
#include <stdio.h>

int
main(int argc, char *argv[])
{
        printf("Hello, World!\n");
        return (0);
}

All the usual targets… just do nothing?! Except install, which
does something entirely unexpected:

$ pmake obj
$ pmake depend
$ pmake
$ pmake install
install   -c   -o root  -g root  -m 444  bsd.README /usr/share/mk/bsd.README
install: cannot stat 'bsd.README': No such file or directory
*** Error code 1

Stop.
bmake: stopped in «cwd»
$ fgrep -r bsd.README /usr/share/mk
/usr/share/mk/README:#  $NetBSD: bsd.README,v 1.18 1997/01/13 00:54:23 mark Exp $
/usr/share/mk/README:#  @(#)bsd.README  5.1 (Berkeley) 5/11/90
$ fgrep -r bsd.README /usr/share/bmake/mk-netbsd/
/usr/share/bmake/mk-netbsd/Makefile:FILES=      bsd.README bsd.doc.mk bsd.dep.mk bsd.files.mk bsd.inc.mk bsd.info.mk \
/usr/share/bmake/mk-netbsd/bsd.README:# $NetBSD: bsd.README,v 1.2 2009/12/30 20:46:22 abs Exp $
/usr/share/bmake/mk-netbsd/bsd.README:# @(#)bsd.README  8.2 (Berkeley) 4/2/94


It looks as if it included /usr/share/bmake/mk-netbsd/Makefile
for some reason?

(“ls -la” confirms that obj/depend/all have not done anything.)

Now it’s not the wrapper:

$ bmake -m /usr/share/bmake/mk-netbsd obj

… also does nothing.

An strace however indicates that my hunch with it (mistakenly)
including a file it is not supposed to might be true and perhaps
at least part of the bug:

$ strace -e file bmake -m /usr/share/bmake/mk-netbsd obj
execve("/usr/bin/bmake", ["bmake", "-m", "/usr/share/bmake/mk-netbsd", "obj"], 0x7fff69fd6188 /* 50 vars */) = 0
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
getcwd("«cwd»", 4096) = 28
openat(AT_FDCWD, "/usr/share/bmake/mk-netbsd", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 3
newfstatat(AT_FDCWD, "«cwd»", {st_mode=S_IFDIR|0755, st_size=4096, ...}, 0) = 0
newfstatat(AT_FDCWD, "«cwd»", {st_mode=S_IFDIR|0755, st_size=4096, ...}, 0) = 0
openat(AT_FDCWD, "«cwd»", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 3
newfstatat(AT_FDCWD, "«cwd»", {st_mode=S_IFDIR|0755, st_size=4096, ...}, 0) = 0
chdir("«cwd»")    = 0
openat(AT_FDCWD, ".", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 3
newfstatat(AT_FDCWD, "«cwd»/obj.x86_64-amd64", 0x7ffc73763830, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "«cwd»/obj.x86_64", 0x7ffc73763830, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "«cwd»/obj", 0x7ffc73763830, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/usr/obj«cwd»", 0x7ffc73763830, 0) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/mk", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 3
openat(AT_FDCWD, "/usr/share/bmake/mk-netbsd/sys.mk", O_RDONLY) = 3
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=27034, si_uid=1000, si_status=0, si_utime=0, si_stime=0} ---
openat(AT_FDCWD, "makefile", O_RDONLY)  = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "Makefile", O_RDONLY)  = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/bmake/mk-netbsd/Makefile", O_RDONLY) = 3
openat(AT_FDCWD, "/usr/share/bmake/mk-netbsd/bsd.own.mk", O_RDONLY) = 3
newfstatat(AT_FDCWD, "/etc/mk.conf", 0x7ffc73765680, 0) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/bmake/mk-netbsd/bsd.prog.mk", O_RDONLY) = 3
newfstatat(AT_FDCWD, "«cwd»/../Makefile.inc", 0x7ffc73765680, 0) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/bmake/mk-netbsd/bsd.own.mk", O_RDONLY) = 3
openat(AT_FDCWD, "/usr/share/bmake/mk-netbsd/bsd.obj.mk", O_RDONLY) = 3
openat(AT_FDCWD, "/usr/share/bmake/mk-netbsd/bsd.own.mk", O_RDONLY) = 3
openat(AT_FDCWD, "/usr/share/bmake/mk-netbsd/bsd.depall.mk", O_RDONLY) = 3
openat(AT_FDCWD, "/usr/share/bmake/mk-netbsd/bsd.man.mk", O_RDONLY) = 3
openat(AT_FDCWD, "/usr/share/bmake/mk-netbsd/bsd.nls.mk", O_RDONLY) = 3
openat(AT_FDCWD, "/usr/share/bmake/mk-netbsd/bsd.files.mk", O_RDONLY) = 3
openat(AT_FDCWD, "/usr/share/bmake/mk-netbsd/bsd.inc.mk", O_RDONLY) = 3
openat(AT_FDCWD, "/usr/share/bmake/mk-netbsd/bsd.links.mk", O_RDONLY) = 3
openat(AT_FDCWD, "/usr/share/bmake/mk-netbsd/bsd.dep.mk", O_RDONLY) = 3
openat(AT_FDCWD, "/usr/share/bmake/mk-netbsd/bsd.sys.mk", O_RDONLY) = 3
openat(AT_FDCWD, ".depend", O_RDONLY)   = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, ".END", 0x7ffc737658a0, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, ".END", 0x7ffc73765880, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, ".END", 0x7ffc73765890, 0) = -1 ENOENT (No such file or directory)
+++ exited with 0 +++

A bit of analysis of that:

Stuff until here looks normal:

Looking at an unfiltered strace, the only thing it does between that and
the next line is:

openat(AT_FDCWD, "/usr/share/mk", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 3
fstat(3, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
getdents64(3, 0x55a0cc05c190 /* 77 entries */, 32768) = 2552
getdents64(3, 0x55a0cc05c190 /* 0 entries */, 32768) = 0
close(3)                                = 0
openat(AT_FDCWD, "/usr/share/bmake/mk-netbsd/sys.mk", O_RDONLY) = 3

So, it lists the directory, but that should do no harm.

The SIGCHLD is from <sys.mk> calling uname(1) to report “Linux”.

Then, for some reason, after trying "makefile" and "Makefile",
instead of continuing to "BSDmakefile" it tries
"/usr/share/bmake/mk-netbsd/Makefile" first, finds it and uses it.
This then causes havoc.

Looking at actual BSD systems shows that /usr/src/share/mk/Makefile
is not installed into /usr/share/mk, so src:bmake should follow.

$ sudo rm /usr/share/bmake/mk-netbsd/Makefile
$ pmake obj
bmake: don't know how to make obj. Stop

bmake: stopped in «cwd»

… huh. But at least a better error.

…

…

…

$ mv BSDmakefile Makefile
$ pmake obj
making «cwd»/obj

…

… ah, so it does not use BSDmakefile at all, and the presence
of /usr/share/bmake/mk-netbsd/Makefile merely hid that.

I’m wondering whether you can pstch BSDmakefile support in,
that’ll be your choice as maintainer, also coordinating with
upstream, I suppose. (Is the omission a Linux thing?)

But IMHO /usr/share/bmake/mk-netbsd/Makefile has to go (and
/usr/share/bmake/mk-bmake does not have a Makefile in it).

*edits Subject*

#1149803#14
Date:
2026-10-03 09:09:35 UTC
From:
To:
We believe that the bug you reported is fixed in the latest version of
bmake, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 1149803@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Andrej Shadura <andrewsh@debian.org> (supplier of updated bmake package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@ftp-master.debian.org)
Format: 1.8
Date: Sat, 03 Oct 2026 10:48:18 +0200
Source: bmake
Architecture: source
Version: 20200710-18
Distribution: unstable
Urgency: medium
Maintainer: Andrej Shadura <andrewsh@debian.org>
Changed-By: Andrej Shadura <andrewsh@debian.org>
Closes: 1043887 1139341 1149803
Changes:
 bmake (20200710-18) unstable; urgency=medium
 .
   * Don’t ship /usr/share/bmake/mk-netbsd/Makefile (Closes: #1149803).
   * Remove unit-tests/Makefile.config on clean (Closes: #1043887).
   * When invoked as pmake, prefer BSDmakefile (Closes: #1139341).
Checksums-Sha1:
 6a9e3b94638f741badead1c429a8db436a320fd2 2170 bmake_20200710-18.dsc
 7d40ecb878a3e97f6f3b106c86961004c23ec09d 38668 bmake_20200710-18.debian.tar.xz
 1a622861232addd7db439fd6ea81d9ef25e553e4 1597544 bmake_20200710-18.git.tar.xz
 1acbbefdfcc4a75781b93dccc59f26a494efd678 17732 bmake_20200710-18_source.buildinfo
Checksums-Sha256:
 91fa9b0ed8912a1f20b1a99f2d9a9dd47c83d6f161bbce4505d2a126fc519ff1 2170 bmake_20200710-18.dsc
 6181c2a57d090a37bca0a426d09e50b84105e7d296564c8d38f376271f0f3b4d 38668 bmake_20200710-18.debian.tar.xz
 e82b28423e9736b70ca456a802ce282b3d27729179a90425f702d99bb4b2edc9 1597544 bmake_20200710-18.git.tar.xz
 fe0dbb1b86aff87ebfdcea4e14b4d999969ab4f5ffde34151d61df51326e4e28 17732 bmake_20200710-18_source.buildinfo
Files:
 1152de3641f0cd9475fc2b74cd55ba03 2170 devel optional bmake_20200710-18.dsc
 239bd2835032ff059788168c3cf6e229 38668 devel optional bmake_20200710-18.debian.tar.xz
 bc8ad63f2f80b2ca02ebf3820efd327d 1597544 devel optional bmake_20200710-18.git.tar.xz
 f12204e1947275d2ab3563c6bc71386d 17732 devel optional bmake_20200710-18_source.buildinfo
Git-Tag-Info: tag=aceb3bd99c354eb6b7ec46b1dcfa83e1defddf76 fp=83dcd17f44b22cc83656eda1e8446b4ac8c77261
Git-Tag-Tagger: Andrej Shadura <andrew.shadura@collabora.co.uk>
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEN02M5NuW6cvUwJcqYG0ITkaDwHkFAmrAwdEACgkQYG0ITkaD
wHlQJRAA75CACWjej9CVfg/gigMCzLz2yOSQtal82+7gdKxxdesikkDlGODU2Doz
aA/xcoMfOS23W6GvBht56pim3mSfMIHPFYwshk/bFOMgfRLI7TD9RwYWIPNs93MF
8b1SPNsWCcliV/aIxgf64tbciuYiYCQqyKZNJOiFUroBhbORRb5thrTvaj1S0ji5
idTHeT2fJZybDqDt13Zqohwhj0XznZ9qHNQQN9IHgIt3tLAmvdcVIIi6dzgj11sa
kbpsOoqXjo9wyHBHtFtGUZJnfqw76N2HCeFhtvM8RaVs17q5SHSqj4um27+7A95x
WPsc/YA4wJb6da+1jhtA3GSO4/3O6kl20to6xBxRd9f8FljWy/xLcnwWmUC/o+ZH
OfjGOFkWzME3s+hT3rrqdFP9dRWyH0ebZXsryaFfzQ/Jf1WJzqaKV4XaS3OnpW/S
gpK956f1uYwbRkzTF8xBOA/jjnqgRqoYWO8aaviVU6C1sqlS7KDhxyPFS7+dw23d
1D36mGxCmsQ40y7itXQuVGFYvneTTBkrY/Os7d1I71VhYt6FNHVKNxcXZTqkaj4T
GEfscLPo1ScBO1nwBG3KD7EFAho4JgudVMz/3ldhp8ismP+1oJF7mtqxok3dz1j3
FmqCTCtvjom+0Rc+QR+optyb7tmFOdnO97KWz6BT5cbDkvwcg+A=
=MSeN
-----END PGP SIGNATURE-----