#
# Imakefile for Discuss libraries libds.a and libdsk.a.
#

/* -I../utils  is a hack to find ss/ss.h, etc */
INCLUDES= -I$(UTILINCDIR) -I../ets -I../utils

SRCS	= tfile.c tunix.c tnet.c stubs.c dsname.c interface.c \
	rpcall.c conv_mgr.c host.c announce.c res_module.c \
	auth_krb.c dsc_enter.c auth_dum.c tmem.c edit.c

# Object files common to libds and libdsk
COMOBJS	= tfile.o tunix.o tnet.o stubs.o dsname.o interface.o rpcall.o \
	conv_mgr.o host.o announce.o dsc_enter.o tmem.o edit.o

# Object files specific to libds or libdsk
DSKOBJS	= res_module.k.o auth_krb.o $(KRBET)
DSOBJS	= res_module.nk.o auth_dum.o

ETS 	= $(ETDIR)/rpc_et.o $(ETDIR)/usp_et.o $(ETDIR)/dsc_et.o
UP_ETS 	= ../$(ETDIR)/rpc_et.o ../$(ETDIR)/dsc_et.o


# I can't really use a GeneralExtendedLibraryTarget here, because the
# external object files have to have an extra ../ in front of them for
# the profiled version.


ExtendedNormalLibraryTarget(ds, $(COMOBJS) $(DSOBJS), $(ETS))
ExtendedNormalLibraryTarget(dsk, $(COMOBJS) $(DSKOBJS), $(ETS))
LintLibraryTarget(ds, $(SRCS))

#ifdef BuildProfiledLibraries
ExtendedProfiledLibraryTarget(ds, $(COMOBJS) $(DSOBJS), $(UP_ETS))
ExtendedProfiledLibraryTarget(dsk, $(COMOBJS) $(DSKOBJS), $(UP_ETS))
#endif

InstallGeneralLibrary(ds, $(DSLIBDIR))
InstallGeneralLibrary(dsk, $(DSLIBDIR))

GeneralLibraryObjectRule()

# Generalizing these is insanely complicated.  Inline! :-)
#ifdef BuildProfiledLibraries
res_module.k.o: res_module.c
	rm -f res_module.k.o res_module.o profiled/res_module.k.o
	$(CC) $(CFLAGS) -DKERBEROS -c -pg res_module.c
	mv res_module.o profiled/res_module.k.o
	$(CC) $(CFLAGS) -DKERBEROS -c res_module.c
	mv res_module.o res_module.k.o
#else
res_module.k.o: res_module.c
	$(CC) $(CFLAGS) -DKERBEROS -c res_module.c
	mv res_module.o res_module.k.o
#endif

#ifdef BuildProfiledLibraries
res_module.nk.o: res_module.c
	rm -f res_module.nk.o res_module.o profiled/res_module.nk.o
	${CC} $(CFLAGS) -c -pg res_module.c
	mv res_module.o profiled/res_module.nk.o
	${CC} ${CFLAGS} -c res_module.c
	mv res_module.o res_module.nk.o
#else
res_module.nk.o: res_module.c
	${CC} ${CFLAGS} -c res_module.c
	mv res_module.o res_module.nk.o
#endif

DependTarget()
LintTarget()
