-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
44 lines (39 loc) · 1.14 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Define source and target.
SOURCE:=src/
TARGET:=/
# Define folders aimed to serve only this application. Useful when removing them
# when they are empty. Only name those as they appear under SOURCE folder (if any).
# If more than one level is set, list deepest entries first
# Separate them with white spaces.
ONLY_APP_FOLDERS:=
# Basic configs
.DEFAULT_GOAL:=info
all: info install uninstall
.PHONY: all
# Info Target.
info:
@echo "Just some info!"
# Install Target.
install:
@echo "Installing files..."
@cp -rf $(wildcard $(SOURCE)*) $(TARGET)
@echo "Done!"
# Uninstall Target.
uninstall:
@echo "Uninstalling files..."
@find $(SOURCE) -type f -or -type l | sed -e 's@^$(SOURCE)@$(TARGET)@' | xargs -I {} rm -fr {}
@if [ -n "$(ONLY_APP_FOLDERS)" ]; then \
echo "Removing empty folders..."; \
fi;
@for dir in $(ONLY_APP_FOLDERS); do \
if [ ! -d "$(TARGET)$$dir" ]; then \
echo "Directory '$(TARGET)$$dir' already removed!" 1>&2; \
continue; \
fi; \
if [ ! -z "`ls -A $(TARGET)$$dir`" ]; then \
echo "Directory '$(TARGET)$$dir' is not empty. Not removing!" 1>&2; \
continue; \
fi; \
rm -rf "$(TARGET)$$dir"; \
done
@echo "Done!"