1 CURL ?= $(shell if test -f /usr/bin/curl ; then echo "curl -H Pragma: -O -R -S --fail --show-error" ; fi)
2 WGET ?= $(shell if test -f /usr/bin/wget ; then echo "wget -nd -m" ; fi)
3 CLIENT ?= $(if $(CURL),$(CURL),$(if $(WGET),$(WGET)))
10 # Thierry - when called from within the build, PWD is /build
13 # get nevr from specfile.
15 NAME := $(shell rpm $(RPMDEFS) $(DISTDEFS) -q --qf "%{NAME}\n" --specfile $(SPECFILE) | head -1)
18 EPOCH := $(shell rpm $(RPMDEFS) $(DISTDEFS) -q --qf "%{EPOCH}\n" --specfile $(SPECFILE) | head -1 | sed 's/(none)//')
20 ifeq ($(EPOCH),(none))
24 VERSION := $(shell rpm $(RPMDEFS) $(DISTDEFS) -q --qf "%{VERSION}\n" --specfile $(SPECFILE)| head -1)
27 RELEASE := $(shell rpm $(RPMDEFS) $(DISTDEFS) -q --qf "%{RELEASE}\n" --specfile $(SPECFILE)| head -1)
30 define get_sources_sha1
31 $(shell cat sources 2>/dev/null | awk 'gensub("^.*/", "", 1, $$2) == "$@" { print $$1; exit; }')
33 define get_sources_url
34 $(shell cat sources 2>/dev/null | awk 'gensub("^.*/", "", 1, $$2) == "$@" { print $$2; exit; }')
36 SOURCEFILES := $(shell cat sources 2>/dev/null | awk '{ print gensub("^.*/", "", 1, $$2) }')
37 SOURCE_RPM := $(firstword $(SOURCEFILES))
39 sources: $(SOURCEFILES) $(TARGETS)
41 $(SOURCEFILES): #FORCE
42 @if [ ! -e "$@" ] ; then echo "$(CLIENT) $(get_sources_url)" ; $(CLIENT) $(get_sources_url) ; fi
43 @if [ ! -e "$@" ] ; then echo "Could not download source file: $@ does not exist" ; exit 1 ; fi
44 @if test "$$(sha1sum $@ | awk '{print $$1}')" != "$(get_sources_sha1)" ; then \
45 echo "sha1sum of the downloaded $@ does not match the one from 'sources' file" ; \
46 echo "Local copy: $$(sha1sum $@)" ; \
47 echo "In sources: $$(grep $@ sources)" ; \
54 @for i in $(SOURCES); do \
55 if [ ! -e "$${i##*/}" ]; then \
56 echo "$(CLIENT) $$i"; \
65 new-sources: download-sources
66 @for i in $(SOURCES); do \
67 echo "$(SHA1SUM) $$i >> sources"; \
68 $(SHA1SUM) $${i##*/} | $(AWK) '{ printf "%s %s\n", $$1, "'"$$i"'" }' >> sources; \
72 RPMDIRDEFS = --define "_sourcedir $(PWD)" --define "_builddir $(PWD)" --define "_srcrpmdir $(PWD)" --define "_rpmdir $(PWD)"
74 rpmbuild $(RPMDIRDEFS) $(RPMDEFS) --nodeps -bp --target $(PREPARCH) $(SPECFILE)
76 # use the stock source rpm, unwrap it,
77 # install our own specfile and patched patches
78 # and patch configs for IPV6
79 # then rewrap with rpm
82 (cd SOURCES; rpm2cpio ../$(SOURCE_RPM) | cpio -diu; \
83 cp ../$(SPECFILE) . ; cp ../linux*.patch . ; \
84 sed -i -e s,CONFIG_IPV6=m,CONFIG_IPV6=y, config-generic)
86 export HOME=$(shell pwd) ; rpmbuild $(RPMDIRDEFS) $(RPMDEFS) --nodeps -bs SOURCES/$(SPECFILE)
87 cp $(SOURCE_RPM) $(EXPECTED_SRPM)
89 TARGET ?= $(shell uname -m)
91 rpmbuild $(RPMDIRDEFS) $(RPMDEFS) --nodeps --target $(TARGET) -bb $(SPECFILE)