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
```
This commit is contained in:
James Patrick 2019-04-27 18:15:45 -04:00
parent e49934c99d
commit d26d20d8d6

View File

@ -1,33 +1,27 @@
SRC_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) 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 define recursive_make
@ ln -svf $(SRC_DIR)/bin/post-merge $(SRC_DIR)/.git/hooks/post-merge for i in */makefile; do; \
update: vim_update echo "`dirname $$i` " ; \
$(MAKE) -C $(SRC_DIR)/`dirname $$i` $1 ; \
echo "" ; \
done
endef
ssh_init: install:
$(info => Setting up ssh config) $(info Initalizing)
@ ! [ -e ~/.ssh/config ] \ $(call recursive_make,install)
&& ln -svf $(SRC_DIR)/ssh/config ~/.ssh/config \
|| echo " ~/.ssh/config already exist. Skipping."
tmux_init: init:
$(info => Setting up tmux) $(info Initalizing)
@ [ $(call cmd_exist,'tmux') ] \ $(call recursive_make,init)
&& ! [ -e ~/.tmux.conf ] \
&& ln -svf $(SRC_DIR)/tmux/tmux.conf ~/.tmux.conf \
|| echo " ~/.tmux.conf already exist. Skipping."
waybar_init: update:
@ [ $(call cmd_exist,'waybar') ] \ $(info Updating)
&& ! [ -e ~/.config/waybar ] \ $(call recursive_make,update)
&& 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
.PHONY: install update init foo remove:
$(info Removing)
$(call recursive_make,remove)