diff --git a/acinclude.m4 b/acinclude.m4 index da4a3b4c4b..3dbc88b9dc 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -55,6 +55,18 @@ AC_ARG_WITH(bsd-kernel-headers, AC_ARG_WITH(bsd-kernel-build, [ --with-bsd-kernel-build=path use the kernel build found at path(optional, defaults to KSRC/i386/compile/GENERIC)] ) + +AC_ARG_WITH([linux-kernel-packaging], + AS_HELP_STRING([--with-linux-kernel-packaging], + [ use standard naming conventions to aid Linux + kernel build packaging (disables MPS, sets the + kernel module name to openafs.ko, and installs + kernel modules into the standard Linux location) + ]), + [ AC_SUBST(LINUX_KERNEL_PACKAGING, "yes") + AC_SUBST(LINUX_LIBAFS_NAME, "openafs") ], + [ AC_SUBST(LINUX_LIBAFS_NAME, "libafs") ] ) + AC_ARG_ENABLE(kernel-module, [ --disable-kernel-module disable compilation of the kernel module (defaults to enabled)],, enable_kernel_module="yes" ) @@ -707,7 +719,11 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*) LINUX_EXPORTS_SYS_OPEN LINUX_EXPORTS_SYS_WAIT4 LINUX_EXPORTS_RCU_READ_LOCK - LINUX_WHICH_MODULES + if test "x$with_linux_kernel_packaging" = "xno" ; then + LINUX_WHICH_MODULES + else + AC_SUBST(MPS,'SP') + fi if test "x$ac_cv_linux_config_modversions" = "xno" -o $AFS_SYSKVERS -ge 26; then AC_MSG_WARN([Cannot determine sys_call_table status. assuming it isn't exported]) ac_cv_linux_exports_sys_call_table=no diff --git a/src/config/Makefile.config.in b/src/config/Makefile.config.in index ced7009136..eeeb59d4fc 100644 --- a/src/config/Makefile.config.in +++ b/src/config/Makefile.config.in @@ -48,6 +48,8 @@ LEX = @LEX@ LIB_AFSDB = @LIB_AFSDB@ LIBS = @LIBS@ LINUX_KERNEL_PATH = @LINUX_KERNEL_PATH@ +LINUX_LIBAFS_NAME=@LINUX_LIBAFS_NAME@ +LINUX_KERNEL_PACKAGING=@LINUX_KERNEL_PACKAGING@ LINUX_VERSION = @LINUX_VERSION@ LINUX_VERS = @LINUX_VERSION@ LWP_OPTMZ = @LWP_OPTMZ@ diff --git a/src/libafs/MakefileProto.LINUX.in b/src/libafs/MakefileProto.LINUX.in index 84eb5fe016..672ce5306a 100644 --- a/src/libafs/MakefileProto.LINUX.in +++ b/src/libafs/MakefileProto.LINUX.in @@ -209,6 +209,9 @@ ${COMPDIRS} ${INSTDIRS} ${DESTDIRS}: ln -fs ${LINUX_KERNEL_PATH}/include/asm-ia64 asm + if [ "${LINUX_KERNEL_PACKAGING}" ] ; then \ + TARGPREFIX="pack_"; \ + fi ; \ for m in ${MPS} ; do \ KDIR=${KOBJ}-${LINUX_VERSION}${LINUX_MODULE_NAME}-$$m ; \ echo Building in directory: $${KDIR} ; \ @@ -226,7 +229,7 @@ ${COMPDIRS} ${INSTDIRS} ${DESTDIRS}: TARG=libafs ; \ fi ; \ cd $${KDIR} ; \ - $(MAKE) -f Makefile.afs SMP_DEF="$${SMP_DEF}" $@_$${TARG} CLIENT=${LINUX_VERSION}${LINUX_MODULE_NAME} KDIR=$${KDIR} || exit $$?; \ + $(MAKE) -f Makefile.afs SMP_DEF="$${SMP_DEF}" $@_$${TARGPREFIX}$${TARG} CLIENT=${LINUX_VERSION}${LINUX_MODULE_NAME} KDIR=$${KDIR} || exit $$?; \ cd ../ ; \ done @@ -244,13 +247,16 @@ linux_destdirs_libafs.mp: dest_libafs.mp linux_destdirs_libafs.ep: dest_libafs.ep linux_destdirs_libafs.bm: dest_libafs.bm +linux_compdirs_pack_libafs: depsrcs pack_libafs +linux_instdirs_pack_libafs: install_pack_libafs +linux_destdirs_pack_libafs: dest_pack_libafs # Below this line are targets when in the COMMON directory: # For Linux there is no kernel NFS server. -LIBAFS = libafs-${CLIENT}.${LINUX_MODULE_EXT} -LIBAFS_MP = libafs-${CLIENT}.mp.${LINUX_MODULE_EXT} -LIBAFS_EP = libafs-${CLIENT}.ep.${LINUX_MODULE_EXT} -LIBAFS_BM = libafs-${CLIENT}.bm.${LINUX_MODULE_EXT} +LIBAFS = ${LINUX_LIBAFS_NAME}-${CLIENT}.${LINUX_MODULE_EXT} +LIBAFS_MP = ${LINUX_LIBAFS_NAME}-${CLIENT}.mp.${LINUX_MODULE_EXT} +LIBAFS_EP = ${LINUX_LIBAFS_NAME}-${CLIENT}.ep.${LINUX_MODULE_EXT} +LIBAFS_BM = ${LINUX_LIBAFS_NAME}-${CLIENT}.bm.${LINUX_MODULE_EXT} INST_LIBAFS = ${DESTDIR}${afskerneldir}/${LIBAFS} INST_LIBAFS_MP = ${DESTDIR}${afskerneldir}/${LIBAFS_MP} @@ -262,6 +268,10 @@ DEST_LIBAFS_MP = ${DEST}/root.client/usr/vice/etc/modload/${LIBAFS_MP} DEST_LIBAFS_EP = ${DEST}/root.client/usr/vice/etc/modload/${LIBAFS_EP} DEST_LIBAFS_BM = ${DEST}/root.client/usr/vice/etc/modload/${LIBAFS_BM} +SYSTEM_LIBAFS = /lib/modules/${CLIENT}/extra/${LINUX_LIBAFS_NAME}/${LINUX_LIBAFS_NAME}.ko + +INST_SYSTEM = ${DESTDIR}${SYSTEM_LIBAFS} +DEST_SYSTEM = ${DEST}/root.client${SYSTEM_LIBAFS} libafs: $(LIBAFS) echo SP Build Complete @@ -276,12 +286,15 @@ libafs.bm: $(LIBAFS_BM) echo BM Build Complete -${LIBAFS} ${LIBAFS_MP} ${LIBAFS_EP} ${LIBAFS_BM}: libafs.ko - cp libafs.ko $@ +pack_libafs: ${LINUX_LIBAFS_NAME}.ko + echo "Packaging Friendly Build Complete" + +${LIBAFS} ${LIBAFS_MP} ${LIBAFS_EP} ${LIBAFS_BM}: ${LINUX_LIBAFS_NAME}.ko + cp ${LINUX_LIBAFS_NAME}.ko $@ .FORCE: -libafs.ko afspag.ko: .FORCE - env EXTRA_CFLAGS="${EXTRA_CFLAGS}" @TOP_SRCDIR@/libafs/make_kbuild_makefile.pl ${KDIR} @TOP_OBJDIR@/src/config/Makefile.config Makefile.afs Makefile.common +${LINUX_LIBAFS_NAME}.ko afspag.ko: .FORCE + env EXTRA_CFLAGS="${EXTRA_CFLAGS}" @TOP_SRCDIR@/libafs/make_kbuild_makefile.pl ${KDIR} $@ @TOP_OBJDIR@/src/config/Makefile.config Makefile.afs Makefile.common env EXTRA_CFLAGS="${EXTRA_CFLAGS}" $(MAKE) -C ${LINUX_KERNEL_PATH} M=@TOP_OBJDIR@/src/libafs/${KDIR} modules @@ -314,6 +327,9 @@ install_libafs.ep: $(INST_LIBAFS_EP) install_libafs.bm: $(INST_LIBAFS_BM) echo BM Install Complete +install_pack_libafs: $(INST_SYSTEM) + echo Packinging Friendly Install Complete + dest_libafs: $(DEST_LIBAFS) echo SP Install Complete @@ -326,6 +342,9 @@ dest_libafs.ep: $(DEST_LIBAFS_EP) dest_libafs.bm: $(DEST_LIBAFS_BM) echo BM Install Complete +dest_pack_libafs: $(DEST_SYSTEM) + echo Packaging Friendly Install Complete + $(INST_LIBAFS): $(LIBAFS) ${INSTALL} -f $? $@ @@ -338,6 +357,9 @@ $(INST_LIBAFS_EP): $(LIBAFS_EP) $(INST_LIBAFS_BM): $(LIBAFS_BM) ${INSTALL} -f $? $@ +$(INST_SYSTEM) $(DEST_SYSTEM): $(LINUX_LIBAFS_NAME).ko + ${INSTALL} -f $? $@ + $(DEST_LIBAFS): $(LIBAFS) ${INSTALL} -f $? $@ diff --git a/src/libafs/make_kbuild_makefile.pl b/src/libafs/make_kbuild_makefile.pl index 35dbba792a..9116869a2e 100755 --- a/src/libafs/make_kbuild_makefile.pl +++ b/src/libafs/make_kbuild_makefile.pl @@ -2,10 +2,10 @@ # make_kbuild_makefile.pl # Generate a Makefile for use with the Linux 2.6+ kernel build system # -# Usage: make_kbuild_makefile.pl ${KDIR} Makefiles... +# Usage: make_kbuild_makefile.pl ${KDIR} ${TARG} Makefiles... # # The specified makefiles will be scanned for variable values -# The libafs.ko module will be built in ${TOP_SRCDIR}/src/libafs/${KDIR}. +# The module ${TARG} will be built in ${TOP_SRCDIR}/src/libafs/${KDIR}. # It will include objects listed in ${AFSAOBJS} and ${AFSNFSOBJS} # The afspag.ko module will be built from objects listed in ${AFSPAGOBJS}. # Appropriate source files for each object will be symlinked into ${KDIR} @@ -17,11 +17,12 @@ use IO::File; -if (@ARGV < 2) { - die "Usage: $0 KDIR Makefiles...\n"; +if (@ARGV < 3) { + die "Usage: $0 KDIR TARG Makefiles...\n"; } -($KDIR, @Makefiles) = @ARGV; +($KDIR, $TARG, @Makefiles) = @ARGV; +$TARG =~ s/\.k?o$//; ## Read in all of the Makefiles given on the command line ## Our ultimate goal is to find the correct source file for each object. @@ -111,8 +112,8 @@ foreach (sort keys %vars) { print $F "$_ = $vars{$_}\n"; } print $F "EXTRA_CFLAGS=$cflags\n"; -print $F "obj-m := libafs.o afspag.o\n"; -print $F "libafs-objs := ", join("\\\n $_", @libafs_objs), "\n"; +print $F "obj-m := $TARG.o afspag.o\n"; +print $F "$TARG-objs := ", join("\\\n $_", @libafs_objs), "\n"; print $F "afspag-objs := ", join("\\\n $_", @afspag_objs), "\n"; print $F "\n$MakefileVersion\n"; $F->close() or die "$KDIR/Makefile: $!\n";