# Some relevant parts of actual makefiles on my computer to show how to use mkflag.

#################################
# You can precede "#<mkflag>" with any number of spaces and all flags
# will have the same indentation.
# Any word in flag line not preceded with a valid switch will be ignored.
# Flag line can contain tabs.
# Flag lines can be continued with either forward or backward slash at end of
# line.  Should this be a problem then add a space to end of line.
# Long descriptions are wrapped.

   #<mkflag> gcc_fsf
   # I${top_builddir}     Search the directory dir for header files
   # I.                   Search the directory dir for header files
   # I${SRC}/includeyy    Search the directory dir for header files
   # I${SRC}/common       Search the directory dir for header files
   # pedantic             Issue all the warnings demanded by strict ISO C and ISO C++; reject all
   #    programs that use forbidden extensions, and some other programs that do not follow ISO C and ISO
   #    C++.
CFLAGS:= \
	-I${top_builddir} -I. \
	-I${SRC}/includeyy -I${SRC}/common \
	-pedantic \
	@CPPFLAGS@ @CFLAGS@ @DEFS@


######################
# You can specify the line to analyze other than the first uncommented line. This
# useful for rules where comments can only be at top of rule.  This fragment
# gets second line of the rule rather than the first.

       #<mkflag> ipfc_ibm 2
       # L=$(L)               Language ID
       # CODEPAGE=$(P)        Character code page
       # COUNTRY=$(C)         DBCS range or country code
$(DRIVERS_NLV)\par1284\parallel.hlp: $(ROOT)\$(SRC_NL_RELATIVE)\par1284.ipf
       $(IPF) $(ROOT)\$(SRC_NL_RELATIVE)\par1284.ipf /l=$(L) /codepage=$(P) /country=$(C)
       copy $(ROOT)\$(SRC_NL_RELATIVE)\par1284.hlp $(DRIVERS_NLV)\par1284\parallel.hlp
       del $(ROOT)\$(SRC_NL_RELATIVE)\par1284.hlp


#####################################################
# The fragment below shows how to document macros CFLAGS and LFLAGS by first
# putting echo statements in the link rule.  You must run the appropriate make utility
# to create response file before running mkflag.

#<mkflag> icc_ibm CFLAGS.FLG
# c                    Perform compile only, no link.
# Gd-                  Use the version of the runtime library that is statically linked.  Default: /Gd-
# Ss                   Allow the double slash (//) format to be used for comments. Default: /Ss-  (C mode
#    only)
# Gm+                  Link with multithread runtime libraries.  Default:  /Gm-
# Q+                   Suppress the logo.
# W0                   Output only severe and unrecoverable error messages generated by the compiler.
# Ge-                  Use the version of the runtime library that assumes a DLL is being built. 
#    Default: /Ge+
# Ms                   Set the default calling convention to _System.
# O+                   Optimize generated code.  Default: /O-

#<mkflag> ilink_ibm LFLAGS.FLG
# NOD                  NO Search default libraries
# MAP                  Generate map file
# NOE                  NO Use extended dictionary to search libraries
# PACKCODE             Pack neighboring code with similar attributes
# IGNORECASE           Ignore capitalization in identifiers

......................

$(OUTDIR)\$(DRIVER).$(EXT): $(O_N LV)\$(DRIVER).def
        $(CREATE_PATH)
        -del $(OUTDIR)\$(DRIVER).$(EXT) 2>&1 > nul
         echo $(CFLAGS) > CFLAGS .FLG
         echo $(LFLAGS) > LFLAGS.FLG
        $(LINK) $(LFLAGS) @<<$(O_NLV)\$(DRIVER).RSP
$(OMNIOBJS:.obj=.obj+
)
$(OUTDIR)\$(DRIVER).dll
$(O_NLV)\$(DRIVER).map
$(LIBSDLL)
$(O_NLV)\$(DRIVER).def
<<keep


###########
REM This fragment demonstrates documenting a batch file. When mkflag utility is
REM run with a filename with extension "CMD" then "#" becomes "REM ".
REM The "REM <mkflag>" is case sensitive and has one space.
REM This fragment is from file "make.cmd".
REM Any undocumented flag is described as "*** unknown flag ***".

REM <mkflag> gcc_fsf
REM  DOS2                     Define macro as 1 (if defn is missing) or defn
REM  O2                       Optimize even more.
REM  Zomf                     Zomf  *** unknown flag ***
REM  Zsys                     Zsys  *** unknown flag ***
REM  o                        Place output in file file.
gcc -DOS2 -O2 -Zomf -Zsys -o compress.exe compress.c isvalid.c


###########
# various  fragments

#<mkflag> rc_ibm
# r                    Create .res file
# x                    Exepack - Compress resources, using method 1 or 2
# DSOM2VERSION         Preprocessor define
# D_PPC_               Preprocessor define
# D_PPC                Preprocessor define
RFLAGS	   = -r -x -DSOM2VERSION -D_PPC_ -D_PPC


!    if "$(BLD_TYPE)"=="retail"
DBG_CFLAGS=
!    else
#<mkflag> icc_ibm
# Ti+                  Generate debugging information.  Default: /Ti-
# DEBUG                Define preprocessor macro. Default value '1'.
# DDEBUG               Define preprocessor macro. Default value '1'.
# DDEBUG_ALERT         Define preprocessor macro. Default value '1'.
# O-                   Do not optimize generated code.  Default: /O-
DBG_CFLAGS= /Ti+ /DEBUG /DDEBUG /DDEBUG_ALERT -O-
!    endif
#<mkflag> icc_ibm
# Sp1                  Pack aggregate members on specified alignment. Default: /Sp4
# Ss+                  Allow the double slash (//) format to be used for comments. Default: /Ss-  (C mode
#    only)
# Ms                   Set the default calling convention to _System.
# C+                   Perform compile only, no link.
# Fo$@                 Generate the object file. Default /Fo+
# Dcdecl=              Define preprocessor macro. Default value '1'.
# D_cdecl=             Define preprocessor macro. Default value '1'.
# Rn                   Produce code to run with no runtime environment. Allow system programming and
#    subsystem development.
# O                    Optimize generated code.  Default: /O-
# Wpro                 Warn about missing function prototypes.
# Q+                   Suppress the logo.
# Yp+                  Depreciated C Set flag.
ICCFLAGS=-Gd-e- -Sp1 -Ss+ -Ms -C+ -Fo$@ -Dcdecl= -D_cdecl= -Rn -O \
    -Wpro -Q+ -Yp+
#<mkflag> icc_ibm
# DBIDI                Define preprocessor macro. Default value '1'.
CFLAGS = /DBIDI $(ICCFLAGS) $(DBG_CFLAGS)
!    if "$(BLD_TYPE)"=="debug"
#<mkflag> ilink_ibm
# NOI                  NO Ignore capitalization in identifiers
# MAP                  Generate map file
# NOL                  NO Display logo, echo response file
# DEBUG                Include debugging information
# NOE                  NO Use extended dictionary to search libraries
LFLAGS = /noi /map /nol /debug /noe
!    else
#<mkflag> ilink_ibm
# NOI                  NO Ignore capitalization in identifiers
# MAP                  Generate map file
# NOL                  NO Display logo, echo response file
# EXEPACK:2            Compress data
# PACKCODE             Pack neighboring code with similar attributes
# PACKDATA             Pack neighboring data with similar attributes
# ALIGN:2              Set alignment factor
# NOE                  NO Use extended dictionary to search libraries
# SEGMENTS:300         Set maximum number of segments
LFLAGS = /noi /map /nol /exepack:2 /packcode /packdata /align:2 /noe /segments:300
!    endif

OS22_H = $(%WATCOM)\h\os2
#<mkflag> wcc386_ow
# i=$(OS22_H)          add another include path
# bt=OS2               build target for operating system <id>
# zq                   operate quietly (equivalent to -q)
# wx                   set warning level to maximum setting
C32FLAGS  = -i=$(OS22_H) -bt=OS2 -zq -wx
WC32    = wcc386 $(C32FLAGS)

OS21_H = $(%WATCOM)\h\os21x
#<mkflag> wcc_ow
# i=$(OS21_H)          add another include path
# bt=os2               build target for operating system <id>
# ms                   small memory model (small code/small data)
# 5                    optimize for Pentium
# omi                  optimization-> generate inline code for math functions
# s                    remove stack overflow checks
# zdp                  DS is pegged to DGROUP
# zff                  FS floats i.e. not fixed to a segment
# zgf                  GS floats i.e. not fixed to a segment
# zu                   SS != DGROUP (i.e., don't assume stack is in your data segment)
# zl                   remove default library information
# zq                   operate quietly
# wx                   set warning level to maximum setting
C16FLAGS  = -i=$(OS21_H) -bt=os2 -ms -5 -omi -s -zdp -zff -zgf -zu -zl -zq -wx

