Whamcloud - gitweb
6cdc071280046a1d275870fd8329d999639bec08
[fs/lustre-release.git] / ldiskfs / ldiskfs / Makefile.in
1 all: modules
2 install: modules_install
3 distdir:
4
5 # copy makefile over to not break patches
6 backfs_extra := $(wildcard @LINUX@/fs/ext4/Makefile)
7
8 backfs_headers := $(wildcard @EXT_DIR@/*.h)
9 linux_headers := $(wildcard @LINUX@/include/linux/ext4*.h)
10 linux_new_headers := dynlocks.h
11 linux_new_headers += htree_lock.h
12 trace_headers := $(wildcard @LINUX@/include/trace/events/ext4*.h)
13
14 backfs_sources := $(filter-out %.mod.c,$(wildcard @EXT_DIR@/*.c))
15
16 ext3_new_sources := extents.c mballoc.c group.h dynlocks.c fiemap.h
17 ext3_new_headers := ext3_extents.h
18
19 ext4_new_sources := dynlocks.c fiemap.h mmp.c
20 ext4_new_sources += htree_lock.c
21 ext4_new_headers :=
22
23 new_sources := $(ext4_new_sources)
24 new_headers := $(ext4_new_headers)
25
26 ldiskfs_patched_sources := $(notdir $(backfs_sources) $(backfs_headers)) $(new_sources) $(new_headers)
27 ldiskfs_sources := $(ldiskfs_patched_sources)
28 ldiskfs_obj := $(filter %.o,$(ldiskfs_sources:.c=.o))
29
30 #--- autoMakefile cut-and-paste start
31
32 ldiskfs_linux_headers := $(addprefix linux/,$(subst ext4,ldiskfs,$(notdir $(linux_headers))))
33
34 $(filter %.c,$(ldiskfs_patched_sources)): sources $(ldiskfs_linux_headers) $(filter %.h,$(ldiskfs_patched_sources))
35
36 ldiskfs_sed_flags = \
37         -e "s/dx_hash_info/ext4_dx_hash_info/g" \
38         -e "s/DX_HASH/EXT4_DX_HASH/g" \
39         -e "s/EXT4/LDISKFS/g" -e "s/ext4/ldiskfs/g"
40
41 %.c: linux-stage/fs/ext4/%.c
42         sed $(strip $(ldiskfs_sed_flags)) $< > $@
43
44 %.h: linux-stage/fs/ext4/%.h
45         sed $(strip $(ldiskfs_sed_flags)) $< > $@
46
47 linux/ldiskfs%.h: linux-stage/include/linux/ext4%.h
48         sed $(strip $(ldiskfs_sed_flags)) $< > $@
49
50 series := @top_srcdir@/kernel_patches/series/ldiskfs-@LDISKFS_SERIES@
51 patches := @top_srcdir@/kernel_patches/patches
52
53 #install-data-local: sources
54 #       destname=@LDISKFS_META_NAME@-@LDISKFS_META_VERSION@/@LINUX_VERSION@; \
55 #       instdest=$(DESTDIR)/usr/src/$$destname; \
56 #       instfiles=$$(find . -name '*.h' | grep -v linux-stage); \
57 #       for instfile in $$instfiles; do \
58 #               if [ "$$(dirname $$instfile)" = "." ]; then \
59 #                       /usr/bin/install -c -D $$instfile $$instdest/ldiskfs/$$instfile; \
60 #               else \
61 #                       /usr/bin/install -c -D $$instfile $$instdest/$$instfile; \
62 #               fi \
63 #       done
64
65 ###############################
66 # Kernel Build Infrastructure #
67 ###############################
68
69 EXTRA_CFLAGS += -I@LINUX@/fs -I@LDISKFSDIR@
70 EXTRA_CFLAGS += -include @abs_top_builddir@/ldiskfs/ldiskfs_config.h
71 EXTRA_CFLAGS += -include @abs_top_builddir@/config.h
72
73 obj-m := ldiskfs.o
74 ldiskfs-objs := $(ldiskfs_obj)
75
76 modules: sources
77         $(MAKE) -C @LINUX_OBJ@ M=$(shell pwd) $@
78
79 clean:
80         $(MAKE) -C @LINUX_OBJ@ M=$(shell pwd) $@
81         if [ -f @LINUX_SYMBOLS@ ]; then $(RM) @LINUX_SYMBOLS@; fi
82         if [ -f Module.markers ]; then $(RM) Module.markers; fi
83
84 modules_install:
85         @# Install the kernel modules
86         $(MAKE) -C @LINUX_OBJ@ M=$(shell pwd) \
87                 INSTALL_MOD_PATH=$(DESTDIR) \
88                 INSTALL_MOD_DIR=updates/kernel/fs/lustre-ldiskfs $@
89         @# Remove extraneous build products when packaging
90         if [ -n "$(DESTDIR)" ]; then \
91                 find $(DESTDIR)/lib/modules/@LINUX_VERSION@ \
92                         -name 'modules.*' | xargs $(RM); \
93         fi
94         sysmap=$(DESTDIR)/boot/System.map-@LINUX_VERSION@; \
95         if [ -f $$sysmap ]; then \
96                 depmod -ae -F $$sysmap @LINUX_VERSION@; \
97         fi
98
99 ################################################
100 # Patched ldiskfs Sources Build Infrastructure #
101 ################################################
102
103 sources: $(backfs_sources) $(backfs_headers) $(linux_headers) $(series) $(trace_headers)
104         rm -rf linux-stage linux sources trace $(ldiskfs_SOURCES)
105         mkdir -p linux-stage/fs/ext4 linux-stage/include/linux \
106                  linux-stage/include/trace/events
107         cp $(backfs_sources) $(backfs_headers) $(backfs_extra) linux-stage/fs/ext4
108         if test -n "$(linux_headers)" ; then \
109                 cp $(linux_headers) linux-stage/include/linux; \
110         fi
111         if test -n "$(trace_headers)" ; then \
112                 cp $(trace_headers) linux-stage/include/trace/events; \
113         fi
114
115 @USE_QUILT_TRUE@        ln -s ../$(patches) linux-stage/patches
116 @USE_QUILT_TRUE@        ln -s ../$(series) linux-stage/series
117 @USE_QUILT_TRUE@        cd linux-stage && quilt push -a -q
118
119 @USE_QUILT_FALSE@       @echo -n "Applying ext4 patches:"
120 @USE_QUILT_FALSE@       @cd linux-stage && for i in $$(<../$(series)) ; do \
121 @USE_QUILT_FALSE@               echo -n " $$i" ; \
122 @USE_QUILT_FALSE@               patch -s -p1 < ../$(patches)/$$i || exit 1 ; \
123 @USE_QUILT_FALSE@       done
124 @USE_QUILT_FALSE@       @echo
125
126         mkdir -p linux trace/events
127         @echo -n "Replacing 'ext4' with 'ldiskfs':"
128         for i in $(notdir $(backfs_headers) $(backfs_sources)) $(new_sources) ; do \
129                 echo -n " $$i" ; \
130                 sed $(strip $(ldiskfs_sed_flags)) \
131                         linux-stage/fs/ext4/$$i > $$i ; \
132         done
133         for i in $(subst ext4,,$(notdir $(backfs_headers))) ; do \
134                 if test -f "ext4$$i" ; then \
135                         echo -n " ext4$$i" ; \
136                         mv ext4$$i ldiskfs$$i ; \
137                 fi ; \
138         done
139         for i in $(subst ext4,,$(notdir $(linux_headers) $(new_headers))) ; do \
140                 echo -n " ext4$$i" ; \
141                 sed $(strip $(ldiskfs_sed_flags)) \
142                         linux-stage/include/linux/ext4$$i \
143                         > linux/ldiskfs$$i ; \
144         done
145         for i in $(subst ext4,,$(notdir $(trace_headers))) ; do \
146                 echo -n " ext4$$i"; \
147                 sed $(strip $(ldiskfs_sed_flags)) \
148                         linux-stage/include/trace/events/ext4$$i \
149                         > trace/events/ldiskfs$$i ; \
150         done
151         for i in $(notdir $(linux_new_headers)) ; do \
152                 echo -n " $$i"; \
153                 sed $(strip $(ldiskfs_sed_flags)) \
154                 linux-stage/include/linux/$$i \
155                 > linux/$$i ; \
156         done
157
158         @echo
159         touch sources
160
161 foo-check:
162         @echo "ldiskfs_sources: $(ldiskfs_sources)"
163         @echo "ldiskfs_SOURCES: $(ldiskfs_SOURCES)"
164         @echo "ldiskfs_headers: $(ldiskfs_headers)"
165         @echo "ldiskfs_objects: $(ldiskfs_objects)"
166         @echo "ldiskfs_OBJECTS: $(ldiskfs_OBJECTS)"
167         @echo "ldiskfs_LDADD: $(ldiskfs_LDADD)"
168
169 MOSTLYCLEANFILES := @MOSTLYCLEANFILES@
170 CLEANFILES = sources $(notdir $(linux_new_headers) $(linux_headers) $(backfs_headers) $(backfs_sources) $(new_sources) $(new_headers) $(trace_headers))
171
172 #--- autoMakefile cut-and-paste end