2.5-18.1
[glibc.git] / fedora / Makefile
blob73a6fd228745507129e83ad85ca70eb04c85c053
1 # Makefile for maintaining glibc fedora-branch and creating Fedora source RPMs.
3 glibc.spec: # The default target.
5 tag-prefix := fedora-
7 .PHONY: update commit-merge tag archive finish_archive srpm rpm
9 snapshot-date-fmt := +'%Y-%m-%d %H:%M %Z'
10 snapshot-name-fmt := +'%Y%m%dT%H%M'
12 include branch.mk
15 on-branch = $(filter-out HEAD,$(glibc-base))
17 snapshot-date := $($(glibc-branch)-sync-date)
18 snapshot-name := $(shell date -u -d '$(snapshot-date)' $(snapshot-name-fmt))
20 tag-name := glibc$(patsubst glibc-%-branch,-%,\
21 $(filter-out HEAD,$(glibc-base)))
22 tar-name := $(subst _,.,$(tag-name))
23 select-snapshot = -r '$($(glibc-branch)-sync-tag)'
24 snapshot-id = $($(glibc-branch)-sync-tag)
26 branch-name := $(patsubst %-$(patsubst glibc-%,%,$(tag-name)),%,\
27 $(glibc-branch))
29 branch.mk-vars = glibc-branch glibc-base DIST_BRANCH COLLECTION \
30 releases-url
32 ifeq (,$(upstream-tag))
33 ifneq (,$(upstream))
34 upstream-tag := glibc-$(subst .,_,$(upstream))
35 endif
36 endif
38 update:
39 now=`date -u $(snapshot-date-fmt)`; \
40 $(if $(upstream-tag),new='$(upstream-tag)';,\
41 name=`date -u -d "$$now" $(snapshot-name-fmt)`; \
42 new="$(tag-prefix)$(tag-name)-$$name"; \
43 cvs -Q rtag $(if $(on-branch),-r $(glibc-base),-D "$$now") $$new libc;\
45 (echo '# This file is updated automatically by Makefile.'; \
46 $(foreach var,$(branch.mk-vars) $(if $(upstream-tag),upstream),\
47 $(if $($(var)),echo '$(var) := $($(var))';)) \
48 echo "$(glibc-branch)-sync-date := $$now"; \
49 echo "$(glibc-branch)-sync-tag := $$new"; \
50 ) > branch.mk; \
51 cd ..; (set -x; cvs -q update -d -P \
52 -j'$($(glibc-branch)-sync-tag)' -j"$$new") \
53 2>&1 | tee fedora/update.log
55 .PHONY: snapshot-time
56 snapshot-time: branch.mk
57 date -d '$(snapshot-date)'
59 commit-merge:
60 cd ..; cvs -Q commit -m"Updated to $(snapshot-id)"
62 glibc.spec: glibc.spec.in ../version.h branch.mk
63 (echo '%define glibcdate $(snapshot-name)'; \
64 echo '%define glibcname $(tar-name)'; \
65 echo '%define glibcsrcdir $(srcdir-name)'; \
66 echo '%define glibc_release_tarballs $(if $(upstream),1,0)'; \
67 sed -n '/VERSION/s/^.*"\([^"]*\)"$$/%define glibcversion \1/p' \
68 ../version.h; \
69 cat $<) > $@.new
70 mv -f $@.new $@
72 ifeq (,$(wildcard glibc.spec))
73 Makefile: glibc.spec ;
74 else
76 spec-nvr := $(shell rpm -q --qf '%{NAME}-%{VERSION}-%{RELEASE}\n' \
77 --specfile glibc.spec | sed 1q)
78 spec-tag = $(subst .,_,$(spec-nvr))
80 ifeq ($(tagged),no)
81 select-release = -r $(glibc-branch)-branch
82 else
83 select-release = -r $(tag-prefix)$(spec-tag)
84 endif
86 tag: glibc.spec
87 cd ..; cvs -Q tag -c $(tag-prefix)$(spec-tag)
89 force-tag: glibc.spec
90 cd ..; cvs -Q tag -F -c $(tag-prefix)$(spec-tag)
92 ifeq (,$(upstream))
93 srcdir-name = $(tar-name)-$(snapshot-name)
94 else
95 tar-name = glibc-$(upstream)
96 srcdir-name = $(tar-name)
98 ifneq ($($(glibc-branch)-sync-tag),$(upstream-tag))
99 define upstream-tag-check
100 @echo Need to run make update upstream=$(upstream); exit 1
101 endef
102 endif
103 endif
105 # Note this rule assumes that your working directory (..) is up to date.
106 $(tar-name)-$(branch-name).patch: makepatch.awk glibc.spec \
107 ../ChangeLog ../*/ChangeLog
108 $(upstream-tag-check)
109 # Use -kk to suppress patches for $ Id $ differences between branches.
110 (cd ..; cvs -q diff -kk -upN $(select-snapshot) $(select-release)) | \
111 awk -v OLDVER=$(srcdir-name) \
112 -v NEWVER=$(srcdir-name)-$(branch-name) \
113 -f $< > patch.tmp
114 mv -f patch.tmp $@
116 # makepatch.awk omits these files from the patch; we put them in a tar file.
117 outside-patch = fedora c_stubs rtkaio powerpc-cpu \
118 localedata/charmaps/GB18030 iconvdata/gb18030.c
120 $(tar-name)-$(branch-name)-$(snapshot-name).tar.bz2: Makefile branch.mk \
121 ../ChangeLog \
122 ../*/ChangeLog
123 $(upstream-tag-check)
124 @rm -rf libc
125 cvs -Q export $(select-release) $(addprefix libc/,$(outside-patch))
126 tar cf - -C libc $(outside-patch) | bzip2 -9 > $@.new
127 rm -rf libc
128 mv -f $@.new $@
130 glibc-tarballs = $(srcdir-name).tar.bz2
131 ifeq (,$(upstream))
132 $(srcdir-name).tar.bz2: Makefile branch.mk
133 @rm -rf $(srcdir-name)
134 cvs -Q export -d $(srcdir-name) $(select-snapshot) libc
135 tar cf - $(srcdir-name) | bzip2 -9 > $@.new
136 rm -rf $(srcdir-name)
137 mv -f $@.new $@
138 else
139 glibc-tarballs += $(srcdir-name:glibc-%=glibc-linuxthreads-%).tar.bz2 \
140 $(srcdir-name:glibc-%=glibc-libidn-%).tar.bz2
142 $(glibc-tarballs):
143 curl -O $(releases-url)/$@
144 endif
146 archives = $(glibc-tarballs) \
147 $(tar-name)-$(branch-name)-$(snapshot-name).tar.bz2 \
148 $(tar-name)-$(branch-name).patch
150 finish_archive: $(archives)
152 archive: glibc.spec
153 $(MAKE) tag finish_archive
155 rpm srpm: $(spec-nvr).src.rpm
156 $(spec-nvr).src.rpm: glibc.spec $(archives)
157 rpmbuild --define "_sourcedir `pwd`" \
158 --define "_specdir `pwd`" \
159 --define "_srcrpmdir `pwd`" \
160 --nodeps -bs $<
163 # These rules are for dealing with the Fedora package repository
164 # and the Red Hat internal build system.
166 # To use this, put in ~/.cvsdistrc at least a line:
167 # DIST_COMMON = /some/checkout/of/dist/common
168 # We will find cvs-import.sh there and use its CVS/Root for where to commit.
170 .PHONY: dist-import
172 -include ~/.cvsdistrc
174 ifdef DIST_COMMON
175 DIST_BRANCH ?= devel
176 COLLECTION ?= dist-fc4
177 BHC_FLAGS ?= -n
179 bhc-baseurl := cvs://cvs.devel.redhat.com/cvs/dist?rpms
180 bhc-url = $(bhc-baseurl)/glibc/$(DIST_BRANCH)\#$(spec-tag)
182 dist-import: $(spec-nvr).src.rpm
183 $(DIST_COMMON)/cvs-import.sh -b $(DIST_BRANCH) $<
184 rpm -qp $< --queryformat '[%{FILEMD5S} %{FILENAMES}\n]' > $@.new
185 mv -f $@.new $@
187 dist-build: dist-import
188 bhc $(BHC_FLAGS) $(COLLECTION) '$(bhc-url)'
190 endif
193 endif