Whamcloud - gitweb
LU-3963 libcfs: convert md[d/t]/mg[c/s] to linux atomic primitives
[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 ldiskfs_sed_flags = \
18         -e "s/dx_hash_info/ext4_dx_hash_info/g" \
19         -e "s/DX_HASH/EXT4_DX_HASH/g" \
20         -e "s/EXT4/LDISKFS/g" -e "s/ext4/ldiskfs/g"
21
22 %.c: linux-stage/fs/ext4/%.c
23         sed $(strip $(ldiskfs_sed_flags)) $< > $@
24
25 %.h: linux-stage/fs/ext4/%.h
26         sed $(strip $(ldiskfs_sed_flags)) $< > $@
27
28 linux/ldiskfs%.h: linux-stage/include/linux/ext4%.h
29         sed $(strip $(ldiskfs_sed_flags)) $< > $@
30
31 series := @top_srcdir@/ldiskfs/kernel_patches/series/ldiskfs-$(LDISKFS_SERIES)
32 patches := @top_srcdir@/ldiskfs/kernel_patches/patches
33
34 sources: $(backfs_sources) $(backfs_headers) $(linux_headers) $(series) $(trace_headers)
35         rm -rf linux-stage linux sources trace $(ldiskfs_SOURCES)
36         mkdir -p linux-stage/fs/ext4 linux-stage/include/linux \
37                  linux-stage/include/trace/events
38         cp $(backfs_sources) $(backfs_headers) $(backfs_extra) linux-stage/fs/ext4
39         if test -n "$(linux_headers)" ; then \
40                 cp $(linux_headers) linux-stage/include/linux; \
41         fi
42         if test -n "$(trace_headers)" ; then \
43                 cp $(trace_headers) linux-stage/include/trace/events; \
44         fi
45 if USE_QUILT
46         ln -s ../$(patches) linux-stage/patches
47         ln -s ../$(series) linux-stage/series
48         cd linux-stage && quilt push -a -q
49 else
50         @echo -n "Applying ext4 patches:"
51         @cd linux-stage && for i in $$(<../$(series)) ; do \
52                 echo -n " $$i" ; \
53                 patch -s -p1 < ../$(patches)/$$i || exit 1 ; \
54         done
55         @echo
56 endif
57         mkdir -p linux trace/events
58         @echo -n "Replacing 'ext4' with 'ldiskfs':"
59         for i in $(notdir $(backfs_headers) $(backfs_sources)) $(new_sources) ; do \
60                 echo -n " $$i" ; \
61                 sed $(strip $(ldiskfs_sed_flags)) \
62                         linux-stage/fs/ext4/$$i > $$i ; \
63         done
64         for i in $(subst ext4,,$(notdir $(backfs_headers))) ; do \
65                 if test -f "ext4$$i" ; then \
66                         echo -n " ext4$$i" ; \
67                         mv ext4$$i ldiskfs$$i ; \
68                 fi ; \
69         done
70         for i in $(subst ext4,,$(notdir $(linux_headers) $(new_headers))) ; do \
71                 echo -n " ext4$$i" ; \
72                 sed $(strip $(ldiskfs_sed_flags)) \
73                         linux-stage/include/linux/ext4$$i \
74                         > linux/ldiskfs$$i ; \
75         done
76         for i in $(subst ext4,,$(notdir $(trace_headers))) ; do \
77                 echo -n " ext4$$i"; \
78                 sed $(strip $(ldiskfs_sed_flags)) \
79                         linux-stage/include/trace/events/ext4$$i \
80                         > trace/events/ldiskfs$$i ; \
81         done
82         for i in $(notdir $(linux_new_headers)) ; do \
83                 echo -n " $$i"; \
84                 sed $(strip $(ldiskfs_sed_flags)) \
85                 linux-stage/include/linux/$$i \
86                 > linux/$$i ; \
87         done
88
89         @echo
90         touch sources
91
92 foo-check:
93         @echo "ldiskfs_sources: $(ldiskfs_sources)"
94         @echo "ldiskfs_SOURCES: $(ldiskfs_SOURCES)"
95         @echo "ldiskfs_headers: $(ldiskfs_headers)"
96         @echo "ldiskfs_objects: $(ldiskfs_objects)"
97         @echo "ldiskfs_OBJECTS: $(ldiskfs_OBJECTS)"
98         @echo "ldiskfs_LDADD: $(ldiskfs_LDADD)"
99
100 MOSTLYCLEANFILES := @MOSTLYCLEANFILES@
101 CLEANFILES = sources $(notdir $(linux_new_headers) $(linux_headers) $(backfs_headers) $(backfs_sources) $(new_sources) $(new_headers) $(trace_headers))
102
103 clean-local:
104         rm -rf linux linux-stage ldiskfs*.h trace modules.order