FBSD: Set KERNBUILDDIR for --with-bsd-kernel-build
[openafs.git] / src / libafs / MakefileProto.FBSD.in
index 1d35739..26e86ea 100644 (file)
@@ -1,73 +1,98 @@
-#/* Copyright (C) 1995, 1989 Transarc Corporation - All rights reserved */
+# Copyright 2000, International Business Machines Corporation and others.
+# All Rights Reserved.
+#
+# This software has been released under the terms of the IBM Public
+# License.  For details, see the LICENSE file in the top-level source
+# directory or online at http://www.openafs.org/dl/license10.html
 #
 srcdir=@srcdir@
 include @TOP_OBJDIR@/src/config/Makefile.config
 
+# tell bsd.kmod.mk to build us vnode_if*
+SRCS=  vnode_if.h
 
-# OS specific object files:
-AFS_OS_OBJS = \
-       osi_groups.o \
-       osi_file.o \
-       osi_inode.o \
-       osi_misc.o \
-       osi_sleep.o \
-       osi_vm.o \
-       osi_vnodeops.o \
-       xdr_int64.o
-
-AFS_OS_NFSOBJS = \
-       osi_vfsops_nfs.o
+# We must set SRCS to include at least one .c file if we are also using
+# vnode_if.h, due to a bug in the system makefiles where the empty string
+# gets expanded to a ".o" entry in OBJS, which there is (correctly) no
+# rule to make.  For simplicity, just set this as all of what would
+# otherwise be AFS_OS_OBJS so that people have a familiar list to look for.
+#
+# OS specific "object" files:
+SRCS+= \
+       osi_crypto.c \
+       osi_gcpags.c \
+       osi_groups.c \
+       osi_file.c \
+       osi_inode.c \
+       osi_misc.c \
+       osi_sleep.c \
+       osi_vcache.c \
+       osi_vm.c \
+       osi_vnodeops.c \
+       osi_module.c
+
+#AFS_OS_NFSOBJS = \
+#      osi_vfsops_nfs.o
 
 AFS_OS_NONFSOBJS = \
        osi_vfsops.o
 
-
 # System specific build commands and flags
-# KDEFS=-DLANGUAGE_C  -I/usr/sys/include -I../include \
-#       -I/usr/src/sys/${HEADER_RT} -I/usr/src/sys/sys \
-#      -DSWAPTYPE=1 -DUERF -DOSF -DCOMPAT_43 -DUFS \
-#      -DRT -DKERNEL -D_KERNEL
-KDEFS=-Wall -fformat-extensions -ansi -nostdinc -I/usr/include -D_KERNEL \
-       -elf -mpreferred-stack-boundary=2 -I/usr/src/sys/sys -I../afs
-DBUG = -O2
-DEFINES= -DAFSDEBUG -DKERNEL -DAFS -DVICE -DNFS -DUFS -DINET -DQUOTA -DGETMOUNT
-OPTF=${OPT} 
-OPTF2=${OPT2} 
-CFLAGS=-I. -I.. -I${TOP_OBJDIR}/src/config ${FSINCLUDES} $(DEFINES) $(KDEFS) $(KOPTS) ${DBUG}
-
+KSRC = @BSD_KERNEL_PATH@
+KBLD = @BSD_KERNEL_BUILD@
+
+# keep symbols if --enable-debug-kernel
+AC_DEBUG_FLAGS = @DEBUG_FLAGS@
+.if !empty(AC_DEBUG_FLAGS)
+DEBUG_FLAGS=   ${AC_DEBUG_FLAGS}
+.endif
+
+# We are not doing very well (WARNS=2 brings in printf format type checking)
+WARNS= 1
+# We have some sketchy code that redeclares prototypes
+CWARNFLAGS+= -Wno-redundant-decls
+
+# setup for bsd.kmod.mk infrastructure
+.PATH: ${TOP_SRCDIR}/afs/FBSD
+KMODDIR=/boot/modules
+KMOD=  libafs
+SYSDIR= ${KSRC}
+.if !empty(KBLD)
+KERNBUILDDIR=${KBLD}
+.endif
 
 # Name of directory to hold object files and libraries.
-KOBJ = STATIC
+KOBJ = MODLOAD
 
 # This tells Makefile.common to use it's single directory build target.
 COMPDIRS = single_compdir
 INSTDIRS = single_instdir
 DESTDIRS = single_destdir
 
-include Makefile.common
-
+# The common sysincludes code needs the 'h' symlink.
+# We cannot include bsd.kmod.mk in this file directly, because it will start
+# generating headers and objects in this directory, which we want in $(KOBJ).
+# We also need the install target from bsd.kmod.mk in $(KOBJ), but the one
+# from Makefile.common in this directory.  A prime candidate for cleanup.
 setup:
        -mkdir $(KOBJ)
-       -$(RM) $(KOBJ)/Makefile $(KOBJ)/Makefile.common $(KOBJ)/config
-       ln -fs ../Makefile $(KOBJ)/Makefile
-       ln -fs ../Makefile.common $(KOBJ)/Makefile.common
-       ln -fs ../config $(KOBJ)/config
-       -$(RM) -f  h net netinet rpc ufs nfs  machine sys vm
-       -ln -fs /usr/src/sys/net net
-       -ln -fs /usr/src/sys/i386/include machine
-       -ln -fs /usr/src/sys/netinet netinet
-       -ln -fs /usr/src/sys/nfs nfs
-       -ln -fs /usr/include/rpc rpc
-       -ln -fs /usr/src/sys/sys sys
-       -ln -fs /usr/src/sys/ufs/ufs ufs
-       -ln -fs /usr/src/sys/sys h
-       -ln -fs /usr/src/sys/vm vm
-       -touch $(KOBJ)/sec_net.h
-
-
-# Below this line are targets when in the COMMON directory:
-LIBAFS = libafs.o
-LIBAFSNONFS = libafs.nonfs.o
+       -$(RM) $(KOBJ)/Makefile $(KOBJ)/Makefile.common
+       $(CP) Makefile $(KOBJ)/Makefile
+       echo ".include <bsd.kmod.mk>" >> $(KOBJ)/Makefile
+       sed -e 's/^install:/afsinstall:/' Makefile.common > $(KOBJ)/Makefile.common
+       -$(RM) -f h
+       -ln -fs ${KSRC}/sys h
+
+# Makefile.common sets AFSAOBJS, COMMON_INCLUDE, TOP_{SRC,OBJ}*, and the like.
+# We must live with its other pollution of targets and build rules.
+include Makefile.common
+
+# we only do the no-NFS case
+OBJS=  ${AFSAOBJS} ${AFSNONFSOBJS}
+
+LIBAFSNONFS=   libafs.ko
+DEFINES= -DAFSDEBUG -DKERNEL -DAFS -DVICE -DNFS -DUFS -DINET -DQUOTA -DGETMOUNT
+CFLAGS+= $(DEFINES) ${COMMON_INCLUDE}
 
 INST_LIBAFS = ${DESTDIR}${afskerneldir}/${LIBAFS}
 INST_LIBAFSNONFS = ${DESTDIR}${afskerneldir}/${LIBAFSNONFS}
@@ -75,60 +100,15 @@ INST_LIBAFSNONFS = ${DESTDIR}${afskerneldir}/${LIBAFSNONFS}
 DEST_LIBAFS = ${DEST}/root.client/bin/${LIBAFS}
 DEST_LIBAFSNONFS = ${DEST}/root.client/bin/${LIBAFSNONFS}
 
+$(DESTDIR)$(KMODDIR)/:
+       $(INSTALL) -d $@
+
+install_libafs:        $(LIBAFSNONFS) $(DESTDIR)$(KMODDIR)/ install
+
+dest_libafs: $(LIBAFSNONFS)
+       ${INSTALL} -d ${DEST}/root.client/bin
+       ${INSTALL} -m 644 $(LIBAFSNONFS) $(DEST_LIBAFSNONFS)
+
+# This is ugly, but the common infrastructure needs a libafs target.
+libafs: depend $(LIBAFSNONFS)
 
-# libafs:      $(LIBAFS) $(LIBAFSNONFS)
-# libafs:      $(LIBAFSNONFS)
-# install_libafs:      $(INST_LIBAFS) $(INST_LIBAFSNONFS)
-# install_libafs:      $(INST_LIBAFSNONFS)
-# dest_libafs: $(DEST_LIBAFS) $(DEST_LIBAFSNONFS)
-# dest_libafs: $(DEST_LIBAFSNONFS)
-libafs:
-       echo WARNING: No kernel module for ${SYS_NAME}
-
-install_libafs:
-       echo WARNING: No kernel module for ${SYS_NAME}
-
-dest_libafs:
-       echo WARNING: No kernel module for ${SYS_NAME}
-
-
-$(INST_LIBAFS): $(LIBAFS)
-       $(INSTALL) -f $? $@
-
-$(INST_LIBAFSNONFS): $(LIBAFSNONFS)
-       $(INSTALL) -f $? $@
-
-$(DEST_LIBAFS): $(LIBAFS)
-       $(INSTALL) -f $? $@
-
-$(DEST_LIBAFSNONFS): $(LIBAFSNONFS)
-       $(INSTALL) -f $? $@
-
-${LIBAFS}: $(AFSAOBJS) $(AFSNFSOBJS)
-       $(LD) -r -o ${LIBAFS} ${AFSAOBJS} ${AFSNFSOBJS}
-
-${LIBAFSNONFS}:  $(AFSAOBJS) $(AFSNONFSOBJS)
-       $(LD) -r -o ${LIBAFSNONFS} ${AFSAOBJS} ${AFSNONFSOBJS}
-
-
-# Object build rules:
-osi_groups.o: $(AFS)/osi_groups.c
-       $(CRULE1)
-osi_file.o: $(AFS)/osi_file.c
-       $(CRULE1)
-osi_inode.o: $(AFS)/osi_inode.c
-       $(CRULE1)
-osi_misc.o: $(AFS)/osi_misc.c
-       $(CRULE1)
-osi_sleep.o: $(AFS)/osi_sleep.c
-       $(CRULE1)
-osi_vfsops_nfs.o: $(AFS)/osi_vfsops.c
-       $(CRULE1) -o osi_vfsops_nfs.o
-osi_vfsops.o: $(AFS)/osi_vfsops.c
-       $(CRULE1) -DAFS_NONFSTRANS
-osi_vm.o: $(AFS)/osi_vm.c
-       $(CRULE1)
-osi_vnodeops.o: $(AFS)/osi_vnodeops.c
-       $(CRULE1)
-xdr_int64.o: $(RX)/xdr_int64.c
-       $(CRULE1)