home *** CD-ROM | disk | FTP | other *** search
-
-
-
- Makemak.c Page 1
-
-
-
- Makemak.c is a program intended to ease the chore of
- establishing dependency lists for the Microsoft Make program. The
- output is suitable for building C or MASM programs or a
- combination of both. The resulting output file will may not be
- 100% usable but it will be close. I find that only a small amount
- of editing is usually necessary to use the make file.
-
- Makemak is invoked in the following manner:
-
- makemak [options] filename
-
-
-
- Where options are:
- -d show make style dependency list
- -v verbose output
- -s show times of all checked files
-
- and filename is the name of the target file that make will
- generate. A make file will not be generated if any options are
- given. The make file is sent to the CRT and can be redirected to
- a file.
-
- Several make macro definitions are also generated. The
- source of these definitions can come from several places. First,
- a set of default definitions are built into the program. Second,
- three environment variables, "CL, LINK, and MASM" are checked and
- any values there become macro definitions. Lastly, a
- configuration, "MAKEMAK.CFG" file is checked and any definitions
- there will be included. This last set will override any
- definitions set internally or from the environment. The program
- looks for "MAKEMAK.CFG" in the current directory. If found, the
- values in it will be used. If "MAKEMAK.CFG" is not found in the
- current directory, an environment variable, "CONFIG" is searched.
- This variable should specify a single directory to search for
- "MAKEMAK.CFG". If the file is found, it's values will be used.
-
- The format of "MAKEMAK.CFG" file is as follows:
-
- cc = C compile command
- c_opts = options used with the C compiler
- cdefs = definitions defined to the C compiler
- mc = ASM compile command
- m_opts = options used with the assembler
- mdefs = definitions defined to the assembler
- lc = link command
- l_opts = options used with the linker
- lmap = name of map file generated by the linker
- libs = library names that the linker searches
-
-
-
-
-
-
-
-
-
-
-
-
-
- Makemak.c Page 2
-
-
- The default settings for all of these macro definitions are:
-
- CC = cl
- C_OPTS = /Zi /Od /c
- CDEFS =
- MC = masm
- M_OPTS = /Zi
- MDEFS =
- LC = link
- L_OPTS = /CO
- LMAP = NUL
- LIBS =
-
- Remember that the definitions in the MAKEMAK.CFG file will
- override both the defaults and the values of the LINK, CL and
- MASM environment variables. Also, the values from the LINK, CL
- and MASM environment variables get mapped into L_OPTS, C_OPTS and
- M_OPTS respectively. Any line that starts with a word that is not
- one of the key words listed above is considered a comment. Any
- key word that is not defined in the config file is assigned the
- default value.
-
- For an example, see the MAKEMAK.CFG file that should have
- accompanied this documentation.
-
- Some rules to follow when using MAKEMAK:
-
- All C, ASM and H files are considered to belong to the
- target executable built by make. This means that the target
- executable will be dependant on all files in the current
- directory with extensions of .C, .ASM and .H. If you have sloppy
- directories that are filled with all sorts of files with these
- extensions, you will end up doing a lot of editing on your make
- file. This may not be what you had intended. To keep things
- clean, give the program you are working on has it's own
- directory. Then you will get a nice, simple make file that may
- not require any editing at all.
-
- Assembler .INCLUDE files are not included in the dependency
- list. To do so requires quite a few modifications to the
- check_for_include and figure_out_include functions. I do not use
- assembler often enough to want that feature anyway. Feel free to
- modify the source if this is a desirable feature for you. Also
- send me a copy of the modified source if you can. If Microsoft
- would standardize it's programming languages the way UNIX
- languages are, the #include directive would serve to find the v
- of C, MASM, PASCAL, FORTRAN, COBOL and other languages with only
- a check of the extension instead of writing a separate
- figure_out_include for each language.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Makemak.c Page 3
-
-
- I believe there is a problem which will require editing of
- the generated make file when the list of header, objects and
- sources becomes to long. It seems the linker does not like the
- long line that is generated with too many files. I have not yet
- bothered to figure out what's wrong. If you find out what's going
- on in these cases, again, try to send me a copy of the modified
- source.
-
- I have found that MAKEMAK will perform acceptably with
- little to no editing of the generated make file for most of my
- small programming tasks. Updating of libraries is the one
- function that I often have to add to the make file.
-
- Parts of this program are based on an article by Dave Taylor
- in the February, 1988 issue of Computer Language. It has been
- extensively modified for DOS. The getopt function is from Augie
- Hansens's book "Proficient C".
-
- Compiled under Microsoft C 5.0
-
- Loran W. Richardson
- 7083 Fairways Drive
- Longmont, CO 80501
- (303) 939-9743
- CIS 70441,3037
-
- HOW IT WORKS ____________
-
- Input options are checked via the Unix style getopt
- function. Error messages are generated for illegal or no options.
- Once the options and/or file name are determined, make macros are
- setup in mak_cfg. Two arrays are generated here. The first,
- mak_macs[] is an array of pointers to strings with the *keywords
- (e.g. C_OPTS) for the macro definitions. The second, defaults[],
- is an array of pointers to strings of the macro definitions
- themselves (without the keyword prefix). During the call to
- mak_cfg, the both arrays are initialized to the program's built
- in definitions. Then a check of the CL, MASM and LINK environment
- variables is made and any values found there will overwrite the
- C_OPTS, M_OPTS and L_OPTS values in the defaults array. The
- mak_macs array will not change. Next, the "MAKEMAK.CFG" file is
- searched for using the C 5.0 _searchenv function. If a
- "MAKEMAK.CFG" file is found, it is read in a line at a time and
- the first word of the line is successively compared to the
- keyword strings in the mak_macs array. If a match is found, the
- rest of the line is copied to the corresponding element of the
- defaults array. This is what sets up the precedence rules for
- defining the macros. (In case you did not follow that, the
- precedence rules are, internal, environment, "MAKEMAK.CFG")
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Makemak.c Page 4
-
-
- Once the macros are defined, all files names in the current
- directory are read into an array, directory[MAXFILES], again
- using C 5.0 language extensions (_dos_findfirst and
- _dos_findnext). There is an internally defined limit of 250 files
- that can be operated on. More files than this and warning message
- is generated, but program execution continues.
-
- If a make file is being generated, the macro definitions for
- the make file are then generated and sent to the screen. Three of
- the macros are HDRS, SRCS, OBJS. These are generated by looking
- at the extension of each file and adding the file name to on or
- more of the three macros definitions. This part is skipped if any
- options were specified on the command line.
-
- If the -s (show times) option was specified, a list of C,
- ASM and H files are printed with the last modification date.
-
- If the verbose option (or no option) is specified, the
- extension of each file is checked to see if it is of an
- appropriate type. If it is, figure_out_includes is called.
-
- Figure_out_includes starts by printing a dependency list of
- the form base_name.obj: base_name.c (or .asm). It then scans the
- file for #include directives. If a #include is found,
- check_for_include is called to verify that the directive has the
- form
- '#include "fname"'. Note that it rejects directives like
- '#include "\myincs\fname"' and '#include <fname>'. In other
- words, the only files we are concerned with will be in the
- current directory. Then a check is made of the array of file
- names to verify that the include file is indeed in the current
- directory. If not a warning message is printed.
-
- If check_for_include returns with a valid include file, this
- file name is printed as part of the dependency list we started
- earlier. Then figure_out_includes is called recursively to see if
- the include file includes another file. And so on.
-
- Once the first file is completely checked, a newline and
- compile command with macros is printed for the file. Then the
- next file is scanned for includes.
-
- Finally, the tail end of the make file is printed. This line
- looks like:
- $(TARGET): $(HDRS) $(SRCS) ($OBJS)
- $(LC) $(L_OPTS) $(OBJS), $(TARGET), $(LMAP), $(LIBS);
-
- The final notes are a description of my compile environment:
- CL=/AS /Zi /Od
- LIBS=d:\lib;d:\lib\local;d:.
- LINK=/CO
- MASM=/Zi
- CONFIG=c:\util\configs
-
-
-
-
-
-
-
-
-
-
- Makemak.c Page 5
-
-
- And of course we need to have a packing list so that you
- know what other stuff you should have recieved with this program.
-
- makemak.exe the whole point of this exercise
- makemak.c main source code for the above
- mak_cfg.c configuration setter upper for makemak
- mak_help.c a small help file for makemak
- makemak.h include file for makemak
- makemak.mak make file that generated makemak
- makemak.cfg a sample configuration file
- getopt.c a Unix style getopt function that I keep in a
- library called SUTIL.lib
- getpname.c a function to extract the program name from
- the command line if _osmajor >= 3.
- SUTIL.LIB The lib with the above two files.
- makemak.prt this file
- makemak.arc all of the above files
-
-
- Have fun. Oh, and please, do send me your modifications if
- you can. Also try to distribute the whole archive. Thanks. whole
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-