Whamcloud - gitweb
LU-17948 llite: replace i_mtime.tv_sec with inode_get_mtime_sec()
[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 := \
14     $(addprefix linux/,$(subst ext4,ldiskfs,$(notdir $(linux_headers)))) \
15     $(addprefix uapi/linux/,$(subst ext4,ldiskfs,$(notdir $(uapi_linux_headers))))
16
17 $(filter %.c,$(ldiskfs_patched_sources)): \
18     sources $(ldiskfs_linux_headers) $(filter %.h,$(ldiskfs_patched_sources))
19
20 # Convert LDISKFS_SUPER_MAGIC back to EXT4_SUPER_MAGIC so that the ldiskfs
21 # code can use the existing kernel headers instead of defining this itself.
22 ldiskfs_sed_flags = \
23         -e "s/dx_hash_info/ext4_dx_hash_info/g" \
24         -e "s/DX_HASH/EXT4_DX_HASH/g" \
25         -e "s/EXT4/LDISKFS/g" -e "s/ext4/ldiskfs/g" \
26         -e "s/LDISKFS_SUPER_MAGIC/EXT4_SUPER_MAGIC/g"
27
28 %.c: linux-stage/fs/ext4/%.c
29         sed $(strip $(ldiskfs_sed_flags)) $< > $@
30
31 %.h: linux-stage/fs/ext4/%.h
32         sed $(strip $(ldiskfs_sed_flags)) $< > $@
33
34 linux/ldiskfs%.h: linux-stage/include/linux/ext4%.h
35         @echo sed $(strip $(ldiskfs_sed_flags)) $< '=>' $@
36         sed $(strip $(ldiskfs_sed_flags)) $< > $@
37
38 uapi/linux/ldiskfs%.h: linux-stage/include/uapi/linux/ext4%.h
39         @echo sed $(strip $(ldiskfs_sed_flags)) $< '=>' $@
40         sed $(strip $(ldiskfs_sed_flags)) $< > $@
41
42 series := @top_srcdir@/ldiskfs/kernel_patches/series/ldiskfs-$(LDISKFS_SERIES)
43 patches := @top_srcdir@/ldiskfs/kernel_patches/patches
44
45 sources: $(backfs_sources) $(backfs_headers) $(linux_headers) $(uapi_linux_headers) $(series) $(trace_headers)
46         rm -rf linux-stage uapi linux sources trace $(ldiskfs_SOURCES)
47         mkdir -p linux-stage/fs/ext4 linux-stage/include/linux \
48                  linux-stage/include/uapi/linux \
49                  linux-stage/include/trace/events
50         cp $(backfs_sources) $(backfs_headers) $(backfs_extra) linux-stage/fs/ext4
51         if test -n "$(linux_headers)" ; then \
52                 cp $(linux_headers) linux-stage/include/linux; \
53         fi
54         if test -n "$(uapi_linux_headers)" ; then \
55                 cp $(uapi_linux_headers) linux-stage/include/uapi/linux; \
56         fi
57         if test -n "$(trace_headers)" ; then \
58                 cp $(trace_headers) linux-stage/include/trace/events; \
59         fi
60 if USE_QUILT
61         ln -s ../$(patches) linux-stage/patches
62         ln -s ../$(series) linux-stage/series
63         cd linux-stage && quilt push -a -q
64 else
65         @echo -n "Applying ext4 patches:"
66         @cd linux-stage && for i in $$(<../$(series)) ; do \
67                 echo -n " $$i" ; \
68                 patch -s -p1 < ../$(patches)/$$i || exit 1 ; \
69         done
70         @echo
71 endif
72         mkdir -p uapi/linux linux trace/events
73         @echo -n "Replacing 'ext4' with 'ldiskfs':"
74         for i in $(notdir $(backfs_headers) $(backfs_sources)) $(new_sources) ; do \
75                 [ -f linux-stage/fs/ext4/$$i ] || continue; \
76                 echo -n " $$i" ; \
77                 sed $(strip $(ldiskfs_sed_flags)) \
78                         linux-stage/fs/ext4/$$i > $$i ; \
79         done
80         for i in $(subst ext4,,$(notdir $(backfs_headers))) ; do \
81                 if test -f "ext4$$i" ; then \
82                         echo -n " ext4$$i" ; \
83                         mv ext4$$i ldiskfs$$i ; \
84                 fi ; \
85         done
86         for i in $(subst ext4,,$(notdir $(uapi_linux_headers))) ; do \
87                 echo -n " ext4$$i" ; \
88                 sed $(strip $(ldiskfs_sed_flags)) \
89                         linux-stage/include/uapi/linux/ext4$$i \
90                         > uapi/linux/ldiskfs$$i ; \
91         done
92         for i in $(subst ext4,,$(notdir $(linux_headers) $(new_headers))) ; do \
93                 echo -n " ext4$$i" ; \
94                 sed $(strip $(ldiskfs_sed_flags)) \
95                         linux-stage/include/linux/ext4$$i \
96                         > linux/ldiskfs$$i ; \
97         done
98         for i in $(subst ext4,,$(notdir $(trace_headers))) ; do \
99                 echo -n " ext4$$i"; \
100                 sed $(strip $(ldiskfs_sed_flags)) \
101                         linux-stage/include/trace/events/ext4$$i \
102                         > trace/events/ldiskfs$$i ; \
103         done
104         for i in $(notdir $(linux_new_headers)) ; do \
105                 echo -n " $$i"; \
106                 sed $(strip $(ldiskfs_sed_flags)) \
107                         linux-stage/include/linux/$$i \
108                 > linux/$$i ; \
109         done
110         @echo
111         touch sources
112
113 foo-check:
114         @echo "ldiskfs_sources: $(ldiskfs_sources)"
115         @echo "ldiskfs_SOURCES: $(ldiskfs_SOURCES)"
116         @echo "ldiskfs_headers: $(ldiskfs_headers)"
117         @echo "ldiskfs_objects: $(ldiskfs_objects)"
118         @echo "ldiskfs_OBJECTS: $(ldiskfs_OBJECTS)"
119         @echo "ldiskfs_LDADD: $(ldiskfs_LDADD)"
120
121 MOSTLYCLEANFILES := @MOSTLYCLEANFILES@
122 CLEANFILES = sources $(notdir $(linux_new_headers) $(linux_headers) $(backfs_headers) $(backfs_sources) $(new_sources) $(new_headers) $(trace_headers))
123
124 clean-local:
125         rm -rf linux linux-stage ldiskfs*.h trace modules.order