# 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
# $Header: /cvs/openafs/src/libafs/MakefileProto.DARWIN.in,v 1.27.2.2 2007/10/09 21:30:02 shadow Exp $
# 
# MakefileProto for Digital Unix systems
#
srcdir=@srcdir@
include @TOP_OBJDIR@/src/config/Makefile.config


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


#AFS_OS_NFSOBJS = osi_vfsops_nfs.o

AFS_OS_NONFSOBJS = osi_vfsops.o


# System specific build commands and flags
KDEFS=
DBUG = 
DEFINES= -D_KERNEL -DKERNEL -DKERNEL_PRIVATE -DDIAGNOSTIC -DUSE_SELECT -DMACH_USER_API -DMACH_KERNEL
<ppc_darwin_80 x86_darwin_80>
KOPTS_DBUG=-g
<ppc_darwin_90 x86_darwin_90>
KOPTS_DBUG=-ggdb
<ppc_darwin_80 x86_darwin_80 ppc_darwin_90 x86_darwin_90>
KOPTS_ppc=-static -nostdinc -nostdlib -fno-builtin -finline -fno-keep-inline-functions -msoft-float -mlong-branch -fsigned-bitfields -arch ppc -Dppc -DPPC -D__PPC__ -DPAGE_SIZE_FIXED -mcpu=750 -mmultiple -fschedule-insns -force_cpusubtype_ALL
KOPTS_x86=-static -nostdinc -nostdlib -fno-builtin -finline -fno-keep-inline-functions -msoft-float -mlong-branch -fsigned-bitfields -arch i386 -Di386 -DI386 -D__I386__ -DPAGE_SIZE_FIXED -march=i686 -mpreferred-stack-boundary=2 -falign-functions=4
ARCH_ppc=$(shell echo "${ARCHFLAGS}" | grep -q -w ppc && echo yes)
ARCH_x86=$(shell echo "${ARCHFLAGS}" | grep -q -w i386 && echo yes)
ifeq ($(ARCH_ppc),yes)
ifeq ($(ARCH_x86),yes)
MODLD=$(CC) -static $(KOPTS_DBUG) -nostdlib -arch ppc -arch i386
CFLAGS_ppc=${KINCLUDES} -I. -I.. -I${TOP_OBJDIR}/src/config $(DEFINES) $(KDEFS) $(KOPTS_ppc) $(KOPTS_DBUG)
CFLAGS_x86=${KINCLUDES} -I. -I.. -I${TOP_OBJDIR}/src/config $(DEFINES) $(KDEFS) $(KOPTS_x86) $(KOPTS_DBUG)
else
MODLD=$(CC) -static $(KOPTS_DBUG) -nostdlib -arch ppc
KOPTS=$(KOPTS_ppc)
CFLAGS=${KINCLUDES} -I. -I.. -I${TOP_OBJDIR}/src/config $(DEFINES) $(KDEFS) $(KOPTS)
endif
else
ifeq ($(ARCH_x86),yes)
MODLD=$(CC) -static $(KOPTS_DBUG) -nostdlib -arch i386
KOPTS=$(KOPTS_x86)
else
_ARCH=$(shell arch)
MODLD=$(CC) -static $(KOPTS_DBUG) -nostdlib -arch $(_ARCH)
KOPTS=$(KOPTS_$(shell echo $(_ARCH) | sed 's/i386/x86/'))
endif
CFLAGS=${KINCLUDES} -I. -I.. -I${TOP_OBJDIR}/src/config $(DEFINES) $(KDEFS) $(KOPTS)
endif
<all -ppc_darwin_80 -x86_darwin_80 -ppc_darwin_90 -x86_darwin_90>
MODLD=$(LD)
CFLAGS=${KINCLUDES} -I. -I.. -I${TOP_OBJDIR}/src/config $(DEFINES) $(KDEFS) $(KOPTS)
<ppc_darwin_70>
KOPTS=-static -fno-common -finline -fno-keep-inline-functions -force_cpusubtype_ALL -msoft-float -mlong-branch 
<ppc_darwin_60>
KOPTS=-no-cpp-precomp -static -fno-common -finline -fno-keep-inline-functions -force_cpusubtype_ALL -msoft-float -mlong-branch 
<ppc_darwin_14 ppc_darwin_13 ppc_darwin_12>
KOPTS=-no-precomp -static -fno-common -finline -fno-keep-inline-functions -force_cpusubtype_ALL -msoft-float -mlong-branch 
<all>
KINCLUDES=-I${KROOT}/System/Library/Frameworks/Kernel.framework/Headers


# 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

include Makefile.common

<ppc_darwin_80 x86_darwin_80 ppc_darwin_90 x86_darwin_90>
ifeq ($(ARCH_ppc),yes)
ifeq ($(ARCH_x86),yes)
# override suffix rule; unfortunately, this causes a warning message
.c.o:
	$(CC) $(COMMON_INCLUDE) $(KERN_DBG) $(CFLAGS_ppc) $(CFLAGS-$@) -o $(patsubst %.o,%.ppc.o,$@) -c $<
	$(CC) $(COMMON_INCLUDE) $(KERN_DBG) $(CFLAGS_x86) $(CFLAGS-$@) -o $(patsubst %.o,%.x86.o,$@) -c $<
	lipo -create $(patsubst %.o,%.ppc.o,$@) $(patsubst %.o,%.x86.o,$@) -output $@
CRULE_NOOPT= \
	$(CC) $(COMMON_INCLUDE) $(KERN_DBG) $(CFLAGS_ppc) $(CFLAGS-$@) -o $(patsubst %.o,%.ppc.o,$@) -c $? && \
	$(CC) $(COMMON_INCLUDE) $(KERN_DBG) $(CFLAGS_x86) $(CFLAGS-$@) -o $(patsubst %.o,%.x86.o,$@) -c $? && \
	lipo -create $(patsubst %.o,%.ppc.o,$@) $(patsubst %.o,%.x86.o,$@) -output $@
CRULE_OPT= \
	$(CC) $(COMMON_INCLUDE) $(KERN_DBG) $(KERN_OPTMZ) $(CFLAGS_ppc) $(CFLAGS-$@) -o $(patsubst %.o,%.ppc.o,$@) -c $? && \
	$(CC) $(COMMON_INCLUDE) $(KERN_DBG) $(KERN_OPTMZ) $(CFLAGS_x86) $(CFLAGS-$@) -o $(patsubst %.o,%.x86.o,$@) -c $? && \
	lipo -create $(patsubst %.o,%.ppc.o,$@) $(patsubst %.o,%.x86.o,$@) -output $@
endif
endif
<all>

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 rpc
	-ln -fs $(KROOT)/System/Library/Frameworks/Kernel.framework/Headers/sys h
	-ln -fs /usr/include/rpc rpc


# Below this line are targets when in the COMMON directory:
LIBAFS = libafs.o
LIBAFSNONFS = libafs.nonfs.o

INST_LIBAFS = ${DESTDIR}${afskerneldir}/afs-nfs.kext
INST_LIBAFSNONFS = ${DESTDIR}${afskerneldir}/afs.kext
DEST_LIBAFS = ${DEST}/root.client/usr/vice/etc/afs-nfs.kext
DEST_LIBAFSNONFS = ${DEST}/root.client/usr/vice/etc/afs.kext


libafs: $(LIBAFSNONFS) ;
install_libafs: $(LIBAFSNONFS) ;
	-mkdir -p ${INST_LIBAFSNONFS}
	-mkdir -p ${INST_LIBAFSNONFS}/Contents
	$(INSTALL) -f ../${DARWIN_INFOFILE} ${INST_LIBAFSNONFS}/Contents/Info.plist
	-mkdir -p ${INST_LIBAFSNONFS}/Contents/MacOS
	$(INSTALL) -f ${LIBAFSNONFS} ${INST_LIBAFSNONFS}/Contents/MacOS/afs

dest_libafs: $(LIBAFSNONFS) ;
	-mkdir -p ${DEST_LIBAFSNONFS}
	-mkdir -p ${DEST_LIBAFSNONFS}/Contents
	$(INSTALL) -f ../${DARWIN_INFOFILE} ${DEST_LIBAFSNONFS}/Contents/Info.plist
	-mkdir -p ${DEST_LIBAFSNONFS}/Contents/MacOS
	$(INSTALL) -f ${LIBAFSNONFS} ${DEST_LIBAFSNONFS}/Contents/MacOS/afs


${LIBAFS}: $(AFSAOBJS) $(AFSNFSOBJS)
	$(MODLD) -r -o ${LIBAFS} ${AFSAOBJS} ${AFSNFSOBJS} -lcc_kext
<ppc_darwin_90 x86_darwin_90>
	dsymutil -o ${LIBAFS}.dSYM ${LIBAFS}
<all>

${LIBAFSNONFS}:  $(AFSAOBJS) $(AFSNONFSOBJS)
	$(MODLD) -r -o ${LIBAFSNONFS} ${AFSAOBJS} ${AFSNONFSOBJS} -lcc_kext
<ppc_darwin_90 x86_darwin_90>
	dsymutil -o ${LIBAFSNONFS}.dSYM ${LIBAFSNONFS}
<all>
