-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.pkg
141 lines (114 loc) · 4.31 KB
/
Makefile.pkg
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# Build all Debian packaging examples
# Copyright (C) 2015 Osamu Aoki
include Makefile.common
#######################################################################
pkg:
-mkdir -p $(TMPDIR)
echo "***$(DEBUG_VERSION)***"
#$(MAKE) prep # prepare source tree for consistent changelog etc.
$(MAKE) tars # make upstream tar files
$(MAKE) makes # add Makefile
$(MAKE) stamps # build source
.PHONY: pkg
#######################################################################
# Preparing upstream sources (prep, tars)
ARCH := $(shell dpkg-architecture -q DEB_TARGET_ARCH)
TERM = dumb
export TERM
ifdef DEBUG_VERSION
VERSIONS := $(DEBUG_VERSION)
else
VERSIONS := $(shell ls -d debhello-* | \
egrep -e '^debhello-[0-9]+\.[0-9]+$$' | \
sed -e 's/^debhello-//' )
endif
TARS := $(addsuffix .tar.gz, $(addprefix debhello-,$(VERSIONS)))
ORIGTARS := $(addsuffix .orig.tar.gz, $(addprefix debhello_,$(VERSIONS)))
CHANGELOGS := $(addsuffix /debian/changelog, $(addprefix debhello-,$(VERSIONS)))
COPYRIGHTS := $(addsuffix /debian/copyright, $(addprefix debhello-,$(VERSIONS)))
COMPATS := $(addsuffix /debian/compat, $(addprefix debhello-,$(VERSIONS)))
READMES := $(addsuffix /debian/README.Debian, $(addprefix debhello-,$(VERSIONS)))
WATCHS := $(addsuffix /debian/watch, $(addprefix debhello-,$(VERSIONS)))
SRCF := $(addsuffix /debian/source/format, $(addprefix debhello-,$(VERSIONS)))
SRCL := $(addsuffix /debian/source/local-options, $(addprefix debhello-,$(VERSIONS)))
CHANGES := $(addsuffix -1_$(ARCH).changes, $(addprefix debhello_,$(VERSIONS)))
WRAPS := $(addprefix debhello-,$(VERSIONS))
prep: $(CHANGELOGS) $(COPYRIGHTS) $(COMPATS) $(READMES) $(WATCHS) $(SRCF) $(SRCL)
# clean whitespaces in line tail (exclude binary files)
-find . -type d \
-regex ".*/\.git" -prune -o \
-regex ".*/png" -prune -o \
-type f -exec sed -i -e 's/[ \t]*$$//' '{}' \;
$(MAKE) $(WRAPS)
tars: $(TARS) $(ORIGTARS)
.PHONY: prep tars
#######################################################################
# Mock user sessions (makes, stamps)
CMDS := $(wildcard debhello-*/step000.cmd)
ifdef DEBUG_VERSION
CMDS := $(filter debhello-$(DEBUG_VERSION)%,$(CMDS))
endif
MAKEFILEX := $(sort $(subst step000.cmd,Makefile, $(CMDS)))
# MAKEFILES is the reserved variable for make !!!
STAMPX := $(sort $(subst step000.cmd,.stamp, $(CMDS)))
CMDSCL := $(sort $(subst /step000.cmd,-clean, $(CMDS)))
CMDSDCL := $(sort $(subst /step000.cmd,-distclean, $(CMDS)))
makes: $(MAKEFILEX)
stamps: $(STAMPX)
clean::
# don't clean packages
distclean:: $(CMDSDCL) $(CMDSCL)
-rm -f *.tar.xz *.tar.gz
-rm -f *.dsc *.changes *.build *.deb *~
.PHONY: makes stamps clean distclean
#######################################################################
# Build rules
debhello-%/debian/changelog: debian-template/changelog
mkdir -p debhello-$*/debian
sed -ne '/debhello ($*-1/,$$p' <$^ >$@
debhello-%/debian/copyright: debian-template/copyright
mkdir -p debhello-$*/debian
cp -f $^ $@
debhello-%/debian/compat: debian-template/compat
mkdir -p debhello-$*/debian
cp -f $^ $@
debhello-%/debian/README.Debian: debian-template/README.Debian
mkdir -p debhello-$*/debian
cp -f $^ $@
debhello-%/debian/watch: debian-template/watch
mkdir -p debhello-$*/debian
cp -f $^ $@
debhello-%/debian/source/format: debian-template/source/format
mkdir -p debhello-$*/debian/source
cp -f $^ $@
debhello-%/debian/source/local-options: debian-template/source/local-options
mkdir -p debhello-$*/debian/source
cp -f $^ $@
debhello-%-wrap:
cd debhello-$* ; \
wrap-and-sort
#######################################################################
debhello-%.tar.gz:
tar --exclude=debhello-$*/debian -cvzf $@ debhello-$*/
debhello_%.orig.tar.gz: debhello-%.tar.gz
ln -sf $^ $@
#######################################################################
debhello-%/Makefile: debian-template/Makefile
ln -sf ../$^ $@
debhello-%/.stamp: debhello-%/Makefile
@echo "============= Build debhello-$* =============="
$(MAKE) -C debhello-$*
touch $@
#######################################################################
debhello-%-clean:
# don't clean packages
debhello-%-distclean:
if [ -e debhello-$*/Makefile ]; then \
$(MAKE) -C debhello-$* clean ; \
fi
-rm -f debhello-$*/.stamp
if [ -e debhello-$*/Makefile ]; then \
$(MAKE) -C debhello-$* distclean ;\
rm -f debhello-$*/Makefile ; \
fi
-rm -f debhello-$*/.stamp