aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 3dc2d096041c51b1054f030fe602e12c75d2576e (plain) (blame)
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
45
46
47
48
49
50
51
.POSIX:

update: update-common update-private update-work

update-common:
	+@for PKGDIR in *; do \
		if test -d "$${PKGDIR}"; then \
			PKG="$$(printf '%s@\n' "$${PKGDIR}" | cut -d @ -f 1)"; \
			HOST="$$(printf '%s@\n' "$${PKGDIR}" | cut -d @ -f 2 | tr A-Z a-z)"; \
			if test -z "$${HOST}" || test "$${HOST}" = "$$(hostname | tr A-Z a-z)"; then \
				if ./check-installed "$${PKG}" 2>/dev/null; then \
					if ! ./check-installed "$$(readlink -- "$${PKGDIR}")" 2>/dev/null; then \
						printf -- '\033[1mcd %s && %s install\033[m\n' "$${PKGDIR}" '$(MAKE)'; \
						(cd -- "$${PKGDIR}" && $(MAKE) install); \
					fi; \
				else\
					printf -- '\033[1mcd %s && %s uninstall\033[m\n' "$${PKGDIR}" '$(MAKE)'; \
					(cd -- "$${PKGDIR}" && $(MAKE) uninstall || :); \
				fi; \
			fi; \
		fi; \
	done

update-private:
	+if test -f .private/pkgs/Makefile || test -f .private/pkgs/makefile; then \
		cd -- .private/pkgs && $(MAKE); \
	fi

update-work:
	+if test -f .work/pkgs/Makefile || test -f .work/pkgs/makefile; then \
		cd -- .work/pkgs && $(MAKE); \
	fi

.DEFAULT:
	+@for PKGDIR in $@; do \
		if test -d "$${PKGDIR}"; then \
			PKG="$$(printf '%s@\n' "$${PKGDIR}" | cut -d @ -f 1)"; \
			HOST="$$(printf '%s@\n' "$${PKGDIR}" | cut -d @ -f 2 | tr A-Z a-z)"; \
			if test -z "$${HOST}" || test "$${HOST}" = "$$(hostname | tr A-Z a-z)"; then \
				if ./check-installed "$${PKG}" 2>/dev/null; then \
					if ! ./check-installed "$$(readlink -- "$${PKGDIR}")" 2>/dev/null; then \
						printf -- '\033[1mcd %s && %s install\033[m\n' "$${PKGDIR}" '$(MAKE)'; \
						(cd -- "$${PKGDIR}" && $(MAKE) install); \
					fi; \
				else\
					printf -- '\033[1mcd %s && %s uninstall\033[m\n' "$${PKGDIR}" '$(MAKE)'; \
					(cd -- "$${PKGDIR}" && $(MAKE) uninstall || :); \
				fi; \
			fi; \
		fi; \
	done