Whamcloud - gitweb
Branch b_release_1_8_1
[fs/lustre-release.git] / ldiskfs / ldiskfs / autoMakefile.am
1 modulefs_DATA = ldiskfs$(KMODEXT)
2
3 ldiskfs_linux_headers := $(addprefix linux/,$(subst @BACKFS@,ldiskfs,$(notdir $(linux_headers))))
4
5 $(filter %.c,$(ldiskfs_patched_sources)): sources $(ldiskfs_linux_headers) $(filter %.h,$(ldiskfs_patched_sources))
6
7 ldiskfs_sed_flags = \
8         -e "s/dx_hash_info/@BACKFS@_dx_hash_info/g" \
9         -e "s/dir_private_info/@BACKFS@_dir_private_info/g" \
10         -e "s/DX_HASH/@BACKFSU@_DX_HASH/g" \
11         -e "s/\<reserve_window/@BACKFS@_reserve_window/g" \
12         -e "s/\<rsv_window_add/@BACKFS@_rsv_window_add/g" \
13         -e "s/@BACKFSU@/LDISKFS/g" -e "s/@BACKFS@/ldiskfs/g"
14
15 %.c: linux-stage/fs/@BACKFS@/%.c
16         sed $(strip $(ldiskfs_sed_flags)) $< > $@
17
18 %.h: linux-stage/fs/@BACKFS@/%.h
19         sed $(strip $(ldiskfs_sed_flags)) $< > $@
20
21 linux/ldiskfs%.h: linux-stage/include/linux/@BACKFS@%.h
22         sed $(strip $(ldiskfs_sed_flags)) $< > $@
23
24 series := @top_srcdir@/kernel_patches/series/ldiskfs-$(LDISKFS_SERIES)
25 patches := @top_srcdir@/kernel_patches/patches
26
27 sources: $(backfs_sources) $(backfs_headers) $(linux_headers) $(series)
28         rm -rf linux-stage linux sources $(ldiskfs_SOURCES)
29         mkdir -p linux-stage/fs/@BACKFS@ linux-stage/include/linux
30         cp $(backfs_sources) $(backfs_headers) $(backfs_extra) linux-stage/fs/@BACKFS@
31         if test -n "$(linux_headers)" ; then \
32                 cp $(linux_headers) linux-stage/include/linux; \
33         fi
34 if USE_QUILT
35         ln -s ../$(patches) linux-stage/patches
36         ln -s ../$(series) linux-stage/series
37         cd linux-stage && quilt push -a -q
38 else
39         @echo -n "Applying @BACKFS@ patches:"
40         @cd linux-stage && for i in $$(<../$(series)) ; do \
41                 echo -n " $$i" ; \
42                 patch -s -p1 < ../$(patches)/$$i || exit 1 ; \
43         done
44         @echo
45 endif
46         mkdir linux
47         @echo -n "Replacing '@BACKFS@' with 'ldiskfs':"
48         for i in $(notdir $(backfs_headers) $(backfs_sources)) $(new_sources) ; do \
49                 echo -n " $$i" ; \
50                 sed $(strip $(ldiskfs_sed_flags)) \
51                         linux-stage/fs/@BACKFS@/$$i > $$i ; \
52         done
53         for i in $(subst @BACKFS@,,$(notdir $(backfs_headers))) ; do \
54                 if test -f "@BACKFS@$$i" ; then \
55                         echo -n " @BACKFS@$$i" ; \
56                         mv @BACKFS@$$i ldiskfs$$i ; \
57                 fi ; \
58         done
59         for i in $(subst @BACKFS@,,$(notdir $(linux_headers) $(new_headers))) ; do \
60                 echo -n " @BACKFS@$$i" ; \
61                 sed $(strip $(ldiskfs_sed_flags)) \
62                         linux-stage/include/linux/@BACKFS@$$i \
63                         > linux/ldiskfs$$i ; \
64         done
65         @echo
66         touch sources
67
68 foo-check:
69         @echo "ldiskfs_sources: $(ldiskfs_sources)"
70         @echo "ldiskfs_SOURCES: $(ldiskfs_SOURCES)"
71         @echo "ldiskfs_headers: $(ldiskfs_headers)"
72         @echo "ldiskfs_objects: $(ldiskfs_objects)"
73         @echo "ldiskfs_OBJECTS: $(ldiskfs_OBJECTS)"
74         @echo "ldiskfs_LDADD: $(ldiskfs_LDADD)"
75
76 MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ 
77 CLEANFILES = sources $(notdir $(linux_headers) $(backfs_headers) $(backfs_sources) $(new_sources) $(new_headers))
78
79 clean: clean-am
80         rm -rf linux linux-stage ldiskfs*.h