Whamcloud - gitweb
63581e340e0deda022ed0e0164d90aabb44b81b0
[fs/lustre-release.git] / lustre / extN / Makefile.am
1 # Copyright (C) 2001  Cluster File Systems, Inc.
2 #
3 # This code is issued under the GNU General Public License.
4 # See the file COPYING in this distribution
5
6 DEFS=-DEXPORT_SYMTAB
7 MODULE = extN
8 modulefs_DATA = extN.o
9 EXTRA_PROGRAMS = extN
10
11 # NOTE: If you are not using a RedHat 12.5 or later kernel, then you need to
12 #       apply the following patch first, as it fixes a number of bugs in ext3.
13 #       It will be applied automatically by the extN build process, or you
14 #       can apply it to the source kernel tree and fix ext3 also.  For chaos22
15 #       (or other RH < 12.5 kernels) use the "chaos22" patch instead.
16 #EXTN_FIXES = ../patches/patch-2.4.18-chaos22
17 EXTN_FIXES = ext3-2.4.18-fixes.diff
18 EXTNP = htree-ext3-2.4.18.diff linux-2.4.18ea-0.8.26.diff
19 EXTNP+= ext3-2.4.18-ino_sb_macro.diff extN-misc-fixup.diff
20 EXTNC = balloc.c bitmap.c dir.c file.c fsync.c ialloc.c inode.c ioctl.c
21 EXTNC+= namei.c super.c symlink.c
22 EXTNI = extN_fs.h extN_fs_i.h extN_fs_sb.h extN_jbd.h
23 EXTN_EXTRA = include/linux/xattr.h include/linux/extN_xattr.h fs/extN/xattr.c
24 extN_SOURCES = $(EXTNC) xattr.c # punch.c
25 extN_DEPENDENCIES = patch-stamp
26 EXTRA_DIST = $(EXTNP) extN-2.4.18-ino_sb_fixup.diff extN-2.4.18-exports.diff \
27         $(wildcard extN.patch-*)
28 DISTCLEANFILES = -r $(extN_SOURCES) sed-stamp patch-stamp *.orig *.rej
29 SUB=-e "s/ext3/extN/g" -e "s/EXT3/EXTN/g"
30
31 distclean:
32         cd .. && rm -f $(EXTN_EXTRA)
33
34 include $(top_srcdir)/Rules
35
36 # Create a fresh extN patch.
37 # This is for when the patch-stamp target fails for your kernel.
38 # Just edit the files until you like them, then do `make diff', and
39 # it will create a specialized patch for your particular kernel.
40 # Check it in, and the build should work for you without disrupting
41 # the other developers.
42 # Of course, the ideal is to merge changes so that the default patch
43 # set works for nearly everybody.  This is mainly for damage control.
44 diff:
45         $(RM) extN.patchT
46         l='$(EXTNC)'; for f in $$l; do                                        \
47           echo "$$f";                                                         \
48           (cd $(top_srcdir) &&                                                \
49             diff -u extN/extN.orig/$$f extN/$$f) >> extN.patchT;              \
50           test $$? -le 1 || exit 1;                                           \
51         done
52         l='$(EXTNI)'; for f in $$l; do                                        \
53           echo "$$f";                                                         \
54           (cd $(top_srcdir) &&                                                \
55             diff -u extN/extN-include.orig/$$f include/linux/$$f)>>extN.patchT;\
56           test $$? -le 1 || exit 1;                                           \
57         done
58         l='$(EXTN_EXTRA)'; for f in $$l; do                                   \
59           f=`echo "$$f" | sed 's%^fs/%%'`;                                    \
60           echo "$$f";                                                         \
61           (cd $(top_srcdir) &&                                                \
62             diff -u /dev/null $$f) >> extN.patchT;                            \
63           test $$? -le 1 || exit 1;                                           \
64         done
65         mv -f extN.patchT $(srcdir)/extN.patch-$(RELEASE)
66         echo "Don't forget to add $(srcdir)/extN.patch-$(RELEASE) to CVS!"
67 .PHONY: diff
68
69 # Just do the SUB transformation on all our source files.
70 sed-stamp:
71         $(RM) $@
72         rm -rf extN.orig extN-include.orig
73         mkdir extN.orig extN-include.orig
74         list='$(EXTNC)'; for f in $$list; do                                  \
75           echo "creating extN.orig/$$f";                                      \
76           sed $(SUB) $(LINUX)/fs/ext3/$$f > extN.orig/$$f;                    \
77         done
78         list='$(EXTNI)'; for i in $$list; do                                  \
79           s=`echo $$i | sed "s/extN/ext3/"`;                                  \
80           echo "creating extN.orig-include/$$i";                              \
81           sed $(SUB) $(LINUX)/include/linux/$$s > extN-include.orig/$$i;      \
82         done
83         echo timestamp > $@
84
85 # Patch the kernel files with our ext3 patches.  We need to go through some
86 # extra hoops because the include files are in a different tree and because
87 # patch likes to make local copies of files with (sym)links when it is patching
88 # them.  To avoid this, we copy/patch in the source dir instead of the build
89 # dir (if they are different).
90 # We also want to preserve the pristine transformed files for the diff target.
91 patch-stamp: sed-stamp $(EXTNP)
92         cp -a extN.orig/* $(srcdir)
93         cp -a extN-include.orig/* $(top_srcdir)/include/linux
94         test -e $(top_srcdir)/fs || ln -s . $(top_srcdir)/fs
95         list='$(EXTN_EXTRA)'; for f in $$list; do $(RM) $(top_srcdir)/$$f; done
96         if [ -f $(srcdir)/extN.patch-$(RELEASE) ]; then                       \
97           echo "applying patch $(srcdir)/extN.patch-$(RELEASE)";              \
98           (cd $(top_srcdir) && patch -p0) < $(srcdir)/extN.patch-$(RELEASE);  \
99         else                                                                  \
100           echo "If first patch fails, read NOTE in extN/Makefile.am";         \
101           list='$(EXTNP)'; \
102           sed '/i_version/q' $(srcdir)/extN.orig/namei.c | tail -2 | grep extN_mark_inode_dirty >/dev/null && list="$(EXTN_FIXES) $$list"; \
103           for p in $$list; do                                \
104             echo "applying patch $$p";                                        \
105             sed $(SUB) $(srcdir)/$$p |                                        \
106               (cd $(top_srcdir) && patch -p1) || exit $$?;                    \
107           done;                                                               \
108           echo "It is OK if the next patch says it is already applied";       \
109           echo "applying patch $(srcdir)/extN-2.4.18-exports.diff";           \
110           (cd $(top_srcdir) &&                                                \
111             patch -N -p1) < $(srcdir)/extN-2.4.18-exports.diff;               \
112           echo "applying patch $(srcdir)/extN-2.4.18-ino_sb_fix.diff";        \
113           (cd $(top_srcdir) &&                                                \
114             patch -p1) < $(srcdir)/extN-2.4.18-ino_sb_fixup.diff || exit $$?; \
115         fi
116         echo timestamp > $@
117
118 $(extN_SOURCES) $(EXTNI) $(EXTN_EXTRA): patch-stamp
119
120 # Don't distribute any patched files.
121 dist-hook:
122         $(RM) $(top_srcdir)/fs
123         list='$(EXTNC)'; for f in $$list; do $(RM) $(distdir)/$$f; done
124         list='$(EXTNI)'; for i in $$list; do                                  \
125           $(RM) $(distdir)/../include/linux/$$i;                              \
126         done
127         list='$(EXTN_EXTRA)'; for f in $$list; do $(RM) $(distdir)/../$$f; done