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