summaryrefslogtreecommitdiffstats
path: root/Makefile.viejo
blob: d2223b4fcb504a634833fb08ea76fe75ca6c8ce0 (plain)
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
all: build_all

PACKAGE=$(PACKAGE_NAME)
-include common.mk
KVERS=$(TCOS_DEFAULT_KERNEL)
KSRC=/usr/src/linux-headers-$(KVERS)
KDREV=tcos

MAINDIR=$(CURDIR)

#MA_DIR ?= /usr/share/modass
#-include $(MA_DIR)/include/generic.make
#-include $(MA_DIR)/include/common-rules.make

clean:
	rm -rf build/*

install:

pre_patch:
	-if [ -e $(CURDIR)/patches/$(MO).patch ]; then (cd build && patch -p1  < ../patches/$(MO).patch) ; fi
	-if [ -e $(CURDIR)/patches/$(MO)-$(KVERS).patch ]; then (cd build && patch -p1  < ../patches/$(MO)-$(KVERS).patch) ; fi


build_tcos_module:
	cd $(MAINDIR)
	mkdir -p build
	tar -jxf /usr/src/$(MO).tar.bz2 -C $(CURDIR)/build/
	-make -f Makefile.viejo pre_patch MO=$(MO)
	cd build/modules/$(MO) && \
		$(MAKE) KDIR=$(KSRC) KVER=$(KVERS)

only_build:
	cd build/modules/$(MO) && \
		$(MAKE) KDIR=$(KSRC) KVER=$(KVERS)


build_tcos_aufs_module:
	cd $(MAINDIR)
	mkdir -p build
	tar -jxf /usr/src/aufs.tar.bz2 -C $(CURDIR)/build/
	make -f Makefile.viejo pre_patch MO=aufs
	cd build/modules/aufs && \
		$(MAKE) -C $(KSRC) M=$(CURDIR)/build/modules/aufs/ modules

install_module:
	cd build/modules/$(MO) && \
		mkdir -p $(DESTDIR) && \
                $(MAKE) KDIR=$(KSRC) KVER=$(KVERS) DESTDIR=$(DESTDIR) install 

install_aufs_module:
	cd build/modules/aufs && \
		mkdir -p $(DESTDIR) && \
                $(MAKE) KVER=$(KVERS) M=$(CURDIR)/build/modules/aufs DESTDIR=$(DESTDIR) install 

build_all: clean
	for mod in "$(TCOS_MODULES)"; do \
		if [ "$$mod" = "aufs" ]; then make -f Makefile.viejo build_tcos_aufs_module ; else make -f Makefile.viejo build_tcos_module MO=$$mod; fi \
	done


install:
	for mod in "$(TCOS_MODULES)"; do \
		if [ "$$mod" = "aufs" ]; then make -f Makefile.viejo install_aufs_module ; else make -f Makefile.viejo install_module MO=$$mod; fi \
	done


patch_%:
	sed 's/_KVERS_/$(KERNEL_$(shell echo $@ | sed 's/patch_//g'))/g' debian/control.modules.in > debian/control
	sed -i 's/_BIN_PKGS_/$(BIN_PKGS)/g' debian/control
	sed -i 's/_SOURCE_PKGS_/$(SOURCE_PKGS)/g' debian/control

	sed 's/_KVERS_/$(KERNEL_$(shell echo $@ | sed 's/patch_//g'))/g' \
		debian/$(PACKAGE)-_KVERS_.postinst > debian/$(PACKAGE)-$(KVERS).postinst
	sed 's/_KVERS_/$(KERNEL_$(shell echo $@ | sed 's/patch_//g'))/g' \
		debian/$(PACKAGE)-_KVERS_.postrm > debian/$(PACKAGE)-$(KVERS).postrm


prepare: clean
	tar -jxf /usr/src/$(MO).tar.bz2 -C build/
	cp -ra build/modules/$(MO) build/modules/$(MO).orig
	make -f Makefile.viejo pre_patch MO=$(MO)

do_patch:
	 diff -Naur --exclude=Makefile build/modules/$(MO).orig build/modules/$(MO) > patches/$(MO)-$(KVERS).patch || true
	 diff -Naur build/modules/$(MO).orig/Makefile build/modules/$(MO)/Makefile > patches/$(MO).patch || true
	 diff -Naur build/modules/$(MO).orig/*/Makefile build/modules/$(MO)/*/Makefile >> patches/$(MO).patch || true