From d26d20d8d6a57f8feaa3fa28536ebde7bd19fd99 Mon Sep 17 00:00:00 2001 From: James Patrick Date: Sat, 27 Apr 2019 18:15:45 -0400 Subject: [PATCH] Simplified base level make to recursive make command. It will look for all first level child `makefile`, and run assigned target. This is equivalent to running: ```shell for i in */makefile; do make -C $i $target done ``` --- makefile | 46 ++++++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/makefile b/makefile index 2dce1ea..3690f46 100644 --- a/makefile +++ b/makefile @@ -1,33 +1,27 @@ SRC_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) -cmd_exist = $(shell (command -v $(1) 1>&2 >/dev/null && echo true || echo false) ) -install: | init update +include lib/shared.mk -init: vim_init tmux_init ssh_init waybar_init - @ ln -svf $(SRC_DIR)/bin/post-merge $(SRC_DIR)/.git/hooks/post-merge -update: vim_update +define recursive_make + for i in */makefile; do; \ + echo "`dirname $$i` " ; \ + $(MAKE) -C $(SRC_DIR)/`dirname $$i` $1 ; \ + echo "" ; \ + done +endef -ssh_init: - $(info => Setting up ssh config) - @ ! [ -e ~/.ssh/config ] \ - && ln -svf $(SRC_DIR)/ssh/config ~/.ssh/config \ - || echo " ~/.ssh/config already exist. Skipping." +install: + $(info Initalizing) + $(call recursive_make,install) -tmux_init: - $(info => Setting up tmux) - @ [ $(call cmd_exist,'tmux') ] \ - && ! [ -e ~/.tmux.conf ] \ - && ln -svf $(SRC_DIR)/tmux/tmux.conf ~/.tmux.conf \ - || echo " ~/.tmux.conf already exist. Skipping." +init: + $(info Initalizing) + $(call recursive_make,init) -waybar_init: - @ [ $(call cmd_exist,'waybar') ] \ - && ! [ -e ~/.config/waybar ] \ - && ln -svf $(SRC_DIR)/waybar ~/.config/waybar \ - || echo " ~/.waybar.conf already exist. Skipping." -vim_init: - @ $(MAKE) -C $(SRC_DIR)/vim init -vim_update: - @ $(MAKE) -C $(SRC_DIR)/vim update +update: + $(info Updating) + $(call recursive_make,update) -.PHONY: install update init foo +remove: + $(info Removing) + $(call recursive_make,remove)