Whamcloud - gitweb
LU-1199 build: Assume that ldiskfs PDO is now standard
[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@/config.h
71
72 obj-m := ldiskfs.o
73 ldiskfs-objs := $(ldiskfs_obj)
74
75 modules: sources
76         $(MAKE) -C @LINUX_OBJ@ M=$(shell pwd) $@
77
78 clean:
79         $(MAKE) -C @LINUX_OBJ@ M=$(shell pwd) $@
80         if [ -f @LINUX_SYMBOLS@ ]; then $(RM) @LINUX_SYMBOLS@; fi
81         if [ -f Module.markers ]; then $(RM) Module.markers; fi
82
83 modules_install:
84         @# Install the kernel modules
85         $(MAKE) -C @LINUX_OBJ@ M=$(shell pwd) \
86                 INSTALL_MOD_PATH=$(DESTDIR) \
87                 INSTALL_MOD_DIR=updates/kernel/fs/lustre-ldiskfs $@
88         @# Remove extraneous build products when packaging
89         if [ -n "$(DESTDIR)" ]; then \
90                 find $(DESTDIR)/lib/modules/@LINUX_VERSION@ \
91                         -name 'modules.*' | xargs $(RM); \
92         fi
93         sysmap=$(DESTDIR)/boot/System.map-@LINUX_VERSION@; \
94         if [ -f $$sysmap ]; then \
95                 depmod -ae -F $$sysmap @LINUX_VERSION@; \
96         fi
97
98 ################################################
99 # Patched ldiskfs Sources Build Infrastructure #
100 ################################################
101
102 sources: $(backfs_sources) $(backfs_headers) $(linux_headers) $(series) $(trace_headers)
103         rm -rf linux-stage linux sources trace $(ldiskfs_SOURCES)
104         mkdir -p linux-stage/fs/ext4 linux-stage/include/linux \
105                  linux-stage/include/trace/events
106         cp $(backfs_sources) $(backfs_headers) $(backfs_extra) linux-stage/fs/ext4
107         if test -n "$(linux_headers)" ; then \
108                 cp $(linux_headers) linux-stage/include/linux; \
109         fi
110         if test -n "$(trace_headers)" ; then \
111                 cp $(trace_headers) linux-stage/include/trace/events; \
112         fi
113
114 @USE_QUILT_TRUE@        ln -s ../$(patches) linux-stage/patches
115 @USE_QUILT_TRUE@        ln -s ../$(series) linux-stage/series
116 @USE_QUILT_TRUE@        cd linux-stage && quilt push -a -q
117
118 @USE_QUILT_FALSE@       @echo -n "Applying ext4 patches:"
119 @USE_QUILT_FALSE@       @cd linux-stage && for i in $$(<../$(series)) ; do \
120 @USE_QUILT_FALSE@               echo -n " $$i" ; \
121 @USE_QUILT_FALSE@               patch -s -p1 < ../$(patches)/$$i || exit 1 ; \
122 @USE_QUILT_FALSE@       done
123 @USE_QUILT_FALSE@       @echo
124
125         mkdir -p linux trace/events
126         @echo -n "Replacing 'ext4' with 'ldiskfs':"
127         for i in $(notdir $(backfs_headers) $(backfs_sources)) $(new_sources) ; do \
128                 echo -n " $$i" ; \
129                 sed $(strip $(ldiskfs_sed_flags)) \
130                         linux-stage/fs/ext4/$$i > $$i ; \
131         done
132         for i in $(subst ext4,,$(notdir $(backfs_headers))) ; do \
133                 if test -f "ext4$$i" ; then \
134                         echo -n " ext4$$i" ; \
135                         mv ext4$$i ldiskfs$$i ; \
136                 fi ; \
137         done
138         for i in $(subst ext4,,$(notdir $(linux_headers) $(new_headers))) ; do \
139                 echo -n " ext4$$i" ; \
140                 sed $(strip $(ldiskfs_sed_flags)) \
141                         linux-stage/include/linux/ext4$$i \
142                         > linux/ldiskfs$$i ; \
143         done
144         for i in $(subst ext4,,$(notdir $(trace_headers))) ; do \
145                 echo -n " ext4$$i"; \
146                 sed $(strip $(ldiskfs_sed_flags)) \
147                         linux-stage/include/trace/events/ext4$$i \
148                         > trace/events/ldiskfs$$i ; \
149         done
150         for i in $(notdir $(linux_new_headers)) ; do \
151                 echo -n " $$i"; \
152                 sed $(strip $(ldiskfs_sed_flags)) \
153                 linux-stage/include/linux/$$i \
154                 > linux/$$i ; \
155         done
156
157         @echo
158         touch sources
159
160 foo-check:
161         @echo "ldiskfs_sources: $(ldiskfs_sources)"
162         @echo "ldiskfs_SOURCES: $(ldiskfs_SOURCES)"
163         @echo "ldiskfs_headers: $(ldiskfs_headers)"
164         @echo "ldiskfs_objects: $(ldiskfs_objects)"
165         @echo "ldiskfs_OBJECTS: $(ldiskfs_OBJECTS)"
166         @echo "ldiskfs_LDADD: $(ldiskfs_LDADD)"
167
168 MOSTLYCLEANFILES := @MOSTLYCLEANFILES@
169 CLEANFILES = sources $(notdir $(linux_new_headers) $(linux_headers) $(backfs_headers) $(backfs_sources) $(new_sources) $(new_headers) $(trace_headers))
170
171 #--- autoMakefile cut-and-paste end