From 62d88cb2024fda024dea625c516b65508d34bfc6 Mon Sep 17 00:00:00 2001 From: Matlo Date: Sun, 17 May 2015 23:09:36 +0200 Subject: [PATCH] Refactor recursive makefiles. --- Makefile | 45 ++++++++++++++++++++++++++++++++++++--------- shared/Makefile | 28 +++++++++++++++++++++++----- 2 files changed, 59 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 010957df..f38eb755 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,27 @@ -DIRS=shared utils core config launcher fpsconfig +DIRS = utils shared core config launcher fpsconfig ifneq ($(OS),Windows_NT) DIRS+= po endif -all: - +for i in $(DIRS); do $(MAKE) -C $$i all; done +BUILDDIRS = $(DIRS:%=build-%) +INSTALLDIRS = $(DIRS:%=install-%) +CLEANDIRS = $(DIRS:%=clean-%) +UNINSTALLDIRS = $(DIRS:%=uninstall-%) -clean: - +for i in $(DIRS); do $(MAKE) -C $$i clean; done +all: $(BUILDDIRS) +$(DIRS): $(BUILDDIRS) +$(BUILDDIRS): + $(MAKE) -C $(@:build-%=%) + +build-core: build-shared +build-config: build-shared +build-launcher: build-shared +build-fpsconfig: build-shared + +clean: $(CLEANDIRS) +$(CLEANDIRS): + $(MAKE) -C $(@:clean-%=%) clean ifeq ($(OS),Windows_NT) install: all @@ -56,12 +69,26 @@ endif mkdir -p setup/ssl/certs cp -u -f /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem setup/ssl/certs/ca-bundle.crt +.PHONY: subdirs $(DIRS) +.PHONY: subdirs $(BUILDDIRS) +.PHONY: subdirs $(CLEANDIRS) +.PHONY: all install clean else -install: all - for i in $(DIRS); do $(MAKE) -C $$i install; done -uninstall: - -for i in $(DIRS); do $(MAKE) -C $$i uninstall; done +install: $(INSTALLDIRS) all +$(INSTALLDIRS): + $(MAKE) -C $(@:install-%=%) install + +uninstall: $(UNINSTALLDIRS) all +$(UNINSTALLDIRS): + $(MAKE) -C $(@:uninstall-%=%) uninstall really-clean: clean uninstall + +.PHONY: subdirs $(DIRS) +.PHONY: subdirs $(BUILDDIRS) +.PHONY: subdirs $(INSTALLDIRS) +.PHONY: subdirs $(UNINSTALLDIRS) +.PHONY: subdirs $(CLEANDIRS) +.PHONY: all install uninstall clean endif diff --git a/shared/Makefile b/shared/Makefile index d82fe1e4..43b59808 100644 --- a/shared/Makefile +++ b/shared/Makefile @@ -1,7 +1,25 @@ -DIRS=controller event updater configupdater configeditor gpp +DIRS = controller event updater configupdater configeditor gpp -all: - +for i in $(DIRS); do $(MAKE) -C $$i all; done +BUILDDIRS = $(DIRS:%=build-%) +INSTALLDIRS = $(DIRS:%=install-%) +CLEANDIRS = $(DIRS:%=clean-%) +UNINSTALLDIRS = $(DIRS:%=uninstall-%) -clean: - +for i in $(DIRS); do $(MAKE) -C $$i clean; done +all: $(BUILDDIRS) +$(DIRS): $(BUILDDIRS) +$(BUILDDIRS): + $(MAKE) -C $(@:build-%=%) + +build-configeditor: build-controller + +clean: $(CLEANDIRS) +$(CLEANDIRS): + $(MAKE) -C $(@:clean-%=%) clean + +install: $(INSTALLDIRS) all +$(INSTALLDIRS): ; + +.PHONY: subdirs $(DIRS) +.PHONY: subdirs $(BUILDDIRS) +.PHONY: subdirs $(CLEANDIRS) +.PHONY: all clean