Commit Graph

31 Commits

Author SHA1 Message Date
Bryan Drewery
3b53f994ea Consider *clean targets as non-build targets as well.
MFC after:	2 weeks
Sponsored by:	DellEMC
2019-07-04 14:51:44 +00:00
Bryan Drewery
6e6be2bbe2 Reduce exec and fstat overhead for non-build targets.
This is mostly targetting 'make showconfig' and 'make test-system-*' for
the benefit of makeman and universe-one-clang work.

Sponsored by:	Dell EMC
2018-06-20 17:20:39 +00:00
Bryan Drewery
fa65e3a53d Handle some .OBJDIR == .CURDIR cases.
- If OBJROOT is SRCTOP then don't add on TARGET.TARGET_ARCH.  This
  only happens at the top-level, and for sub-directories when the
  user is clever with MAKEOBJDIRPREFIX=/.
- Don't bother checking 'test -w' on .CURDIR.
- Properly set OBJTOP/OBJROOT to SRCTOP in various needed cases.
- Check if the OBJDIR is writable even for *clean* targets since it
  determines which .OBJDIR the user gets;  If they cannot write to an
  existing eligible .OBJDIR then it needs to clean in .CURDIR instead.
- Add guard to cleanworld/cleanuniverse from removing SRCTOP.
- Ensure OBJTOP is proper for .OBJDIR=.CURDIR which fixes finding
  libraries since src.libnames.mk is based on OBJTOP.
- Avoid some chdir(2) for modifying .OBJDIR

Sponsored by:	Dell EMC Isilon
2017-11-10 02:09:33 +00:00
Bryan Drewery
b284f32266 AUTO_OBJ: Allow 'make cleandir obj all' combinations.
The cleanobj target will not really remove the OBJDIR in this case,
it will only remove the OBJDIR if only clean targets are ran.

Sponsored by:	Dell EMC Isilon
2017-11-05 00:12:12 +00:00
Bryan Drewery
aba77ddd8a AUTO_OBJ: Set .OBJDIR=.CURDIR earlier for NO_OBJ Makefiles.
auto.obj.mk is loaded before the Makefile which may have NO_OBJ set inside of
it.  In that case we can't avoid creating the OBJDIR but we do need to avoid
using it.  Fixing .OBJDIR in bsd.init.mk at least fixes all of the build .mk
files to have a proper .OBJDIR.  It does not fix the Makefile itself but
usually if they have NO_OBJ set they are not inspecting ${.OBJDIR} anyhow.

It is ideal to only have this in bsd.init.mk and to remove it from bsd.obj.mk,
but then bsd.obj.mk would need to include bsd.init.mk.  Doing something like
that would require more testing.  It has been proposed that bsd.obj.mk not be
included directly but it has been possible for too long to do so to change it
at this point.

Note too that it may make sense to fix .OBJDIR even when AUTO_OBJ is not
enabled but the historical behavior has always been that NO_OBJ just avoids
running 'make obj', so .OBJDIR should already be .CURDIR.

Also while NO_OBJ seems like it should be removed at this point, it is not
always possible to fix Makefiles to properly use an .OBJDIR.  The cost of
keeping NO_OBJ support is minimal.

Sponsored by:	Dell EMC Isilon
2017-11-05 00:11:58 +00:00
Simon J. Gerraty
2506d70010 Use OBJS_SRCS_FILTER to control setting OBJS from SRCS
Some makefiles do reachover builds.
In some cases it is convenient to list subdirs of the distribution
in SRCS.

It is not very convenient, or always even desirable to have corresponding
subdirs in .OBJDIR, so OBJS_SRCS_FILTER allows the makefile to choose.
The default value 'R' matches existing practice.

But a makefile can set OBJS_SRCS_FILTER= T (the R gets added by
bsd.init.mk) to avoid the need for subdirs in .OBJDIR

Differential Revision:	https://reviews.freebsd.org/D12218
Reviewed by:	bdrewery
2017-09-16 05:42:27 +00:00
Bryan Drewery
05f3e1fe94 Fix 'make clean all' to work again.
This likely broke completely with r308599.

Apply the same fix for 'make destroy' which is a DIRDEPS_BUILD thing.

PR:		219819
Reported by:	trasz
MFC after:	3 days
Sponsored by:	Dell EMC Isilon
2017-06-20 20:52:06 +00:00
Eric van Gyzen
c9d34d6652 Fix INSTALL_AS_USER with external nsswitch databases
The INSTALL_AS_USER option tells "install" to use the current
user name as the owner of the installed file.  The "install"
command executed by the build is statically linked, so it does not
load nsswitch modules, such as nss_ldap.so, so it fails when
the user is only defined in such a database.

Fix it to use the current UID instead of user name.  This works
for all users.  I expect it is also slightly more efficient.

Reviewed by:	sjg
MFC after:	3 days
Sponsored by:	Dell EMC
Differential Revision:	https://reviews.freebsd.org/D10862
2017-05-28 00:45:28 +00:00
Eric van Gyzen
4f2bab59e7 Fix INSTALL_AS_USER
Move INSTALL_AS_USER into bsd.init.mk to maximize the chance that
it has final authority over fooOWN and fooGRP.

Reviewed by:	sjg
MFC after:	3 days
Sponsored by:	Dell EMC
Differential Revision:	https://reviews.freebsd.org/D10810
2017-05-28 00:43:12 +00:00
Bryan Drewery
1f265bbd8e Fix some "don't build" optimizations from r308599 not working due to a typo.
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2017-05-06 05:37:36 +00:00
Bryan Drewery
d7173250be Consolidate the "don't build" optimizations into _SKIP_BUILD.
_SKIP_BUILD will be set when nothing is expected to be built.  This can
be used to optimize some tree-walks and operations which don't need to
load dependency files or generate dependencies via beforebuild-style
hacks.

MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2016-11-13 00:11:02 +00:00
Bryan Drewery
f4fbac1931 DIRDEPS_BUILD: Don't hook 'beforebuild' into 'all' in MAKELEVEL 0.
This was a mistake in r295641, but is effectively prevented from
being a problem due to r296699 preventing 'make all' from being
usable at MAKELEVEL 0 for DIRDEPS_BUILD.

MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2016-11-13 00:10:59 +00:00
Bryan Drewery
9e2f435fc1 Add a 'make print-dir' that simply traverses all directories and prints them.
This is useful for finding connected directories.

MFC after:	1 week
Sponsored by:	EMC / Isilon Storage Division
2016-08-31 19:30:52 +00:00
Bryan Drewery
d95fa04249 Don't warn about needing filemon for makeman.
r287879 wasn't quite enough here since Makefile.inc1 is running
'make -C release -V VERSION' and hitting the warning.

Reported by:	lattera
Sponsored by:	EMC / Isilon Storage Division
Approved by:	re (blanket, META_MODE)
2016-06-29 16:45:01 +00:00
Bryan Drewery
b8ef21b88a WITH_META_MODE: Lessen the filemon(4) requirement scope.
- Move the sys.mk filemon requirement to bsd.init.mk as a warning.
  This is intended only to show when building directly in a subdirectory
  without filemon loaded.
- Move the error into Makefile and only apply it when building
  from the META_TGT_WHITELIST target list.

-DNO_FILEMON can be used to suppress both the warning and the error but
makes WITH_META_MODE less useful.  It will only compare build commands
in this mode rather than track all dependencies.

This fixes installing from a jail which doesn't need filemon in this
phase [1].

Reported by:	Nikolai Lifanov <lifanov@mail.lifanov.com> [1]
Approved by:	re (implicit)
Sponsored by:	EMC / Isilon Storage Division
2016-06-14 16:20:19 +00:00
Bryan Drewery
1bd4272fb9 Consolidate common beforebuild logic.
Sponsored by:	EMC / Isilon Storage Division
2016-02-16 02:09:48 +00:00
Simon J. Gerraty
71c66d9edc Avoid anoying warning 2015-06-14 03:27:22 +00:00
Simon J. Gerraty
ccfb965433 Add META_MODE support.
Off by default, build behaves normally.
WITH_META_MODE we get auto objdir creation, the ability to
start build from anywhere in the tree.

Still need to add real targets under targets/ to build packages.

Differential Revision:       D2796
Reviewed by: brooks imp
2015-06-13 19:20:56 +00:00
Simon J. Gerraty
f5374544f1 Building on fmake is no longer possible so removed tests for bmake. 2015-06-10 18:14:38 +00:00
Simon J. Gerraty
1d01c27d5f Include bsd.opts.mk before local.init.mk 2014-05-16 14:56:06 +00:00
Simon J. Gerraty
3b8f084595 Merge head 2014-04-28 07:50:45 +00:00
Warner Losh
8609cb7bfd Include bsd.opts.mk before Makefile.inc so Makefile.inc can do things
based on MK_xxx symbols. Continue to include bsd.own.mk after
Makefile.inc to preserve current behavior.
2014-04-24 02:02:51 +00:00
David E. O'Brien
d9a447559b Sync with HEAD. 2013-02-08 16:10:16 +00:00
Dag-Erling Smørgrav
edd42017c9 Remove all support for legacy NOFOO and NO_FOO build options. 2013-01-10 22:44:19 +00:00
Simon J. Gerraty
72f888f181 Allow clean at level 0 2012-11-08 21:39:00 +00:00
Marcel Moolenaar
7750ad47a9 Sync FreeBSD's bmake branch with Juniper's internal bmake branch.
Requested by: Simon Gerraty <sjg@juniper.net>
2012-08-22 19:25:57 +00:00
Hartmut Brandt
84aac27381 Make sure the only thing that follows .endif or .else is a comment. 2005-04-11 07:13:29 +00:00
Ruslan Ermilov
a6ac4fb307 Revert previous revision. Including bsd.compat.mk is necessary
both from sys.mk (to handle old knobs set in /etc/make.conf),
and from here (to handle old knobs set in individual makefiles).
2005-01-09 12:55:47 +00:00
Ruslan Ermilov
52dbe95f4d Include bsd.compat.mk early from sys.mk, enough for makefiles
using conditional statements to see the new spellings of NO_*
knobs (in case user still uses old spellings).

Reported by:	kris
2004-12-23 08:51:50 +00:00
Ruslan Ermilov
07736e20e9 NOATM -> NO_ATM 2004-12-21 09:08:06 +00:00
Ruslan Ermilov
2bdaf7e81c Don't include bsd.own.mk from sys.mk, this makes it impossible
to use ``.if defined()'' inside bsd.own.mk to test for defines
in individual makefiles.  For example, setting DEBUG_FLAGS in
Makefile didn't take the desired effect on the STRIP assignment.

Added bsd.init.mk (like in NetBSD) that handles the inclusion
of ../Makefile.inc and bsd.own.mk from all bsd.*.mk files that
"build something".

Back out bsd.own.mk,v 1.15: moved OBJFORMAT initialization back
to sys.mk (several source tree makefiles want to check it early)
and removed MACHINE_ARCH initialization (it's hard to see from
looking at the commitlogs what the problem was at the time, but
now it serves no purpose).

Prohibit the direct inclusion of bsd.man.mk and bsd.libnames.mk.

Protect bsd.obj.mk from repetitive inclusion.  Prohibiting the
direct inclusion of bsd.obj.mk might be a good idea too.
2002-04-17 13:49:29 +00:00