vhci: build kernel module & library
[simavr] / examples / vhci / Makefile
1 #
2 # This makefile attempts to compile the vhci core module and the
3 # libusb-vhci library by downloading known tarballs, hacking them
4 # a little and compiling them
5
6 # This has been tested on debian, but coild possibly work in other
7 # distro. the only "real" dependency is to have the linux kernel
8 # header symlinked at /lib/modules/<your host kernel version/build
9 #
10
11 HCD_V           = 1.14
12 VHCI_V          = 0.6
13 BASE_URL        = http://downloads.sourceforge.net/project/usb-vhci
14
15 all: library
16
17 module: vhci-hcd-$(HCD_V)/usb-vhci-hcd.ko
18
19 vhci-hcd-$(HCD_V)/usb-vhci-hcd.ko: vhci-hcd-$(HCD_V)
20         make -C vhci-hcd-$(HCD_V) \
21                 KDIR=/lib/modules/${shell uname -r}/build \
22                 CORE_INCLUDE_DIR=$(PWD)/vhci-hcd-$(HCD_V)/linux/2.6.32/drivers/usb/core
23
24 vhci-hcd-$(HCD_V).tar.bz2: 
25         wget $(BASE_URL)/linux%20kernel%20module/$@
26
27 vhci-hcd-$(HCD_V): vhci-hcd-$(HCD_V).tar.bz2
28         tar jxf $@.tar.bz2 && \
29                 cd $@ && \
30                 cat ../patches/hcd-*.patch | patch --merge -p1 
31         sed -i -e 's|#define DEBUG|#undef DEBUG|' vhci-hcd-$(HCD_V)/usb-vhci-hcd.c
32
33 library: lib/libusb_vhci.a
34
35 lib/libusb_vhci.a: module libusb_vhci-$(VHCI_V)
36         ln -snf vhci-hcd-$(HCD_V) linux && \
37                 cd libusb_vhci-$(VHCI_V) && \
38                 ./configure --prefix=$(PWD) CPPFLAGS="-I$(PWD)" --enable-static --disable-shared && \
39                         make && make install
40
41 libusb_vhci-$(VHCI_V).tar.bz2:
42         wget $(BASE_URL)/native%20libraries/libusb_vhci-$(VHCI_V).tar.bz2
43
44 libusb_vhci-$(VHCI_V): libusb_vhci-$(VHCI_V).tar.bz2
45         tar jxf $@.tar.bz2 && \
46                 cd $@ && \
47                 cat ../patches/vhci-*.patch | patch --merge -p1 
48
49 clean:
50         rm -rf libusb_vhci-$(VHCI_V) vhci-hcd-$(HCD_V) lib include linux
51
52 distclean: clean
53         rm -rf *.tar.bz2