Once you have the source files, you can create Generic's makefile and then compile and link the application by using NMAKE. To compile and link Generic, the makefile must carry out these steps:
Use CL to compile the GENERIC.C file.
Use Microsoft Segmented Executable Linker (LINK) to link the GENERIC.OBJ object file with the Windows library and the module-definition file, GENERIC.DEF.
Use RC to create a binary resource file and add it to the executable file of the Windows application.
The following will properly compile and link the files created for Generic:
# Standard Windows makefile. NMAKE compares the creation date of
# the file to the left of the colon with the file(s) to the right
# of the colon. If the file(s) on the right are newer than the
# file on the left, NMAKE will execute all of the command lines
# following this line that are indented by at least one tab or
# space. Any valid MS-DOS command line may be used.
# Update the resource if necessary.
generic.res: generic.rc generic.h
rc /r generic.rc
# Update the object file if necessary.
generic.obj: generic.c generic.h
cl /c /Gsw /Oas /Zpe generic.c
# Update the executable file if necessary. (If it is necessary,
# add the resource back in.)
generic.exe: generic.obj generic.def
link /nod generic, , , slibcew libw, generic.def
rc generic.res
# If the .RES file is new and the .EXE file is not, update the
# resource. Note that the .RC file can be updated without having
# to either compile or link the file.
generic.exe: generic.res
rc generic.res
The first two lines in this makefile direct NMAKE to create a compiled resource file, GENERIC.RES, if either the resource-definition file GENERIC.RC or the new header file GENERIC.H has been updated. The /r option of the rc command creates a compiled resource file without attempting to add it to an executable file, since this must be done as the last step in the process.
The next two lines direct NMAKE to create the GENERIC.OBJ file if GENERIC.C or GENERIC.H has a more recent access date than the current GENERIC.OBJ file. The cl command takes several options that prepare the application for execution under Windows. The minimum required options are /c, /Gw, and /Zp. In this case, CL treats Generic as a small-model application. Generic and all other applications in this guide are small-model applications.
NMAKE then creates the new GENERIC.EXE file if the GENERIC.OBJ or GENERIC.DEF file has a more recent access date than the current GENERIC.EXE file. Small Windows applications, like Generic, must be linked with the Windows SLIBW.LIB library and the Windows version of the C run-time library, SLIBCEW.LIB. The object file GENERIC.OBJ and the module-definition file GENERIC.DEF are used as arguments in the LINK command line.
The last rc command automatically appends the compiled resources in the file GENERIC.RES to the executable file GENERIC.EXE.