Whamcloud - gitweb
LU-9339 ldiskfs: Make ldiskfs buildable on kernels with no project quota
[fs/lustre-release.git] / ldiskfs / autoMakefile.am
1 EXTRA_DIST = kernel_patches
2
3 if MODULES
4 if LDISKFS_ENABLED
5 all-local: sources
6
7 modulefs_DATA = ldiskfs$(KMODEXT)
8
9 ldiskfs$(KMODEXT): sources
10 endif
11 endif
12
13 ldiskfs_linux_headers := $(addprefix linux/,$(subst ext4,ldiskfs,$(notdir $(linux_headers))))
14
15 $(filter %.c,$(ldiskfs_patched_sources)): sources $(ldiskfs_linux_headers) $(filter %.h,$(ldiskfs_patched_sources))
16
17 # Convert LDISKFS_SUPER_MAGIC back to EXT4_SUPER_MAGIC so that the ldiskfs
18 # code can use the existing kernel headers instead of defining this itself.
19 ldiskfs_sed_flags = \
20         -e "s/dx_hash_info/ext4_dx_hash_info/g" \
21         -e "s/DX_HASH/EXT4_DX_HASH/g" \
22         -e "s/EXT4/LDISKFS/g" -e "s/ext4/ldiskfs/g" \
23         -e "s/LDISKFS_SUPER_MAGIC/EXT4_SUPER_MAGIC/g"
24
25 %.c: linux-stage/fs/ext4/%.c
26         sed $(strip $(ldiskfs_sed_flags)) $< > $@
27
28 %.h: linux-stage/fs/ext4/%.h
29         sed $(strip $(ldiskfs_sed_flags)) $< > $@
30
31 linux/ldiskfs%.h: linux-stage/include/linux/ext4%.h
32         sed $(strip $(ldiskfs_sed_flags)) $< > $@
33
34 series := @top_srcdir@/ldiskfs/kernel_patches/series/ldiskfs-$(LDISKFS_SERIES)
35 patches := @top_srcdir@/ldiskfs/kernel_patches/patches
36
37 sources: $(backfs_sources) $(backfs_headers) $(linux_headers) $(series) $(trace_headers)
38         rm -rf linux-stage linux sources trace $(ldiskfs_SOURCES)
39         mkdir -p linux-stage/fs/ext4 linux-stage/include/linux \
40                  linux-stage/include/trace/events
41         cp $(backfs_sources) $(backfs_headers) $(backfs_extra) linux-stage/fs/ext4
42         if test -n "$(linux_headers)" ; then \
43                 cp $(linux_headers) linux-stage/include/linux; \
44         fi
45         if test -n "$(trace_headers)" ; then \
46                 cp $(trace_headers) linux-stage/include/trace/events; \
47         fi
48 if USE_QUILT
49         ln -s ../$(patches) linux-stage/patches
50         ln -s ../$(series) linux-stage/series
51         cd linux-stage && quilt push -a -q
52 else
53         @echo -n "Applying ext4 patches:"
54         @cd linux-stage && for i in $$(<../$(series)) ; do \
55                 echo -n " $$i" ; \
56                 patch -s -p1 < ../$(patches)/$$i || exit 1 ; \
57         done
58         @echo
59 endif
60         mkdir -p linux trace/events
61         @echo -n "Replacing 'ext4' with 'ldiskfs':"
62         for i in $(notdir $(backfs_headers) $(backfs_sources)) $(new_sources) ; do \
63                 echo -n " $$i" ; \
64                 sed $(strip $(ldiskfs_sed_flags)) \
65                         linux-stage/fs/ext4/$$i > $$i ; \
66         done
67         for i in $(subst ext4,,$(notdir $(backfs_headers))) ; do \
68                 if test -f "ext4$$i" ; then \
69                         echo -n " ext4$$i" ; \
70                         mv ext4$$i ldiskfs$$i ; \
71                 fi ; \
72         done
73         for i in $(subst ext4,,$(notdir $(linux_headers) $(new_headers))) ; do \
74                 echo -n " ext4$$i" ; \
75                 sed $(strip $(ldiskfs_sed_flags)) \
76                         linux-stage/include/linux/ext4$$i \
77                         > linux/ldiskfs$$i ; \
78         done
79         for i in $(subst ext4,,$(notdir $(trace_headers))) ; do \
80                 echo -n " ext4$$i"; \
81                 sed $(strip $(ldiskfs_sed_flags)) \
82                         linux-stage/include/trace/events/ext4$$i \
83                         > trace/events/ldiskfs$$i ; \
84         done
85         for i in $(notdir $(linux_new_headers)) ; do \
86                 echo -n " $$i"; \
87                 sed $(strip $(ldiskfs_sed_flags)) \
88                 linux-stage/include/linux/$$i \
89                 > linux/$$i ; \
90         done
91
92         @echo
93         touch sources
94
95 foo-check:
96         @echo "ldiskfs_sources: $(ldiskfs_sources)"
97         @echo "ldiskfs_SOURCES: $(ldiskfs_SOURCES)"
98         @echo "ldiskfs_headers: $(ldiskfs_headers)"
99         @echo "ldiskfs_objects: $(ldiskfs_objects)"
100         @echo "ldiskfs_OBJECTS: $(ldiskfs_OBJECTS)"
101         @echo "ldiskfs_LDADD: $(ldiskfs_LDADD)"
102
103 MOSTLYCLEANFILES := @MOSTLYCLEANFILES@
104 CLEANFILES = sources $(notdir $(linux_new_headers) $(linux_headers) $(backfs_headers) $(backfs_sources) $(new_sources) $(new_headers) $(trace_headers))
105
106 clean-local:
107         rm -rf linux linux-stage ldiskfs*.h trace modules.order