[comp.lang.c] makefiles

ADLER1%BRANDEIS.BITNET@wiscvm.wisc.EDU (07/28/87)

I am interested in trying to compile a complicated set of about 40 files
on a SUN. There is a Makefile included with the set so if I wanted to
I could compile them using the c compiler normally resident on the SUN
by just typing "make". However, I would like to see what happens if
I compile them with the GNU compiler. One thing to try would be to
modify the Makefile so that it uses the GNU compiler instead of the
usual one. I don't know how to do that. Another thing to try would be
to figure out what the Makefile actually does and implement that by
hand, executing all the relevant commands myself and making sure that
I always compile using the GNU compiler instead of the usual one.
I don't know how to do that either.

Anyone want to tell me how to do either or both? I assume there is a
general answer. If not, details are available on request.

Thanks.

Allan Adler
ADLER1@BRANDEIS.BITNET

tim@comcon.UUCP (Tim Brown) (06/12/90)

I have been wrestling with this problem, I *have* RTFM and still I am
a little confused.  I wrote some functions and put them into a
library.  Can someone suggest the best way to maintain the library
with as few lines as possible but still maintain it the same way as
individually targeted objects?

I do it like this now:

replace.o:	replace.c $(includes)
		cc $(CFLAGS) -c replace.c

[ many other functions set up just like the first ]

libccd.a:	$(objs) /* All the .o's */
		ar rv libccd.a $(objs)

This works but is error prone and tedious to change, any ideas?

I tried this:

libccd:		$(objs)  .... where objs are like, libccd(replace.o)...
		@echo Library up to date!

The above is from the manual and seems to work ok, but make doesn't
see changes in the .c files this way.  What am I missing?  The book
says something about a $% macro but gives no example.


Thanks in advance.  I would like email replies on this whether or not
you post a followup.

Tim Brown
{}!nstar!comcon!tim

darcy@druid.uucp (D'Arcy J.M. Cain) (06/15/90)

In article <411@comcon.UUCP> tim@comcon.UUCP (Tim Brown) writes:
>I have been wrestling with this problem, I *have* RTFM and still I am
>a little confused.  I wrote some functions and put them into a
>library.  Can someone suggest the best way to maintain the library
>with as few lines as possible but still maintain it the same way as
>individually targeted objects?
>
Here's the pertinent part of my local library makefile.  I use GNU Make.

CC=gcc
CFLAGS =	-O -Wall
UNIX_L =	/usr/lib/libcain.a
OBJECTS =	parse nx_wk_dy strmem calcsecs asc_date \
			now scandate scantime crctab chkenv \
			getarg addext fullname qsort ssearch

all:	$(foreach o, $(OBJECTS), $o.o)
	ar r $(UNIX_L) $?

You may wish to use "module.o" instead of "module" in the variable assignment
and drop the foreach.  I only use it because the full file compiles the modules
for DOS at the same time.

-- 
D'Arcy J.M. Cain (darcy@druid)     |   Government:
D'Arcy Cain Consulting             |   Organized crime with an attitude
West Hill, Ontario, Canada         |
(416) 281-6094                     |