summaryrefslogtreecommitdiff
path: root/olpc/Makefile
blob: c1a7751598a983de20940bc474f3c21d099c6cb1 (plain) (blame)
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
CP		= cp

OLPCBUILDBASE	= $(srctree)/olpc

HEAD		= $(shell git-log -n1 --pretty=format:%h)

ifeq ($(BUILDNUMBER),)
BUILDNUMBER := 1
endif

ifeq ($(RPM),)
RPM := rpmbuild
endif

# Directories

BUILDDIR	= $(OLPCBUILDBASE)/BUILD
RPMSDIR		= $(OLPCBUILDBASE)/RPMS/
RPMSNOARCHDIR	= $(OLPCBUILDBASE)/RPMS/noarch
SRPMSDIR	= $(OLPCBUILDBASE)/SRPMS
SPECSDIR	= $(OLPCBUILDBASE)/SPECS
SOURCESDIR	= $(OLPCBUILDBASE)/SOURCES

SPECFILE	= $(SPECSDIR)/olpc-2.6.spec

# Symlink
KERNELDIR	= linux-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)

# Kernel tarball for RPM
TARBALL		= $(SOURCESDIR)/olpc-2.6.tar.bz2

# Config file
CONFIG_SRC	= arch/x86/configs/olpc_defconfig
RPMCONFIGFILE	= $(SOURCESDIR)/kernel-olpc-custom.config

# What to clean out
clean-dirs := $(BUILDDIR) $(RPMSDIR) $(RPMSDIR) $(SRPMSDIR)
CLEAN_FILES += $(RPMCONFIGFILE) $(TARBALL) $(SOURCESDIR)/$(KERNELDIR)

olpc-tarball: $(TARBALL)

#
# Update config file
#
$(RPMCONFIGFILE) : $(CONFIG_SRC)
	cp $(CONFIG_SRC) $(RPMCONFIGFILE)

#
# Create a tarball out of the gittree
#
$(TARBALL): 
	@make distclean; \
	git-status | grep --quiet modified || git-status | grep --quiet Untracked; \
	if [ $$? -eq 0 ]; then \
		echo "*** TREE IS NOT CLEAN. PLEASE COMMMIT CHANGES FIRST ***"; \
		git-status; \
		exit -1;\
	fi; \
	mkdir -p $(SOURCESDIR); \
	cd $(SOURCESDIR); \
	ln -s $(srctree) $(KERNELDIR); \
	tar -X $(OLPCBUILDBASE)/.tarignore -X $(srctree)/.gitignore \
		--exclude=olpc/SOURCES/$(KERNELDIR) -hvcjf $(TARBALL) $(KERNELDIR)/

#
# The Kernel RPM and its ingredients
#
olpc-kernel-rpm: $(TARBALL) $(SPECFILE) $(RPMCONFIGFILE)
	mkdir -p $(BUILDDIR) $(RPMSNOARCHDIR) $(SRPMSDIR); \
	$(RPM) -ba $(SPECFILE) \
	--target=i586 \
	--define "sublevel $(SUBLEVEL)" \
	--define "_builddir $(BUILDDIR)" \
	--define "_rpmdir $(RPMSDIR)" \
	--define "_sourcedir $(SOURCESDIR)" \
	--define "_specdir $(SPECSDIR)" \
	--define "_srcrpmdir $(SRPMSDIR)" \
	--define "head $(HEAD)" \
	--define "olpc $(BUILDNUMBER)" \
	--define "dist 1.olpc"