/*
** INGRES 6.0 special makefile for back/dmf
**
** History:
** 	23-aug-1990 (jonb)
**		Created.  Make partially linked iimerge.o, including
**		everything except the UDT code.
**	05-dec-1990 (bonobo)
**		Builds iimerge.o, conditionally builds iidbms.o	if SQSSPPSLIB is
**		defined (iidbms.o will be partially linked with	SQSSPPSLIB). 
**		Provides rules to build non-iimerged executables for debugging.
**		For example, if you wish to make a standalone lockstat, just say
**		"ming $ING_BUILD/bin/lockstat".
**	25-sep-1991 (mikem) integrated following change: 08-Jan-1991 (anton)
**		Reoreded library lists.  MALLOCLIB >MUST< be last and
**		COMPATLIB >MUST< be right before MALLOCLIB.
**		New ordering matches scdmain.c ming hint better.
**	25-sep-1991 (mikem) integrated following change: 25-mar-1991 (bonobo)
**		Added SDLIB; Won't link properly without it.
**	25-sep-1991 (mikem) integrated following change: 16_apr-1991 (kwatts)
**		Changed SDLIB additions so that only fully linked
**		executables have them (cf iiuseradt.o).
**	25-sep-1991 (mikem) integrated following change: 24-jun-91 (jonb)
**		Added cd to /tmp before creating temporary dmfmerge.o file.
**		On some SYSV platforms, ar won't extract into anything other
**		than the current directory.
**	25-sep-1991 (mikem) integrated following change: 15-aug-91 (mikem)
**		bug #39255
**		Added logstat to the list of "special" executables so that
**		this MINGS file can be used to build a separate "logstat"
**		(rather than just an iimerge).
**	25-sep-1991 (mikem) integrated following change: 11-Sep-91 (vijay)
**		Removed libs specified twice for ld.
**	25-sep-1991 (mikem) integrated following change: 12-Sep-91 (vijay)
**		BryanP points out that PSFLIB needs to be specified before
**		and after OPFLIB for one pass linkers to work.
**	30-jul-1992 (pholman)
**		Add SXFLIB to iimerge, to pull in C2 functions.
**	05-nov-92 (bonobo)
**		Add CUFLIB for andre's SQLSTATE project.
**	09-nov-92 (fpang)
**		Add RQFLIB and TPFLIB because Star is ready. Also added
**		rule to build iistar.
**	22-jan-1993 (bryanp)
**		rcpstat is now a DMF_MERGE executable.
**	19-mar-1993 (dianeh)
**		Modified to have real dependencies so that things only
**		rebuild when they need to; added some symbols and .USE
**		rules to simplify things.
**      14-sep-1993 (stevet)
**  	    	Added iiclsadt.o to the link commands.  
**      21-sep-1993 (stevet)
**  	        Fixed typo on link command for iidbms and cleaned up
**              other link commands to use the same file order.
**	5-jan-93 (peterk)
**		remove targets before building in the .DBMSEXE and .MERGEEXE
**		rules to avoid: 1) updating the underlying file to which a
**		symlink points; and/or 2) clobbering the paging file of a
**		running executable.
**	19-jan-93 (peterk)
**		remove iimerge.o target before building to avoid writing
**		through symlink; on Solaris ld does not move the file out
**		the way.
**	17-dec-97 (stephenb)
**		Add repstat program.
**      10-Oct-00 (hweho01)
**              Add CCLDSVRFLAGS to hold the special linker options 
**              for dbms server only.
**	06-Feb-2001 (hanje04)
**		As part of fix for SIR 103876, if USE_SHARED_SVR_LIBS=true
**		iimerge.o only needs to be dmfmerge.o rename. .SRVRDOTO
**		as been ammended to allow this.
**	09-Feb-2001 (hanje04)
**		Changed above change to use use_shared_svr_libs instead and
**		to source shlibinfo at the beginning of .SRVRDOTO. This is 
**		ming was not picking up the defn. of USE_SHARED_SVR_LIBS
**		from Mingbase.mk properly.
**	13-Feb-2001 (hanje04)
**		Added chmod to give iimerge.o the correct permissions
**		in the 'use_shared_svr_libs' part of .SRVRDOTO.
**      10-Jul-2001 (hweho01)
**              Replaced the hard coded option for ar and ld commands 
**              with AREXTRFLAGS and LDDMFFLAGS, allow platform specific  
**              entries. 
**	01-aug-2001 (toumi01)
**		i64_aix port included this change, which I believe was
**		done by stephenb and which 1. cannot be integrated in this
**		form and 2. is probably not necessary:
**		< ld -r -o $(<) dmfmerge.o $(SRVRLIBS)
**		> ld -f elf64 -r -o $(<) dmfmerge.o $(SRVRLIBS)
**	11-mar-2002 (somsa01)
**		Copied from MING64 for 64-bit add-on package.
**	2-feb-2004 (stephenb)
**	 	Fix SDLIB to SDLIB64 to allow target $ING_BUILD/bin/lp64/iidbms
**	  	to build.
**      28-apr-2004 (sheco02)
**              Swap the order of DBUTILLIB and DMFLIB in order for iimerg
**              to be properly linked and created.
*/

$(SQSPPSLIB:T=V)IIDBMSOBJ = $(INGLIB64)/iidbms.o 
$(SQSPPSLIB:T=N)IIDBMSOBJ = $(INGLIB64)/iimerge.o
$(SQSPPSLIB:T=N)LIBSXF = $(SXFLIB64)
$(SQSPPSLIB:T=V)LIBSXF =

SRVRLIBS = $(SCFLIB64) $(PSFLIB64) $(OPFLIB64) $(PSFLIB64) \
		$(RDFLIB64) $(QEFLIB64) $(QSFLIB64) $(DMFLIB64) \
		$(DBUTILLIB64) $(GWFLIB64) $(ADFLIB64) $(ULFLIB64) \
		$(TPFLIB64) $(RQFLIB64) $(GCFLIB64) $(LIBSXF) \
		$(CUFLIB64) $(COMPATLIB64) $(MALLOCLIB64) $(SQSPPSLIB)

files : $(IIDBMSOBJ)

.SRVRDOTO : .USE
	. shlibinfo
        if $use_shared_svr_libs
        then
        cd /tmp
        ar $(AREXTRFLAGS) $(DMFLIB64) dmfmerge.o
        $(RM) $(RMFLAGS) $(<)
        $(CP) dmfmerge.o $(<)
	$(CHMOD) $(FILEMODE) $(<)
        rm -f dmfmerge.o
        else
	cd /tmp
	ar $(AREXTRFLAGS) $(DMFLIB64) dmfmerge.o
	$(RM) $(RMFLAGS) $(<)
	ld $(LDDMFFLAGS) -o $(<) dmfmerge.o $(SRVRLIBS)
	$(CHMOD) $(FILEMODE) $(<)
	rm -f dmfmerge.o
	fi

$(IIDBMSOBJ) : $(SRVRLIBS) .SRVRDOTO

.DBMSEXE : .USE
	$(RM) $(RMFLAGS) $(<)
	$(CC) $(CCLDFLAGS) $(CCLDSVRFLAGS) -o $(<) $(IIDBMSOBJ) \
	$(SDLIB64) $(INGLIB64)/iiuseradt.o $(INGLIB64)/iiclsadt.o \
	$(LDLIBRARIES)
	$(CHMOD) 4$(EXEMODE) $(<)

.MERGEEXE : .USE
	$(RM) $(RMFLAGS) $(<)
	$(CC) $(CCLDFLAGS) -o $(<) $(INGLIB64)/iimerge.o $(SDLIB64) \
	$(INGLIB64)/iiuseradt.o $(INGLIB64)/iiclsadt.o $(LDLIBRARIES)
	$(CHMOD) 4$(EXEMODE) $(<)

$(INGBIN64)/iistar :  $(IIDBMSOBJ) $(INGLIB64)/iiuseradt.o \
			$(INGLIB64)/iiclsadt.o .DBMSEXE
$(INGBIN64)/iidbms :  $(IIDBMSOBJ) $(INGLIB64)/iiuseradt.o \
			$(INGLIB64)/iiclsadt.o .DBMSEXE
$(INGBIN64)/cacheutil : $(INGLIB64)/iimerge.o $(INGLIB64)/iiuseradt.o \
    	    	    	$(INGLIB64)/iiclsadt.o .MERGEEXE
$(INGBIN64)/dmfacp : $(INGLIB64)/iimerge.o $(INGLIB64)/iiuseradt.o \
    	    	    	$(INGLIB64)/iiclsadt.o .MERGEEXE
$(INGBIN64)/dmfjsp : $(INGLIB64)/iimerge.o $(INGLIB64)/iiuseradt.o \
    	    	    	$(INGLIB64)/iiclsadt.o .MERGEEXE
$(INGBIN64)/dmfrcp : $(INGLIB64)/iimerge.o $(INGLIB64)/iiuseradt.o \
    	    	    	$(INGLIB64)/iiclsadt.o .MERGEEXE
$(INGBIN64)/lartool : $(INGLIB64)/iimerge.o $(INGLIB64)/iiuseradt.o \
    	    	    	$(INGLIB64)/iiclsadt.o .MERGEEXE
$(INGBIN64)/lockstat : $(INGLIB64)/iimerge.o $(INGLIB64)/iiuseradt.o \
    	    	    	$(INGLIB64)/iiclsadt.o .MERGEEXE
$(INGBIN64)/logdump : $(INGLIB64)/iimerge.o $(INGLIB64)/iiuseradt.o \
    	    	    	$(INGLIB64)/iiclsadt.o .MERGEEXE
$(INGBIN64)/logstat : $(INGLIB64)/iimerge.o $(INGLIB64)/iiuseradt.o \
    	    	    	$(INGLIB64)/iiclsadt.o .MERGEEXE
$(INGBIN64)/rcpstat : $(INGLIB64)/iimerge.o $(INGLIB64)/iiuseradt.o \
    	    	    	$(INGLIB64)/iiclsadt.o .MERGEEXE
$(INGBIN64)/rcpconfig : $(INGLIB64)/iimerge.o $(INGLIB64)/iiuseradt.o \
    	    	    	$(INGLIB64)/iiclsadt.o .MERGEEXE
$(INGBIN64)/repstat : $(INGLIB64)/iimerge.o $(INGLIB64)/iiuseradt.o \
    	    	    	$(INGLIB64)/iiclsadt.o .MERGEEXE
