Whamcloud - gitweb
Branch b1_6
[fs/lustre-release.git] / lustre / ldiskfs / autoMakefile.am
1 if MODULES
2 if LDISKFS
3 modulefs_DATA = ldiskfs$(KMODEXT)
4 endif
5 endif
6
7 ldiskfs_linux_headers := $(addprefix linux/,$(subst ext3,ldiskfs,$(notdir $(linux_headers))))
8
9 $(filter %.c,$(ldiskfs_patched_sources)): sources $(ldiskfs_linux_headers) $(filter %.h,$(ldiskfs_patched_sources))
10
11 ldiskfs_sed_flags = \
12         -e "s/dx_hash_info/ext3_dx_hash_info/g" \
13         -e "s/dir_private_info/ext3_dir_private_info/g" \
14         -e "s/DX_HASH/EXT3_DX_HASH/g" \
15         -e "s/reserve_window/ext3_reserve_window/g" \
16         -e "s/rsv_window_add/ext3_rsv_window_add/g" \
17         -e "s/EXT3/LDISKFS/g" -e "s/ext3/ldiskfs/g"
18
19 %.c: linux-stage/fs/ext3/%.c
20         sed $(strip $(ldiskfs_sed_flags)) $< > $@
21
22 %.h: linux-stage/fs/ext3/%.h
23         sed $(strip $(ldiskfs_sed_flags)) $< > $@
24
25 linux/ldiskfs%.h: linux-stage/include/linux/ext3%.h
26         sed $(strip $(ldiskfs_sed_flags)) $< > $@
27
28 #
29 # FIXME: we need to grab the series in configure somehow
30 # (see bug 1679)
31 #
32 series := @top_srcdir@/lustre/kernel_patches/series/ldiskfs-$(LDISKFS_SERIES)
33 patches := @top_srcdir@/lustre/kernel_patches/patches
34
35 sources: $(ext3_sources) $(ext3_headers) $(linux_headers) $(series)
36         rm -rf linux-stage linux sources $(ldiskfs_SOURCES)
37         mkdir -p linux-stage/fs/ext3 linux-stage/include/linux
38         cp $(ext3_sources) $(ext3_headers) $(ext3_extra) linux-stage/fs/ext3
39         cp $(linux_headers) linux-stage/include/linux
40 if USE_QUILT
41         ln -s ../$(patches) linux-stage/patches
42         ln -s ../$(series) linux-stage/series
43         cd linux-stage && quilt push -a -q
44 else
45         @echo -n "Applying ext3 patches:"
46         @cd linux-stage && for i in $$(<../$(series)) ; do \
47                 echo -n " $$i" ; \
48                 patch -s -p1 < ../$(patches)/$$i || exit 1 ; \
49         done
50         @echo
51 endif
52         mkdir linux
53         @echo -n "Replacing 'ext3' with 'ldiskfs':"
54         @for i in $(notdir $(ext3_headers) $(ext3_sources)) $(new_sources) ; do \
55                 echo -n " $$i" ; \
56                 sed $(strip $(ldiskfs_sed_flags)) \
57                         linux-stage/fs/ext3/$$i > $$i ; \
58         done
59         @for i in $(subst ext3,,$(notdir $(linux_headers) $(new_headers))) ; do \
60                 echo -n " ext3$$i" ; \
61                 sed $(strip $(ldiskfs_sed_flags)) \
62                         linux-stage/include/linux/ext3$$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) $(ext3_headers) $(ext3_sources) $(new_sources) $(new_headers))
78
79 clean: clean-am
80         rm -rf linux linux-stage