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)))
8 SPECFILE = kernel-2.6-planetlab.spec
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_md5
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) }')
38 sources: $(SOURCEFILES) $(TARGETS)
40 $(SOURCEFILES): #FORCE
41 @if [ ! -e "$@" ] ; then echo "$(CLIENT) $(get_sources_url)" ; $(CLIENT) $(get_sources_url) ; fi
42 @if [ ! -e "$@" ] ; then echo "Could not download source file: $@ does not exist" ; exit 1 ; fi
43 @if test "$$(md5sum $@ | awk '{print $$1}')" != "$(get_sources_md5)" ; then \
44 echo "md5sum of the downloaded $@ does not match the one from 'sources' file" ; \
45 echo "Local copy: $$(md5sum $@)" ; \
46 echo "In sources: $$(grep $@ sources)" ; \
53 @for i in $(SOURCES); do \
54 if [ ! -e "$${i##*/}" ]; then \
55 echo "$(CLIENT) $$i"; \
64 new-sources: download-sources
65 @for i in $(SOURCES); do \
66 echo "$(MD5SUM) $$i >> sources"; \
67 $(MD5SUM) $${i##*/} | $(AWK) '{ printf "%s %s\n", $$1, "'"$$i"'" }' >> sources; \
71 RPMDIRDEFS = --define "_sourcedir $(PWD)" --define "_builddir $(PWD)" --define "_srcrpmdir $(PWD)" --define "_rpmdir $(PWD)"
73 rpmbuild $(RPMDIRDEFS) $(RPMDEFS) --nodeps -bp --target $(PREPARCH) $(SPECFILE)
76 rpmbuild $(RPMDIRDEFS) $(RPMDEFS) --nodeps -bs $(SPECFILE)
78 TARGET ?= $(shell uname -m)
80 rpmbuild $(RPMDIRDEFS) $(RPMDEFS) --nodeps --target $(TARGET) -bb $(SPECFILE)