1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
|
# Makefile for the NT filesystem kernel part
#
# Copyright (C) 1997 Rgis Duchesne
#
# Note : Do 'make clean_makespace' each time you modify this Makefile.
# Files
# Sources that go into the kernel
KSRC = fs.c sysctl.c support.c ../common/util.c ../common/inode.c ../common/dir.c ../common/super.c ../common/attr.c
KHEADERS = \
../common/attr.h \
../common/inode.h \
../common/struct.h \
../common/support.h \
../common/util.h \
../common/dir.h \
../common/macros.h \
../common/super.h \
../common/types.h \
sysctl.h
# Objects to build
OBJ = $(KSRC:.c=.o)
# Module to build
MOD = ../ntfs.o
# Dependancies
DDIR = .depend
DFILE = all
# Linux
KERNEL=/usr/src/linux
LLIB = $(KERNEL)/lib/lib.a
LMAKEFILE = $(KERNEL)/Makefile
LCONFIG = $(KERNEL)/.config
LMODVER = $(KERNEL)/include/linux/modversions.h
# Program
LD = @LD@
CC = @CC@
INSTALL = @INSTALL@
DEPMOD = @DEPMOD@
INSMOD = @INSMOD@
RMMOD = @RMMOD@
MOUNT = @MOUNT@
UMOUNT = @UMOUNT@
# Variables
# Version of the installed kernel sources
KVERSION = @kversion@
# Allow debugging
DEBUG = @debug@
# Mount point for the NTFS partition
MOUNT_POINT = @mount_point@
# Default NTFS device
MDEVICE = @ntfs_volume@
.PHONY : all check_make smp check_conf modver cflags clean clean_worspace \
clean_makespace install mount umount
all: smp modver cflags $(MOD)
# Check the Linux kernel main Makefile presence
check_make:
ifeq ($(LMAKEFILE),$(wildcard $(LMAKEFILE)))
@echo Found Linux kernel main Makefile
SMP = $(shell sed -n -e "s/^SMP = \(.*\)/\1/p" $(LMAKEFILE))
else
@echo $(LMAKEFILE) is missing
@echo Please install kernel sources before trying again
endif
smp: check_make
# SMP kernel detection
ifeq ($(SMP),1)
@echo Running kernel is SMP
DFLAGS += -D__SMP__
else
@echo Running kernel is not SMP
endif
# Check the Linux kernel configuration file presence
check_conf:
ifeq ($(LCONFIG),$(wildcard $(LCONFIG)))
@echo Found Linux kernel configuration file
include $(LCONFIG)
else
@echo $(LCONFIG) is missing
@echo Please configure kernel sources before trying again
endif
modver: check_conf
# Module versioning detection
ifeq ($(CONFIG_MODVERSIONS),y)
@echo Running kernel has module versioning enabled
DFLAGS += -DMODVERSIONS -include $(LMODVER)
else
@echo Running kernel has module versioning disabled
endif
# Compilation flags
cflags:
# To reach config.h
CFLAGS = -I..
# To reach the common stuff
CFLAGS += -I../common
# Compute dependencies (.d)
CFLAGS += -MMD
# Warnings
CFLAGS += -Wall -Wstrict-prototypes
# Debug option
ifeq ($(DEBUG),y)
CFLAGS += -g3 -O
CFLAGS += -DDEBUG
else
CFLAGS += -O2 -fomit-frame-pointer
endif
# Kernel code
CFLAGS += -D__KERNEL__ -D_POSIX_SOURCE
# Kernel module
CFLAGS += -DMODULE
# Detected flags
CFLAGS += $(DFLAGS)
# Flags from 'configure'
CFLAGS += @gcccflags@ @DEFS@
# Build kernel module
$(MOD): $(OBJ)
ifeq ($(LLIB),$(wildcard $(LLIB)))
@echo Found Linux kernel library
$(LD) -r $(OBJ) $(LLIB) -o $@
else
@echo $(LLIB) is missing
@echo Please compile kernel sources before trying again
endif
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
@if [ -r $(@:.o=.d) ]; then \
if [ ! -d $(DDIR) ]; then \
echo Creating the dependancy directory; \
mkdir $(DDIR); \
fi; \
mv $(@:.o=.d) $(DDIR); \
cat $(DDIR)/*.d > $(DDIR)/$(DFILE); \
fi
# Include the dependancies. Don't warn (-) if there is no .d
-include $(DDIR)/$(DFILE)
# Put the tree in its scratch state
clean: clean_workspace clean_makespace
# Remove work files from the work space
clean_workspace:
@rm -f core *~; \
echo Linux21 workspace is now clean
# Remove files created by this Makefile
clean_makespace:
@rm -rf $(DDIR) $(OBJ) $(MOD); \
echo Linux21 makespace is now clean
# Install the module
install: all
$(INSTALL) -d /lib/modules/$(KVERSION)/fs; \
$(INSTALL) $(MOD) /lib/modules/$(KVERSION)/fs; \
$(DEPMOD) -a
# Mount the NT filesystem
mount: all
ifneq ($(MDEVICE),)
ifneq ($(MOUNT_POINT),)
sync; \
$(INSMOD) -m $(MOD) > ntfs.map; \
$(MOUNT) -t ntfs -oumask=0 $(MDEVICE) $(MOUNT_POINT)
else
@echo You must specify a mount point in configure
endif
else
@echo You must specify the device to mount in configure
endif
# Umount the NT filesystem
umount:
$(UMOUNT) $(MOUNT_POINT); \
$(RMMOD) ntfs
# produce kernel patch
#FIXME: how get I rid of the last chunk of struct.h?
#FIXME: how can I split with only one marker up-to and starting-from
ntfs_fs_i.h: ../common/struct.h ntfs_fs_i.h.in
csplit ../common/struct.h %NTFS_INODE_INFO_START%+1 /NTFS_INODE_INFO_END/
csplit -f yy $@.in /BODY1/ %BODY2%+1
cat yy00 xx00 yy01 >$@
rm xx?? yy??
ntfs_fs_sb.h: ../common/struct.h ntfs_fs_sb.h.in
csplit ../common/struct.h %NTFS_SB_INFO_START%+1 /NTFS_SB_INFO_END/
csplit -f yy $@.in /BODY1/ %BODY2%+1
cat yy00 >$@
sed 's/ntfs_inode/ntfs_inode_info/' <xx00 >>$@
cat yy01 >>$@
rm xx?? yy??
patch-kernel: ntfs_fs_i.h ntfs_fs_sb.h
cmp -s $(KERNEL)/include/linux/ntfs_fs_i.h ntfs_fs_i.h|| install ntfs_fs_i.h $(KERNEL)/include/linux
cmp -s $(KERNEL)/include/linux/ntfs_fs_sb.h ntfs_fs_sb.h|| install ntfs_fs_sb.h $(KERNEL)/include/linux
cmp -s $(KERNEL)/include/linux/ntfs_fs.h ntfs_fs.h || install ntfs_fs.h $(KERNEL)/include/linux
install ntfs.txt $(KERNEL)/Documentation/filesystems
install -d $(KERNEL)/fs/ntfs
for f in $(KSRC) $(KHEADERS);do \
cmp -s $$f $(KERNEL)/fs/ntfs/$$f || \
install $$f $(KERNEL)/fs/ntfs; \
done
sed "s/DATE/`date +%y%m%d`/" <kernelmakefile >$(KERNEL)/fs/ntfs/Makefile
patch -N -p1 -d $(KERNEL) <kernelpatch
|