# @(#) $Revision: 78.1 $
#
# Common makefile for libsec/libprot
#
INC=/usr/include
LIBNAME=libprot

OBJECTS_BLS =	\
    accept_pw.o		\
    authaudit.o		\
    authcap.o		\
    data.o		\
    discr.o		\
    disk.o		\
    fields.o		\
    getdvagent.o	\
    getpasswd.o		\
    getprdfent.o	\
    getprfient.o	\
    getprlpent.o	\
    getprpwent.o	\
    getprtcent.o	\
    gsecerrno.o		\
    identity.o		\
    iscomsec.o		\
    map_ids.o		\
    passlen.o		\
    printbuf.o		\
    privileges.o	\
    psecerror.o		\
    randomword.o	\
    sec_errlst.o	\
    security.o		\
    seed.o		\
    subsystems.o	\
    tod.o 		\
    getspent.o

OBJECTS_COM =	\
    accept_pw.o		\
    authcap.o		\
    data.o		\
    discr.o		\
    fields.o		\
    getdvagent.o	\
    getpasswd.o		\
    getprdfent.o	\
    getprpwent.o	\
    getprtcent.o	\
    getspwent.o		\
    identity.o		\
    iscomsec.o		\
    map_ids.o		\
    passlen.o		\
    putspwent.o		\
    randomword.o	\
    seed.o		\
    tod.o 		\
    getspent.o		\
    write_sec.o

OBJS_COM_REENT =	\
    rgetspwent.o	\
    rgetprpwent.o

OBJECTS_SL_BLS = $(OBJECTS_BLS:.o=_sl.o)
OBJECTS_SL_COM = $(OBJECTS_COM:.o=_sl.o)
OBJS_SL_COM_REENT = $(OBJS_COM_REENT:.o=_sl.o)
HEADERS = accept_pw_msg.h identity_msg.h nl_accept_pw_msg.h nl_identity_msg.h

all: shared archive

all_com: shared_com archive_com 

archive:
	@$(MAKE) OBJS="$(OBJECTS_BLS)" DIR=tmp $(LIBNAME)

shared:	
	@$(MAKE) OBJS="$(OBJECTS_SL_BLS)" DIR=tmp_sl $(LIBNAME)


archive_com:
	@$(MAKE) OBJS="$(OBJECTS_COM) $(OBJS_COM_REENT)" DIR=tmp $(LIBNAME)

shared_com:	
	@$(MAKE) OBJS="$(OBJECTS_SL_COM) $(OBJS_SL_COM_REENT)" DIR=tmp_sl $(LIBNAME)

$(LIBNAME): $(OBJS)
	@echo "\tLinking objects to ../$(DIR)..."
	@if [ ! -d ../$(DIR) ]; then            \
            mkdir ../$(DIR) >/dev/null 2>&1;    \
	fi;                                     \
	exit 0
	@cd ../$(DIR); rm -f $(OBJS) OK.$@
	@ln $(OBJS) ../$(DIR)
	touch ../$(DIR)/OK.$@

#
# cleanup
#
clean:
	@echo Removing '*.o'
	@rm -f $(OBJECTS_BLS) $(OBJECTS_SL_BLS)

clean_com:
	@echo Removing '*.o'
	@rm -f $(OBJECTS_COM) $(OBJECTS_SL_COM) $(OBJS_COM_REENT) $(OBJS_SL_COM_REENT)

clobber:
	@echo "Clobbering is done by the top-level makefile"

#
# special cc invocations for shared library objects and archive objects
#
.SUFFIXES:	_sl.o

.c_sl.o:
	$(CC) -c $(CFLAGS) +z  $< -o $@

.c.o:
	$(CC) -c $(CFLAGS)  $< -o $@

#$(OBJECTS_BLS) $(OBJECTS_SL_BLS): \
	$(INC)/sys/types.h $(INC)/sys/security.h $(INC)/sys/audit.h \
	$(INC)/prot.h $(HEADERS)

$(OBJECTS_COM) $(OBJECTS_SL_COM): \
	$(INC)/sys/types.h $(INC)/hpsecurity.h $(INC)/sys/audit.h \
	$(INC)/prot.h $(HEADERS)

accept_pw.o accept_pw_sl.o:	\
		$(INC)/stdio.h $(INC)/pwd.h $(INC)/grp.h \
		$(INC)/ctype.h

authaudit.o authaudit_sl.o:	\
		$(INC)/stdio.h $(INC)/sys/stat.h

authcap.o authcap.o_ls:		\
		$(INC)/ctype.h $(INC)/stdio.h $(INC)/fcntl.h

discr.o discr_sl.o:		\
		$(INC)/pwd.h $(INC)/grp.h $(INC)/fcntl.h \
		$(INC)/stdio.h $(INC)/sys/stat.h

fields.o fields_sl.o:		\
		$(INC)/pwd.h $(INC)/stdio.h $(INC)/macros.h

getpasswd.o getpasswd_sl.o:	\
		$(INC)/stdio.h $(INC)/signal.h $(INC)/termio.h \
		$(INC)/macros.h

getprfient.o getprfient_sl.o:	\
		$(INC)/sys/dir.h $(INC)/stdio.h

getprdfent.o getprdfent_sl.o:	\
		$(INC)/stdio.h

getprpwent.o getprpwent_sl.o:	\
		$(INC)/pwd.h $(INC)/stdio.h

getprtcent.o getprtcent_sl.o:	\
		$(INC)/stdio.h

gsecerrno.o gsecerrno_sl.o:	\
		$(INC)/sys/secdefines.h $(INC)/sys/security.h \
		$(INC)/sys/auditsysc.h

identity.o identity_sl.o:	\
		$(INC)/stdio.h $(INC)/signal.h

iscomsec.o iscomsec_sl.o:	\
		$(INC)/sys/stat.h

passlen.o passlen_sl.o:		\
		$(INC)/math.h

psecerror.o psecerror_sl.o:	\
		$(INC)/sys/secdefines.h $(INC)/stdio.h

putspwent.o putspwent_sl.o:	\
		$(INC)/stdio.h $(INC)/pwd.h

randomword.o randomword_sl.o:	\
		$(INC)/stdio.h $(INC)/pwd.h $(INC)/grp.h \
		$(INC)/macros.h

sec_errlst.o sec_errlst_sl.o:	\
		$(INC)/sys/secdefines.h

seed.o seed_sl.o:		\
		$(INC)/stdio.h

tod.o tod_sl.o:			\
		$(INC)/stdio.h

write_sec.o write_sec_sl.o:	\
		$(INC)/stdio.h

nl_accept_pw_msg.h: accept_pw_msg.h
		-findstr accept_pw_msg.h > accept_pw_msg.str
		insertmsg accept_pw_msg.str > ../accept_pw_msg.msg

nl_identity_msg.h: identity_msg.h
		-findstr identity_msg.h > identity_msg.str
		insertmsg -n51 identity_msg.str > ../identity_msg.msg

# --------------------------
# special rules            
# --------------------------

getspwent.o 		\
getspwent_sl.o:	getspwent.c
	$(CC) $(CFLAGS) -c +z -D_THREAD_SAFE -D_REENTRANT -D_CMA_NOWRAPPERS -D_CMA_HP_INT_NONANSI getspwent.c -o $@

rgetspwent.o 		\
rgetspwent_sl.o: getspwent.c
	$(CC) $(CFLAGS) +z  -D_THREAD_SAFE -D_REENTRANT -D_CMA_NOWRAPPERS -D_CMA_HP_INT_NONANSI -D_REENTRANT_FUNCTIONS -c getspwent.c -o $@

rgetprpwent.o		\
rgetprpwent_sl.o: getprpwent.c
	$(CC) $(CFLAGS) +z  -D_THREAD_SAFE -D_REENTRANT -D_CMA_NOWRAPPERS -D_CMA_HP_INT_NONANSI -D_REENTRANT_FUNCTIONS -c getprpwent.c -o $@
