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 # get nevr from specfile.
12 NAME := $(shell rpm $(RPMDEFS) $(DISTDEFS) -q --qf "%{NAME}\n" --specfile $(SPECFILE) | head -1)
15 EPOCH := $(shell rpm $(RPMDEFS) $(DISTDEFS) -q --qf "%{EPOCH}\n" --specfile $(SPECFILE) | head -1 | sed 's/(none)//')
17 ifeq ($(EPOCH),(none))
21 VERSION := $(shell rpm $(RPMDEFS) $(DISTDEFS) -q --qf "%{VERSION}\n" --specfile $(SPECFILE)| head -1)
24 RELEASE := $(shell rpm $(RPMDEFS) $(DISTDEFS) -q --qf "%{RELEASE}\n" --specfile $(SPECFILE)| head -1)
27 define get_sources_md5
28 $(shell cat sources 2>/dev/null | awk 'gensub("^.*/", "", 1, $$2) == "$@" { print $$1; exit; }')
30 define get_sources_url
31 $(shell cat sources 2>/dev/null | awk 'gensub("^.*/", "", 1, $$2) == "$@" { print $$2; exit; }')
33 SOURCEFILES := $(shell cat sources 2>/dev/null | awk '{ print gensub("^.*/", "", 1, $$2) }')
35 sources: $(SOURCEFILES) $(TARGETS)
37 $(SOURCEFILES): #FORCE
38 @if [ ! -e "$@" ] ; then $(CLIENT) $(get_sources_url) ; fi
39 @if [ ! -e "$@" ] ; then echo "Could not download source file: $@ does not exist" ; exit 1 ; fi
40 @if test "$$(md5sum $@ | awk '{print $$1}')" != "$(get_sources_md5)" ; then \
41 echo "md5sum of the downloaded $@ does not match the one from 'sources' file" ; \
42 echo "Local copy: $$(md5sum $@)" ; \
43 echo "In sources: $$(grep $@ sources)" ; \
50 @for i in $(SOURCES); do \
51 if [ ! -e "$${i##*/}" ]; then \
52 echo "$(CLIENT) $$i"; \
61 new-sources: download-sources
62 @for i in $(SOURCES); do \
63 echo "$(MD5SUM) $$i >> sources"; \
64 $(MD5SUM) $${i##*/} | $(AWK) '{ printf "%s %s\n", $$1, "'"$$i"'" }' >> sources; \
68 RPMDIRDEFS = --define "_sourcedir $(PWD)" --define "_builddir $(PWD)" --define "_srcrpmdir $(PWD)" --define "_rpmdir $(PWD)"
70 rpmbuild $(RPMDIRDEFS) $(RPMDEFS) --nodeps -bp --target $(PREPARCH) $(SPECFILE)
73 rpmbuild $(RPMDIRDEFS) $(RPMDEFS) --nodeps -bs $(SPECFILE)
75 TARGET ?= $(shell uname -m)
77 rpmbuild $(RPMDIRDEFS) $(RPMDEFS) --nodeps --target $(TARGET) -bb $(SPECFILE)