Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a macro to ignore file patterns in calls to find in the recipies #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ all: bin usr dotfiles etc ## Installs the bin and etc directory files and the do
.PHONY: bin
bin: ## Installs the bin directory files.
# add aliases for things in bin
for file in $(shell find $(CURDIR)/bin -type f -not -name "*-backlight" -not -name ".*.swp"); do \
$(eval find-ignore := *-backlight .*.swp)
for file in $(shell find $(CURDIR)/bin -type f $(call findn't,$(find-ignore))); do \
f=$$(basename $$file); \
sudo ln -sf $$file /usr/local/bin/$$f; \
done

.PHONY: dotfiles
dotfiles: ## Installs the dotfiles.
# add aliases for dotfiles
for file in $(shell find $(CURDIR) -name ".*" -not -name ".gitignore" -not -name ".git" -not -name ".config" -not -name ".github" -not -name ".*.swp" -not -name ".gnupg"); do \
$(eval find-ignore := .gitignore .git .config .github .*.swp .gnupg)
for file in $(shell find $(CURDIR) -name ".*" $(call findn't,$(find-ignore))); do \
f=$$(basename $$file); \
ln -sfn $$file $(HOME)/$$f; \
done; \
Expand Down Expand Up @@ -48,7 +50,8 @@ LAPTOP_XORG_FILE=/etc/X11/xorg.conf.d/10-dell-xps-display.conf
.PHONY: etc
etc: ## Installs the etc directory files.
sudo mkdir -p /etc/docker/seccomp
for file in $(shell find $(CURDIR)/etc -type f -not -name ".*.swp"); do \
$(eval find-ignore := .*.swp)
for file in $(shell find $(CURDIR)/etc -type f $(call findn't,$(find-ignore))); do \
f=$$(echo $$file | sed -e 's|$(CURDIR)||'); \
sudo mkdir -p $$(dirname $$f); \
sudo ln -f $$file $$f; \
Expand All @@ -67,7 +70,8 @@ etc: ## Installs the etc directory files.

.PHONY: usr
usr: ## Installs the usr directory files.
for file in $(shell find $(CURDIR)/usr -type f -not -name ".*.swp"); do \
$(eval find-ignore := .*.swp)
for file in $(shell find $(CURDIR)/usr -type f $(call findn't,$(find-ignore))); do \
f=$$(echo $$file | sed -e 's|$(CURDIR)||'); \
sudo mkdir -p $$(dirname $$f); \
sudo ln -f $$file $$f; \
Expand Down Expand Up @@ -95,3 +99,9 @@ shellcheck: ## Runs the shellcheck tests on the scripts.
.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

# $(call findn't,$(list of patterns to not `find`))
# returns '-not -name "pattern"' for each pattern in find-not patterns
define findn't
$(foreach i,$(1),-not -name "$i")
endef