From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Eiler, James A." Newsgroups: gmane.os.tru64.managers Subject: SUMMARY: Question about make Date: Wed, 07 Aug 2002 14:57:15 -0400 Sender: tru64-unix-managers-owner@ornl.gov Message-ID: NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: main.gmane.org 1028746614 12077 127.0.0.1 (7 Aug 2002 18:56:54 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 7 Aug 2002 18:56:54 +0000 (UTC) Return-path: Original-Received: from sws1.ctd.ornl.gov ([160.91.20.101]) by main.gmane.org with smtp (Exim 3.35 #1 (Debian)) id 17cVzJ-00038g-00 for ; Wed, 07 Aug 2002 20:56:53 +0200 Original-Received: (qmail 8049 invoked by uid 5); 7 Aug 2002 18:57:31 -0000 Original-Followup-To: poster Precedence: bulk Original-Received: (qmail 8040 invoked from network); 7 Aug 2002 18:57:30 -0000 Original-Received: from unknown (HELO emroute2.cind.ornl.gov) (128.219.159.41) by 0 with SMTP; 7 Aug 2002 18:57:30 -0000 Original-Received: from emroute2.cind.ornl.gov (LOCALHOST [127.0.0.1]) by emroute2.cind.ornl.gov (PMDF V6.1-1 #39060) with ESMTP id <0H0H00I0LLZTCV@emroute2.cind.ornl.gov> for tru64-unix-managers@sws1.ctd.ornl.gov (ORCPT tru64-unix-managers@ornl.gov) ; Wed, 07 Aug 2002 14:57:30 -0400 (EDT) Original-Received: from NOAADC-MSW03.NOA.Alcoa.com (noaadc-msw03.noa.alcoa.com [147.154.9.220]) by emroute2.cind.ornl.gov (PMDF V6.1-1 #39060) with ESMTP id <0H0H008MGLZLNQ@emroute2.cind.ornl.gov> for tru64-unix-managers@sws1.ctd.ornl.gov (ORCPT tru64-unix-managers@ornl.gov) ; Wed, 07 Aug 2002 14:57:22 -0400 (EDT) Original-Received: from noaadc-mxi03.NOA.Alcoa.com (unverified) by NOAADC-MSW03.NOA.Alcoa.com (Content Technologies SMTPRS 4.2.10) with ESMTP id for ; Wed, 07 Aug 2002 14:57:20 -0400 Original-Received: by noaadc-mxi03.NOA.Alcoa.com with Internet Mail Service (5.5.2653.19) id ; Wed, 07 Aug 2002 14:57:20 -0400 Content-return: allowed Original-To: "tru64-unix-managers@ornl. gov \(E-mail\)" X-Mailer: Internet Mail Service (5.5.2653.19) Xref: main.gmane.org gmane.os.tru64.managers:1264 X-Report-Spam: http://spam.gmane.org/gmane.os.tru64.managers:1264 Many thanks to: Paul Gallop Peyton Bland Steve J. Dyer Joerg Bruehe Original Question: Trying to put together a Makefile. I've got some "customers" who need FORTRAN and C modules in a library and I've got other customers who emphatically don't want anything to do with FORTRAN - hence the library must be only C. I'd like to do something with make that automatically checks to see if the FORTRAN compiler exists on a given system - then, if so, go ahead and compile and generate the library. I've currently got a macro that can be uncommented to get make to include the FORTRAN stuff, but think you all could help me find a better way! Final Solution: Decided to use an approach suggested by Joerg Bruehe: Use a hierarchy of makefiles. My "first" makefile looks like this: mkdepend: @-if ( type f95 >> /dev/null ) ; then \ make -f Makefile.ara "FORTRAN=TRUE", "FOR=f95"; \ elif ( type f90 >> /dev/null ); then \ make -f Makefile.ara "FORTRAN=TRUE", "FOR=f90"; \ elif ( type f77 >> /dev/null ); then \ make -f Makefile.ara "FORTRAN=TRUE", "FOR=f77"; \ else \ make -f Makefile.ara; \ fi depend: make -f Makefile.ara depend clean: make -f Makefile.ara clean My "second" makefile (Makefile.ara) then uses the make macro substitution feature to create my list of modules to be included in my library... here are the salient parts of Makefile.ara: ########################################################################### # Define objects to put into the ara library ########################################################################### # # The following is a macro substitution of the form: # # $(MACRO?string1:string2) # # If MACRO is defined, string1 is assigned to MACRO. Otherwise, string2 # is assigned to MACRO. # # So, if the macro FORTRAN has been defined (see Makefile), LIBARA_OBJECTS # will be assigned all of the C and FORTRAN objects that make up the # library. Otherwise, only the C objects will be used. # LIBARA_OBJECTS = $(FORTRAN?${LIBARA_OBJS_C} ${LIBARA_OBJS_F}:${LIBARA_OBJS_C}) LIBARA_OBJS_C=\ ${OBJDIR}/bumpit.o \ ${OBJDIR}/datestr.o \ ${OBJDIR}/dump_ptbl_info.o \ ${OBJDIR}/elapsed_time.o \ . . . ${OBJDIR}/utimdat.o LIBARA_OBJS_F=\ ${OBJDIR}/asdate.o\ ${OBJDIR}/astime.o\ ${OBJDIR}/getargs_f.o\ ${OBJDIR}/int2.o\ ${OBJDIR}/int4.o\ ${OBJDIR}/rbit.o\ ${OBJDIR}/rjbit.o\ ${OBJDIR}/sbit.o\ ${OBJDIR}/sjbit.o\ ${OBJDIR}/zbit.o\ ${OBJDIR}/zjbit.o libara.a: $(LIBDIR)/libara.a $(LIBDIR)/libara.a : $(LIBARA_OBJECTS) $(AR) -r $@ $(LIBARA_OBJECTS)