###############################################################################
##  MAK\SQL\FCLT.NMK
##
##    Project: FACILITOR
##
##             (c) 1996-2022 Aareon Nederland B.V.
##
##   Auteur:    Ir. P.G. Feij
##   $Revision$
##   $Id$
##
##      Makefile for SQL-DDL scripts for Oracle/Facilitor
##          Generates some scripts like FILE.SQL and FILE_.SQL
##          where FILE is the (wrapped) runtime version
##          and FILE_ is the unwrapped version to be archived
##
##          Create intial scripts as well as the latest upgrade
##
###############################################################################
##    REQUIRES:
##
##        NMAKE.EXE (requires NMAKE.EXE)
##             Microsoft (R) Program Maintainance Utility Version 1.11
##        CL.EXE
##             Microsoft (R) C Optimizing Compiler Version 6.00A
##             -for precompiling only-
##        WRAP.EXE (12.1.0.2.0 or better) from Oracle
##             needs to be available in searchpath (by Oracle Client Installer)
##
##        SED.EXE
##             GNU sed version 4.2
##             Copyright (C) 2003 Free Software Foundation, Inc.
##
##        Some of these to be found in ..\MAKTOOLS
##
##    Uses (external) defines: None
##
##    Note: If new modules are added, all source have to be mentioned separately,
##          which is quite obvious from the existing usage in this file..
##
##    Note: For each new schema version (release) the from and to version must be
##          mentioned explicitly, which is a pity but it makes sense too
##
###############################################################################
##
##    Steps performed are:
##          All files are preprocessed using intermediate temp files
##          and then combined into final scripts.

#############
##
## Directories
##
#############
PROJSRC=.
PROJEXE=z:\Project\FACILITOR\BUILD

### SOURCE DEFINES (gets info from commandline) ###

##
## New style using schemanumbers
##
CURRENTVERSION=51
NEXTVERSION=52
FILEVERSION=a
NEXTROOT=DB$(NEXTVERSION)$(FILEVERSION)
CURRENTUPDATE=DB$(CURRENTVERSION)to$(NEXTVERSION)

UPROOT=$(PROJSRC)\_UP
SRCUPDATE=$(UPROOT)\$(CURRENTUPDATE)
SRCRECREA=$(UPROOT)\recreate
##
## PATH DEFINES
##
MAK=.

##
## Source rootdirectory
##
MSRC=$(PROJSRC)
INC=/I$(PROJSRC)
EXE=$(PROJEXE)

### TOOL DEFINES (gets info from OS-environment)  ###

PRECOMP=$(MAKTOOLS)\CL
## WRAP1=$(MAKTOOLS)\WRAP.EXE
WRAP1=WRAP.EXE
PRECOMP_OPTIONS=/EP /D_VER=$(CURRENTUPDATE)$(FILEVERSION) /D_DBV=$(NEXTVERSION)$(FILEVERSION)
CLEANUP1=$(MAKTOOLS)\sedclean.bat

##
## DEPENDENCIES
##

.SUFFIXES: .SRC

##
## RESULTS
##
all:    $(EXE)\$(NEXTROOT)\FCLT$(NEXTVERSION)$(FILEVERSION).SQL \
        $(EXE)\$(NEXTROOT)\RECRE$(NEXTVERSION)$(FILEVERSION).SQL \
        $(EXE)\$(NEXTROOT)\$(CURRENTUPDATE)$(FILEVERSION).SQL

##
## DEPENDENCIES AND ACTIONS
##
$(EXE)\$(NEXTROOT)\FCLT$(NEXTVERSION)$(FILEVERSION).SQL:   \
      $(MAK)\fclt.nmk           \
      $(MSRC)\fclt.src          \
      $(MSRC)\modules.h         \
      $(MSRC)\comsql.h          \
      $(MSRC)\adm\adm_tab.src   \
      $(MSRC)\adm\adm_pac.src   \
      $(MSRC)\alg\algsql.h      \
      $(MSRC)\ins\inssql.h      \
      $(MSRC)\alg\alg_ind.src   \
      $(MSRC)\alg\alg_ini.src   \
      $(MSRC)\alg\alg_pac.src   \
      $(MSRC)\alg\alg_seq.src   \
      $(MSRC)\alg\alg_tab.src   \
      $(MSRC)\alg\alg_tri.src   \
      $(MSRC)\alg\alg_vie.src   \
      $(MSRC)\aut\aut_ind.src   \
      $(MSRC)\aut\aut_seq.src   \
      $(MSRC)\aut\aut_tab.src   \
      $(MSRC)\aut\aut_tri.src   \
      $(MSRC)\aut\aut_ini.src   \
      $(MSRC)\bes\bes_ind.src   \
      $(MSRC)\bes\bes_ini.src   \
      $(MSRC)\bes\bes_pac.src   \
      $(MSRC)\bes\bes_seq.src   \
      $(MSRC)\bes\bes_tab.src   \
      $(MSRC)\bes\bes_tri.src   \
      $(MSRC)\bes\bes_vie.src   \
      $(MSRC)\bez\bez_ind.src   \
      $(MSRC)\bez\bez_ini.src   \
      $(MSRC)\bez\bez_pac.src   \
      $(MSRC)\bez\bez_seq.src   \
      $(MSRC)\bez\bez_tab.src   \
      $(MSRC)\bez\bez_tri.src   \
      $(MSRC)\bez\bez_vie.src   \
      $(MSRC)\bgt\bgt_ind.src   \
      $(MSRC)\bgt\bgt_ini.src   \
      $(MSRC)\bgt\bgt_pac.src   \
      $(MSRC)\bgt\bgt_seq.src   \
      $(MSRC)\bgt\bgt_tab.src   \
      $(MSRC)\bgt\bgt_tri.src   \
      $(MSRC)\bgt\bgt_vie.src   \
      $(MSRC)\cad\cad_ind.src   \
      $(MSRC)\cad\cad_ini.src   \
      $(MSRC)\cad\cad_pac.src   \
      $(MSRC)\cad\cad_seq.src   \
      $(MSRC)\cad\cad_tab.src   \
      $(MSRC)\cad\cad_tri.src   \
      $(MSRC)\cad\cad_vie.src   \
      $(MSRC)\cnd\cnd_tab.src   \
      $(MSRC)\cnd\cnd_pac.src   \
      $(MSRC)\cnd\cnd_tri.src   \
      $(MSRC)\cnd\cnd_vie.src   \
      $(MSRC)\cnt\cnt_ind.src   \
      $(MSRC)\cnt\cnt_ini.src   \
      $(MSRC)\cnt\cnt_pac.src   \
      $(MSRC)\cnt\cnt_seq.src   \
      $(MSRC)\cnt\cnt_tab.src   \
      $(MSRC)\cnt\cnt_tri.src   \
      $(MSRC)\cnt\cnt_vie.src   \
      $(MSRC)\ctr\ctr_ind.src   \
      $(MSRC)\ctr\ctr_ini.src   \
      $(MSRC)\ctr\ctr_pac.src   \
      $(MSRC)\ctr\ctr_seq.src   \
      $(MSRC)\ctr\ctr_tab.src   \
      $(MSRC)\ctr\ctr_tri.src   \
      $(MSRC)\ctr\ctr_vie.src   \
      $(MSRC)\ctr\ctr_lcl.src   \
      $(MSRC)\exc\exc_ind.src   \
      $(MSRC)\exc\exc_seq.src   \
      $(MSRC)\exc\exc_tri.src   \
      $(MSRC)\exc\exc_tab.src   \
      $(MSRC)\exc\exc_seq.src   \
      $(MSRC)\exc\exc_pac.src   \
      $(MSRC)\exc\exc_ini.src   \
      $(MSRC)\fac\fac_ind.src   \
      $(MSRC)\fac\fac_ini.src   \
      $(MSRC)\fac\fac_lcl.src   \
      $(MSRC)\fac\fac_lclhints.src \
      $(MSRC)\fac\fac_set.src   \
      $(MSRC)\fac\fac_pac.src   \
      $(MSRC)\fac\fac_paca.src  \
      $(MSRC)\fac\fac_pacano.src   \
      $(MSRC)\fac\fac_pacx.src  \
      $(MSRC)\fac\fac_pacf.src  \
      $(MSRC)\fac\fac_pacl.src  \
      $(MSRC)\fac\fac_pacflex.src  \
      $(MSRC)\fac\fac_pacdel.src  \
      $(MSRC)\fac\fac_pactsk.src  \
      $(MSRC)\fac\fac_seq.src   \
      $(MSRC)\fac\fac_tab.src   \
      $(MSRC)\fac\fac_tri.src   \
      $(MSRC)\fac\fac_vie.src   \
      $(MSRC)\fac\fac_vieexp.src \
      $(MSRC)\ini\ini_ind.src   \
      $(MSRC)\ini\ini_ini.src   \
      $(MSRC)\ini\ini_pac.src   \
      $(MSRC)\ini\ini_seq.src   \
      $(MSRC)\ini\ini_tab.src   \
      $(MSRC)\ini\ini_tri.src   \
      $(MSRC)\ini\fmis\fmis_ini.sql   \
      $(MSRC)\ini\itsm\itsm_ini.sql   \
      $(MSRC)\ini\plat\plat_ini.sql   \
      $(MSRC)\ins\ins_ind.src   \
      $(MSRC)\ins\ins_ini.src   \
      $(MSRC)\ins\ins_lcl.src   \
      $(MSRC)\ins\ins_pac.src   \
      $(MSRC)\ins\ins_seq.src   \
      $(MSRC)\ins\ins_tab.src   \
      $(MSRC)\ins\ins_tri.src   \
      $(MSRC)\ins\ins_vie.src   \
      $(MSRC)\kpi\kpi_ind.src   \
      $(MSRC)\kpi\kpi_ini.src   \
      $(MSRC)\kpi\kpi_pac.src   \
      $(MSRC)\kpi\kpi_seq.src   \
      $(MSRC)\kpi\kpi_tab.src   \
      $(MSRC)\kpi\kpi_tri.src   \
      $(MSRC)\kpi\kpi_vie.src   \
      $(MSRC)\mld\mld_ind.src   \
      $(MSRC)\mld\mld_ini.src   \
      $(MSRC)\mld\mld_lcl.src   \
      $(MSRC)\mld\mld_pac.src   \
      $(MSRC)\mld\mld_seq.src   \
      $(MSRC)\mld\mld_tab.src   \
      $(MSRC)\mld\mld_typ.src   \
      $(MSRC)\mld\mld_tri.src   \
      $(MSRC)\mld\mld_vie.src   \
      $(MSRC)\mrk\mrk_ind.src   \
      $(MSRC)\mrk\mrk_ini.src   \
      $(MSRC)\mrk\mrk_pac.src   \
      $(MSRC)\mrk\mrk_seq.src   \
      $(MSRC)\mrk\mrk_tab.src   \
      $(MSRC)\mrk\mrk_tri.src   \
      $(MSRC)\mrk\mrk_vie.src   \
      $(MSRC)\msg\msg_ind.src   \
      $(MSRC)\msg\msg_ini.src   \
      $(MSRC)\msg\msg_pac.src   \
      $(MSRC)\msg\msg_seq.src   \
      $(MSRC)\msg\msg_tab.src   \
      $(MSRC)\msg\msg_tri.src   \
      $(MSRC)\msg\msg_vie.src   \
      $(MSRC)\fin\fin_ind.src   \
      $(MSRC)\fin\fin_ini.src   \
      $(MSRC)\fin\fin_pac.src   \
      $(MSRC)\fin\fin_seq.src   \
      $(MSRC)\fin\fin_tab.src   \
      $(MSRC)\fin\fin_tri.src   \
      $(MSRC)\fin\fin_vie.src   \
      $(MSRC)\prj\prj_ind.src   \
      $(MSRC)\prj\prj_ini.src   \
      $(MSRC)\prj\prj_pac.src   \
      $(MSRC)\prj\prj_seq.src   \
      $(MSRC)\prj\prj_tab.src   \
      $(MSRC)\prj\prj_tri.src   \
      $(MSRC)\prj\prj_vie.src   \
      $(MSRC)\prs\prs_ind.src   \
      $(MSRC)\prs\prs_ini.src   \
      $(MSRC)\prs\prs_pac.src   \
      $(MSRC)\prs\prs_seq.src   \
      $(MSRC)\prs\prs_tab.src   \
      $(MSRC)\prs\prs_tri.src   \
      $(MSRC)\prs\prs_vie.src   \
      $(MSRC)\res\res_ind.src   \
      $(MSRC)\res\res_ini.src   \
      $(MSRC)\res\res_lcl.src   \
      $(MSRC)\res\res_pac.src   \
      $(MSRC)\res\res_seq.src   \
      $(MSRC)\res\res_tab.src   \
      $(MSRC)\res\res_tri.src   \
      $(MSRC)\res\res_vie.src   \
      $(MSRC)\web\web_ind.src   \
      $(MSRC)\web\web_ini.src   \
      $(MSRC)\web\web_pac.src   \
      $(MSRC)\web\web_seq.src   \
      $(MSRC)\web\web_tab.src   \
      $(MSRC)\web\web_tri.src   \
      $(MSRC)\web\web_vie.src
 @IF NOT EXIST $(EXE)\$(NEXTROOT)\NUL mkdir $(EXE)\$(NEXTROOT)
 $(PRECOMP) $(PRECOMP_OPTIONS) $(MSRC)\fclt.src>$(TEMP)\$(*B)_.sql
 $(CLEANUP1) $(TEMP)\$(*B)_.sql
 COPY $(TEMP)\$(*B)_.sql $(EXE)\$(NEXTROOT)\FCLT$(NEXTVERSION)$(FILEVERSION)_.SQL
 $(WRAP1) iname=$(TEMP)\$(*B)_.sql oname=$(TEMP)\$(*B).sql
 COPY $(TEMP)\$(*B).sql $(EXE)\$(NEXTROOT)\FCLT$(NEXTVERSION)$(FILEVERSION).SQL

$(MSRC)\fac\_fac_lclmdl.src: \
    $(MSRC)\fac\fac_lclmdl.csv
 cscript /nologo $(MSRC)\fac\parse_fac_lclmld.js $** >$@

##########################################################################
#### UPDATES CONSIST OF UPDATE AND RECREATE scripts
##########################################################################
$(EXE)\$(NEXTROOT)\$(CURRENTUPDATE)$(FILEVERSION).SQL: \
      $(SRCUPDATE).src       \
      $(UPROOT)\prologue.inc \
      $(UPROOT)\epilogue.inc \
      $(MAK)\fclt.nmk        \
      $(MSRC)\fclt.src       \
      $(MSRC)\comsql.h       \
      $(EXE)\$(NEXTROOT)\FCLT$(NEXTVERSION)$(FILEVERSION).sql
 @IF NOT EXIST $(EXE)\$(NEXTROOT)\NUL mkdir $(EXE)\$(NEXTROOT)
 $(PRECOMP) $(PRECOMP_OPTIONS) $(SRCUPDATE).src>$(TEMP)\$(*B)_.sql
 $(CLEANUP1) $(TEMP)\$(*B)_.sql
 COPY $(TEMP)\$(*B)_.sql $(EXE)\$(NEXTROOT)\$(CURRENTUPDATE)$(FILEVERSION)_.SQL
 $(WRAP1) iname=$(TEMP)\$(*B)_.sql oname=$(TEMP)\$(*B).sql
 COPY $(TEMP)\$(*B).sql $(EXE)\$(NEXTROOT)\$(CURRENTUPDATE)$(FILEVERSION).SQL

$(EXE)\$(NEXTROOT)\RECRE$(NEXTVERSION)$(FILEVERSION).SQL: \
      $(SRCRECREA).src   \
      $(SRCRECREA).inc   \
      $(MAK)\fclt.nmk    \
      $(MSRC)\fclt.src   \
      $(MSRC)\comsql.h   \
      $(MSRC)\fac\fac_lcl.src   \
      $(MSRC)\fac\fac_lclhints.src \
      $(EXE)\$(NEXTROOT)\FCLT$(NEXTVERSION)$(FILEVERSION).sql
 @IF NOT EXIST $(EXE)\$(NEXTROOT)\NUL mkdir $(EXE)\$(NEXTROOT)
 $(PRECOMP) $(PRECOMP_OPTIONS) $(SRCRECREA).src>$(TEMP)\$(*B)_.sql
 $(CLEANUP1) $(TEMP)\$(*B)_.sql
 COPY $(TEMP)\$(*B)_.sql $(EXE)\$(NEXTROOT)\RECRE$(NEXTVERSION)$(FILEVERSION)_.SQL
 $(WRAP1) iname=$(TEMP)\$(*B)_.sql oname=$(TEMP)\$(*B).sql
 COPY $(TEMP)\$(*B).sql $(EXE)\$(NEXTROOT)\RECRE$(NEXTVERSION)$(FILEVERSION).SQL

## END-OF-FILE
