all: modules install: modules_install distdir: # copy makefile over to not break patches backfs_extra := $(wildcard @LINUX@/fs/ext4/Makefile) backfs_headers := $(wildcard @EXT_DIR@/*.h) linux_headers := $(wildcard @LINUX@/include/linux/ext4*.h) linux_new_headers := dynlocks.h linux_new_headers += htree_lock.h trace_headers := $(wildcard @LINUX@/include/trace/events/ext4*.h) backfs_sources := $(filter-out %.mod.c,$(wildcard @EXT_DIR@/*.c)) ext3_new_sources := extents.c mballoc.c group.h dynlocks.c fiemap.h ext3_new_headers := ext3_extents.h ext4_new_sources := dynlocks.c fiemap.h mmp.c ext4_new_sources += htree_lock.c ext4_new_headers := new_sources := $(ext4_new_sources) new_headers := $(ext4_new_headers) ldiskfs_patched_sources := $(notdir $(backfs_sources) $(backfs_headers)) $(new_sources) $(new_headers) ldiskfs_sources := $(ldiskfs_patched_sources) ldiskfs_obj := $(filter %.o,$(ldiskfs_sources:.c=.o)) #--- autoMakefile cut-and-paste start ldiskfs_linux_headers := $(addprefix linux/,$(subst ext4,ldiskfs,$(notdir $(linux_headers)))) $(filter %.c,$(ldiskfs_patched_sources)): sources $(ldiskfs_linux_headers) $(filter %.h,$(ldiskfs_patched_sources)) ldiskfs_sed_flags = \ -e "s/dx_hash_info/ext4_dx_hash_info/g" \ -e "s/DX_HASH/EXT4_DX_HASH/g" \ -e "s/EXT4/LDISKFS/g" -e "s/ext4/ldiskfs/g" %.c: linux-stage/fs/ext4/%.c sed $(strip $(ldiskfs_sed_flags)) $< > $@ %.h: linux-stage/fs/ext4/%.h sed $(strip $(ldiskfs_sed_flags)) $< > $@ linux/ldiskfs%.h: linux-stage/include/linux/ext4%.h sed $(strip $(ldiskfs_sed_flags)) $< > $@ series := @top_srcdir@/kernel_patches/series/ldiskfs-@LDISKFS_SERIES@ patches := @top_srcdir@/kernel_patches/patches #install-data-local: sources # destname=@LDISKFS_META_NAME@-@LDISKFS_META_VERSION@/@LINUX_VERSION@; \ # instdest=$(DESTDIR)/usr/src/$$destname; \ # instfiles=$$(find . -name '*.h' | grep -v linux-stage); \ # for instfile in $$instfiles; do \ # if [ "$$(dirname $$instfile)" = "." ]; then \ # /usr/bin/install -c -D $$instfile $$instdest/ldiskfs/$$instfile; \ # else \ # /usr/bin/install -c -D $$instfile $$instdest/$$instfile; \ # fi \ # done ############################### # Kernel Build Infrastructure # ############################### EXTRA_CFLAGS += -I@LINUX@/fs -I@LDISKFSDIR@ EXTRA_CFLAGS += -include @abs_top_builddir@/ldiskfs/ldiskfs_config.h EXTRA_CFLAGS += -include @abs_top_builddir@/config.h obj-m := ldiskfs.o ldiskfs-objs := $(ldiskfs_obj) modules: sources $(MAKE) -C @LINUX_OBJ@ M=$(shell pwd) $@ clean: $(MAKE) -C @LINUX_OBJ@ M=$(shell pwd) $@ if [ -f Module.markers ]; then $(RM) Module.markers; fi distclean: -rm -f Makefile maintainer-clean: -rm -f Makefile modules_install: @# Install the kernel modules $(MAKE) -C @LINUX_OBJ@ M=$(shell pwd) \ INSTALL_MOD_PATH=$(DESTDIR) \ INSTALL_MOD_DIR=updates/kernel/fs/lustre-ldiskfs $@ @# Remove extraneous build products when packaging if [ -n "$(DESTDIR)" ]; then \ find $(DESTDIR)/lib/modules/@LINUX_VERSION@ \ -name 'modules.*' | xargs $(RM); \ fi sysmap=$(DESTDIR)/boot/System.map-@LINUX_VERSION@; \ if [ -f $$sysmap ]; then \ depmod -ae -F $$sysmap @LINUX_VERSION@; \ fi ################################################ # Patched ldiskfs Sources Build Infrastructure # ################################################ sources: $(backfs_sources) $(backfs_headers) $(linux_headers) $(series) $(trace_headers) rm -rf linux-stage linux sources trace $(ldiskfs_SOURCES) mkdir -p linux-stage/fs/ext4 linux-stage/include/linux \ linux-stage/include/trace/events cp $(backfs_sources) $(backfs_headers) $(backfs_extra) linux-stage/fs/ext4 if test -n "$(linux_headers)" ; then \ cp $(linux_headers) linux-stage/include/linux; \ fi if test -n "$(trace_headers)" ; then \ cp $(trace_headers) linux-stage/include/trace/events; \ fi @USE_QUILT_TRUE@ ln -s ../$(patches) linux-stage/patches @USE_QUILT_TRUE@ ln -s ../$(series) linux-stage/series @USE_QUILT_TRUE@ cd linux-stage && quilt push -a -q @USE_QUILT_FALSE@ @echo -n "Applying ext4 patches:" @USE_QUILT_FALSE@ @cd linux-stage && for i in $$(<../$(series)) ; do \ @USE_QUILT_FALSE@ echo -n " $$i" ; \ @USE_QUILT_FALSE@ patch -s -p1 < ../$(patches)/$$i || exit 1 ; \ @USE_QUILT_FALSE@ done @USE_QUILT_FALSE@ @echo mkdir -p linux trace/events @echo -n "Replacing 'ext4' with 'ldiskfs':" for i in $(notdir $(backfs_headers) $(backfs_sources)) $(new_sources) ; do \ echo -n " $$i" ; \ sed $(strip $(ldiskfs_sed_flags)) \ linux-stage/fs/ext4/$$i > $$i ; \ done for i in $(subst ext4,,$(notdir $(backfs_headers))) ; do \ if test -f "ext4$$i" ; then \ echo -n " ext4$$i" ; \ mv ext4$$i ldiskfs$$i ; \ fi ; \ done for i in $(subst ext4,,$(notdir $(linux_headers) $(new_headers))) ; do \ echo -n " ext4$$i" ; \ sed $(strip $(ldiskfs_sed_flags)) \ linux-stage/include/linux/ext4$$i \ > linux/ldiskfs$$i ; \ done for i in $(subst ext4,,$(notdir $(trace_headers))) ; do \ echo -n " ext4$$i"; \ sed $(strip $(ldiskfs_sed_flags)) \ linux-stage/include/trace/events/ext4$$i \ > trace/events/ldiskfs$$i ; \ done for i in $(notdir $(linux_new_headers)) ; do \ echo -n " $$i"; \ sed $(strip $(ldiskfs_sed_flags)) \ linux-stage/include/linux/$$i \ > linux/$$i ; \ done @echo touch sources foo-check: @echo "ldiskfs_sources: $(ldiskfs_sources)" @echo "ldiskfs_SOURCES: $(ldiskfs_SOURCES)" @echo "ldiskfs_headers: $(ldiskfs_headers)" @echo "ldiskfs_objects: $(ldiskfs_objects)" @echo "ldiskfs_OBJECTS: $(ldiskfs_OBJECTS)" @echo "ldiskfs_LDADD: $(ldiskfs_LDADD)" MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ CLEANFILES = sources $(notdir $(linux_new_headers) $(linux_headers) $(backfs_headers) $(backfs_sources) $(new_sources) $(new_headers) $(trace_headers)) #--- autoMakefile cut-and-paste end