# 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

# MakefileProto for Linux i386 systems
#

#DESTDIR=DEST/
#include ../config/Makefile.${SYS_NAME}

# OS specific object files:
AFS_OS_OBJS = \
	osi_alloc.o \
	osi_cred.o \
	osi_groups.o \
	osi_inode.o \
	osi_file.o \
	osi_misc.o \
	osi_module.o \
	osi_sleep.o \
	osi_vfsops.o \
	osi_vm.o \
	osi_vnodeops.o \
	xdr.o \
	xdr_array.o

AFS_OS_NFSOBJS =

AFS_OS_NONFSOBJS =


# System specific build commands and flags
CC = gcc
LD = ld
# -Wall
CCFLAGS =   -O2 -fomit-frame-pointer \
	-fno-strength-reduce -pipe -m486 -malign-loops=2 -malign-jumps=2 \
	-malign-functions=2
DEFINES = -D__KERNEL__  -DCPU=586 -DKERNEL -D_KERNEL -DMODULE ${SMP_DEF} $(VERS_DEF)
INCLUDES = -I. -I../

CFLAGS = $(CCFLAGS) $(DEFINES) $(INCLUDES)

# Name of directory to hold object files and libraries.
KOBJ = MODLOAD

# COMPDIRS is called in Makefile.common to do the actual builds.
COMPDIRS=linux_compdirs


include Makefile.common

setup:
	-rm -f h net netinet sys rpc
	-ln -s rx rpc
	for v in ${LINUX_VERS} ; do \
			KDIR=$(KOBJ)-$$v; \
			mkdir -p $${KDIR}; \
			ln -fs ../Makefile $${KDIR}/Makefile ; \
			ln -fs ../Makefile.common $${KDIR}/Makefile.common; \
	done
	
# Compile SP and MP clients as requested

LINUX_INCDIR=include/linux

${COMPDIRS}:
	for v in ${LINUX_VERS} ; do \
		IDIR=${LINUX_SRCDIR}/${LINUX_INCDIR}; \
		rm -f h; \
		ln -s $${IDIR} h; \
		rm -f linux; \
		ln -s $${IDIR} linux; \
		rm -f net; \
		ln -s $${IDIR} net; \
		rm -f netinet; \
		ln -s $${IDIR} netinet; \
		rm -f sys; \
		ln -s $${IDIR} sys; \
		rm -f asm-generic; \
		ln -s ${LINUX_SRCDIR}$$v/include/asm-generic asm-generic; \
		rm -f asm; \
		ln -s ${LINUX_SRCDIR}/include/asm asm ; \
			KDIR=${KOBJ}-$$v ; \
			echo Building in directory: $${KDIR} ; \
			cd $${KDIR} ; \
			$(MAKE) libafs.o CLIENT=$$v || exit $$?; \
			cd ../ ; \
	done

afsaclean:
	-rm -rf ${KOBJ}*

# Below this line are targets when in the COMMON directory:
# For Linux there is no kernel NFS server.
LIBAFS = libafs.o

${LIBAFS}: $(AFSAOBJS) $(AFSNONFSOBJS)
	$(RM) -f $@
	$(LD) -r -o $@ $(AFSAOBJS) $(AFSNONFSOBJS)

# Linux specific objects
osi_alloc.o: $(AFS)/osi_alloc.c
	$(CRULE1);
osi_cred.o: $(AFS)/osi_cred.c
	$(CRULE1);
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_module.o: $(AFS)/osi_module.c
	$(CRULE1);
osi_sleep.o: $(AFS)/osi_sleep.c
	$(CRULE1);
osi_vfsops.o: $(AFS)/osi_vfsops.c
	$(CRULE1);
osi_vm.o: $(AFS)/osi_vm.c
	$(CRULE1);
osi_vnodeops.o: $(AFS)/osi_vnodeops.c
	$(CRULE1);
xdr.o: $(RX)/xdr.c
	$(CRULE1);
xdr_int64.o: $(RX)/xdr_int64.c
	$(CRULE1);
xdr_array.o: $(RX)/xdr_array.c
	$(CRULE1);
