summaryrefslogtreecommitdiff
path: root/scripts
Unidiff
Diffstat (limited to 'scripts') (more/less context) (ignore whitespace changes)
-rwxr-xr-xscripts/GeneratePackageMake228
1 files changed, 228 insertions, 0 deletions
diff --git a/scripts/GeneratePackageMake b/scripts/GeneratePackageMake
new file mode 100755
index 0000000..d5ccee5
--- a/dev/null
+++ b/scripts/GeneratePackageMake
@@ -0,0 +1,228 @@
1# generate file containg control name / package name / files
2find . -name *.control | grep -v -- "-mt.control" | while read i
3do
4 i=${i/.\//}
5 CDIR=${i%/*}
6 BNAME=${i##*/}
7 BNAME=${BNAME/.control/}
8 echo "cdir: ${CDIR}"
9 echo "bname: ${BNAME}"
10 grep -e "Package:" -e "Files:" ./${i}
11done > /tmp/ALL
12
13#
14# makefile header
15#
16
17cat << MAKEFILEHEADER
18
19#
20# generate -mt.control file from regular control
21# arg 1 : path to control file to convert
22#
23
24define GenerateMTControl
25@echo "Generating -mt control file for \$(basename \$<)"
26@\$(OPIEDIR)/scripts/tothreaded \$< \$(OPIEDIR)/AllThreadedPackages
27endef
28
29#
30# package one control file
31# arg 1 : directory from OPIEROOT where control file resides
32# arg 2 : control file basename without -mt (no .control)
33# arg 3 : control file basename with -mt if needed
34# arg 4 : package name (value specified by Package: ...)
35#
36
37define DoPackage
38@echo \"Building ipk of \$(4)\"
39@( \$(ForSubst) ) > \$(TOPDIR)/scripts/subst
40@( \$(ForFileSubst) ) > \$(TOPDIR)/scripts/Filesubst
41@( cd \$(OPIEDIR); \\
42 \$(OPIEDIR)/scripts/mkipkg \\
43 --subst=\$(OPIEDIR)/scripts/subst \\
44 --filesubst=\$(OPIEDIR)/scripts/filesubst \\
45 --control=\$(OPIEDIR)/\$(1)/\$(3).control \\
46 --prerm=\$(OPIEDIR)/\$(1)/\$(2).prerm \\
47 --preinst=\$(OPIEDIR)/\$(1)/\$(2).preinst \\
48 --postrm=\$(OPIEDIR)/\$(1)/\$(2).postrm \\
49 --postinst=\$(OPIEDIR)/\$(1)/\$(2).postinst \\
50 --strip=\$(STRIP) \$(OPIEDIR); \\
51 rm -f \$(OPIEDIR)/Packages/\$(4)_*.ipk; \\
52 mv *.ipk \$(OPIEDIR)/Packages; \\
53 touch \$(OPIEDIR)/Packages/\$(4) \\
54) || true
55endef
56
57#
58# prepared for generating the substfile for every build
59#
60
61define ForSubst
62echo 's,\\\$\$QPE_VERSION,\$(QPE_VERSION),g'; \\
63echo 's,\\\$\$OPIE_VERSION,\$(OPIE_VERSION),g'; \\
64echo 's,\\\$\$QTE_VERSION,\$(QTE_VERSION),g'; \\
65echo 's,\\\$\$QTE_REVISION,\$(QTE_REVISION),g'; \\
66echo 's,\\\$\$SUB_VERSION,\$(SUB_VERSION),g'; \\
67echo 's,\\\$\$EXTRAVERSION,\$(EXTRAVERSION),g'; \\
68echo 's,\\\$\$QTE_BASEVERSION,\$(QTE_BASEVERSION),g'
69endef
70
71define ForFileSubst
72echo 's,\\\$\$OPIEDIR/root/,/,g'; \\
73echo 's,\$(OPIEDIR)/root/,/,g'; \\
74echo 's,\\\$\$OPIEDIR,\$(prefix),g'; \\
75echo 's,\$(OPIEDIR),\$(prefix),g'; \\
76echo 's,\\\$\$QTDIR,\$(prefix),g'; \\
77echo 's,\$(QTDIR),\$(prefix),g'; \\
78echo 's,^\(\./\)*root/,/,g'; \\
79echo 's,^\(\./\)*etc/,\$(prefix)/etc/,g'; \\
80echo 's,^\(\./\)*lib/,\$(prefix)/lib/,g'; \\
81echo 's,^\(\./\)*bin/,\$(prefix)/bin/,g'; \\
82echo 's,^\(\./\)*pics/,\$(prefix)/pics/,g'; \\
83echo 's,^\(\./\)*sounds/,\$(prefix)/sounds/,g'; \\
84echo 's,^\(\./\)*i18n/,\$(prefix)/i18n/,g'; \\
85echo 's,^\(\./\)*plugins/,\$(prefix)/plugins/,g'; \\
86echo 's,^\(\./\)*apps/,\$(prefix)/apps/,g'; \\
87echo 's,^\(\./\)*share/,\$(prefix)/share/,g'; \\
88echo 's,^\(\./\)*i18n/,\$(prefix)/i18n/,g'; \\
89echo 's,^\(\./\)*help/,\$(prefix)/help/,g'
90endef
91
92#
93# Will contain a list of all non-mt control files
94ALLCONTROLFILES=
95
96#
97# Will contain a list of all packaging targets
98ALLPACKAGES=
99
100# s contains now single space
101s=\$(x) \$(x)
102
103#
104# for convenience : generate AllTh
105ATP=\$(OPIEDIR)/AllThreadedPackages
106
107MAKEFILEHEADER
108
109while read k
110do
111 CDIR="${k#* }"
112 read k
113 BNAME="${k#* }"
114 read k
115 case $k in
116 *"ackage:"*)
117 Pkg="${k#* }"
118 Pkg="${Pkg// }"
119 ;;
120 *"iles:"*)
121 Files="${k/Files:/}"
122 ;;
123 esac
124 read k
125 case $k in
126 *"ackage:"*)
127 Pkg="${k#* }"
128 Pkg="${Pkg// }"
129 ;;
130 *"iles:"*)
131 Files="${k/Files:/}"
132 ;;
133 esac
134
135 cat << HERE
136#
137# package $Pkg in ${BNAME}
138#
139
140package-${Pkg} : \$(OPIEDIR)/Packages/$Pkg
141package-${Pkg}-mt : \$(OPIEDIR)/Packages/$Pkg-mt
142
143# collect control files and package targets
144
145ALLCONTROLFILES += ${CDIR}/${BNAME}.control
146ALLPACKAGES += $Pkg
147
148# to generate -mt control file
149\$(OPIEDIR)/${CDIR}/${BNAME}-mt.control : \$(OPIEDIR)/${CDIR}/${BNAME}.control
150 \$(GenerateMTControl)
151
152HERE
153
154 if [ ! -z "${Files}" ]
155 then
156
157 cat << HERE
158# optimize speed
159.phony : \$(wildcard \$(addprefix \$(OPIEDIR)/,${Files}))
160
161# capture missing files (because not built)
162\$(OPIEDIR)/Packages/$Pkg \$(OPIEDIR)/Packages/$Pkg-mt \$(SUBSTFILES): \$(wildcard \$(addprefix \$(OPIEDIR)/,${Files}))
163HERE
164
165# echo "\$(wildcard \$(addprefix \$(OPIEDIR)/,${Files})) : "
166
167 fi
168
169 cat << HERE
170\$(OPIEDIR)/Packages/$Pkg : \$(OPIEDIR)/${CDIR}/${BNAME}.control
171 @\$(call DoPackage,${CDIR},${BNAME},${BNAME},${Pkg})
172\$(OPIEDIR)/Packages/$Pkg-mt : \$(OPIEDIR)/${CDIR}/${BNAME}-mt.control
173 @\$(call DoPackage,${CDIR},${BNAME},${BNAME}-mt,${Pkg}-mt)
174
175HERE
176
177done < /tmp/ALL
178
179cat << HERE
180#
181# regenerate package file if control files are modified
182#
183
184Package.make : \$(addprefix \$(OPIEDIR)/,\$(ALLCONTROLFILES))
185
186#
187# make targets to build packages
188# needs quicklauncher link in location (because dangling
189# links are not considered as true files by the wildcard command)
190#
191# if you want to build one package only then use
192# make package-<basenameof control>
193# or make package-<basenameof control>-mt
194#
195
196packages : /opt/QtPalmtop/bin/quicklauncher \\
197 \$(OPIEDIR)/Packages \\
198 \$(add prefix \$(OPIEDIR)/Packages/,\$(ALLPACKAGES))
199packages-mt : /opt/QtPalmtop/bin/quicklauncher \\
200 \$(ATP) \\
201 \$(OPIEDIR)/Packages \\
202 \$(addprefix \$(OPIEDIR)/Packages/,\$(addsuffix -mt,\$(ALLPACKAGES)))
203
204#
205# capture missing quichlauncher link
206#
207
208/opt/QtPalmtop/bin/quicklauncher :
209 @echo "create a link from /opt/QtPalmtop to \$(OPIEDIR) for this target to work"
210 exit 2
211
212#
213# Create Packages directory
214#
215
216\$(OPIEDIR)/Packages :
217 @mkdir \$(OPIEDIR)/Packages
218
219#
220# update file containing all packages
221#
222
223\$(ATP) : \$(addprefix \$(OPIEDIR)/,\$(ALLCONTROLFILES))
224 @echo "Generating \$(notdir \$(ATP))"
225 @echo -e "\$(subst \$(s),,\$(foreach i,\$(ALLPACKAGES),\$(i)\n))" > \$@
226HERE
227
228rm /tmp/ALL