;----------------------------------------------------------------------------
;
;    MODULE NAME:   MAKEMSI.MMH
;
;        $Author: gao $
;      $Revision: 9888 $
;          $Date: 2004-12-20 14:59:16 -0600 (Mon, 20 Dec 2004) $
;       $Logfile:   C:/DBAREIS/Projects.PVCS/Win32/MakeMsi/MakeMsi.mmh.pvcs  $
;      COPYRIGHT:   (C)opyright Dennis Bareis, Australia, 2003
;                   All rights reserved.
;
;    DESCRIPTION:   This is the main ("ENTRY POINT") header that can be
;                   used to make or update MSI files.
;
;                   Do NOT touch this file it is included by your script!
;
;                   No VB knowledge is required.
;
;                   Note that it is expected that users will use MSIVAL2
;                   to validate any generated MSIs.
;----------------------------------------------------------------------------

;--- Load MAKEMSI version number --------------------------------------------
#include "MmVersion.mmh"

;--- Output copyright -------------------------------------------------------
#define? MAKEMSI_HOMEPAGE <?PpwizardAuthorBaseWebDir>makemsi.htm
#info ^MAKEMSI version <$MAKEMSI_VERSION>^
#info ^(C)opyright Dennis Bareis, Australia (2003-2004)^
#info ^All rights reserved.^
#info ^See "<$MAKEMSI_HOMEPAGE>"^

;--- Need specific version of PPWIZARD? -------------------------------------
#require "03.300"               ;;"ConsoleCount()"

;--- On NT based operating system? ------------------------------------------
#if pos('COMMAND.COM', '<??*COMSPEC>') <> 0
   ;--- DOS -----------------------------------------------------------------
   #define IsDos                           ;;Win95, 95, ME
   #define Stderr2Out                      ;;Can't do in DOS
   #define Cmd.EXE        command.com
   #define? VALID_ValidateTheGeneratedMsi \
            #Info ^Can't validate the generated MSI under DOS (Please use ORCA for validation)...^
#elseif
   ;--- NT ------------------------------------------------------------------
   #define IsNT                            ;;Windows NT4, 2000, XP, ?
   #define Stderr2Out     2>&1
   #define Cmd.EXE        cmd.exe
#endif

;--- Defaults ---------------------------------------------------------------
#RexxVar  RxGeneratedKeySuffix = ''
#define?  MAKEMSI_HTML_EXTENSION        htm        ;;Default extension
#define?  MAKEMSI_UPDATING_WHAT_EXTN    MSI        ;;Extension of file
#define?  MAKEMSI_UPDATING_WHAT_TEXT    MSI        ;;Descriptive text (not extension) used in messages
#ifndef   MAKEMSI_CREATING_MERGE_MODULE
    #define?  MAKEMSI_PROPERTY_PREFIX  _MAKEMSI_
#elseif
    #define?  MAKEMSI_PROPERTY_PREFIX  _MAKEMSI<$MAKEMSM_KEY_SUFFIX>_
#endif
#define?  MAKEMSI_TABLENAME_PREFIX      _MAKEMSI_
#define?  MAKEMSI_TABLENAME_CABS        <$MAKEMSI_TABLENAME_PREFIX>Cabs
#define?  MAKEMSI_TABLENAME_FILESOURCE  <$MAKEMSI_TABLENAME_PREFIX>FileSource
#define?  MAKEMSI_MM_DIR                <?InputComponent $$FilePart:Location>
#define?  MAKEMSI_MM_BASENAME           <?InputComponent $$FilePart:Name>
#define?  MAKEMSI_DATE_TIME_FORMAT      %c
#define?  MAKEMSI_INPUTFILE_DATE_TIME_SUMMARY_FORMAT   <$MAKEMSI_DATE_TIME_FORMAT> ;;Blank to disable summary line
#define?  MAKEMSI_INPUTFILE_DATE_TIME_SUMMARY_TITLE    <?InputFile:n>
#define?  MAKEMSI_SUMMARY_LINES_TO_DROP                Operating Syst;Rexx Version
#define?  MAKEMSI_BASE_REGISTRY_KEY                    Software\MakeMSI            ;;Any other keys branch from here (CU or LM)
#define?  MAKEMSI_MAXLNG_PRODUCTNAME    63         ;;Documented limit which is validated by ICE??

;--- Some environmental information -----------------------------------------
#ifndef MAKEMSI_USERNAME
    #DefineRexx ''
       ;--- Try PCVS ID -----------------------------------------------------
       @@UserName = getenv("vcsid");

       ;--- TRY "USERNAME" --------------------------------------------------
       if  @@UserName = '' then
           @@UserName = getenv("USERNAME");

       ;--- Failed? ---------------------------------------------------------
       if  @@UserName = '' then
           @@UserName = "UnknownUser";

       ;--- Set up the macro ------------------------------------------------
       call MacroSet 'MAKEMSI_USERNAME', @@UserName;
    #DefineRexx
#endif
#if ['<??*COMPUTERNAME? $$IsBlank>' = 'Y']
    #define?  MAKEMSI_COMPUTERNAME    UnknownComputer
#elseif
    #define?  MAKEMSI_COMPUTERNAME    <??*COMPUTERNAME?>
#endif




;--- Some of the "external" files we use ------------------------------------
#define EXTN_REXX              4mm                     ;;Want install to leave ".REX" alone!
#define NAME_REGINA.EXE        Reg<$EXTN_REXX>.exe     ;;Rename exe in case another version of regina installed
#define NAME_REGINA.DLL        Reg<$EXTN_REXX>.dll     ;;Rename dll in case another version of regina installed (note EXE patched to load this name!)
#define NAME_PPWIZARD.REX      PpWiz4MM.<$EXTN_REXX>   ;;Don't interfer with any existing PPWIZARD
#define NAME_TEE.REX           Tee4MM.<$EXTN_REXX>     ;;User may have their own TEE program

;--- Some codes useful in VB literals ("<$VbCRLF>" etc) ---------------------
#( ''
   #define VbChr           ;;Note MSIDIFF has the similar "reverse" mappings
   #define  {$From} <?x{$From}>
   #RexxVar {$From} =x= ^" & {$To} & "^
#)
<$VbChr From="CRLF" To="vbCRLF">  ;;Carriage Return + Line Feed
<$VbChr From="LF" To="vbLF">      ;;Line Feed only
<$VbChr From="DQ" To='""""'>      ;;Double quote

;--- "VbExp" can be used in a literal ---------------------------------------
#RexxVar          DoubleQuote =x= '"'
#define VbExp  <?xDoubleQuote> & {$Exp} & <?xDoubleQuote>   ;;<$Property "FRED_Exp" Value="<$VbExp Exp=~FormatDateTime(date(), 0)~>">

;--- Default information ----------------------------------------------------
#NextId
#DefineRexx ''
   ;--- Remember Details about the base output locations --------------------
   @@RxOutput  = '<?OutputFile>';
   call MacroSet 'MAKEMSI_OUTDIR',   FilePart('location', @@RxOutput), '?'
   call MacroSet 'MAKEMSI_OUTBASE',  FilePart('basename', @@RxOutput), '?'
   call MacroSet 'MAKEMSI_OUTLEXTN', FilePart('WithoutExtn',  @@RxOutput), '?'

   ;--- Log directory -------------------------------------------------------
   call MacroSet 'MAKEMSI_OUT_LOG_DIR',          FilePart('location', @@RxOutput) || 'Log\', '?'
   call MacroSet 'MAKEMSI_OUT_LOG_DIR_RELATIVE', FileNameRelative(FilePart('location', @@RxOutput) || 'Log') || '\', '?'  ;;MAKECAB.EXE can't handle long dir names (piece of crap...)

   ;--- OUTPUT directory for the database -----------------------------------
   call MacroSet 'MAKEMSI_OUT_MSI_DIR', FilePart('location', @@RxOutput) || '<$MAKEMSI_UPDATING_WHAT_EXTN>\', '?'
#DefineRexx
#DefineRexx ''
   call MakeDirectoryTree "<$MAKEMSI_OUT_LOG_DIR>";
#DefineRexx


;---[4Doco-MainLoggingDirectories]---
;--- Set up some other logging directories (defaults/suggestions) -----------
#define? MAKEMSI_CA_DIR            <$MAKEMSI_OUT_LOG_DIR $$DEL:\>CustomActions    ;;Custom Action code
#define? MAKEMSI_NONCA_SCRIPT_DIR  <$MAKEMSI_OUT_LOG_DIR $$DEL:\>Scripts          ;;Scripts which are NOT Custom Action code
#define? MAKEMSI_VBSCA_DIR         <$MAKEMSI_CA_DIR $$DEL:\>VB                    ;;Custom Actions - VBSCRIPT based
#define? MAKEMSI_JSCA_DIR          <$MAKEMSI_CA_DIR $$DEL:\>JavaScript            ;;Custom Actions - JSCRIPT based
#define? MAKEMSI_VBSCRIPT_DIR      <$MAKEMSI_NONCA_SCRIPT_DIR $$DEL:\>VB          ;;VBSCRIPT (not custom actions)
#define? MAKEMSI_JSCRIPT_DIR       <$MAKEMSI_NONCA_SCRIPT_DIR $$DEL:\>JavaScript  ;;JSCRIPT  (not custom actions)
#define? MAKEMSI_COMPILE_DIR       <$MAKEMSI_OUT_LOG_DIR_RELATIVE $$DEL:\>Cabinet ;;Use as short a name as possible to help overcome MS MAKECAB.EXE bugs
#define? MAKEMSI_MSIVALIDATION_DIR <$MAKEMSI_OUT_LOG_DIR $$DEL:\>Validation       ;;Validation related files
#define? MAKEMSI_OTHER_DIR         <$MAKEMSI_OUT_LOG_DIR $$DEL:\>Other            ;;Sundry other files
;---[4Doco-MainLoggingDirectories]---


;--- Affects the HTML reporting (stops columns getting too wide) ------------
#define? PPWIZARD_WBR_AFTER     /?&_.|\    ;;Chopping preferred at these characters
#define? PPWIZARD_WBR_MAX       20         ;;Chop at 20 bytes

;--- Include other headers which support MAKEMSI operations -----------------
#include "FileMake.MMH"       ;;"FileMake" macro
#include "SourceFile.MMH"     ;;"SourceFile" macro
#include "SUNDRY.MMH"         ;;Assorted general purpose (generally small) commands and definitions
#include "MMMODE.MMH"         ;;MAKEMSI Processing mode logic/validation
#include "Platform.MMH"       ;;Platform macro and similar logic
#include "OnExit.MMH"         ;;on exit processing
#include "Valid.MMH"          ;;Validation code (MSIVAL2.EXE)
#include "Samples.MMH"        ;;copies "samples" to samples directory.
#include "Location.MMH"       ;;UpdateMmLocation
#include "Stamp.MMH"          ;;StampSourceDetailsIntoProperty
#include "MSI.MMH"            ;;MSI
#include "TableRow.MMH"       ;;Table, TableCreate, TableDelete, Row, RowsDeleteAll, RowsDelete
#include "TableDef.MMH"       ;;TableDefinition, Column, TableDefinitionIDT
#include "Tables.MMH"         ;;Define tables
#include "TableIE.MMH"        ;;TableExportToIdt, TableImportFromIdt
#include "Access.MMH"         ;;Permissions related
#include "Feature.MMH"        ;;Feature
#include "Component.MMH"      ;;Component
#include "Summary.MMH"        ;;Summary
#include "Property.MMH"       ;;Property
#include "Icon.MMH"           ;;Icon
#include "ShortCut.MMH"       ;;Shortcut
#include "Registry.MMH"       ;;Registry
#include "KeyPath.MMH"        ;;KeyPathRegistry
#include "RemFile.MMH"        ;;RemoveFile
#include "Environ.MMH"        ;;Path, Environment
#include "DirMap.MMH"         ;;MapUserDir (directory mapping)
#include "DirTree.MMH"        ;;DirectoryTree
#include "Dir1.MMH"           ;;Directory
#include "File.MMH"           ;;File macro
#include "Files.MMH"          ;;Files macro
#include "FileCmt.MMH"        ;;FileComment macro
#include "RegistryCmt.MMH"    ;;RegistryComment macro
#include "Binary.MMH"         ;;Binary  (must be included after "file.mmh")
#include "VER.MMH"            ;;VERSION file handling
#include "Guid.MMH"           ;;Guid related
#include "Dialog.MMH"         ;;Dialog related
#include "DialogTemplate.MMH"
#include "VbsCA.MMH"          ;;VbsBuild, VbsCa etc
#include "JsCA.MMH"           ;;JsCa etc
#include "ExeCA.MMH"          ;;ExeCa
#include "DllCA.MMH"          ;;DllCa
#include "Extn.MMH"           ;;Extn, /Extn, ExtnAction
#include "Service.MMH"        ;;ServiceInstall, ServiceControl
#include "Ini.MMH"            ;;IniFile, /IniFile, IniSection, /IniSection, Ini
#include "Find.MMH"           ;;FileFind, RegistryFind
#include "AbortIf.MMH"        ;;AbortIf
#include "Schedule.MMH"       ;;Schedule
#include "ADSI.MMH"           ;;ADSI, /ADSI
#include "ComPlus.MMH"        ;;ComPlusApp, /ComPlusApp
#include "RegImport.MMH"      ;;RegistryImport
#include "WrapInst.MMH"       ;;WrapInstall
#include "MergeMod.MMH"       ;;MergeModule stuff
#include "RunCmd.mmh"         ;;RunCmd & /RunCmd
#include "COMPILE.MMH"        ;;The "compile" (pass 2) process
#include "CodePage.MMH"       ;;Code page related commands
#include "SrcCode.MMH"        ;;Show Source code in HTML
#include "SelfReg.MMH"        ;;SelfReg
#include "MsiExtra.MMH"       ;;"MsiExtraFiles" etc
#include "CaType.MMH"         ;;Custom Action type related code
#include "Seq#.MMH"           ;;Sequence number relates code



;--- Get change details (May wish to refer to version etc in prod info) -----
#define? MAKEMSI_BEFORE_VerFileGetChangeHistory
#define? MAKEMSI_AFTER_VerFileGetChangeHistory
<$MAKEMSI_BEFORE_VerFileGetChangeHistory>
<$VerFileGetChangeHistory>
<$MAKEMSI_AFTER_VerFileGetChangeHistory>


;--- Read the VER file to extract PRODUCT information -----------------------
#define? MAKEMSI_BEFORE_VerFileGetProductInfo
#define? MAKEMSI_AFTER_VerFileGetProductInfo
<$MAKEMSI_BEFORE_VerFileGetProductInfo>
<$VerFileGetProductInfo>
<$MAKEMSI_AFTER_VerFileGetProductInfo>


;--- Display the product and version information to the user ----------------
#(
   #define? MAKEMSI_DISPLAY_PRODUCT_VERSION_INFO

   #info "PRODUCT NAME : <$ProdInfo.ProductName>"
   #info "PRODUCT VER  : <$ProductVersion>"
#)
#ifndef VER_FILE_DONT_USE_IT
   <$MAKEMSI_DISPLAY_PRODUCT_VERSION_INFO>
#endif
#RexxVar @@ProductName = ^<$ProdInfo.ProductName>^
#evaluate ^^ ^@@ProductNameLng = length(@@ProductName)^
#if [@@ProductNameLng > <$MAKEMSI_MAXLNG_PRODUCTNAME>]
    #(
        #error ^The product name is <??@@ProductNameLng> characters long
                (max allowed is <$MAKEMSI_MAXLNG_PRODUCTNAME>):{NL}{NL}    "<??@@ProductName>"^
    #)
#endif

;--- Make sure we record details about this header --------------------------
<$SourceFile Version="<$MAKEMSI_VERSION>">


;--- Record details about the main ".MM" file -------------------------------
<$SourceFile Type="Source" FileName=^<?InputFile>^ Version="?">

;--- Add date/time details about the main input file to the summary ---------
#if    ['<$MAKEMSI_INPUTFILE_DATE_TIME_SUMMARY_FORMAT>' <> '']
   #evaluate ^^ ^call Summary "<$MAKEMSI_INPUTFILE_DATE_TIME_SUMMARY_TITLE>", FileQueryDateTime('<?InputFile>', '<$MAKEMSI_INPUTFILE_DATE_TIME_SUMMARY_FORMAT>')^
#endif

;--- User wish to remove some standard(or other)  PPWIZARD summary lines? ---
#if ['<$MAKEMSI_SUMMARY_LINES_TO_DROP>' <> '']
   ;--- Supplied as a semicolon delimitered list ----------------------------
   #{ set ^@@TITLE={;}<$MAKEMSI_SUMMARY_LINES_TO_DROP>^
      #evaluate ^^ ^call Summary "<??SET_@@TITLE>",, 'DROP'^
   #}
#endif

;**      CommentBlock  /* (Saturday 08/02/2003, 12:38:15, by USER "Dennis") */
;**+--------------------------------------------------------------------------
;**|;--- Probably end up removing this ------------------------------------------
;**|#define PopulateStandardTables \
;**|        #include "Populate.MMH"
;**+--------------------------------------------------------------------------
;**                    /* (Saturday 08/02/2003, 12:38:15, by USER "Dennis") */


