Yet more update tweaks.
[kopensolaris-gnu/glibc.git] / fedora / Makefile
1 # Makefile for maintaining glibc fedora-branch and creating Fedora source RPMs.
2
3 tag-prefix := fedora-
4
5 .PHONY: update commit-merge commit patch tag archive finish_archive srpm rpm
6 FORCE:
7
8 snapshot-date-fmt := +'%Y-%m-%d %H:%M %Z'
9 snapshot-name-fmt := +'%Y%m%dT%H%M'
10
11 include branch.mk
12
13
14 on-branch = $(filter-out HEAD,$(glibc-base))
15
16 snapshot-date := $($(glibc-branch)-sync-date)
17 snapshot-name := $(shell date -u -d '$(snapshot-date)' $(snapshot-name-fmt))
18
19 tar-name := glibc$(subst _,.,$(patsubst glibc-%-branch,-%,\
20                                         $(filter-out HEAD,$(glibc-base))))
21 select-snapshot = -r '$($(glibc-branch)-sync-tag)'
22 snapshot-id = $($(glibc-branch)-sync-tag)
23
24
25 update:
26         now=`date -u $(snapshot-date-fmt)`; \
27         name=`date -u -d "$$now" $(snapshot-name-fmt)`; \
28         new="$(tag-prefix)$(tar-name)-$$name"; \
29         cvs -Q rtag $(if $(on-branch),-r $(glibc-base),-D "$$now") $$new libc;\
30         (echo '# This file is updated automatically by Makefile.'; \
31          echo 'glibc-branch := $(glibc-branch)'; \
32          echo 'glibc-base := $(glibc-base)'; \
33          echo "$(glibc-branch)-sync-date := $$now"; \
34          echo "$(glibc-branch)-sync-tag := $$new"; \
35         ) > branch.mk; \
36         cd ..; (set -x; cvs -q update -d -P \
37                             -j'$($(glibc-branch)-sync-tag)' -j"$$new") \
38                    2>&1 | tee fedora/update.log
39
40 commit-merge:
41         cd ..; cvs -Q commit -m"Updated to $(snapshot-id)"
42
43 glibc.spec: glibc.spec.in ../version.h branch.mk
44         (echo '%define glibcdate $(snapshot-name)'; \
45          sed -n '/VERSION/s/^.*"\([^"]*\)"$$/%define glibcversion \1/p' \
46              ../version.h; \
47          cat $<) > $@.new
48         mv -f $@.new $@
49
50 spec-nvr := $(shell rpm -q --qf '%{NAME}-%{VERSION}-%{RELEASE}\n' \
51                         --specfile glibc.spec | sed 1q)
52 spec-tag = $(subst .,_,$(spec-nvr))
53
54 tag: glibc.spec
55         cd ..; cvs -Q tag -c $(tag-prefix)$(spec-tag)
56
57 $(tar-name)-$(glibc-branch).patch: makepatch.awk glibc.spec FORCE
58         (cd ..; cvs -q diff -upN \
59                     $(select-snapshot) -r $(tag-prefix)$(spec-tag)) | \
60         awk -v OLDVER=$(tar-name)-$(snapshot-name) \
61             -v NEWVER=$(tar-name)-$(snapshot-name)-$(glibc-branch) \
62             -f $< > patch.tmp
63         mv -f patch.tmp $@
64
65 # makepatch.awk omits these files from the patch; we put them in a tar file.
66 outside-patch = fedora c_stubs rtkaio glibc-compat \
67                 localedata/charmaps/GB18030 iconvdata/gb18030.c
68
69 $(tar-name)-$(glibc-branch)-$(snapshot-name).tar.bz2: FORCE
70         @rm -rf libc
71         cvs -Q export -r$(tag-prefix)$(spec-tag) \
72                       $(addprefix libc/,$(outside-patch))
73         tar cf - -C libc $(outside-patch) | bzip2 -9 > $@.new
74         rm -rf libc
75         mv -f $@.new $@
76
77 $(tar-name)-$(snapshot-name).tar.bz2: Makefile branch.mk
78         @rm -rf $(tar-name)-$(snapshot-name)
79         cvs -Q export -d $(tar-name)-$(snapshot-name) $(select-snapshot) libc
80         tar cf - $(tar-name)-$(snapshot-name) | bzip2 -9 > $@.new
81         rm -rf $(tar-name)-$(snapshot-name)
82         mv -f $@.new $@
83
84 archives = $(tar-name)-$(snapshot-name).tar.bz2 \
85            $(tar-name)-$(glibc-branch)-$(snapshot-name).tar.bz2 \
86            $(tar-name)-$(glibc-branch).patch
87 finish_archive: $(archives)
88
89 archive: glibc.spec
90         $(MAKE) tag finish_archive
91
92 rpm srpm: $(spec-nvr).src.rpm
93 $(spec-nvr).src.rpm: glibc.spec $(archives)
94         rpmbuild --define "_sourcedir `pwd`" \
95                  --define "_specdir `pwd`" \
96                  --define "_srcrpmdir `pwd`" \
97                  --nodeps -bs $<