File: Makefile

package info (click to toggle)
olpc-kbdshim 12-3
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 208 kB
  • ctags: 178
  • sloc: ansic: 1,868; sh: 132; makefile: 73
file content (121 lines) | stat: -rw-r--r-- 3,109 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# Copyright (C) 2009 Paul G. Fox
# Licensed under the terms of the GNU GPL v2 or later; see COPYING for details.

PACKAGE=olpc-kbdshim

# don't edit .spec -- edit .spec.tmpl
SPEC=$(PACKAGE).spec

DATETAG=$(shell date +%Y%m%d)
GITHEAD=git$(shell test -d .git && git rev-parse --short HEAD )

ifeq ($(do_rel),)
    SNAP=.$(DATETAG)$(GITHEAD)
endif

VERSION=12
RELEASE=$(shell cat .spec_release 2>/dev/null || echo error)
SRELEASE=$(RELEASE)$(SNAP)

TARBALL=$(PKGVER)-$(GITHEAD).tar.gz
SRPM=$(PKGVER)-$(SRELEASE).src.rpm

MOCK=./mock-wrapper -r fedora-11-i386 --resultdir=$(MOCKDIR)
MOCKDIR=./rpms
CWD=$(shell pwd)

PKGVER=$(PACKAGE)-$(VERSION)

# may be set externally to RPM_OPT_FLAGS
OPT_FLAGS ?= -O2 -g

#####

PROGS = olpc-kbdshim-hal olpc-kbdshim

# the "hal" version runs as a HAL addon daemon, and needs several
# libraries for the HAL interfaces
olpc-kbdshim-hal: \
	CFLAGS = -Wall $(OPT_FLAGS) -DVERSION=$(VERSION) \
	    $$(pkg-config --cflags hal) \
	    $$(pkg-config --cflags glib-2.0) \
	    $$(pkg-config --cflags dbus-glib-1)

olpc-kbdshim-hal: \
	LDLIBS = $$(pkg-config --libs hal) \
	    $$(pkg-config --libs glib-2.0) \
	    $$(pkg-config --libs dbus-glib-1)

# non-hal version of kbdshim is much simpler.  the downside is that
# it only monitors the local keyboard and touchpad, and won't detect
# user activity on USB devices.
olpc-kbdshim: CFLAGS = -Wall $(OPT_FLAGS) -DVERSION=$(VERSION)

#####

all: $(PROGS)

# testing targets
tarball:  $(TARBALL)
srpm: $(SRPM)


src_distribute: $(TARBALL) $(SRPM)
	scp $(TARBALL) $(SRPM)  \
		crank:public_html/rpms/srpms
#	scp $(SPEC) \
#		crank:public_html/rpms/srpms/$(SPEC)-$(VERSION)-$(SRELEASE)
distribute: src_distribute rpms/$(PKGVER)-$(SRELEASE).fc11.i586.rpm
	scp rpms/$(PKGVER)-$(SRELEASE).fc11.i586.rpm \
		crank:public_html/rpms

privdist:
	scp rpms/$(PKGVER)-$(SRELEASE).fc11.i586.rpm \
		crank:public_html/private_rpms
	ssh crank ln -sf \
		$(PKGVER)-$(SRELEASE).fc11.i586.rpm \
		public_html/private_rpms/$(PKGVER)-$(RELEASE).latest.rpm

# create the real spec (carefully!) so it refers to a) our tarball, and
# b) our prerelease string.
$(SPEC): ALWAYS
	sed \
	-e 's/__VERSION__/$(VERSION)/' \
	-e 's/__RELEASE__/$(SRELEASE)/' \
	-e 's/__TARBALL__/$(TARBALL)/' \
	$(SPEC).tmpl > $(SPEC)


# build the tarball directly from git.
# THIS MEANS NO UNCOMMITED CHANGES WILL BE INCLUDED!!!

$(TARBALL):
	-git diff --exit-code # working copy is clean?
	-git diff --cached --exit-code # uncommitted changes?
	git archive --format=tar --prefix=$(PKGVER)/ HEAD | gzip -c > $@


# build the SRPM from the spec and the tarball

$(SRPM): $(SPEC) $(TARBALL)
	rpmbuild --define "_specdir $(CWD)" \
		 --define "_sourcedir $(CWD)" \
		 --define "_builddir $(CWD)"  \
		 --define "_srcrpmdir $(CWD)"  \
		 --define "_rpmdir $(CWD)"  \
		 --define "dist %nil"  \
		 --nodeps -bs $(SPEC)

# build rpm from the srpm
mock: $(SRPM)
	@mkdir -p $(MOCKDIR)
	$(MOCK) -q --init
	$(MOCK) --installdeps $(SRPM)
	$(MOCK) -v --no-clean --rebuild $(SRPM)

clean:
	rm -f *.o $(PROGS)
	-$(RM) $(SRPM) $(TARBALL)
	-$(RM) -rf $(MOCKDIR)

.PHONY: tarball srpm mock ALWAYS