From owner-freebsd-questions Tue Feb 2 00:22:21 1999 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id AAA05764 for freebsd-questions-outgoing; Tue, 2 Feb 1999 00:22:21 -0800 (PST) (envelope-from owner-freebsd-questions@FreeBSD.ORG) Received: from allegro.lemis.com (allegro.lemis.com [192.109.197.134]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id AAA05758 for ; Tue, 2 Feb 1999 00:22:15 -0800 (PST) (envelope-from grog@freebie.lemis.com) Received: from freebie.lemis.com (freebie.lemis.com [192.109.197.137]) by allegro.lemis.com (8.9.1/8.9.0) with ESMTP id SAA22530; Tue, 2 Feb 1999 18:52:08 +1030 (CST) Received: (from grog@localhost) by freebie.lemis.com (8.9.2/8.9.0) id SAA01787; Tue, 2 Feb 1999 18:52:05 +1030 (CST) Date: Tue, 2 Feb 1999 18:52:05 +1030 From: Greg Lehey To: Kent Stewart Cc: "freebsd-questions@FreeBSD.org" Subject: Re: Make File Generator Message-ID: <19990202185205.A76680@freebie.lemis.com> References: <36B5FF82.D89176C1@3-cities.com> <19990202094916.R71384@freebie.lemis.com> <36B68FF4.48331073@3-cities.com> <19990202162039.U76680@freebie.lemis.com> <36B6A459.F889B88E@3-cities.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.95.1i In-Reply-To: <36B6A459.F889B88E@3-cities.com>; from Kent Stewart on Mon, Feb 01, 1999 at 11:08:09PM -0800 WWW-Home-Page: http://www.lemis.com/~grog Organization: LEMIS, PO Box 460, Echunga SA 5153, Australia Phone: +61-8-8388-8286 Fax: +61-8-8388-8725 Mobile: +61-41-739-7062 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Monday, 1 February 1999 at 23:08:09 -0800, Kent Stewart wrote: > Greg Lehey wrote: >> >> On Monday, 1 February 1999 at 21:41:08 -0800, Kent Stewart wrote: >>> Greg Lehey wrote: >>>> On Monday, 1 February 1999 at 11:24:50 -0800, Kent Stewart wrote: >>>>> On most of the Unix systems I have used there is a make generator for >>>>> Fortran. I don't see such a product on FreeBSD for f77. I have a large >>>>> program, i.e., more than 300 modules, that was last used on a Cray. The >>>>> sources as provided do not contain a makefile. I would like to try and build >>>>> it on FreeBSD but would hate to have to create the makefile by hand . >>>>> Is there something like mkmf that will generate a makefile. >>>> >>>> Not that I know of. Have you tried gmake? It knows about Fortran >>>> programs. You probably need very little to make a usable Makefile. >>>> For example, if you create a single executable out of your 300 .f >>>> programs, you might do: >>>> >>>> $ ls *.f | xargs | sed 's/^/PROG: /' > Makefile >>>> >>>> Substitute the name of your program for PROG. >>> >>> I had thought about gmake. The gmake manual is intimdating. It is easy to >>> modify something that is generated and works. Creating the makefile from >>> scratch is something else. I also assumed that I needed to supply parameters >>> to the veraious steps. Your suggested sequence was so simple that it was >>> worth it to see what it would do. The problem is that the main program >>> overwhelms the table and kills the build on the first module and continues >>> on. The message I get is that I have to supply -Nn802 to f77 for the main >>> program. I don't think it would matter if the table was extended for all of >>> the modules. I didn't capture the output; however, the defaults appear to >>> work for everything else. The other thing is that this process isn't >>> generating object output and it takes about 45 minutes to compile >>> everything. That becomes a serious problem because it recompiles everything, >>> everytime. >> >> I'm not sure I understand this, but it doesn't sound right. What does >> your Makefile look like? > > I used the piped command and starts out with the program name: a.f a1.f a2.f > ... name.f ... z.f > > The line wraps many times . > > I have downloaded the GMake Manual and I'm looking at adding the rules. It > will have to be broken into the separate modules. Why? >>> A make generator should create something that looks like >>> >>> stuff ... >>> >>> main.o : main.f >>> f77 -? main.f >>> link1.o : link1.f >>> f77 -? link1.f >> >> No, a Makefile generator should *never* generate something like that >> unless each and every module needs a different command, which would be >> very poor style. You can replace all of this stuff with: >> >> .f.o: >> f77 -? $< >> >> This has the advantage that it will still work if you add modules to >> the directory. > > I like that. It is KISS simple. There are actually two programs with some > modules being shared and not all but I'm not worrying about that > right now. Ah. That's different, of course. Yes, that *is* something to worry about. But then all you need is: all: prog1 prog2 prog1: a.o b.o c.o g.o prog2: a.o d.o f.o g.o > It is easier to build each in their own directory. Not necessarily. Then you need PATH directives and make implementation dependent things. If they share a lot of modules, you're better off in one directory. >> To get object files for each source file, try making the Makefile like >> this: >> >> $ ls *.f | sed 's/.f$/.o/ | xargs | sed 's/^/PROG: /' > Makefile >> >> This will make the program dependent on the objects and not on the >> sources. > > It looked like it was starting out right but complains about too > many names. Hmm. I tried it and found I'd left out an apostrophe. Should be: $ls *.f | sed 's/.f$/.o/' | xargs | sed 's/^/PROG: /' > Makefile When I run it on this directory: $ ls Makefile ew.f g.f hfg.f rq.f we.f wqer.f cwste.f ewr.f gd.f hw.f sd.f weyt.f d.f f.f gdf.f qw.f tq.f wq.f df.f fd.f h.f qwe.f w.f wqe.f I get: PROG: cwste.o d.o df.o ew.o ewr.o f.o fd.o g.o gd.o gdf.o h.o hfg.o hw.o qw.o qwe.o rq.o sd.o tq.o w.o we.o weyt.o wq.o wqe.o wqer.o Then I run gmake: $ gmake -k f77 -c cwste.f -o cwste.o f77 -c d.f -o d.o f77 -c df.f -o df.o f77 -c ew.f -o ew.o f77 -c ewr.f -o ewr.o f77 -c f.f -o f.o f77 -c fd.f -o fd.o f77 -c g.f -o g.o f77 -c gd.f -o gd.o f77 -c gdf.f -o gdf.o f77 -c h.f -o h.o f77 -c hfg.f -o hfg.o f77 -c hw.f -o hw.o f77 -c qw.f -o qw.o f77 -c qwe.f -o qwe.o f77 -c rq.f -o rq.o f77 -c sd.f -o sd.o f77 -c tq.f -o tq.o f77 -c w.f -o w.o f77 -c we.f -o we.o f77 -c weyt.f -o weyt.o f77 -c wq.f -o wq.o f77 -c wqe.f -o wqe.o f77 -c wqer.f -o wqer.o This doesn't perform the link stage. You'd need a rule for that. Change again: $ ls *.f | sed 's/.f$/.o/' | xargs | sed 's/^/OBJS = /' > Makefile This gives the first line of the following Makefile; you need to add the rest yourself: OBJS = cwste.o d.o df.o ew.o ewr.o f.o fd.o g.o gd.o gdf.o h.o hfg.o hw.o qw.o qwe.o rq.o sd.o tq.o w.o we.o weyt.o wq.o wqe.o wqer.o prog: ${OBJS} ld -o $@ ${OBJS} When I run gmake, I get: $ gmake ld -o prog cwste.o d.o df.o ew.o ewr.o f.o fd.o g.o gd.o gdf.o h.o hfg.o hw.o qw.o qwe.o rq.o sd.o tq.o w.o we.o weyt.o wq.o wqe.o wqer.o /usr/libexec/elf/ld: warning: cannot find entry symbol _start; defaulting to 08048074 This last message tells me that I at least have created a broken executable; since all my modules are empty, that's not surprising. It should work for you. > I will have to create the rules version and see what it does. Nope, you never need that. > I still haven't seen an option to create object output. Yes you have, you just didn't recognize it :-) Greg -- See complete headers for address, home page and phone numbers finger grog@lemis.com for PGP public key To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message