Merge remote branch 'origin/master' into fedora/master
[glibc.git] / fedora / Makefile
bloba9e0e700ca202072aff9856b9e9f2aa648b2783d
1 # Makefile for maintaining Fedora branches and creating Fedora source RPMs.
3 glibc.spec: # The default target.
5 .PHONY: follow merge merge-base tag force-tag archive finish_archive srpm rpm
7 releases-url := ftp://sources.redhat.com/pub/glibc/releases/
8 tag-prefix := fedora/
9 branch-name := fedora
11 GIT ?= git
12 git = $(shell $(GIT) $1 $2)
13 gitconf = $(call git,config,--get $1)
14 branchname = $(patsubst refs/heads/%,%,$1)
16 my-branch := $(call branchname,$(call git,symbolic-ref,HEAD))
17 upstream-remote := $(call gitconf,branch.$(my-branch).remote)
18 upstream-branch := $(call branchname,$(call gitconf,branch.$(my-branch).follow))
20 dep-my-branch := $(firstword $(wildcard ../.git/refs/heads/$(my-branch) \
21 ../.git/packed-refs))
22 dep-upstream-branch := $(firstword $(wildcard \
23 ../.git/refs/remotes/$(upstream-remote)/$(upstream-branch) \
24 ../.git/packed-refs))
26 # Use 'make follow branch=release/3.14/master' to switch this checkout
27 # to a new upstream branch to merge from.
28 follow:
29 ifeq (,$(branch))
30 @echo "Use '$(MAKE) follow branch=NAME'"; exit 2
31 else
32 $(GIT) rev-parse --verify $(upstream-remote)/$(branch)
33 $(GIT) config branch.$(my-branch).follow $(branch)
34 @$(GIT) branch -v | grep "^. $(subst .,\\.,$(my-branch)) "
35 endif
37 # Use this to merge upstream changes into this branch.
38 # It will fail if conflict resolution is required.
39 # Then you follow up with editting, 'git add FILE...', and git commit.
40 merge:
41 $(GIT) pull
42 $(GIT) merge $(upstream-remote)/$(upstream-branch)
44 describe-merge = describe --match 'glibc-*'
46 merge-base-id := $(call git,merge-base,\
47 HEAD $(upstream-remote)/$(upstream-branch))
48 merge-base-name := $(call git,$(describe-merge) $(merge-base-id))
50 merge-base:
51 @echo $(merge-base-id) $(merge-base-name)
53 snapshot-name := $(patsubst glibc-%,%,$(merge-base-name))
55 tar-name = $(merge-base-name)
57 upstream-pristine = \
58 $(GIT) $(describe-merge) --exact-match > /dev/null 2>&1 $(merge-base-id)
60 glibc.spec: glibc.spec.in $(dep-my-branch)
61 @rm -f $@.new
62 echo '%define glibcsrcdir $(tar-name)' > $@.new
63 if $(upstream-pristine); then \
64 echo '%define glibc_release_url $(releases-url)' >> $@.new; \
65 else : ; fi; \
66 $(GIT) show $(my-branch):version.h \
67 | sed -n '/VERSION/s/^.*"\([^"]*\)"$$/%define glibcversion \1/p' \
68 >> $@.new
69 echo '### $< follows:' >> $@.new
70 cat $< >> $@.new
71 mv -f $@.new $@
73 ifeq (,$(wildcard glibc.spec))
74 Makefile: glibc.spec ;
75 else
77 spec-nvr := $(shell rpm -q --qf '%{NAME}-%{VERSION}-%{RELEASE}\n' \
78 --specfile glibc.spec 2> /dev/null | sed 1q)
79 spec-tag = $(spec-nvr)
81 tag-spec = -a -m'$(spec-nvr)' $(tag-prefix)$(spec-tag)
83 tag: glibc.spec
84 $(GIT) tag $(tag-spec)
86 force-tag: glibc.spec
87 $(GIT) tag -f $(tag-spec)
89 endif
91 # Omit these files from the patch and put them in a tar file.
92 outside-patch = fedora/ c_stubs/ rtkaio/ \
93 localedata/charmaps/GB18030 iconvdata/gb18030.c
95 glibc-$(branch-name).patch: glibc.spec Makefile $(dep-upstream-branch)
96 @echo "Creating $@ from `$(git-describe) $(my-branch)`..."
97 @$(GIT) diff -a --no-renames $(merge-base-id)..$(my-branch) \
98 | awk '$$1 == "diff" && $$2 == "--git" { file = $$3 } \
99 $$1 == "---" && $$2 == "/dev/null" { $$2 = file } \
100 { print }' \
101 | filterdiff --remove-timestamps --clean --strip=1 \
102 -x '*/.gitignore' \
103 $(patsubst %,-x '*/%',$(patsubst %/,%/*,$(outside-patch)))\
104 --addoldprefix='$(merge-base-name)/' \
105 --addnewprefix='$(spec-nvr)/' \
106 > patch.tmp
107 @mv -f patch.tmp $@
109 git-describe = $(GIT) describe --long --always
111 define git-tar
112 echo "Creating $@ from `$(git-describe) $1`..."; \
113 (cd ..; $(GIT) archive --format=tar --prefix='$(tar-name)/' $1 $2) \
114 | bzip2 -9 > $@.new && \
115 mv -f $@.new $@
116 endef
118 $(tar-name)-$(branch-name).tar.bz2: glibc.spec Makefile
119 @$(call git-tar,$(my-branch),$(outside-patch))
121 $(tar-name).tar.bz2: $(dep-upstream-branch) Makefile
122 @if $(upstream-pristine); then \
123 echo 'Fetching from $(releases-url)...'; \
124 curl -C - -O $(releases-url)/$@; \
125 else \
126 $(call git-tar,$(merge-base-id)); \
129 archives = $(tar-name).tar.bz2 \
130 $(tar-name)-$(branch-name).tar.bz2 \
131 glibc-$(branch-name).patch
133 finish_archive: $(archives)
135 archive: glibc.spec
136 $(MAKE) tag finish_archive
138 rpm srpm: $(spec-nvr).src.rpm
139 $(spec-nvr).src.rpm: glibc.spec $(archives)
140 rpmbuild --define "_sourcedir `pwd`" \
141 --define "_specdir `pwd`" \
142 --define "_srcrpmdir `pwd`" \
143 --nodeps -bs $<
146 # These rules are for dealing with the Fedora package repository
147 # and build system.
149 # To use this, put in ~/.cvspkgsrc at least a line:
150 # COMMON_DIR ?= /some/checkout/of/pkgs/common
151 # We will find cvs-import.sh there and use its CVS/Root for where to commit.
153 .PHONY: dist-import
155 -include ~/.cvspkgsrc
157 ifdef COMMON_DIR
158 DIST_BRANCH ?= devel
160 pkgs-baseurl := cvs://cvs.fedoraproject.org/cvs/pkgs?rpms
161 pkgs-url = $(pkgs-baseurl)/glibc/$(DIST_BRANCH)\#$(spec-tag)
163 pkgs-import: $(spec-nvr).src.rpm
164 cd $(COMMON_DIR) && cvs -q update
165 $(COMMON_DIR)/cvs-import.sh -b $(DIST_BRANCH) $<
166 rpm -qp $< --queryformat '[%{FILEMD5S} %{FILENAMES}\n]' > $@.new
167 mv -f $@.new $@
169 build: pkgs-import
170 cd $(COMMON_DIR)/../glibc/$(DIST_BRANCH) && \
171 cvs -q update && \
172 $(MAKE) build
174 endif