/*
** Rebuild message file whenever any message source file changes.
** Must recompile all sources, not just the changed ones, since the
** message file is not updateable and must be entirely re-created.
**
** History:
**	05-apr-1990 (boba)
**		Change fe.msg to fe.cat.msg to avoid conflict of
**		resulting header with fe.h in front.  This file is
**		generated with the mkfecat tool.  Build 6.2 version of
**		message files using ercompile62.  Copy 6.2 versions to
**		6.1 versions since, for UNIX ports, the 6.2 version was
**		used starting with 6.1.
**	03-oct-1990 (sandyd)
**		As of 6.3/03, yet another .mnx file format was introduced
**		(since the bucket limit of the slow_v2.mnx was insufficient
**		to hold all the messages we now have).  But because there
**		are too many messages now, we can no longer generate old-format
**		.mnx files from current .msg source.  (The old .msg source
**		will have to be retained as well as the old ercompile source.)
**		For now, all we can build are the *_v3's, and I've changed
**		this MINGS file to have the *_v3 targets.
**	08-oct-1990 (sandyd)
**		Added conditional setting of GENERRNAME (thanks to fpang) so
**		that this MINGS file will work for both Development and
**		Porting directory structures.
**	05-nov-1990 (sandyd)
**		Merged ingres63p r1.5 with 27-sep-1990 (jonb) ingres6302p 
**		change 340126:  Copy the generr.h file to the deliverables 
**		area, being as it's deliverable.
**	04-dec-1990 (sandyd)
**		Let's ercompile ALL the .msg files that now exist here.  Some
**		of these (ergwf.msg, errqf.msg, ertpf.msg) are just for STAR
**		and gateways, so they are irrelevant to 6.3/03 UNIX, but it
**		can't hurt to get them into the ercompile list now so that this
**		won't get overlooked when they do become relevant.
**      30-jul-92 (pholman)
**		Add SXF message file (for C2, Security Extensions)
**	9-sep-92 (daveb)
**		Add GLF message file
**	31-oct-92 (andre)
**	    replace -g<gen err file> with -q<sqlstate file>; .mnx format's 
**	    changing, so rename .mnx files to fast_v4.mnx $(INGMSG)/slow_v4.mnx
**	18-jan-93 (dianeh)
**		Reinstated the generr.h target that was deleted in previous
**		change; modified so it behaves correctly (and really builds
**		the files if they're not there.)
**	12-feb-93 (dianeh)
**		Added individual targets for generated .h files; removed
**		SOURCES symbol; changed dependency for {fast,slow}_v4.mnx
**		to be just the concatenated msg file; changed the commands
**		for the {fast,slow}_v4.mnx targets to just generate the
**		target file, not any header files; corrected name of the
**		dudbms header source file name (should be .qsh not .qh).
**	19-feb-93 (dianeh)
**		Reintroduced the "SOURCES" symbol (but call it MSGFILES)
**		so that backend-only builds will work correctly (also
**		alphabetized the list of .msg files).
**	19-feb-93 (dianeh)
**		Corrected where the MSGFILES symbol goes on the ercompile
**		command line.
**	17-jun-1993 (dianeh)
**		Removed most of the .HDR targets for .msg files -- only
**		those that are actually used should bother to be built.
**	17-oct-93 (peterk)
**		Remove targets for baroque before copying
**	24-nov-93 (dianeh)
**		Added links for *.mnx file in $INGINSTALL -- needed for
**		being able to bring up build-environment "installations".
**	14-dec-93 (peterk)
**		remove targets unconditionally before building them;
**		the #ifdef BAROQUE was not working.
**	07-jan-94 (tyler)
**		Don't create links to *.mnx $INGINSTALL - no longer needed. 
**	10-may-95 (hanch04)
**		added api.h
**	12-may-95 (hanch04)
**		removed api.h, changed to raat.h
**	24-Jul-95 (gordy)
**		Added AIF message file.
**	20-Jan-97 (gordy)
**		Added OpenAPI (AIF) header file.
**	03-Aug-1998 (fanra01)
**		Add ddf message file, urs and wsf message files.
**	20-aug-1999 (somsa01)
**		Added iiapicc.h .
**	20-aug-1999 (somsa01)
**		Added iiapicc.h .
**	23-Mar-00 (gordy)
**		Added JDBC message file.
**	30-may-01 (thoda04)
**		Added ODBC message file.
*/

$(BAROQUE:T=N)SQLSTATENAME = $(ING_SRC)/common/hdr/hdr/sqlstate.h
$(BAROQUE:T=V)SQLSTATENAME = $(ING_SRC)/common/hdr/$(ING_VERS)/hdr/sqlstate.h

MSGFILES = \
	eradf.msg eraif.msg erclf.msg erdmf.msg erddf.msg erduf.msg ergcf.msg \
	erglf.msg ergwf.msg eropf.msg erpsf.msg erqef.msg erqsf.msg errdf.msg \
	errqf.msg erscf.msg ersxf.msg ertpf.msg erulf.msg erurs.msg erusf.msg \
	erwsf.msg erjdbc.msg erodbc.msg fe.cat.msg

files : $(INGFILES)/raat.h $(INGFILES)/generr.h $(INGFILES)/sqlstate.h \
        $(INGFILES)/iiapi.h $(INGFILES)/iiapicc.h $(INGMSG)/fast_v4.mnx \
	$(INGMSG)/slow_v4.mnx

dudbms.h :: dudbms.qsh .HDR
erclf.h :: erclf.msg .HDR
erddf.h :: erddf.msg .HDR
erglf.h :: erglf.msg .HDR
erodbc.h:: erodbc.msg .HDR
erscf.h :: erscf.msg .HDR
erurs.h :: erurs.msg .HDR
erusf.h :: erusf.msg .HDR
erwsf.h :: erwsf.msg .HDR

$(INGFILES)/raat.h : raat.h
	$(RM) -f $(<)
	$(CP) $(>) $(<)
	$(CHMOD) $(FILEMODE) $(<)

$(INGFILES)/generr.h : generr.h
	$(RM) -f $(<)
	$(CP) $(>) $(<)
	$(CHMOD) $(FILEMODE) $(<)

$(INGFILES)/sqlstate.h : sqlstate.h
	$(RM) -f $(<)
	$(CP) $(>) $(<)
	$(CHMOD) $(FILEMODE) $(<)

$(INGFILES)/iiapi.h : iiapi.h
	$(RM) -f $(<)
	grep -v "^##" $(>) > $(<)
	$(CHMOD) $(FILEMODE) $(<)

$(INGFILES)/iiapicc.h : iiapicc.h
	$(RM) -f $(<)
	grep -v "^##" $(>) > $(<)
	$(CHMOD) $(FILEMODE) $(<)

$(INGMSG)/fast_v4.mnx : $(MSGFILES)
	@
	$(RM) -f $(<)
	$(ERCOMPILE) -q$(SQLSTATENAME) -f$(<) $(MSGFILES)
	chmod $(FILEMODE) $(<)

$(INGMSG)/slow_v4.mnx : $(MSGFILES)
	@
	$(RM) -f $(<)
	$(ERCOMPILE) -q$(SQLSTATENAME) -s$(<) $(MSGFILES)
	chmod $(FILEMODE) $(<)

