[comp.lang.c] Command line length and using Make

hollen@eta.megatek.uucp (Dion Hollenbeck) (12/20/89)

From article <78@motto.UUCP>, by dave@motto.UUCP (David Brown):
> My biggest problem is not with Microsoft's make, per se, but with the
> command line limits on utilities such as the linker.  What I would
> like to do is something like
> 
> 	OBJS = file1.obj \
> 	       file2.obj \
> 		 ...
> 	       file200.obj
> 
> 		...
> 
> 	prog.exe: $(OBJS)
> 		link $(OBJS), prog, ...
> 
> However, even if I get around the 512 byte limit in macros by having
> multiple macros (OBJ1, OBJ2, ...), link won't accept so long a command
> line.  I'm forced to keep a separate response file for the link, which
> means maintaining another list of all the object names.
> 
 I have this same problem with Turbo C which will accept response
files for the linker also.  Originally, I was keeping two lists of
objects, the one defined in macros in the makefile, and the one
in the response file, and then the light dawned on me.  

 	prog.exe: $(OBJS)
		echo $(OBJS) > objs.rsp
		echo $(LIBS) > libs.rsp
 		link @objs.rsp, prog, ..., @libs.rsp
 
In this manner, I always have the response files created from the
latest macros in my makefile AND get over the command line
limitations.

Another place I do this is that Turbo C has a config file which will
set all sorts of standardly used command line options before reading
the command line.  I also echo all my -D and -I options out into this
file at .c.obj time so that I will never exceed the command line
length with the cc command since my search and define options often
get quite lengthy.

The other thing which I do with make is get it to generate all my
standard Turbo config files and all my batch files for me.  I define
all the directory tree in macros and use the macros in the body
of what I would want in the batch file.  For example:


ROOT	=	C:
GLOBIDR =	${ROOT}\bin



autoexec:
	set GLOB = ${GLOBDIR}
		.
		.
	(end of autoexec.bat)


Invoke it to make autoexec.bat with:

	make -n autoexec > autoexec.bat

The -n option to make will tell it to merely echo the commands it would
have executed and you redirect them into the file you want to create.
You can make every batch file you use which requires directory paths,
and if you move a directory, you can just remake the batch files without
having to worry about missing one.  Also, have targets using macros in
your makefile for where to copy the batch files once you have made them.

If enough people are interested in this topic of how to use make to
generate just about everything you can imagine for you, I will post
an archive I have created with fairly extensive explanations of
how to do these kinds of things and lots of others.  Please E-mail
me and if sufficient interest, I will post, else I will mail 
individually.  Give me about two weeks cause of the holidays.


	Dion Hollenbeck             (619) 455-5590 x2814
	Megatek Corporation, 9645 Scranton Road, San Diego, CA  92121

        uunet!megatek!hollen       or  hollen@megatek.uucp