After getting a few pointers from jhb at BSDCan on what a bsd.kmod.mk-using Makefile should look like, I have been trying my hand at porting the OpenAFS kernel module build system to use it. (The main thing this gets us is not having to manually track version- and architecture-dependent CFLAGS and the like.) However, the path is not exactly smooth.

A lot of the difficulty is in getting an autogenerated vnode_if.h while using a list of files to include in the module(from the common OpenAFS code) that's given as a list of object files. If there's already a vnode_if.h sitting around, I can just use OBJS and things progress quite nicely; however, if I have to get back to SRCS for the use of sys/conf/kmod.mk's vnode_if.h logic, I get this sort of build failure (full log attached) with the attached Makefile: gcc -I. -I.. -I../nfs [more includes and defines] -I/usr/devel/openafs/git/openafs/include/afs -I@/sys -Imachine -I. -I@ -I@/contrib/altq -finline-limit=8000 --param inline-unit-growth=100 --param large-function-growth=1000 -fno-common -fno-omit-frame-pointer -mcmodel=kernel -mno-red-zone -mfpmath=387 -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -msoft-float -fno-asynchronous-unwind-tables -ffreestanding -fstack-protector -std=iso9899:1999 -fstack-protector -Wno-redundant-decls -Wsystem-headers -Werror -Wno-pointer-sign -o osi_crypto.o -c /usr/devel/openafs/git/openafs/src/afs/FBSD/osi_crypto.c /usr/devel/openafs/git/openafs/src/libafs/MODLOAD/../../afs/FBSD/osi_crypto.c vnode_if.h
gcc: cannot specify -o with -c or -S with multiple files

That last bit, "-o osi_crypto.o -c /path/to/osi_crypto.c /path/to/osi_crypto.c vnode_if.h" is quite troublesome. Any thoughts on what is causing those extra files to be listed would be greatly appreciated. (Comments on other issues in the Makefile are welcome, too -- it's still in pretty rough shape.)

I should note that though Makefile.common does define a osi_crypto.o target, "make -d A" reports: using existing source /usr/devel/openafs/git/openafs/src/afs/FBSD/osi_crypto.c
        applying .c -> .o to "osi_crypto.o"


Thanks,

Ben Kaduk
# 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=.
include /usr/devel/openafs/git/openafs/src/config/Makefile.config
# we unset these to work around flags we don't want
# XCFLAGS sets -fPIC, which is forbidden for mcmodel=kernel
XCFLAGS=
COMMON_CFLAGS=
# XXX not sure if these need to be (re)defined here
INSTALL = /usr/bin/install -c
INSTALL_DATA = ${INSTALL} -m 644
INSTALL_PROGRAM = ${INSTALL} 
INSTALL_SCRIPT = ${INSTALL}

# System specific build commands and flags
KSRC = /usr/src/sys
KBLD = /usr/obj/usr/src/sys/GENERIC

# We suck
WARNS= 1
# setting WARNS=0 did not help with this?!
CWARNFLAGS+= -Wno-redundant-decls

# setup for bsd.kmod.mk infrastructure
.PATH:  ${.CURDIR}/../../afs \
        ${.CURDIR}/../../afs/FBSD \
        ${.CURDIR}/../../afs/VNOPS
KMODDIR=/boot/modules
KMOD=   libafs
SYSDIR= ${KSRC}
# Name of directory to hold object files and libraries.
KOBJ = MODLOAD

# This tells Makefile.common to use it's single directory build target.
COMPDIRS = single_compdir
INSTDIRS = single_instdir
DESTDIRS = single_destdir

# Very ugly.  But many of these links are needed for common code to work.
setup:
        -mkdir $(KOBJ)
        -$(RM) $(KOBJ)/Makefile $(KOBJ)/Makefile.common
        ln -fs ../Makefile $(KOBJ)/Makefile
        ln -fs ../Makefile.common $(KOBJ)/Makefile.common
        -$(RM) -f  h rpc ufs machine
        -ln -fs ${KSRC}/amd64/include machine
        -ln -fs ${KSRC}/ufs/ufs ufs
        -ln -fs ${KSRC}/rpc rpc
        -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

# This is quite awkward.  The code in kmod.mk checks for vnode_if.h in
# SRCS, but I am given a list of object files from the common code.
# Resort to variable substitution black magic, below.
SRCS = vnode_if.h

# OS specific object files:
AFS_OS_OBJS = osi_crypto.o \
        osi_gcpags.o \
        osi_groups.o \
        osi_file.o \
        osi_inode.o \
        osi_misc.o \
        osi_sleep.o \
        osi_vcache.o \
        osi_vm.o \
        osi_vnodeops.o \
        osi_module.o 

AFS_OS_NONFSOBJS = \
        osi_vfsops.o

SRCS+=  ${AFS_OS_OBJS:S/.o$/.c/g} ${AFS_OS_NONFSOBJS:S/.o$/.c/g} \
        ${AFSAOBJS:S/.o$/.c/g}

DEFINES= -DAFSDEBUG -DKERNEL -DAFS -DVICE -DNFS -DUFS -DINET -DQUOTA -DGETMOUNT
CFLAGS+= $(DEFINES) ${COMMON_INCLUDE} -I@/sys -Imachine

INST_LIBAFS = ${DESTDIR}${afskerneldir}/${LIBAFS}
INST_LIBAFSNONFS = ${DESTDIR}${afskerneldir}/${LIBAFSNONFS}

DEST_LIBAFS = ${DEST}/root.client/bin/${LIBAFS}
DEST_LIBAFSNONFS = ${DEST}/root.client/bin/${LIBAFSNONFS}

install_libafs: 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: libafs.ko

.include <bsd.kmod.mk>

Attachment: build.log
Description: Binary data

_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"

Reply via email to