| 1 |
# Copyright (C) 2009 Paul G. Fox |
| 2 |
# Licensed under the terms of the GNU GPL v2 or later; see COPYING for details. |
| 3 |
|
| 4 |
PACKAGE=olpc-powerd |
| 5 |
VERSION=23 |
| 6 |
|
| 7 |
|
| 8 |
# don't edit .spec -- edit .spec.tmpl |
| 9 |
SPEC=$(PACKAGE).spec |
| 10 |
|
| 11 |
DATETAG=$(shell date +%Y%m%d) |
| 12 |
GITHEAD=git$(shell test -d .git && git rev-parse --short HEAD ) |
| 13 |
|
| 14 |
ifeq ($(do_rel),) |
| 15 |
SNAP=.$(DATETAG)$(GITHEAD) |
| 16 |
endif |
| 17 |
|
| 18 |
|
| 19 |
RELEASE=$(shell cat .spec_release 2>/dev/null || echo error) |
| 20 |
SRELEASE=$(RELEASE)$(SNAP) |
| 21 |
|
| 22 |
TARBALL=$(PKGVER)-$(GITHEAD).tar.gz |
| 23 |
SRPM=$(PKGVER)-$(SRELEASE).src.rpm |
| 24 |
|
| 25 |
MOCK=./mock-wrapper -r fedora-11-i386 --resultdir=$(MOCKDIR) |
| 26 |
MOCKDIR=./rpms |
| 27 |
CWD=$(shell pwd) |
| 28 |
|
| 29 |
PKGVER=$(PACKAGE)-$(VERSION) |
| 30 |
|
| 31 |
# may be set externally to RPM_OPT_FLAGS |
| 32 |
OPT_FLAGS ?= -O2 -g |
| 33 |
|
| 34 |
##### |
| 35 |
|
| 36 |
PROGS = olpc-switchd pnmto565fb |
| 37 |
|
| 38 |
CFLAGS = -Wall $(OPT_FLAGS) -DVERSION=$(VERSION) |
| 39 |
|
| 40 |
##### |
| 41 |
|
| 42 |
all: version $(PROGS) |
| 43 |
|
| 44 |
# testing targets |
| 45 |
tarball: $(TARBALL) |
| 46 |
srpm: $(SRPM) |
| 47 |
|
| 48 |
version: Makefile |
| 49 |
@echo "powerd_version='version $(VERSION)'" >version |
| 50 |
|
| 51 |
src_distribute: $(TARBALL) $(SRPM) |
| 52 |
scp $(TARBALL) $(SRPM) \ |
| 53 |
crank:public_html/rpms/srpms |
| 54 |
# scp $(SPEC) \ |
| 55 |
# crank:public_html/rpms/srpms/$(SPEC)-$(VERSION)-$(SRELEASE) |
| 56 |
distribute: src_distribute rpms/$(PKGVER)-$(SRELEASE).fc11.i586.rpm |
| 57 |
scp rpms/$(PKGVER)-$(SRELEASE).fc11.i586.rpm \ |
| 58 |
crank:public_html/rpms |
| 59 |
|
| 60 |
privdist: |
| 61 |
scp rpms/$(PKGVER)-$(SRELEASE).fc11.i586.rpm \ |
| 62 |
crank:public_html/private_rpms |
| 63 |
ssh crank ln -sf \ |
| 64 |
$(PKGVER)-$(SRELEASE).fc11.i586.rpm \ |
| 65 |
public_html/private_rpms/$(PKGVER)-$(RELEASE).latest.rpm |
| 66 |
|
| 67 |
# create the real spec (carefully!) so it refers to a) our tarball, and |
| 68 |
# b) our prerelease string. |
| 69 |
$(SPEC): ALWAYS |
| 70 |
sed \ |
| 71 |
-e 's/__VERSION__/$(VERSION)/' \ |
| 72 |
-e 's/__RELEASE__/$(SRELEASE)/' \ |
| 73 |
-e 's/__TARBALL__/$(TARBALL)/' \ |
| 74 |
$(SPEC).tmpl > $(SPEC) |
| 75 |
|
| 76 |
|
| 77 |
# build the tarball directly from git. |
| 78 |
# THIS MEANS NO UNCOMMITED CHANGES WILL BE INCLUDED!!! |
| 79 |
|
| 80 |
$(TARBALL): |
| 81 |
-git diff --exit-code # working copy is clean? |
| 82 |
-git diff --cached --exit-code # uncommitted changes? |
| 83 |
git archive --format=tar --prefix=$(PKGVER)/ HEAD | gzip -c > $@ |
| 84 |
|
| 85 |
|
| 86 |
# build the SRPM from the spec and the tarball |
| 87 |
|
| 88 |
$(SRPM): $(SPEC) $(TARBALL) |
| 89 |
rpmbuild --define "_specdir $(CWD)" \ |
| 90 |
--define "_sourcedir $(CWD)" \ |
| 91 |
--define "_builddir $(CWD)" \ |
| 92 |
--define "_srcrpmdir $(CWD)" \ |
| 93 |
--define "_rpmdir $(CWD)" \ |
| 94 |
--define "dist %nil" \ |
| 95 |
--nodeps -bs $(SPEC) |
| 96 |
|
| 97 |
# build rpm from the srpm |
| 98 |
mock: version $(SRPM) |
| 99 |
@mkdir -p $(MOCKDIR) |
| 100 |
$(MOCK) -q --init |
| 101 |
$(MOCK) --installdeps $(SRPM) |
| 102 |
$(MOCK) -v --no-clean --rebuild $(SRPM) |
| 103 |
|
| 104 |
clean: |
| 105 |
rm -f *.o $(PROGS) |
| 106 |
-$(RM) $(SRPM) $(TARBALL) |
| 107 |
-$(RM) -rf $(MOCKDIR) |
| 108 |
|
| 109 |
.PHONY: tarball srpm mock ALWAYS |