Module Name: src Committed By: sjg Date: Sun Nov 10 02:39:14 UTC 2024
Modified Files: src/usr.bin/make: main.c make.1 Log Message: make: allow -f .../Makefile If the arg to -f or an entry in .MAKE.MAKEFILE_PREFERENCE starts with ".../" look for the rest of the path in .CURDIR and above. Reviewed by: rillig To generate a diff of this commit: cvs rdiff -u -r1.634 -r1.635 src/usr.bin/make/main.c cvs rdiff -u -r1.379 -r1.380 src/usr.bin/make/make.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/make/main.c diff -u src/usr.bin/make/main.c:1.634 src/usr.bin/make/main.c:1.635 --- src/usr.bin/make/main.c:1.634 Tue Aug 27 04:52:14 2024 +++ src/usr.bin/make/main.c Sun Nov 10 02:39:14 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.634 2024/08/27 04:52:14 rillig Exp $ */ +/* $NetBSD: main.c,v 1.635 2024/11/10 02:39:14 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -111,7 +111,7 @@ #include "trace.h" /* "@(#)main.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: main.c,v 1.634 2024/08/27 04:52:14 rillig Exp $"); +MAKE_RCSID("$NetBSD: main.c,v 1.635 2024/11/10 02:39:14 sjg Exp $"); #if defined(MAKE_NATIVE) __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 " "The Regents of the University of California. " @@ -1636,6 +1636,20 @@ ReadMakefile(const char *fname) Parse_File("(stdin)", -1); Var_Set(SCOPE_INTERNAL, "MAKEFILE", ""); } else { + if (strncmp(fname, ".../", 4) == 0) { + name = Dir_FindHereOrAbove(curdir, fname + 4); + if (name != NULL) { + /* Dir_FindHereOrAbove returns dirname */ + path = str_concat3(name, "/", + str_basename(fname)); + free(name); + fd = open(path, O_RDONLY); + if (fd != -1) { + fname = path; + goto found; + } + } + } /* if we've chdir'd, rebuild the path name */ if (strcmp(curdir, objdir) != 0 && *fname != '/') { path = str_concat3(curdir, "/", fname); Index: src/usr.bin/make/make.1 diff -u src/usr.bin/make/make.1:1.379 src/usr.bin/make/make.1:1.380 --- src/usr.bin/make/make.1:1.379 Sat Sep 21 23:42:53 2024 +++ src/usr.bin/make/make.1 Sun Nov 10 02:39:14 2024 @@ -1,4 +1,4 @@ -.\" $NetBSD: make.1,v 1.379 2024/09/21 23:42:53 sjg Exp $ +.\" $NetBSD: make.1,v 1.380 2024/11/10 02:39:14 sjg Exp $ .\" .\" Copyright (c) 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" from: @(#)make.1 8.4 (Berkeley) 3/19/94 .\" -.Dd September 21, 2024 +.Dd November 10, 2024 .Dt MAKE 1 .Os .Sh NAME @@ -60,10 +60,11 @@ If no .Fl f Ar makefile option is given, .Nm -tries to open -.Sq Pa makefile -then -.Sq Pa Makefile +looks for the makefiles listed in +.Va .MAKE.MAKEFILE_PREFERENCE +(default +.Sq Pa makefile , +.Sq Pa Makefile ) in order to find the specifications. If the file .Sq Pa .depend @@ -240,6 +241,13 @@ If is .Ql \&- , standard input is read. +If +.Ar makefile +starts with the string +.Ql \&.../ , +.Nm +searches for the specified path in the rest of the argument +in the current directory and its parents. Multiple makefiles may be specified, and are read in the order specified. .It Fl I Ar directory Specify a directory in which to search for makefiles and included makefiles.