# 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

  EXPORTS = -bexport:export.exp
  IMPORTS = /lib/kernex.exp /lib/syscalls.exp ${srcdir}/extras.exp
     KOBJ = export.o symtab.o

include ../config/Makefile.version

all: ${TOP_LIBDIR}/export.exp ${TOP_LIBDIR}/export64.exp ${TOP_LIBDIR}/extras.exp cfgexport cfgafs
	${INSTALL} ${srcdir}/export.h ${KERNELDIR}
	${INSTALL} export.exp ${KERNELDIR}
	${INSTALL} export64.exp ${KERNELDIR}
	${INSTALL} ${srcdir}/export.h ${UKERNELDIR}
	${INSTALL} export64.exp ${UKERNELDIR}
	${INSTALL} export.exp ${UKERNELDIR}

noversion system: install

install:    ${DESTDIR}${afskerneldir}/export.ext \
	${DESTDIR}${afskerneldir}/export.ext.nonfs \
	${DESTDIR}${afskerneldir}/export64.ext.nonfs \
	${DESTDIR}${libdir}/afs/export.exp \
	${DESTDIR}${libdir}/afs/export64.exp \
	${DESTDIR}${libdir}/afs/extras.exp \
	${DESTDIR}${afskerneldir}/cfgexport \
	${DESTDIR}${afskerneldir}/cfgafs \
	${DESTDIR}${afskerneldir}/export64.ext \
	${DESTDIR}${afskerneldir}/cfgexport64 \
	${DESTDIR}${afskerneldir}/cfgafs64 

export.exp: ${srcdir}/export4.exp ${srcdir}/export5.exp
	case ${SYS_NAME} in \
	rs_aix4* ) \
		cp -p ${srcdir}/export4.exp export.exp ; \
		cp -p ${srcdir}/export4-64.exp export64.exp ;; \
	rs_aix5* ) \
		cp -p ${srcdir}/export5.exp export.exp ; \
		cp -p ${srcdir}/export5-64.exp export64.exp ;; \
	esac

export.ext: ${KOBJ}
	${LD} -o export.ext -eexport ${IMPORTS} ${KOBJ} ${EXPORTS} -lcsys

export64.ext: export64.o symtab64.o
	${LD} -b64 -o export64.ext -eexport ${IMPORTS} export64.o symtab64.o \
		-bexport:export64.exp -lcsys

export.ext.nonfs: export.nonfs.o symtab.o
	${LD} -o export.ext.nonfs -eexport ${IMPORTS} export.nonfs.o \
		symtab.o ${EXPORTS} -lcsys

export64.ext.nonfs: export64.nonfs.o symtab64.o
	${LD} -b64 -o export64.ext.nonfs -eexport ${IMPORTS} export64.nonfs.o \
		symtab64.o -bexport:export64.exp -lcsys

symtab.o symtab64.o: ${srcdir}/symtab.c
	case ${SYS_NAME} in \
	rs_aix4* ) \
		${CC} ${CFLAGS} -c ${srcdir}/symtab.c ;; \
	rs_aix5* ) \
		${CC} ${CFLAGS} -q64 -D__XCOFF64__ -DAFS_64BIT_KERNEL -DAFS_AIX51_ENV -c ${srcdir}/symtab.c ; \
		mv symtab.o symtab64.o ; \
		${CC} ${CFLAGS} -DAFS_AIX51_ENV -c ${srcdir}/symtab.c ;; \
	esac

export.o export64.o: ${srcdir}/export.c
	case ${SYS_NAME} in \
	rs_aix4* ) \
		${CC} ${CFLAGS} -c ${srcdir}/export.c ;; \
	rs_aix5* ) \
		${CC} ${CFLAGS} -q64 -D__XCOFF64__ -DAFS_64BIT_KERNEL -DAFS_AIX51_ENV -c ${srcdir}/export.c ; \
		mv export.o export64.o ; \
		${CC} ${CFLAGS} -DAFS_AIX51_ENV -c ${srcdir}/export.c ;; \
	esac
               
export.nonfs.o export64.nonfs.o: ${srcdir}/export.c
	case ${SYS_NAME} in \
	rs_aix4* ) \
		${CC} ${INCS} -DAFS_NONFSTRANS -c ${srcdir}/export.c ;; \
	rs_aix5* ) \
		${CC} -q64 ${INCS} -D__XCOFF64__ -DAFS_64BIT_KERNEL -DAFS_NONFSTRANS -DAFS_AIX51_ENV -c ${srcdir}/export.c ; \
		mv export.o export64.nonfs.o ; \
		${CC} ${INCS} -DAFS_NONFSTRANS -DAFS_AIX51_ENV -c ${srcdir}/export.c ;; \
	esac
	-mv export.o export.nonfs.o

cfgexport: cfgexport.o
	${CC} -g ${INCS} -o cfgexport cfgexport.o

cfgexport64: cfgexport64.o
	${CC} -g ${INCS} -q64 -o cfgexport64 cfgexport64.o

cfgafs: cfgafs.o
	${CC} ${INCS} -o cfgafs cfgafs.o

cfgafs64: cfgafs64.o
	${CC} -g ${INCS} -q64 -o cfgafs64 cfgafs64.o

cfgexport64.o: ${srcdir}/cfgexport.c AFS_component_version_number.c
	${CC} -g -q64 ${CFLAGS} -D__XCOFF64__ -c ${srcdir}/cfgexport.c -o cfgexport64.o

cfgexport.o: ${srcdir}/cfgexport.c AFS_component_version_number.c
cfgafs.o: ${srcdir}/cfgafs.c AFS_component_version_number.c
cfgafs64.o: ${srcdir}/cfgafs.c AFS_component_version_number.c
	${CC} -q64 ${CFLAGS} -c ${srcdir}/cfgafs.c -o cfgafs64.o

clean:
	$(RM) -f *.o *.Zlst *.map *.out cfgexport cfgafs *.ext AFS_component_version_number.c export.exp export64.exp

${DEST}/root.client/usr/vice/etc/dkload/export.ext: export.ext
	${INSTALL} $? $@

${DEST}/root.client/usr/vice/etc/dkload/export64.ext: @AIX64@export64.ext
@AIX64@	${INSTALL} $? $@

${DEST}/root.client/usr/vice/etc/dkload/export.ext.nonfs: export.ext.nonfs
	${INSTALL} $? $@

${DEST}/root.client/usr/vice/etc/dkload/export64.ext.nonfs: @AIX64@export64.ext.nonfs
@AIX64@	${INSTALL} $? $@

${DEST}/lib/afs/export.exp: export.exp
	${INSTALL} $? $@

${DEST}/lib/afs/export64.exp: export64.exp
	${INSTALL} $? $@

${DESTDIR}${libdir}/afs/export.exp: export.exp
	${INSTALL} $? $@ 

${DESTDIR}${libdir}/afs/export64.exp: export64.exp
	${INSTALL} $? $@ 

${TOP_LIBDIR}/export.exp: export.exp
	${INSTALL} $? $@

${TOP_LIBDIR}/export64.exp: export64.exp
	${INSTALL} $? $@

${DEST}/lib/afs/extras.exp: ${srcdir}/extras.exp
	${INSTALL} $? $@

${DESTDIR}${libdir}/afs/extras.exp: ${srcdir}/extras.exp
	${INSTALL} $? $@


${TOP_LIBDIR}/extras.exp: ${srcdir}/extras.exp
	${INSTALL} $? $@


${DEST}/root.client/usr/vice/etc/dkload/cfgexport: cfgexport
	${INSTALL} $? $@

${DEST}/root.client/usr/vice/etc/dkload/cfgexport64: @AIX64@cfgexport64
@AIX64@	${INSTALL} $? $@

${DEST}/root.client/usr/vice/etc/dkload/cfgafs: cfgafs
	${INSTALL} $? $@

${DEST}/root.client/usr/vice/etc/dkload/cfgafs64: @AIX64@cfgafs64
@AIX64@	${INSTALL} $? $@

dest:    ${DEST}/root.client/usr/vice/etc/dkload/export.ext \
	${DEST}/root.client/usr/vice/etc/dkload/export.ext.nonfs \
	${DEST}/root.client/usr/vice/etc/dkload/export64.ext.nonfs \
	${DEST}/lib/afs/export.exp \
	${DEST}/lib/afs/export64.exp \
	${DEST}/lib/afs/extras.exp \
	${DEST}/root.client/usr/vice/etc/dkload/cfgexport \
	${DEST}/root.client/usr/vice/etc/dkload/cfgafs \
	${DEST}/root.client/usr/vice/etc/dkload/export64.ext \
	${DEST}/root.client/usr/vice/etc/dkload/cfgexport64 \
	${DEST}/root.client/usr/vice/etc/dkload/cfgafs64 
