From 5a79aa40e5a82a8358df0ab581f436df1e204134 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sat, 6 Sep 2014 08:00:47 -0600 Subject: Add an install target to all makefiles. For the import build, the top-level Makefile now does two passes: (1) builds libapp.a, then (2) installs the programs (not yet finished) --- apps/Makefile | 70 ++++++++++++++++++++++------------------------------------- 1 file changed, 26 insertions(+), 44 deletions(-) (limited to 'apps/Makefile') diff --git a/apps/Makefile b/apps/Makefile index 0ad9596d6..3ed1f3f87 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -110,72 +110,53 @@ BIN = libapps$(LIBEXT) # Build targets all: $(BIN) -.PHONY: $(INSTALLED_APPS) import context depend clean distclean +.PHONY: import install context .depdirs depend clean distclean + +define SDIR_template +$(1)_$(2): + $(Q) $(MAKE) -C $(1) $(2) TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" +endef $(INSTALLED_APPS): $(Q) $(MAKE) -C $@ TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" -$(BIN): $(INSTALLED_APPS) +$(foreach SDIR, $(INSTALLED_APPS), $(eval $(call SDIR_template,$(SDIR),all))) +$(foreach SDIR, $(INSTALLED_APPS), $(eval $(call SDIR_template,$(SDIR),install))) +$(foreach SDIR, $(INSTALLED_APPS), $(eval $(call SDIR_template,$(SDIR),context))) +$(foreach SDIR, $(INSTALLED_APPS), $(eval $(call SDIR_template,$(SDIR),depend))) +$(foreach SDIR, $(INSTALLED_APPS), $(eval $(call SDIR_template,$(SDIR),clean))) +$(foreach SDIR, $(INSTALLED_APPS), $(eval $(call SDIR_template,$(SDIR),distclean))) + +$(BIN): $(foreach SDIR, $(INSTALLED_APPS), $(SDIR)_all) + +install: $(foreach SDIR, $(INSTALLED_APPS), $(SDIR)_install) + +.import: $(BIN) install import: - $(Q) $(MAKE) TOPDIR="$(APPDIR)/import" + $(Q) $(MAKE) .import TOPDIR="$(APPDIR)/import" -context: -ifeq ($(CONFIG_WINDOWS_NATIVE),y) - $(Q) for %%G in ($(INSTALLED_APPS)) do ( \ - $(MAKE) -C %%G TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" context \ - ) -else - $(Q) for dir in $(INSTALLED_APPS) ; do \ - $(MAKE) -C $$dir TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" context ; \ - done -endif +context: $(foreach SDIR, $(INSTALLED_APPS), $(SDIR)_context) -.depend: context Makefile $(SRCS) -ifeq ($(CONFIG_WINDOWS_NATIVE),y) - $(Q) for %%G in ($(INSTALLED_APPS)) do ( \ - if exist %%G\.depend del /f /q %%G\.depend \ - $(MAKE) -C %%G TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" depend \ - ) -else - $(Q) for dir in $(INSTALLED_APPS) ; do \ - rm -f $$dir/.depend ; \ - $(MAKE) -C $$dir TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" depend ; \ - done -endif +.depdirs: $(foreach SDIR, $(INSTALLED_APPS), $(SDIR)_depend) + +.depend: context Makefile .depdirs $(Q) touch $@ depend: .depend -clean: -ifeq ($(CONFIG_WINDOWS_NATIVE),y) - $(Q) for %%G in ($(SUBDIRS)) do ( \ - $(MAKE) -C %%G clean TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" \ - ) -else - $(Q) for dir in $(SUBDIRS) ; do \ - $(MAKE) -C $$dir clean TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)"; \ - done -endif +clean: $(foreach SDIR, $(INSTALLED_APPS), $(SDIR)_clean) $(call DELFILE, $(BIN)) $(call CLEAN) -distclean: +distclean: $(foreach SDIR, $(INSTALLED_APPS), $(SDIR)_distclean) ifeq ($(CONFIG_WINDOWS_NATIVE),y) - $(Q) for %%G in ($(SUBDIRS)) do ( \ - $(MAKE) -C %%G distclean TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" \ - ) - $(call DELFILE, .depend) $(Q) ( if exist external ( \ echo ********************************************************" \ echo * The external directory/link must be removed manually *" \ echo ********************************************************" \ ) else - $(Q) for dir in $(SUBDIRS) ; do \ - $(MAKE) -C $$dir distclean TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)"; \ - done - $(call DELFILE, .depend) $(Q) ( if [ -e external ]; then \ echo "********************************************************"; \ echo "* The external directory/link must be removed manually *"; \ @@ -183,5 +164,6 @@ else fi; \ ) endif + $(call DELFILE, .depend) -- cgit v1.2.3