~armagetronad-dev/armagetronad/0.2.9-build-work

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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
# Copyright (C) 2005  by Manuel Moos
# and the AA DevTeam (see the file AUTHORS(.txt) in the main source directory)
# Last change by $Author$ on $Date$

all: tarsource
full: all rpm deb
pack: tarsource webdoc windoc zipsource
rpm-mdk: mandriva
rpm-mdkded: mandriva-dedicated

# everything z-man can build at home and work
z-man-home: tarsource zipsource webdoc windoc portable_client portable_server winbin uploadcheck
z-man-home-32: portable_client portable_server uploadcheck
#z-man-work: autopackage-legacyserver autopackage-client

# other builders are invited to add their build sets.

# include automatically generated files with definitions

include IncludesMakefile3

# clean RPM build directory
rpmclean:
	#
	# *****************************************
	# * clean RPM build directory             *
	# *****************************************
	#
	for f in $(RPMTOPDIR)/*; do rm -rf $$f/*; done

# set common variables
BASENAME=$(PACKAGE)-$(VERSION)
#RCNAME=$(BASENAME)-rc$(RC)
RCNAME=$(BASENAME)
BASENAMEDED=$(PACKAGE)-dedicated-$(VERSION)
#RCNAMEDED=$(BASENAMEDED)-rc$(RC)
RCNAMEDED=$(BASENAMEDED)
RCNAME.server=$(RCNAMEDED)
RCNAME.client=$(RCNAME)
RCNAME.legacyserver=$(RCNAMEDED)

# directory for release candidate
RCDIR=$(BUILDDIR)/B${RC}
$(RCDIR)/.tag: $(BUILDDIR)/.tag
	test -d $(RCDIR) || mkdir $(RCDIR)
	echo "" > $@

# upload directory
UPLOAD=$(RCDIR)/Upload
$(UPLOAD)/.tag: $(RCDIR)/.tag
	test -d $(UPLOAD) || mkdir $(UPLOAD)
	echo "" > $@

# upload directory for zeroinstall archives
0UPLOAD=$(UPLOAD)/ZeroInstall/$(RC)
0UPLOADTAG=$(0UPLOAD)/README.txt
$(0UPLOADTAG): $(UPLOAD)/.tag
	test -d $(0UPLOAD) || mkdir -p $(0UPLOAD)
	echo "IMPORTANT, READ ME:\nThese files are for the ZeroInstall system and hard to get working if you donwload them manually.\nStick to the files one folder up or use our ZeroInstall feeds (which we very much recommend):\nhttp://wiki.armagetronad.org/index.php/0Install" > $@
	todos $@

ZEROINSTTAG=$(RCDIR)/.0installtag

uploadcheck: $(UPLOAD)/.tag
#   check for windows build directory dumped into Upload
	if test -d $(UPLOAD)/dist; then RC=$(RC) RCDIR=$(RCDIR) VERSION=$(VERSION) PACKAGE=${PACKAGE} scripts/handledist; rm -f $(ZEROINSTTAG); fi

# bump rc number
bump:
	# update release candidate number
	rm builds/.tag
.PHONY: bump

SOURCEDIR=$(RCDIR)/$(PACKAGE)-$(VERSION)

RELEASETAGFILE = $(BUILDDIR)/.releasetag

$(RELEASETAGFILE): $(SOURCEDIR)/.tag $(VERSIONTAG) $(RCFILE)
	#
	# ************************************************
	# * determine core version, release tag and slot *
	# ************************************************
	#
	sh $(SOURCEDIR)/batch/make/releasetag $(VERSION) > $@ || { rm $@; false; }

include $(RELEASETAGFILE)

# build tarball
INPUTTARBALLBASE=tarballs/$(PACKAGE)-$(VERSION).src.tar
#INPUTTARBALLBASE2=tarballs/armagetronad-$(VERSION).tar.gz
TARBALLBASE=$(UPLOAD)/$(RCNAME).src.tar
TARBALLGZ=$(TARBALLBASE).gz
TARBALLBZ=$(TARBALLBASE).bz2

tarsource: $(TARBALLBZ) $(TARBALLGZ)

$(INPUTTARBALLBASE): $(wildcard $(INPUTTARBALLBASE).*)
	#
	# *****************************************
	# *  unpack sources                       *
	# *****************************************
	#
	${TESTVERSION}
#	mv $(INPUTTARBALLBASE2) $(INPUTTARBALLBASE).gz || true
	if test -r $(INPUTTARBALLBASE).gz  && gzip -f -d $(INPUTTARBALLBASE).gz; then echo done; else rm -f $(INPUTTARBALLBASE).gz; fi
	if test -r $(INPUTTARBALLBASE).bz2  && bzip2 -f -d $(INPUTTARBALLBASE).bz2; then echo done; else rm -f $(INPUTTARBALLBASE).bz2; fi
	test -r $@ || { echo "Source tarball not found. Please rerun make." ; rm -rf  ${SOURCETAG} ${VERSIONTAG}; false; }

$(TARBALLBZ): $(INPUTTARBALLBASE) $(UPLOAD)/.tag
	#
	# *****************************************
	# *  repack sources as bz2                *
	# *****************************************
	#
	rm -f $@
	mkdir -p tarballs/unpack
	rm -rf tarballs/unpack/*
	cd tarballs/unpack && tar -xf ../$(PACKAGE)-$(VERSION).src.tar
	cd tarballs/unpack && tar -cjf ../$(PACKAGE)-$(VERSION).src.tar.bz2 *
	rm -rf tarballs/unpack
	mv tarballs/$(PACKAGE)-$(VERSION).src.tar.bz2 $@
	test -r $@
	touch $@

$(TARBALLGZ): $(INPUTTARBALLBASE) $(UPLOAD)/.tag
	#
	# *****************************************
	# *  repack sources as gz                 *
	# *****************************************
	#
	${TESTVERSION}
	rm -f $@
	mkdir -p tarballs/unpack2
	rm -rf tarballs/unpack2/*
	cd tarballs/unpack2 && tar -xf ../$(PACKAGE)-$(VERSION).src.tar
	cd tarballs/unpack2 && tar -czf ../$(PACKAGE)-$(VERSION).src.tar.gz *
	rm -rf tarballs/unpack2
	mv tarballs/$(PACKAGE)-$(VERSION).src.tar.gz $@
	test -r $@
	touch $@

.PHONY: tarsrc

RPMVERSION=${COREVERSION}-${RELEASETAG}.${RC}
RPMSOURCE=$(RPMTOPDIR)/SOURCES/$(BASENAME).src.tar.bz2
rpmprepare: $(RPMSOURCE)
$(RPMSOURCE): $(TARBALLBZ)
	#
	# *****************************************
	# *  prepare RPM build                    *
	# *****************************************
	#

	# copy sources cleanly
	test -d "$(RPMTOPDIR)"
	rm -rf $(RPMTOPDIR)/SOURCES/$(PACKAGE)*.tar.bz2
	cp $(TARBALLBZ) $(RPMSOURCE)

RPMTAG=$(RCDIR)/.rpm
rpmbuild: $(RPMTAG).ba
rpmtest: $(RPMTAG).bl
$(RPMTAG).%: $(RPMSOURCE)  redhat/armagetronad.spec.%.m4
	#
	# *****************************************
	# *  Testing RPM build stage by stage     *
	# *****************************************
	#

	@echo Building rpms stage $*...
	cd redhat; bash ./build -$* --short-circuit 
	touch $@

$(RPMTAG).bl: $(RPMTAG).bi
$(RPMTAG).bi: $(RPMTAG).bc
$(RPMTAG).bc: $(RPMTAG).bp

$(RPMTAG): $(RPMSOURCE) redhat/*
	#
	# *****************************************
	# *  RPM build                            *
	# *****************************************
	#

	@echo Building rpms...
	touch $@.bc
	cd redhat; bash ./build -ba
	touch $@ $@.bi

rpm: $(RPMTAG).harvest
$(RPMTAG).harvest: $(RPMTAG)
	#
	# *****************************************
	# *  harvest and rename RPM build         *
	# *****************************************
	#
	find $(RPMTOPDIR) -name "$(PACKAGE)*.rpm" -exec mv \{\} $(UPLOAD) \;

#   rename files so the visible version matches our source version
	for f in ${UPLOAD}/*.rpm; do\
		ARCH=`rpm -qp --queryformat '%{arch}' $$f` ;\
		mv $$f `echo $$f | sed -e "s,${RPMVERSION},${VERSION}-${RC}," -e "s,-${RC}.$${ARCH},-${RC}.${OSTAG_GENERIC},"`;\
	done

#   rename source rpm to indicate that it is for an old version of libxml
	if test $(ALLOW_OLDLIBXML2) = yes; then mv ${UPLOAD}/${PACKAGE}-${VERSION}-${RC}.src.rpm ${UPLOAD}/${PACKAGE}-${VERSION}-${RC}.libxml2-pre-2_6_12.src.rpm; fi
	touch $@

# categorize files for aabeta upload, once with and once without upload
aabeta:
	#
	# *****************************************
	# *  categorizing files for aabeta        *
	# *****************************************
	#
	cd $(UPLOAD); USERNAME_AABETA=${USERNAME_AABETA} OSTAG=${OSTAG} OSTAG_AABETA=${OSTAG_AABETA} OSTAG_GENERIC=${OSTAG_GENERIC} PACKAGER=${PACKAGER} bash ../../../../scripts/aabeta

upload-aabeta:
	#
	# *****************************************
	# *  preparing upload to aabeta           *
	# *****************************************
	#
	cd $(UPLOAD); DO_UPLOAD=yes USERNAME_AABETA=${USERNAME_AABETA} OSTAG=${OSTAG} OSTAG_AABETA=${OSTAG_AABETA} OSTAG_GENERIC=${OSTAG_GENERIC} PACKAGER=${PACKAGER} bash ../../../../scripts/aabeta

.PHONY: aabeta upload-aabeta

mandriva: $(RPMSOURCE) mandriva/armagetronad-mdk.spec
	#
	# *****************************************
	# *  Mandriva RPM build                   *
	# *****************************************
	#
	cp mandriva/*.png $(RPMTOPDIR)/SOURCES/

	#cd mandriva
	rpm	 -ba mandriva/armagetronad-mdk.spec
	cp $(RPMTOPDIR)/RPMS/i586/armagetronad*.rpm $(UPLOAD)

mandriva-dedicated: $(RPMSOURCE) mandriva/armagetronad-dedicated-mdk.spec
	#
	# *****************************************
	# *  Mandriva RPM build                   *
	# *****************************************
	#
	cp mandriva/*.png $(RPMTOPDIR)/SOURCES/

	#cd mandriva
	rpm  -ba mandriva/armagetronad-dedicated-mdk.spec
	cp $(RPMTOPDIR)/RPMS/i586/armagetronad*.rpm $(UPLOAD)

include rawbin/Makefile

# documentation build
WINDOCDIR=$(RCDIR)/doc.windows

# windows documentation
windoc: $(WINDOCDIR)
$(RCDIR)/doc.%.build: $(SOURCEDIR)/.tag
	#
	# *****************************************
	# *  prepare $* documentation build          
	# *****************************************
	#
	# create build directory
	rm -rf $@
	mkdir $@

	# configure and make documentation
	CXXFLAGS="$(CXXFLAGS) -O0" docstyle=$* bash scripts/configure $@ $(SOURCEDIR)	--prefix='/usr/local' --disable-glout

$(RCDIR)/doc.%: $(RCDIR)/doc.%.build
	#
	# *****************************************
	# *  $* documentation build          
	# *****************************************
	#
	# install documentation
	rm -rf $@ $@-build
	mkdir $@-build
	DESTDIR=`pwd`/$@-build $(MAKE) -C $(RCDIR)/doc.$*.build/src/doc install

	# copy documentation to destination
	mv $@-build/usr/local/share/doc/games/$(PACKAGE)-dedicated/html $@
	rm -rf $@-build

# web documentation
webdoc:$(RCDIR)/doc.web

# keep windows build dir
.PRECIOUS: $(RCDIR)/doc.windows.build $(RCDIR)/doc.web.build

sourcedir: $(SOURCEDIR)/.tag
$(SOURCEDIR)/.tag: $(INPUTTARBALLBASE) $(RCDIR)/.tag
	#
	# *****************************************
	# *  unpacking source                     *
	# *****************************************
	#
	${TESTVERSION}
	rm -rf $(SOURCEDIR)
	cd $(RCDIR); tar -xf ../../../$(INPUTTARBALLBASE)
	test -d $(SOURCEDIR)
	touch $(SOURCEDIR)
	find $(SOURCEDIR) -name "*.html" -exec rm \{\} \;
	echo "" > $@

# windows source zip
WINSOURCE=$(UPLOAD)/$(RCNAME).src.zip
WINSOURCEDIR=$(SOURCEDIR)-win
WINBUILDDIR=$(RCDIR)/doc.windows.build

zipsource: $(WINSOURCE)
$(WINSOURCEDIR): $(SOURCEDIR)/.tag $(WINDOCDIR) $(WINBUILDDIR) Makefile scripts/winsrc
	#
	# *****************************************
	# *  prepare windows source               *
	# *****************************************
	#
	test "$(AA_VISUALC)" != "" || { echo -e "\nCVS module armagetronad_build_visualc needs to be checked out parallel to this directory for Windows source build.\n"; false; }
	rm -rf $@ $@-proto $(RCDIR)/$(PACKAGE)
	PROGNAME=$(PROGNAME) VERSION=$(VERSION) bash scripts/winsrc $@-proto $(SOURCEDIR) $(WINBUILDDIR) $(WINDOCDIR) $(AA_VISUALC) $(AA_CODEBLOCKS)
	mv $@-proto $@
	touch $@

$(WINSOURCE): $(WINSOURCEDIR) $(UPLOAD)/.tag
	#
	# *****************************************
	# *  pack windows source                  *
	# *****************************************
	#
	rm -f $@
	bash scripts/chdirexec $(RCDIR) zip -q -r $@ $(WINSOURCEDIR)
	touch $@

winbin: $(WINSOURCEDIR).hasbeenbuilt
$(WINSOURCEDIR).hasbeenbuilt: $(WINSOURCEDIR) $(UPLOAD)/.tag ${AA_WINLIBS}/SDL
	#
	# *****************************************
	# *  build windows
	# *****************************************
	#
	rm -rf $(WINSOURCEDIR).build
	cp -ax $(WINSOURCEDIR) $(WINSOURCEDIR).build
	rm -f ${RCDIR}/winlibs; ln -s $$(pwd)/${AA_WINLIBS} ${RCDIR}/winlibs
	cd $(WINSOURCEDIR).build; if test -z "$$DISPLAY"; then DISPLAY=:0.0 xterm -e "bash ./fromunix.sh"; else bash ./fromunix.sh; fi
	mv ${RCDIR}/dist $(UPLOAD)/
#	$(MAKE) uploadcheck
	touch $@

DEBSOURCEDIR=$(SOURCEDIR)-debian
debianprepare: $(DEBSOURCEDIR)
$(DEBSOURCEDIR): $(SOURCEDIR)/.tag
	#
	# *****************************************
	# *  prepare debian build                 *
	# *****************************************
	#
	mkdir -p $(RCDIR)/tmp
	cd $(RCDIR)/tmp; tar -xf ../../../../$(INPUTTARBALLBASE)
	mv $(RCDIR)/tmp/$(PACKAGE)-$(VERSION) $@
	rmdir $(RCDIR)/tmp
	cp -ax debian $@
	chmod 755 $@/debian/rules

debianbuild: $(DEBSOURCEDIR)
	#
	# *****************************************
	# *  build debian package                 *
	# *****************************************
	#
	cd $<; fakeroot debian/rules binary

deb: debianbuild $(UPLOAD)/.tag
	#
	# *****************************************
	# *  harvesting debian package            *
	# *****************************************
	#
	find $(RCDIR) -name "$(PACKAGE)*.deb" -exec mv \{\} $(UPLOAD) \;


DEBVERSION=$(subst -,~,$(subst _,~,$(subst _rc,_arc,${VERSION})))~ppa
UBUNTUSOURCEDIR=$(RCDIR)/$(PACKAGE)-$(DEBVERSION)
$(UBUNTUSOURCEDIR)%.tag: $(TARBALLBZ) $(UPLOAD)/.tag
	#
	# *****************************************
	# *  prepare ubuntu build                 *
	# *****************************************
	#
	rm -rf $(UBUNTUSOURCEDIR)$*
	ln -f $(TARBALLBZ) `echo $(UBUNTUSOURCEDIR)$*.orig.tar.bz2 | sed -e s,$(PACKAGE)-,$(PACKAGE)_,`
	mkdir -p $(RCDIR)/tmp2
	cd $(RCDIR)/tmp2; tar -xjf ../../../../$(TARBALLBZ)
	mv $(RCDIR)/tmp2/$(PACKAGE)-$(VERSION) $(UBUNTUSOURCEDIR)$*
	rmdir $(RCDIR)/tmp2
#   adapt the following line as ubuntu releases get updated
	git -C ../ubuntu pull || { HOME=/noway git clone https://gitlab.com/armagetronad/ubuntu-packaging.git ../ubuntu && git -C ../ubuntu checkout ubuntu-bionic-0.2.8.3; }
	cp -ax ../ubuntu/debian $(UBUNTUSOURCEDIR)$*/debian
#   rebrand package
	cd $(UBUNTUSOURCEDIR)$*/debian/; for f in * bin/* source/* man/*; do dest=$$(echo $$f | sed -e "s,armagetronad,${PACKAGE},g"); test -d $$f || { sed -e "s/armagetronad/${PACKAGE}/g" < $$f | sed -e "s/${PACKAGE}\.net/armagetronad.net/g" --e "s/${PACKAGE}\.source/armagetronad.source/g" > $$dest.out; rm $$f; mv $$dest.out $$dest; } done
	chmod 755 $(UBUNTUSOURCEDIR)$*/debian/rules
#   build changelog
	DIST="`echo $* | sed -e s/^[0-9]*// -e s/.*~//`"; test -z $$DIST && DIST=hardy; sed -e "s/@distribution@/$$DIST/g" -e "s/@package@/$(PACKAGE)/g" -e "s/@version@/${DEBVERSION}$*/g" -e "s;@date@;$$(date -R);g" < doc/ubuntu-changelog.txt > $(UBUNTUSOURCEDIR)$*/debian/changelog
	cat < ../ubuntu/debian/changelog >> $(UBUNTUSOURCEDIR)$*/debian/changelog
	echo "x" > $@

$(RCDIR)/ubuntu%.tag: $(UBUNTUSOURCEDIR)%.tag
	#
	# *****************************************
	# *  ubuntu build                         *
	# *****************************************
	#
	cd $(UBUNTUSOURCEDIR)$*; fakeroot debian/rules binary
#   harvesting debian package(s)
	find $(RCDIR) -name "$(PACKAGE)*.deb" -exec mv \{\} $(UPLOAD) \;
	echo "x" > $@

xubuntu-build-%: $(RCDIR)/ubuntu%.tag
	echo $@

#real targets for the user
ubuntu: xubuntu-build-$(RC)
	echo $@
ubuntu-%: xubuntu-build-$(RC)~%
	echo $@

$(RCDIR)/${PACKAGE}_${DEBVERSION}%_source.changes: $(UBUNTUSOURCEDIR)%.tag
	#
	# ************************************
	# *  preparing ubuntu source for ppa *
	# ************************************
	#
	cd $(UBUNTUSOURCEDIR)$* && debuild -S -sa

xupload-ubuntu-%: $(RCDIR)/${PACKAGE}_${DEBVERSION}%_source.changes
	#
	# ***********************************
	# *  uploading ubuntu source to ppa *
	# ***********************************
	#
	cd $(RCDIR) && dput ppa:armagetronad-dev/ppa ${PACKAGE}_${DEBVERSION}$*_source.changes

#real targets for the user
upload-ubuntu: xupload-ubuntu-$(RC)
	echo $@
upload-ubuntu-%: xupload-ubuntu-$(RC)~%
	echo $@

upload-ubuntu-all: \
upload-ubuntu-focal \
upload-ubuntu-eoan \
upload-ubuntu-bionic \
upload-ubuntu-xenial \
upload-ubuntu-trusty
	echo $@

# generic client build
GENERIC_CLIENT_DIR=$(RCDIR)/client.build
GENERIC_CONFIGURE_ARGUMENTS=--prefix='/usr/local' --disable-uninstall --disable-restoreold --enable-etc --enable-automakedefaults --disable-useradd
CLIENT_CONFIGURE_ARGUMENTS=${GENERIC_CONFIGURE_ARGUMENTS} --disable-sysinstall --disable-initscripts
generic_client: $(GENERIC_CLIENT_DIR).tag
$(GENERIC_CLIENT_DIR).tag: $(SOURCEDIR)/.tag
	#
	# *****************************************
	# *  generic client build          
	# *****************************************
	#
	# create build directory
	rm -rf $(GENERIC_CLIENT_DIR)/config.cache $(GENERIC_CLIENT_DIR)/Makefile
	mkdir -p $(GENERIC_CLIENT_DIR)

	# configure and make
	bash scripts/configure $(GENERIC_CLIENT_DIR) $(SOURCEDIR) $(CLIENT_CONFIGURE_ARGUMENTS)

	${MAKE} -C $(GENERIC_CLIENT_DIR)
	touch $@

GENERIC_SERVER_DIR=$(RCDIR)/server.build
SERVER_CONFIGURE_ARGUMENTS=$(GENERIC_CONFIGURE_ARGUMENTS) --disable-glout --enable-armathentication
generic_server: $(GENERIC_SERVER_DIR).tag
$(GENERIC_SERVER_DIR).tag: $(SOURCEDIR)/.tag
	#
	# *****************************************
	# *  generic server build          
	# *****************************************
	#
	# create build directory
	rm -rf $(GENERIC_SERVER_DIR)/config.cache $(GENERIC_SERVER_DIR)/Makefile
	mkdir -p $(GENERIC_SERVER_DIR)

	# configure and make
	bash scripts/configure $(GENERIC_SERVER_DIR) $(SOURCEDIR) $(SERVER_CONFIGURE_ARGUMENTS)

	${MAKE} -C $(GENERIC_SERVER_DIR)
	touch $@

generic_build: generic_client generic_server

# portable client build
PORTABLE_CLIENT_BASENAME=$(subst ",,${PROGNAME})
#"
PORTABLE_CLIENT_NAME=$(shell echo ${PORTABLE_CLIENT_BASENAME} | sed -e "s, ,,g")
APPDIR_CLIENT=$(RCDIR)/$(PORTABLE_CLIENT_NAME).AppDir
PORTABLE_CLIENT=$(UPLOAD)/$(PORTABLE_CLIENT_NAME)_${VERSION}
portable_client: $(PORTABLE_CLIENT)
$(PORTABLE_CLIENT): $(GENERIC_CLIENT_DIR).tag portable/AppRun portable/build portable/fixlinks WorkMakefile $(UPLOAD)/.tag
	#
	# *****************************************
	# *  package portable client
	# *****************************************
	#
#   install into appdir
	rm -rf ${APPDIR_CLIENT}
	${MAKE} -C ${GENERIC_CLIENT_DIR} DESTDIR=$$(pwd)/${APPDIR_CLIENT} install

#   delegate
	APPDIR=${APPDIR_CLIENT} PORTABLE=${PORTABLE_CLIENT} PACKAGE=${PACKAGE} portable/build	

# portable server build
PORTABLE_SERVER_BASENAME=$(subst ",,${PROGNAME})Dedicated
#"
PORTABLE_SERVER_NAME=$(shell echo ${PORTABLE_SERVER_BASENAME} | sed -e "s, ,,g")
APPDIR_SERVER=$(RCDIR)/$(PORTABLE_SERVER_NAME).AppDir
PORTABLE_SERVER=$(UPLOAD)/$(PORTABLE_SERVER_NAME)_${VERSION}
portable_server: $(PORTABLE_SERVER)
$(PORTABLE_SERVER): $(GENERIC_SERVER_DIR).tag portable/AppRun portable/build portable/fixlinks WorkMakefile $(UPLOAD)/.tag
	#
	# *****************************************
	# *  package portable server
	# *****************************************
	#
#   install into appdir
	rm -rf ${APPDIR_SERVER}
	${MAKE} -C ${GENERIC_SERVER_DIR} DESTDIR=$$(pwd)/${APPDIR_SERVER} install

#   delegate
	APPDIR=${APPDIR_SERVER} PORTABLE=${PORTABLE_SERVER} PACKAGE=${PACKAGE}-dedicated portable/build	

# plain binary tarball
BINARY_CLIENT_TARBALL_NAME=${PACKAGE}-${VERSION}.${OSTAG_GENERIC}
CLIENT_TARBALL_DIR=$(RCDIR)/$(BINARY_CLIENT_TARBALL_NAME).fortar
BINARY_CLIENT_TARBALL=$(0UPLOAD)/$(BINARY_CLIENT_TARBALL_NAME).bin.tar.bz2
binary_client_tarball: $(BINARY_CLIENT_TARBALL)
$(BINARY_CLIENT_TARBALL): $(GENERIC_CLIENT_DIR).tag portable/AppRun $(0UPLOADTAG)
	#
	# *****************************************
	# *  package client as tarball
	# *****************************************
	#
#   install into appdir
	rm -rf ${CLIENT_TARBALL_DIR}
	${MAKE} -C ${GENERIC_CLIENT_DIR} DESTDIR=$$(pwd)/${CLIENT_TARBALL_DIR} install

#   copy AppRun
	cp portable/AppRun ${CLIENT_TARBALL_DIR}/run
	find ${CLIENT_TARBALL_DIR} -type f  -name "*.desktop" -exec mv \{\} ${CLIENT_TARBALL_DIR}/ \;

#   tar it up
	wd=$$(pwd); cd ${CLIENT_TARBALL_DIR}; tar -cjf $${wd}/${BINARY_CLIENT_TARBALL} *
	rm -f $(ZEROINSTTAG)

# plain binary tarball
BINARY_SERVER_TARBALL_NAME=${PACKAGE}-dedicated-${VERSION}.${OSTAG_GENERIC}
SERVER_TARBALL_DIR=$(RCDIR)/$(BINARY_SERVER_TARBALL_NAME).fortar
BINARY_SERVER_TARBALL=$(0UPLOAD)/$(BINARY_SERVER_TARBALL_NAME).bin.tar.bz2
binary_server_tarball: $(BINARY_SERVER_TARBALL)
$(BINARY_SERVER_TARBALL): $(GENERIC_SERVER_DIR).tag portable/fixlinks portable/AppRun $(0UPLOADTAG)
	#
	# *****************************************
	# *  package server as tarball
	# *****************************************
	#
#   install into appdir
	rm -rf ${SERVER_TARBALL_DIR}
	${MAKE} -C ${GENERIC_SERVER_DIR} DESTDIR=$$(pwd)/${SERVER_TARBALL_DIR} install

#   copy AppRun
	cp portable/AppRun ${SERVER_TARBALL_DIR}/run
	find ${SERVER_TARBALL_DIR} -type f -name "*.desktop" -exec mv \{\} ${SERVER_TARBALL_DIR}/ \;

	APPDIR=${SERVER_TARBALL_DIR} portable/fixlinks 

#   tar it up
	wd=$$(pwd); cd ${SERVER_TARBALL_DIR}; tar -cjf $${wd}/${BINARY_SERVER_TARBALL} *
	rm -f $(ZEROINSTTAG)

binary_tarball: binary_client_tarball binary_server_tarball

0install:
	#
	# *****************************************
	# *  checking out zeroinstall streams
	# *****************************************
	#
	rm -rf $@
	bzr branch bzr+ssh://bazaar.launchpad.net/~armagetronad-dev/armagetronad/trunk-zeroinstall-work $@
	cd $@; bzr push bzr+ssh://bazaar.launchpad.net/~armagetronad-dev/armagetronad/trunk-zeroinstall-work

0install/update: 0install

# sf upload subdirectory
# get a stable year tag
$(UPLOAD).datetag:
	date +BUILDYEAR=%Y > $@
sinclude $(UPLOAD).datetag

SF_DIRECTORY=$(shell echo "$(SERIES)" | sed -e 's,^0.2.8$$,stable,' -e 's,^\(.*\)-snapshots,snapshots/\1,' -e 's,^hacks$$,snapshots/hacks,' -e 's,\(snapshots.*\),\1/$(BUILDYEAR),')

zeroinstall:  uploadcheck $(ZEROINSTTAG)
$(ZEROINSTTAG): $(BINARY_CLIENT_TARBALL) $(BINARY_SERVER_TARBALL) 0install 0install/update
	#
	# *****************************************
	# *  update zeroinstall stream
	# *****************************************
	#
	SF_DIRECTORY=$(SF_DIRECTORY) OSTAG_GENERIC=${OSTAG_GENERIC} PACKAGE=${PACKAGE} SERIES=${SERIES} FILE=${BINARY_CLIENT_TARBALL} VERSION=${VERSION} RC=${RC} 0install/update
	SF_DIRECTORY=$(SF_DIRECTORY) OSTAG_GENERIC=${OSTAG_GENERIC} PACKAGE=${PACKAGE}-dedicated SERIES=${SERIES} FILE=${BINARY_SERVER_TARBALL} VERSION=${VERSION} RC=${RC} 0install/update
	touch $@

APFILE=$(RCDIR)/.package
autopackage-client: $(APFILE).client
autopackage-server: $(APFILE).server
autopackage-legacyserver: $(APFILE).legacyserver
autopackage: autopackage-client autopackage-server
$(APFILE).%: $(SOURCEDIR)/.tag package/Makefile package/default.apspec $(UPLOAD)/.tag
	#
	# *****************************************
	# *  build autopackage $*
	# *****************************************
	#
	rm -rf ap-$*
	SOURCEDIR=$(SOURCEDIR) $(MAKE) -C package release-$*
	mv ap-$*/*.package $(UPLOAD)/$(RCNAME.$*).$(OSTAG_GENERIC).package
	rm -rf ap-$*
	touch $@

# rename renegade uploads
upload-rename: uploadcheck
	if test $(PACKAGE) != armagetronad; then cd $(UPLOAD); for f in armagetronad*; do if echo $$f | egrep "armagetronad-0|armagetronad-dedicated-0" > /dev/null; then mv $$f $$(echo $$f | sed -e "s,armagetronad,$(PACKAGE),"); fi; done; fi

upload-lp: $(SOURCEDIR)/.tag uploadcheck upload-rename
	#
	# *****************************************
	# *  uploading compiled files to lp       *
	# *****************************************
	#
	cp doc/releasenotes.txt $(UPLOAD)/
	head -n 1000 $(SOURCEDIR)/ChangeLog > $(UPLOAD)/ChangeLog
	cd ${UPLOAD};  ../../../../scripts/lp-upload armagetronad "$(SERIES)" "$(VERSION)" *.gz *.bz2 *.zip *.deb *.package *.rpm *.exe *.dmg $(PORTABLE_CLIENT_NAME)*
#	cd ${UPLOAD}; PROJ=armagetron-builds; test $(PACKAGE) = armagetronad && PROJ=armagetronad; ../../../../scripts/lp-upload "$$PROJ" "$(SERIES)" "$(VERSION)" *.gz *.bz2 *.zip *.deb *.package *.rpm *.exe *.dmg

upload-sf: uploadcheck upload-rename
	#
	# *****************************************
	# *  uploading compiled files to sf       *
	# *****************************************
	#
	#echo $(SF_DIRECTORY); false
	cp doc/releasenotes.txt $(UPLOAD)/
	todos $(UPLOAD)/releasenotes.txt
	cd ${UPLOAD}; mkdir -p armagetronad/$(SF_DIRECTORY)/$(VERSION); rsync -r -e ssh armagetronad z-man,armagetronad@frs.sourceforge.net:/home/frs/project/a/ar/; rm -rf armagetronad; rsync --ignore-existing -avP -e ssh * z-man,armagetronad@frs.sourceforge.net:/home/frs/project/a/ar/armagetronad/$(SF_DIRECTORY)/$(VERSION)/; rsync -avP --no-R -e ssh * z-man,armagetronad@frs.sourceforge.net:/home/frs/project/a/ar/armagetronad/$(SF_DIRECTORY)/$(VERSION)/

TOEMPTYLINE=sed -e "s,^$$,," -e "t q" -e "p" -e "d" -e ": q" -e "q"

FRESHMEAT=${RCDIR}/freshmeat
freshmeat: ${FRESHMEAT} 
${FRESHMEAT}: ${RCDIR}
	#
	# *****************************************
	# *  prepare freshmeat submission         *
	# *****************************************
	#
	echo "Project: $(PACKAGE)" > $@
	if test $(STABLE) = false; then echo "Branch: Development" >> $@; else echo "Branch: Stable" >> $@; fi
	echo "Version: $(VERSION)" >> $@
	echo "#Release-Focus: Minor feature enhancements" >> $@
	echo "#Release-Focus: Major feature enhancements" >> $@
	echo "#Release-Focus: Minor bugfixes" >> $@
	echo "#Release-Focus: Major bugfixes" >> $@
	echo "#Release-Focus: Minor security fixes" >> $@
	echo "#Release-Focus: Major security fixes" >> $@
	echo "Hide: N" >> $@
	echo "Home-page-URL: http://www.armagetronad.net" >> $@
	echo "RPM-URL: http://prdownloads.sourceforge.net/armagetronad/`ls $(UPLOAD)/*.rpm | grep -e "src\|dedicated" -v | sed -e "s,.*/,,"`?download" >> $@
	echo "Gzipped-tar-URL: http://prdownloads.sourceforge.net/armagetronad/`echo $(TARBALLGZ) | sed -e "s,.*/,,"`?download" >> $@
	echo "Bzipped-tar-URL: http://prdownloads.sourceforge.net/armagetronad/`echo $(TARBALLBZ) | sed -e "s,.*/,,"`?download" >> $@
	echo "OSX-URL: http://prdownloads.sourceforge.net/armagetronad/armagetronad-$(VERSION).macosx-universal.dmg?download" >> $@
#   echo "CVS-URL: http://cvs.sourceforge.net/viewcvs.py/armagetronad" >> $@
	echo "" >> $@

# extract description
	V=$(VERSION);\
	while ! test -z $$V; do\
		grep -A 20 -a "^$$V:" doc/description.txt | tail -n 20 | $(TOEMPTYLINE) >> $@;\
		V=`echo $$V | sed -e "s,.$$,,"`;\
	done

	$$EDITOR $@
	echo "use freshmeat-submit < $@ to submit."