1 |
# |
2 |
# @(#)$Id: Makefile,v 1.1 2009/02/26 16:04:13 templon Exp $ |
3 |
# |
4 |
|
5 |
####################################################### |
6 |
# |
7 |
# General settings |
8 |
# |
9 |
####################################################### |
10 |
|
11 |
.PHONY: release minorversion majorversion tagversion |
12 |
.PHONY: pack rpm pkg prep clean dist userdoc apidoc check |
13 |
.PHONY: checkmndfiles checkcfgtags checkdprfiles |
14 |
.PHONY: checksrctags header help tagstable markobsolete |
15 |
|
16 |
#################################################################### |
17 |
# Linux specific settings |
18 |
#################################################################### |
19 |
# |
20 |
# |
21 |
|
22 |
_rpmbuild := $(shell [ -x /usr/bin/rpmbuild ] && echo rpmbuild || echo rpm) |
23 |
_builddir := $(shell rpm --eval %_builddir) |
24 |
_specdir := $(shell rpm --eval %_specdir) |
25 |
_sourcedir := $(shell rpm --eval %_sourcedir) |
26 |
_srcrpmdir := $(shell rpm --eval %_srcrpmdir) |
27 |
_rpmdir := $(shell rpm --eval %_rpmdir) |
28 |
|
29 |
CFG_MK = config-$(PACKAGE).mk |
30 |
include $(CFG_MK) |
31 |
_module = $(NAME) |
32 |
_vpfx = $(NAME)_ |
33 |
_vtag = $(subst -,_,$(subst .,_,$(_vpfx)$(VERSION)$(BRANCH))) |
34 |
_prodname = $(NAME)-$(VERSION)$(BRANCH) |
35 |
_prodtar = $(_prodname).src.tgz |
36 |
|
37 |
# if INSTALLPREFIX is defined, install files go there. |
38 |
# Otherwise use TARGPREFIX also as place to install files. |
39 |
|
40 |
ifeq ($(INSTALLPREFIX),) |
41 |
INSTALLPREFIX := $(TARGPREFIX) |
42 |
endif |
43 |
|
44 |
# some SVN commands (ckeckout, update, commit) are by default quiet unless |
45 |
# SVN_VERB is defined |
46 |
_svn := svn --quiet |
47 |
ifneq ($(SVN_VERB),) |
48 |
_svn := svn |
49 |
endif |
50 |
# same for rpm |
51 |
_rpm := $(_rpmbuild) --quiet |
52 |
ifneq ($(RPM_VERB),) |
53 |
_rpm := $(_rpmbuild) |
54 |
endif |
55 |
|
56 |
_os := $(shell uname -s) |
57 |
_date := $(shell date '+%d/%m/%y %H:%M') |
58 |
|
59 |
############################################################################### |
60 |
# Macros |
61 |
############################################################################### |
62 |
|
63 |
# _error, message |
64 |
# _warn, message |
65 |
# _fatal,err msg,exit code: print "err msg" and quit with "exit code" (the if |
66 |
# clause is just used to group the commands) |
67 |
_fatal = if true; then echo "[FATAL] $(1)">&2; exit $(2); fi |
68 |
_error = echo "[ERROR] $(1)">&2 |
69 |
_warn = echo "[WARN] $(1)">&2 |
70 |
|
71 |
############################################################################### |
72 |
# SVN |
73 |
############################################################################### |
74 |
_SVN_BRNCH_SDIR := branches |
75 |
_SVN_TAG_SDIR := tags |
76 |
_SVN_TRNK_SDIR := trunk |
77 |
|
78 |
################################################################### |
79 |
# Create linux specific build directories |
80 |
################################################################### |
81 |
|
82 |
envdir:: $(_srcrpmdir) $(_rpmdir) |
83 |
$(_srcrpmdir): |
84 |
mkdir -p $(_srcrpmdir) |
85 |
$(_rpmdir): |
86 |
mkdir -p $(_rpmdir) |
87 |
|
88 |
#################################################################### |
89 |
# Create new release/version/majorversion |
90 |
#################################################################### |
91 |
# |
92 |
# These targets update the X.Y.Z components of the version in the |
93 |
# config file and then commit the current version, tagging all |
94 |
# files with the release number from the config file. Also |
95 |
# wires the current date and time into the config file. Also |
96 |
# adds an entry to the ChangeLog. |
97 |
|
98 |
# check that the requested operation is allowed: |
99 |
# - refuse to run if SVN passwords/credentials caching is off |
100 |
# - forbid committing in tags/ directory |
101 |
_svn_cfg_file = $(HOME)/.subversion/config |
102 |
_checkop: |
103 |
@if [ ! -r $(_svn_cfg_file) ]; then\ |
104 |
$(call _fatal,$(_svn_cfg_file): svn config file not found/readable,1);\ |
105 |
fi |
106 |
@if [ "`sed -nr '/^\s*store-passwords\s*=\s*no/ p' $(_svn_cfg_file)`" ]; then\ |
107 |
$(call _fatal, please set 'store-passwords = yes' in your svn config file $(_svn_cfg_file),1);\ |
108 |
fi |
109 |
@if [ "`sed -nr '/^\s*store-auth-creds\s*=\s*no/ p' $(_svn_cfg_file)`" ]; then\ |
110 |
$(call _fatal, please set 'store-auth-creds = yes' in your svn config file $(_svn_cfg_file),1);\ |
111 |
fi |
112 |
@if [ "`svn info | sed -nr '/\/$(_SVN_TAG_SDIR)\/*/ p'`" ]; then\ |
113 |
$(call _fatal,operation not allowed in "$(_SVN_TAG_SDIR)/",1);\ |
114 |
fi |
115 |
@if [ "`svn info | sed -n '/\/$(_SVN_BRNCH_SDIR)\/*/ p'`" ]; then\ |
116 |
$(call _fatal,the build tools do not work in "$(_SVN_TAG_SDIR)/",1);\ |
117 |
fi |
118 |
|
119 |
release: _checkop config.tmp |
120 |
@echo '[INFO] increasing release number x.x.<X> and timestamp..' |
121 |
@perl <config.tmp >$(CFG_MK) -e 'while (<>) ' \ |
122 |
-e '{ s/^(VERSION=\d+\.\d+\.)(\d+)(.*)$$/$$1.($$2+1).$$3/e;' \ |
123 |
-e 's/^(RELEASE=)(\d+)(.*)$$/$$1."1".$$3/e; print; }' |
124 |
@$(MAKE) tagversion |
125 |
|
126 |
minorversion: _checkop config.tmp |
127 |
@echo '[INFO] increasing minorversion number x.<X>.x and timestamp..' |
128 |
@perl <config.tmp >$(CFG_MK) -e 'while (<>) ' \ |
129 |
-e '{ s/^(VERSION=\d+\.)(\d+)(\..*)$$/$$1.($$2+1).".0"/e;' \ |
130 |
-e ' s/^(RELEASE=)(\d+)(.*)$$/$$1."1".$$3/e; print; }' |
131 |
@$(MAKE) tagversion |
132 |
|
133 |
majorversion: _checkop config.tmp |
134 |
@echo '[INFO] increasing majorversion number <X>.x.x and timestamp..' |
135 |
@perl <config.tmp >$(CFG_MK) -e 'while (<>)' \ |
136 |
-e '{ s/^(VERSION=)(\d+)(\..*)$$/$$1.($$2+1).".0.0"/e;' \ |
137 |
-e ' s/^(RELEASE=)(\d+)(.*)$$/$$1."1".$$3/e; print; }' |
138 |
@$(MAKE) tagversion |
139 |
|
140 |
config.tmp: $(CFG_MK) |
141 |
@$(_svn) update . |
142 |
@sed <$(CFG_MK) >config.tmp '/^DATE=/d' |
143 |
@echo 'DATE=$(_date)' >>config.tmp |
144 |
@cp $(CFG_MK) $(CFG_MK)~ |
145 |
|
146 |
tagversion: _checkop |
147 |
@echo "[INFO] svn committing new release: $(VERSION)" |
148 |
@rm -f config.tmp |
149 |
@perl -e '$$date=`date +%Y-%m-%d`;' \ |
150 |
-e 'chomp($$date);' \ |
151 |
-e '$$login=getlogin();' \ |
152 |
-e '$$logstr="<unknown>";' \ |
153 |
-e '$$logstr=(getpwnam($$login))[6] if defined $$login;' \ |
154 |
-e 'print $$date." $$logstr\n\n"; '\ |
155 |
-e 'print "\t* Release: $(NAME)-$(VERSION)\n";' >ChangeLog.tmp |
156 |
@if [ "$(EDITOR)" -a -x "$(EDITOR)" ]; then \ |
157 |
perl -e 'print "\t- [your comment here]"' >>ChangeLog.tmp; \ |
158 |
$(EDITOR) ChangeLog.tmp; \ |
159 |
perl -e '$$/=undef; $$text=<>; $$text =~ s/\s*\n*$$//s;' \ |
160 |
-e 'print "$$text\n\n"' < ChangeLog.tmp > ChangeLog.tmp2; \ |
161 |
mv ChangeLog.tmp2 ChangeLog.tmp; \ |
162 |
else \ |
163 |
echo "[INFO] Enter ChangeLog comment (hit CTRL+D to stop):"; \ |
164 |
perl -e '$$text=""; while(<>) { $$text .= "\t$$_" };' \ |
165 |
-e '$$text =~ s/^\s*(.+?)\s*\n*$$/$$1/s;' \ |
166 |
-e 'chomp($$text); print "\t- $$text\n\n"' >>ChangeLog.tmp; \ |
167 |
fi |
168 |
@if [ ! -r ChangeLog ] ; then touch ChangeLog ; $(_svn) add ChangeLog ; fi |
169 |
@cp ChangeLog.tmp /tmp/ChangeLog.tmp.$$$ |
170 |
@cat ChangeLog >>ChangeLog.tmp |
171 |
@mv ChangeLog.tmp ChangeLog |
172 |
@$(_svn) commit -F /tmp/ChangeLog.tmp.$$$ |
173 |
@rm -f /tmp/ChangeLog.tmp.$$$ |
174 |
@$(MAKE) _tag_dir=$(_vtag) svntag |
175 |
@$(MAKE) _tag_dir=latest _trg_tag=$(_vtag) svnextag |
176 |
@$(MAKE) tagstable |
177 |
|
178 |
# auxiliary target to build an SVN tag. Input parameter is _tag_dir, which |
179 |
# is the leaf subdirectory (intermediate subdirectories are built transparently); |
180 |
# _co_root is the checkout root, |
181 |
# _co_locl is the local path to the module in the checkout |
182 |
# _co_subd is the sub-path to the module in the checkout |
183 |
# that is: |
184 |
# $pwd == $_co_root/$_co_locl == $_co_root/$_co_subd/$_module |
185 |
# |
186 |
_svn_root = $(shell svn info | sed -nr 's/^.+Root:\s+(\S+)$$/\1/ p') |
187 |
_svn_url = $(shell svn info | sed -nr 's/^URL:\s+(\S+)$$/\1/ p') |
188 |
_co_locl = $(shell echo $(_svn_url) | sed -nr 's%^\S+?/$(_SVN_TRNK_SDIR)/%% p') |
189 |
_co_subd = $(shell echo $(_co_locl) | sed -nr 's%/$(_module)$$%% p') |
190 |
# don't ask me why this doesn't work... |
191 |
# _co_root = $(shell echo -n $(PWD) |\ |
192 |
# sed -r 's%^(.+?)/(\S*$(_SVN_TRNK_SDIR)/)?$(_co_locl)$$%\1%' | sed -r 's%/*$$%%') |
193 |
_co_root = $(shell pwd | \ |
194 |
perl -e '$$a=<>; $$a=~s%^(\S+?)/([^/]*$(_SVN_TRNK_SDIR)/)?$(_co_locl)$$%$$1%; print $$a' |\ |
195 |
sed -r 's%/*$$%%') |
196 |
ifneq ($(QTTR_CO_ROOT),) |
197 |
_co_root = $(QTTR_CO_ROOT) |
198 |
endif |
199 |
svntag: _checkop |
200 |
@if [ "$(DEBUG)" ]; then\ |
201 |
echo "[DEBUG] _svn_root=$(_svn_root)" >&2;\ |
202 |
echo "[DEBUG] _svn_url=$(_svn_url)" >&2;\ |
203 |
echo "[DEBUG] _co_locl=$(_co_locl)" >&2;\ |
204 |
echo "[DEBUG] _co_subd=$(_co_subd)" >&2;\ |
205 |
echo "[DEBUG] _co_root=$(_co_root)" >&2;\ |
206 |
fi |
207 |
@[ "$(_tag_dir)" ] || $(call _fatal,no tag directory specified,1) |
208 |
@[ "$(_co_root)" -a "$(_svn_root)" ]\ |
209 |
|| $(call _fatal,checkout and/or SVN root not defined,2) |
210 |
@echo "[INFO] svn tagging new release: $(_tag_dir)" |
211 |
@src_path=$$PWD;\ |
212 |
dst_url=$(_svn_root)/$(_SVN_TAG_SDIR)/$(_co_subd)/$(_module);\ |
213 |
dst_path=$(_co_root)/$(_SVN_TAG_SDIR)/$(_co_subd)/$(_module);\ |
214 |
[ "$(DEBUG)" ] && echo "[DEBUG] dst_url=$$dst_url" >&2;\ |
215 |
[ "$(DEBUG)" ] && echo "[DEBUG] dst_path=$$dst_path" >&2;\ |
216 |
aux=$(_co_subd);\ |
217 |
[ "$(DEBUG)" ] && echo "[DEBUG] aux=$$aux" >&2;\ |
218 |
saux='';\ |
219 |
made_sdir=0;\ |
220 |
tag_mod_root='';\ |
221 |
while [ "$$aux" ]; do\ |
222 |
sdir=`echo -n $$aux | sed -nr 's%^([^/]+).*?$$%\1% p'`;\ |
223 |
[ $$made_sdir -eq 0 ] && tag_mod_root=$$sdir;\ |
224 |
[ "$(DEBUG)" ] && echo "[DEBUG] sdir=$$sdir" >&2;\ |
225 |
saux=$$saux/$$sdir;\ |
226 |
dst_surl=$(_svn_root)/$(_SVN_TAG_SDIR)/$$saux;\ |
227 |
[ "$(DEBUG)" ] && echo "[DEBUG] dst_surl=$$dst_surl" >&2;\ |
228 |
if (svn info $$dst_surl 2>&1 | egrep "\(Not a valid URL\)") >/dev/null; then\ |
229 |
$(_svn) mkdir $$dst_surl -m "Made directory $(_SVN_TAG_SDIR)$$saux" \ |
230 |
|| $(call _fatal,$$dst_surl: cant make svn dir,3);\ |
231 |
fi;\ |
232 |
aux=`echo -n $$aux | sed -nr "s%^$$sdir/%% p"`;\ |
233 |
[ "$(DEBUG)" ] && echo "[DEBUG] aux=$$aux" >&2;\ |
234 |
made_sdir=1;\ |
235 |
done;\ |
236 |
if (svn info $$dst_url 2>&1 | egrep "\(Not a valid URL\)") >/dev/null; then\ |
237 |
[ "$(DEBUG)" ] && echo "[DEBUG] svn mkdir $$dst_url" >&2;\ |
238 |
$(_svn) mkdir $$dst_url -m "Made directory $(_SVN_TAG_SDIR)/$(_co_subd)/$(_module)"\ |
239 |
|| $(call _fatal,$$dst_url: cant make svn dir,4);\ |
240 |
fi;\ |
241 |
[ "$(DEBUG)" ] && echo "[DEBUG] svn copy $$src_path $$dst_url/$(_tag_dir)" >&2;\ |
242 |
$(_svn) copy $$src_path $$dst_url/$(_tag_dir) -m "Added tag $(_module)/$(_tag_dir)" \ |
243 |
|| $(call _fatal,$$src_path: cant svn copy to $$dst_url/$(_tag_dir),5);\ |
244 |
[ "$(DEBUG)" ] && echo "[DEBUG] svn co $$dst_url/$(_tag_dir) $$dst_path/$(_tag_dir)" >&2;\ |
245 |
$(_svn) checkout $$dst_url/$(_tag_dir) $$dst_path/$(_tag_dir) \ |
246 |
|| $(call _fatal,$$dst_url/$(_tag_dir): cant svn check out,6) |
247 |
|
248 |
|
249 |
svnextag: _checkop |
250 |
@[ "$(_tag_dir)" ] || $(call _fatal,no tag directory specified,1) |
251 |
@[ "$(_trg_tag)" ] || $(call _fatal,no target tag specified,2) |
252 |
@echo "[INFO] svn tagging external reference: $(_tag_dir) -> $(_trg_tag)" |
253 |
@[ "$(_co_root)" -a "$(_svn_root)" ]\ |
254 |
|| $(call _fatal,checkout and/or SVN root not defined,3) |
255 |
@src_sdir=$(_SVN_TAG_SDIR)/$(_co_subd)/$(_module)/$(_trg_tag);\ |
256 |
src_url=$(_svn_root)/$$src_sdir;\ |
257 |
src_path=$(_co_root)/$$src_sdir;\ |
258 |
dst_sdir=$(_SVN_TAG_SDIR)/$(_co_subd)/$(_module)/$(_tag_dir);\ |
259 |
dst_url=$(_svn_root)/$$dst_sdir;\ |
260 |
dst_path=$(_co_root)/$$dst_sdir;\ |
261 |
if (svn info $$dst_url 2>&1 | egrep "\(Not a valid URL\)") >/dev/null; then\ |
262 |
$(_svn) mkdir $$dst_url -m "Made directory $$dst_surl"\ |
263 |
|| $(call _fatal,$$dst_surl: cant make svn dir,4);\ |
264 |
cd $(_co_root)/$(_SVN_TAG_SDIR);\ |
265 |
$(_svn) checkout $$dst_url $$dst_path \ |
266 |
|| $(call _fatal,$$dst_url: cant svn check out,5);\ |
267 |
else\ |
268 |
$(_svn) checkout $$dst_url $$dst_path \ |
269 |
|| $(call _fatal,$$dst_url: cant svn check out,6);\ |
270 |
$(_svn) propdel svn:externals $$dst_path \ |
271 |
|| $(call _fatal,$$dst_path: cant delete svn:externals,7);\ |
272 |
rm -rf $$dst_path/*;\ |
273 |
fi;\ |
274 |
ext_rev=`svn info $$src_url | sed -nr 's%^Revision:\s+(\S+)$$%\1% p'`;\ |
275 |
[ "$$ext_rev" ] || $(call _fatal,cant determine external revision,8);\ |
276 |
$(_svn) propset svn:externals "$(_trg_tag) -r$$ext_rev $$src_url" $$dst_path \ |
277 |
|| $(call _fatal,$$dst_path: cant set svn:externals,9);\ |
278 |
$(_svn) commit $$dst_path -m "Added tag $(_module)/$(_tag_dir) -> $(_trg_tag)" \ |
279 |
|| $(call _fatal,$$dst_path: cant svn commit,10);\ |
280 |
$(_svn) update $$dst_path || $(call _fatal,$$dst_path: cant svn update,11) |
281 |
|
282 |
|
283 |
tagstable: _checkop |
284 |
@echo "[INFO] tagging 'stable' release" |
285 |
@prompt='Do you want to tag this release as 'stable'? [no]: ';\ |
286 |
while read -p "$$prompt" ans || exit 1; do\ |
287 |
[ -z $$ans ] && ans='no';\ |
288 |
case $$ans in\ |
289 |
[Yy]|[Yy]es)\ |
290 |
_tag_dir=stable _trg_tag=$(_vtag) $(MAKE) svnextag;\ |
291 |
break;\ |
292 |
;;\ |
293 |
[Nn]|[Nn]o)\ |
294 |
break;\ |
295 |
;;\ |
296 |
*)\ |
297 |
prompt='Answer either "yes" or not at all: ';\ |
298 |
esac;\ |
299 |
done |
300 |
|
301 |
|
302 |
# mark as OBSOLETE (no SVN tag is added). A message to be added to config.mk |
303 |
# can be passed through the variable OBSOLETE_MSG |
304 |
markobsolete: _checkop |
305 |
@[ -w config.mk ]\ |
306 |
|| $(call _fatal,config.mk: file missing or not writable,1) |
307 |
@if [ "`sed -nr '/^\s*OBSOLETE/ p' config.mk`" ]; then\ |
308 |
$(call _fatal,already marked as OBSOLETE,2);\ |
309 |
fi |
310 |
@echo "[INFO] marking as OBSOLETE" |
311 |
@obs_msg='1';\ |
312 |
if [ ! -z "$$OBSOLETE_MSG" ]; then\ |
313 |
obs_msg="$$OBSOLETE_MSG";\ |
314 |
fi;\ |
315 |
echo OBSOLETE="$$obs_msg" >> config.mk |
316 |
@$(_svn) commit -m 'Module marked as OBSOLETE'\ |
317 |
|| $(call _fatal,cant svn commit,3) |
318 |
|
319 |
|
320 |
|
321 |
#################################################################### |
322 |
# Build distributions in tar & RPM/PKG format |
323 |
#################################################################### |
324 |
# |
325 |
# These targets make distribution tar files and PKGs/RPMs from the |
326 |
# CVS repository, using the version declared in the config file. |
327 |
# The checked-out files in the current directory are neither |
328 |
# modified, nor read (apart from the config file). |
329 |
# |
330 |
# "pack" and "rpm" built from the sources in the current directory. |
331 |
# |
332 |
# |
333 |
# The prep:: target allows the including makefile to specify actions |
334 |
# required to process the files at distribution pack time. |
335 |
# |
336 |
# These targets make distribution tar files and PKGs/RPMs based on the |
337 |
# checked-out sources in the current directory. No connection to |
338 |
# the CVS repository is required, and the files do not need to be |
339 |
# committed. The RPM version numbers are generated from the |
340 |
# version number specified in the config file. |
341 |
# |
342 |
|
343 |
pack: envdir |
344 |
@echo packing distribution... |
345 |
@rm -rf $(_builddir)/$(_prodname) |
346 |
@rm -f $(_sourcedir)/$(_prodtar) |
347 |
@mkdir -p $(_builddir)/$(_prodname) |
348 |
@find . -path '*CVS*' -prune -o -type f -print >files.tmp |
349 |
@tar cfT - files.tmp |(cd $(_builddir)/$(_prodname) ; tar xf -) |
350 |
@rm -f files.tmp |
351 |
@[ ! -f specfile.spec -a -f specfile.cin ] \ |
352 |
&& cp specfile.cin \ |
353 |
$(_builddir)/$(_prodname)/specfile.spec \ |
354 |
|| : ; |
355 |
@cp cl2rpm \ |
356 |
$(_builddir)/$(_prodname)/ > /dev/null 2>&1 \ |
357 |
|| : ; |
358 |
@cd $(_builddir)/$(_prodname) ; \ |
359 |
sed <$(CFG_MK) >config.tmp \ |
360 |
-e 's%^RELEASE=\(.*\)%RELEASE=\1%' \ |
361 |
-e 's%^VERSION=.*%&$(BRANCH)%' ; \ |
362 |
mv config.tmp $(CFG_MK) ; \ |
363 |
echo 'TARFILE=$(_prodtar)' >>$(CFG_MK) ; \ |
364 |
echo 'PROD=\#' >>$(CFG_MK) ; \ |
365 |
$(MAKE) config.sh ;\ |
366 |
$(MAKE) prep ;\ |
367 |
test -n "$(_test_dep)" && rm -f $(_test_dep) ;\ |
368 |
rm -f config.sh |
369 |
@cd $(_builddir) ; tar czf $(_sourcedir)/$(_prodtar) $(_prodname) |
370 |
|
371 |
filelist: install |
372 |
# |
373 |
# ---- DO NOT MODIFY BELOW THIS LINE --- NEEDED FOR SPECFILE |
374 |
# |
375 |
@find $(INSTALLPREFIX) -type d | sed -e 's^$(INSTALLPREFIX)g' -e 's/^/%dir /' >> $(INSTALLPREFIX)/.filelist |
376 |
@find $(INSTALLPREFIX) ! -type d -a ! -name ".filelist" | sed -e 's^$(INSTALLPREFIX)g' >> $(INSTALLPREFIX)/.filelist |
377 |
@echo File found in distribution |
378 |
@cat $(INSTALLPREFIX)/.filelist |
379 |
|
380 |
spec: pack |
381 |
@echo generating specfile.spec ... |
382 |
@cd $(_builddir)/$(_prodname) ; \ |
383 |
$(MAKE) config.sh ;\ |
384 |
./config.sh <specfile.spec >$(_specdir)/$(_prodname).spec |
385 |
@test -f ChangeLog && \ |
386 |
cl2rpm ChangeLog \ |
387 |
>>$(_specdir)/$(_prodname).spec || true |
388 |
|
389 |
rpm: spec |
390 |
@echo building rpm ... |
391 |
@cd $(_specdir) ; $(_rpmbuild) -ba $(_specdir)/$(_prodname).spec |
392 |
|
393 |
pkg: spec |
394 |
@echo building pkg ... |
395 |
@cd $(_specdir) ; $(_pkgbuild) -f $(_specdir)/$(_prodname).spec |
396 |
|
397 |
prep:: |
398 |
|
399 |
##################################################################### |
400 |
# Create substitution script |
401 |
#################################################################### |
402 |
# |
403 |
# This target reads the config file and creates a shell script which |
404 |
# can substitute variables of the form @VAR@ for all config |
405 |
# variables VAR. The messing around with the temporary makefile is |
406 |
# to ensure that any recursive or external references in the |
407 |
# variable values are evaluated by "make" in the same context as |
408 |
# when the config file is included in the makefile. |
409 |
|
410 |
config.sh: Makefile $(_test_dep) |
411 |
@cp /dev/null makefile.tmp |
412 |
@echo include $(CFG_MK) >>makefile.tmp |
413 |
@echo dumpvars: >>makefile.tmp |
414 |
@cat $(CFG_MK) paths.mk | \ |
415 |
perl >>makefile.tmp -e 'my $$fmt = "\t\@echo \"-e \\\"s\@%s\@\$$(%s)g\\\" \\\\\"" ; while (<>) { $$v{$$1}=1 if /^([A-Za-z0-9_]+)\s*:?=.*$$/; } map { printf "$$fmt >>config.sh\n", $$_, $$_; } sort(keys(%v)); print "\n"; ' |
416 |
@echo '#!/bin/sh' >config.sh |
417 |
@echo 'sed \' >>config.sh |
418 |
@$(MAKE) -f makefile.tmp dumpvars >/dev/null |
419 |
@echo ' -e "s/\@MSG\@/ ** Generated file : do not edit **/"'>>config.sh |
420 |
@chmod oug+x config.sh |
421 |
@rm makefile.tmp |
422 |
|
423 |
#################################################################### |
424 |
# Configure |
425 |
#################################################################### |
426 |
|
427 |
%:: %.cin config.sh |
428 |
@echo configuring $@ ... |
429 |
@rm -f $@ ; cp $< $@ |
430 |
@./config.sh <$< >$@ ; chmod oug-w $@ |
431 |
|
432 |
%.$(MANSECT):: %.$(MANSECT).man.cin |
433 |
@echo creating $@ ... |
434 |
@./config.sh <$< >$@ ; chmod oug-w $@ |
435 |
|
436 |
configure: $(shell find . -name \*\.cin 2>/dev/null | sed -e 's/.cin//' || echo) |
437 |
|
438 |
#################################################################### |
439 |
# Install |
440 |
#################################################################### |
441 |
|
442 |
install: configure |
443 |
@echo installing in $(INSTALLPREFIX) ... |
444 |
# |
445 |
# MODIFY location of installed scripts/binaries here |
446 |
# |
447 |
|
448 |
ifdef MYMODS |
449 |
@mkdir -p $(INSTALLPREFIX)/$(MODSUFFIX) |
450 |
for i in $(MYMODS) ; do \ |
451 |
install -m 0444 $$i $(INSTALLPREFIX)/$(MODSUFFIX) ; \ |
452 |
done || : |
453 |
endif |
454 |
|
455 |
ifdef MYDOCS |
456 |
@mkdir -p $(INSTALLPREFIX)/$(DOCSUFFIX) |
457 |
for i in $(MYDOCS) ; do \ |
458 |
install -m 0444 $$i $(INSTALLPREFIX)/$(DOCSUFFIX) ; \ |
459 |
done || : |
460 |
endif |
461 |
|
462 |
ifdef MYCONFIGS |
463 |
@mkdir -p $(INSTALLPREFIX)/$(CONFIGSUFFIX) |
464 |
@for i in $(MYCONFIGS) ; do \ |
465 |
install -m 0444 $$i $(INSTALLPREFIX)/$(CONFIGSUFFIX) ; \ |
466 |
done || : |
467 |
endif |
468 |
|
469 |
ifdef MYSCRIPTS |
470 |
@mkdir -p $(INSTALLPREFIX)/$(SCRIPTSUFFIX) |
471 |
@for i in $(MYSCRIPTS) ; do \ |
472 |
install -m 0555 $$i $(INSTALLPREFIX)/$(SCRIPTSUFFIX) ; \ |
473 |
done || : |
474 |
endif |
475 |
|
476 |
ifdef MYTESTFILES |
477 |
@mkdir -p $(INSTALLPREFIX)/$(TESTSUFFIX) |
478 |
@for i in $(MYTESTFILES) ; do \ |
479 |
install -m 0555 $$i $(INSTALLPREFIX)/$(TESTSUFFIX) ; \ |
480 |
done || : |
481 |
endif |
482 |
|
483 |
ifdef MYPLUGINS |
484 |
@mkdir -p $(INSTALLPREFIX)/$(PLUGINSUFFIX) |
485 |
@for i in $(MYPLUGINS) ; do \ |
486 |
install -m 0555 $$i $(INSTALLPREFIX)/$(PLUGINSUFFIX) ; \ |
487 |
done || : |
488 |
endif |
489 |
|
490 |
#################################################################### |
491 |
|
492 |
clean:: |
493 |
@echo cleaning common files ... |
494 |
@rm -f config.sh config.tex |
495 |
@rm -f `find . -name '*~'` |
496 |
@rm -f `find . -name '*#'` |
497 |
@rm -f `find . -name '*.tmp'` |
498 |
@rm -f `find . -name \*\.cin 2>/dev/null | sed -e 's/.cin//'` |
499 |
dist: pack |
500 |
|
501 |
|
502 |
|