-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
78 lines (76 loc) · 2.73 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
all:
@:
setup:
ifndef DESTDIR
@echo "The setup target requires a DESTDIR parameter,"
@echo "e.g.: \"make setup DESTDIR=/path/to/slackbuilds/repo/\""
else
@if [ ! -d "$$DESTDIR" ]; then \
echo "===> Error: $$DESTDIR is not a directory or it does not exist" >&2; \
exit 1; \
fi; \
if [ ! -d "$$DESTDIR/.git/" ]; then \
echo "===> Error: $$DESTDIR does not look like a git repository" >&2; \
exit 1; \
fi; \
if ! which git >/dev/null 2>&1; then \
echo "===> Error: No git found on your system" >&2; \
exit 1; \
fi; \
cd $$DESTDIR; \
if [ "$$(git config --get remote.origin.url)" != "git://git.slackbuilds.org/slackbuilds.git" ]; then \
echo "===> Error: $$DESTDIR does not look like a slackbuilds repository" >&2; \
exit 1; \
fi; \
categories=$$(git ls-tree -d --name-only HEAD); \
packages=$$(git ls-tree -dr --name-only HEAD | awk -F/ 'NF==2{print $$0}'); \
cd - >/dev/null; \
echo "===> Creating Makefile"; \
n=$$(sed -ne '/@category@/=' src/Makefile.in); \
>$$DESTDIR/Makefile; \
sed -ne "1,$$(($$n-1))p" src/Makefile.in >>$$DESTDIR/Makefile; \
for cat in $$categories; do \
echo "SUBDIR += $$cat" >>$$DESTDIR/Makefile; \
done; \
sed -ne "$$(($$n+1)),"'$$p' src/Makefile.in >>$$DESTDIR/Makefile; \
echo "===> Creating bin subdir"; \
rm -rf $$DESTDIR/bin; \
mkdir -p $$DESTDIR/bin; \
cp -pf src/bin/* $$DESTDIR/bin; \
echo "===> Creating mk subdir"; \
rm -rf $$DESTDIR/mk; \
mkdir -p $$DESTDIR/mk; \
cp -pf src/mk/*.mk $$DESTDIR/mk; \
for cat in $$categories; do \
echo "===> Creating $$cat/Makefile and $$cat/*/Makefile"; \
pkgs=$$(echo "$$packages" | sed -ne "\,^$$cat/,s,,,p"); \
mkdir -p $$DESTDIR/$$cat; \
>$$DESTDIR/$$cat/Makefile; \
echo 'SBODIR = $${CURDIR:/'"$$cat"'=}' >>$$DESTDIR/$$cat/Makefile; \
echo "" >>$$DESTDIR/$$cat/Makefile; \
for pkg in $$pkgs; do \
echo 'SUBDIR += '"$$pkg" >>$$DESTDIR/$$cat/Makefile; \
done; \
echo "" >>$$DESTDIR/$$cat/Makefile; \
echo 'include $${SBODIR}/mk/sbo.subdir.mk' >>$$DESTDIR/$$cat/Makefile; \
for pkg in $$pkgs; do \
if [ -f "$$DESTDIR/$$cat/$$pkg/Makefile" ]; then \
while read line; do \
if [ "$${line#SBODIR}" = "$$line" ]; then \
echo "Warning: $$cat/$$pkg/Makefile is already exists" >&2; \
continue 2; \
fi; \
break; \
done <$$DESTDIR/$$cat/$$pkg/Makefile; \
fi; \
mkdir -p $$DESTDIR/$$cat/$$pkg; \
>$$DESTDIR/$$cat/$$pkg/Makefile; \
echo 'SBODIR = $${CURDIR:/'"$$cat"'/'"$$pkg"'=}' >>$$DESTDIR/$$cat/$$pkg/Makefile; \
echo "" >>$$DESTDIR/$$cat/$$pkg/Makefile; \
echo 'DIST_SUBDIR ?= '"$$pkg" >>$$DESTDIR/$$cat/$$pkg/Makefile; \
echo "" >>$$DESTDIR/$$cat/$$pkg/Makefile; \
echo 'include $${SBODIR}/mk/sbo.mk' >>$$DESTDIR/$$cat/$$pkg/Makefile; \
done; \
done
endif
.PHONY: all setup