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
|
# Makefile for the NT filesystem kernel part
#
# Copyright (C) 1997 Rgis Duchesne
#
# Note : Do 'make clean_makespace' each time you modify this Makefile.
# Files
# Objects to build
OBJ = fs.o sysctl.o support.o ../common/util.o ../common/inode.o ../common/dir.o ../common/super.o ../common/attr.o
# Module to build
MOD = ../ntfs.o
# Dependancies
DDIR = .depend
DFILE = all
# Linux
LLIB = /usr/src/linux/lib/lib.a
LMAKEFILE = /usr/src/linux/Makefile
LCONFIG = /usr/src/linux/.config
LMODVER = /usr/src/linux/include/linux/modversions.h
# Program
LD = ld
CC = gcc
INSTALL = /usr/bin/install -c
DEPMOD = /sbin/depmod
INSMOD = /sbin/insmod
RMMOD = /sbin/rmmod
MOUNT = mount
UMOUNT = umount
# Variables
# Version of the installed kernel sources
KVERSION = $(shell kernelversion)
# Allow debugging
DEBUG =
# Mount point for the NTFS partition
MOUNT_POINT =
# Default NTFS device
MDEVICE =
.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) -I/usr/src/linux/include
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 += -pipe -fno-strength-reduce -DHAVE_CONFIG_H
# 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 Linux20 workspace is now clean
# Remove files created by this Makefile
clean_makespace:
@rm -rf $(DDIR) $(OBJ) $(MOD); \
echo Linux20 makespace is now clean
# Install the module
install: all
$(INSTALL) -d $(DESTDIR)/lib/modules/$(KVERSION)/fs; \
$(INSTALL) -m 644 $(MOD) $(DESTDIR)/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
|