let ipkg fail when a package file to be installed is not found
[openwrt/staging/wigyori.git] / openwrt / package / shfs / patches / 101-kmod-build.patch
1 --- shfs-0.35-orig/shfs/Linux-2.4/Makefile 2004-06-01 15:16:19.000000000 +0200
2 +++ shfs-0.35-2/shfs/Linux-2.4/Makefile 2005-04-09 02:34:35.000000000 +0200
3 @@ -1,3 +1,17 @@
4 +#
5 +# the original Makefile was trashed and replaced by this one
6 +# The main reason is that loadable modules should be built with
7 +# the same compile flags the kernel was built with, so we'd better
8 +# let the kernel tree build the module for us, like that :
9 +#
10 +# make -C $(KERNEL_DIR) SUBDIRS="$(shell pwd)" modules
11 +# make -C $(KERNEL_DIR) SUBDIRS="$(shell pwd)" modules_install
12 +#
13 +#
14 +# $(TOPDIR)/lib/string.o is needed at link time because the memchr function
15 +# is not exported on mips (insmod: unresolved symbol memchr)
16 +#
17 +
18 ifndef KERNEL
19 KERNEL=$(shell uname -r)
20 endif
21 @@ -10,67 +24,30 @@
22 KERNEL_SOURCES=${MODULESDIR}/build
23 endif
24
25 -ifeq (${MODVERSIONS},detect)
26 - ifeq ($(shell test -e ${KERNEL_SOURCES}/include/linux/modversions.h; echo $$?),0)
27 - MODVERSIONS=yes
28 - endif
29 -endif
30 -
31 -ifeq (${MODVERSIONS},yes)
32 -MVER=-DMODVERSIONS -DEXPORT_SYMTAB
33 -endif
34 -
35 -LINVER=linux-${KERNEL}
36 -
37 -ALL_TARGETS := shfs.o
38 -
39 -SEARCHDIRS := -I- -I. -I${KERNEL_SOURCES}/include #-I/usr/src/linux/include/
40 +all: all-y
41
42 -CC := gcc
43 -CFLAGS = -O2 -fomit-frame-pointer -fno-strict-aliasing -pipe -Wall ${SEARCHDIRS} -DMODULE ${MVER} -D__KERNEL__ -DLINUX
44 -LINKER := ld
45 -LDFLAGS = -r
46 -LOADLIBES :=
47 +O_TARGET := shfs.o
48
49 -all: ${ALL_TARGETS}
50 +shfs-objs := dcache.o dir.o fcache.o file.o inode.o ioctl.o proc.o shell.o symlink.o
51
52 -%.o: %.c $(wildcard *.h)
53 - ${CC} ${CFLAGS} -c $< -o $@
54 +obj-y := $(shfs-objs)
55 +obj-m := $(O_TARGET)
56
57 -shfs.o: dcache.o dir.o fcache.o file.o inode.o ioctl.o proc.o shell.o symlink.o
58 - ${LINKER} ${LDFLAGS} -o $@ ${filter-out %.a %.so, $^} ${LOADLIBES}
59 -
60 -tidy:
61 - ${RM} core dcache.o dir.o fcache.o file.o inode.o ioctl.o proc.o shell.o symlink.o
62 -
63 -clean: tidy patch-clean
64 - ${RM} shfs.o
65 +-include $(TOPDIR)/Rules.make
66
67 +all-y:
68 + make -C ${KERNEL_SOURCES} TOPDIR="${KERNEL_SOURCES}" SUBDIRS="$(shell pwd)" modules
69 +
70 install: shfs.o
71 rm -f ${MODULESDIR}/kernel/fs/shfs/shfs.o
72 install -m644 -b -D shfs.o ${MODULESDIR}/kernel/fs/shfs/shfs.o
73 - if [ -x /sbin/depmod -a "${ROOT}" = "/" ]; then /sbin/depmod -aq; fi
74
75 uninstall:
76 rm -rf ${MODULESDIR}/kernel/fs/shfs
77 - if [ -x /sbin/depmod -a "${ROOT}" = "/" ]; then /sbin/depmod -aq; fi
78
79 -patch:
80 - rm -rf ${LINVER} ${LINVER}.orig; mkdir ${LINVER};
81 - for i in Documentation fs/shfs include/linux; do \
82 - mkdir -p ${LINVER}/$$i; \
83 - done
84 - cp ${KERNEL_SOURCES}/Documentation/Configure.help ${LINVER}/Documentation
85 - cp ${KERNEL_SOURCES}/fs/{Makefile,Config.in} ${LINVER}/fs
86 - cp -r ${LINVER} ${LINVER}.orig
87 - cp ../../Changelog *.c shfs_debug.h proc.h ${LINVER}/fs/shfs/
88 - cp shfs.h shfs_fs* ${LINVER}/include/linux/
89 - (cd ${LINVER}; patch -p1 <../kernel-config.diff)
90 - find . -type f -name "*.orig" -print | xargs rm -f
91 - diff -urN ${LINVER}.orig ${LINVER} >${LINVER}.diff; true
92 -
93 -patch-clean:
94 - rm -rf ${LINVER} ${LINVER}.orig;
95 - rm -f ${LINVER}.diff
96 -
97 -.PHONY : all tidy clean install uninstall patch patch-clean
98 +clean:
99 + rm -f core *.o *.a *.s
100 +
101 +shfs.o: $(shfs-objs)
102 + $(LD) -r -o $@ $(shfs-objs) $(TOPDIR)/lib/string.o
103 +