Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!mcvax!ukc!eagle!mtr From: mtr@eagle.ukc.ac.uk (M.T.Russell) Newsgroups: comp.windows.x Subject: Re: Multiple targets with one source Message-ID: <3447@eagle.ukc.ac.uk> Date: Thu, 29-Oct-87 08:18:25 EST Article-I.D.: eagle.3447 Posted: Thu Oct 29 08:18:25 1987 Date-Received: Wed, 4-Nov-87 04:43:24 EST References: <2496@calmasd.GE.COM> Reply-To: mtr@ukc.ac.uk (M.T.Russell) Organization: Computing Lab, University of Kent at Canterbury, UK. Lines: 64 Summary: Expires: Sender: Followup-To: In article <2496@calmasd.GE.COM> jjo@calmasd.UUCP (Jay Olson) writes: >We have an environment which I am sure is becoming quite common these >days: a network with a variety of Suns, Vaxen and other assorted machines, >many of which run NFS and can see filesystems on other machines in the >network. Right now, the X11 source is NFS mounted so that both the Suns >and the Vaxen can access it. > >However, it is somewhat inconvenient to actually build and install X for >both types of machines using the same source. If I have built one particular >version (say the Sun), and wish to make a small change to the other (say >the Vax), I have to make clean, possibly fiddle with some files, remake the >makefiles, remake the dependencies, and completely remake X. Needless to >say, this is quite time-consuming. We also have this configuration, and I have found one method which avoids doing complete rebuilds when you want to make a binary for a new machine (I haven't used it on the X sources yet, only my own programs). You have a single letter macro (I use M) which is defined differently for each machine ("sun_" on the sun, "vax_" on the vax etc). Then in the makefile call the .o files "foo.$Mo" instead of "foo.o". You supply a rule for making the .$Mo files from the .c files. You also prepend $M to the name of the binary or library to be made. Thus a typical makefile looks like this: # makefile for baz .c.$Mo: $(CC) $(CFLAGS) -c $*.c mv $*.o $*.$Mo OBJS = foo.$Mo bar.$Mo $Mbaz: $(OBJS) $(CC) $(CFLAGS) -o $Mbaz $(OBJS) foo.$Mo: foo.c foo.h bar.$Mo: bar.c foo.h bar.h If M is defined as "vax_", this builds foo.vax_o and bar.vax_o then links them to make vax_baz. If you change a source file (say foo.c) a remake will make foo.vax_o and vax_baz. If you then move to a Sun, the remake will make foo.sun_o and sun_baz. You either set $M in the environment, or if your version of make won't read the environment, have a shell script in your local bin: #! /bin/sh /bin/make "M=vax_" $* One advantage of this scheme is that you don't have to remember which machine you are on - just say "make" and the right target for the machine gets built. A disadvantage is that you can't have makes running simultaneously on different machines - the temporary .o files clash. It the -o flag for cc worked with -c this wouldn't be a problem. Also, the Sun cc whines verbosely about files with a unknown suffix being passed to ld (but makes the binary OK). Mark Russell mtr@ukc.ac.uk