]> arthur.barton.de Git - ax-make.git/commitdiff
Refactor recursion logic, add AX_AUTO_RECURSE_DISABLE option
authorAlexander Barton <alexander.barton@thomas-daily.de>
Fri, 15 May 2020 11:04:34 +0000 (13:04 +0200)
committerAlexander Barton <alex@barton.de>
Fri, 15 May 2020 11:20:31 +0000 (13:20 +0200)
This allows to ...

- Disable auto-recursion behaviour by setting AX_AUTO_RECURSE_DISABLE=1
- Specifying the default targets (for "make" without any targets listed
  by overwriting the "default" target)
- Building sub-trees by adding support for "make <dir> [...]" invocation

Makefile.ax

index 180ce3c51ffb5681cea53b9551ea1a1dc00f6dbe..5e1a97f63db427e91a225c00e022e2e27f597850 100644 (file)
@@ -1,6 +1,6 @@
 #
 # ax-make: Alex' Simple Makefile System
-# Copyright (c)2014 Alexander Barton (alex@barton.de)
+# Copyright (c)2014-2020 Alexander Barton (alex@barton.de)
 #
 # This library is free software; you can redistribute it and/or modify
 # it under the terms of the GNU Lesser General Public License as published
@@ -15,9 +15,15 @@ PREFIX ?= /usr/local
 USER ?= $(shell id -un)
 GROUP ?= $(shell stat --format=%G $(DESTDIR)$(PREFIX) 2>/dev/null || id -gn)
 
-all: all-ax all-local
-
-all-ax: $(ALL) $(SUBDIRS)
+ifndef AX_AUTO_RECURSE_DISABLE
+# Automatically recurse into all $(SUBDIR)s for the default target.
+default: $(ALL) $(SUBDIRS) all-local
+all: $(ALL) all-ax all-local
+else
+# Automatic recursion for default target is disabled!
+default: $(ALL) all-local
+all: $(ALL) all-ax all-local
+endif
 
 clean: clean-ax clean-local
 
@@ -36,6 +42,10 @@ all-ax clean-ax distclean-ax maintainer-clean-ax check-ax install-ax:
          $(MAKE) -C $$subdir $$target || exit 1; \
         done
 
+$(SUBDIRS):
+       $(AX_SILENT)echo "Making default in \"$@\" ..."; \
+        $(MAKE) -C "$@" || exit 1
+
 .PHONY: all clean distclean maintainer-clean check install
 .PHONY: all-ax clean-ax distclean-ax maintainer-clean-ax check-ax install-ax
 .PHONY: all-local clean-local distclean-local maintainer-clean-local check-local install-local