Don't check for existence of source file/dir as find return only existing ones.
SHELL = /bin/sh
.PHONY: all
all:
ifeq '' '$(HOME)'
$(error HOME env var not set!)
endif
host_os = linux
ifneq '' '$(COMSPEC)'
host_os = windows
endif
OVERRIDDEN_ITEMS = .Xdefaults .bashrc .mailsign .xinitrc .mc .vimrc .inputrc .ssh .hgrc .hgignore .bazaar
IFNONEXIST_ITEMS = .wgetrc
.PHONY: install
install:
for item in $(OVERRIDDEN_ITEMS); do \
if [ -f $$item ]; then \
install -m 640 $$item $(HOME)/$$item; \
fi; \
if [ -d $$item ]; then \
for file in `find $$item`; do \
if [ -d $$file ]; then \
mkdir -p $(HOME)/$$file; \
continue; \
fi; \
install -m 640 $$file $(HOME)/$$file; \
done; \
fi; \
done
for item in $(IFNONEXIST_ITEMS); do \
if [ -f $$item -a ! -f $(HOME)/$$item ]; then \
install -m 640 $$item $(HOME)/$$item; \
fi; \
if [ -d $$item ]; then \
for file in `find $$item`; do \
if [ -d $$file ]; then \
mkdir -p $(HOME)/$$file; \
continue; \
fi; \
if [ ! -f $(HOME)/$$file ]; then \
install -m 640 $$file $(HOME)/$$file; \
fi; \
done; \
fi; \
done
.PHONY: uninstall
uninstall:
rm -f $(HOME)/.mailsign
.PHONY: clean
clean:
.PHONY: distclean
distclean: clean