[gnu.gcc.bug] Suggested improvement to GCC Makefile

aks%ccse@HUB.UCSB.EDU (aks@hub, Alan Stebbens) (05/19/89)

The following is a patch to the "gcc" Makefile which will allow multiple
versions of the compiler to coexist.  It also makes it very clear which
version of the compiler (and its attendant files) is installed. 
Basically, the files are all installed with the version number appended,
and symbolic links are used as the unadorned names.  These patches may
not be suitable for all systems; specifically, those which do not
support symbolic links.  In which case, you could simply redefine the
"MAKELINK" macro to copy. 

Oh yeah, the other improvement is that the Makefile will now only
install those files which have actually changed; previously, install
caused all the files to be always be installed, even if it was
unecessary. 

Alan Stebbens <aks@hub.ucsb.edu>

The patch follows (to be applied to gcc-1.35/Makefile).
==============================
*** Makefile.orig	Thu May 18 09:28:48 1989
--- Makefile	Thu May 18 13:47:04 1989
***************
*** 1,5 ****
--- 1,6 ----
  # Makefile for GNU C compiler.
  #   Copyright (C) 1987, 1988 Free Software Foundation, Inc.
+ VERSION=1.35
  
  #This file is part of GNU CC.
  
***************
*** 80,85 ****
--- 81,113 ----
  # Number to put in man-page filename.
  manext = 1
  
+ # The files to install/rdist
+ GCC=		$(bindir)/gcc
+ GCC1=		$(libdir)/gcc-cc1
+ GCC1PLUS=	$(libdir)/gcc-cc1+
+ GNULIB=		$(libdir)/gcc-gnulib
+ GCPP=		$(libdir)/gcc-cpp
+ GCCMAN=		$(mandir)/gcc.$(manext)
+ GCCDIR=		$(libdir)/gcc-include
+ 
+ LINKFILES=	$(GCC) $(GCC1) $(GNULIB) $(GCPP) $(GCCMAN) $(GCCDIR)
+ 
+ GCCV=		$(GCC)-$(VERSION)
+ GCC1V=		$(GCC1)-$(VERSION)
+ GCC1PLUSV=	$(GCC1PLUS)-$(VERSION)
+ GNULIBV=	$(GNULIB)-$(VERSION)
+ GCPPV=		$(GCPP)-$(VERSION)
+ GCCMANV=	$(GCCMAN)-$(VERSION)
+ GCCDIRV=	$(GCCDIR)-$(VERSION)
+ 
+ INSTALLFILES =	$(GCCV) $(GCC1V) $(GNULIBV) $(GCPPV) $(GCCMANV) $(GCCDIRV)
+ RDISTHOSTS =
+ 
+ MAKELINK=	rm -f $@ ; ln -s $@-$(VERSION) $@
+ PUTFILE=	$(INSTALL) $? $@
+ PUTFILEMAYBE=	if [ -f $? ] ; then $(PUTFILE) ; fi
+ RANLIB=		if [ -f /usr/ucb/ranlib ] ; then ranlib $@ ; fi
+ 
  # Additional system libraries to link with.
  CLIB=
  
***************
*** 480,497 ****
  	-rm -f *.dvi
  
  # Copy the files into directories where they will be run.
! install: all
! 	-mkdir $(libdir)
! 	-if [ -f cc1 ] ; then $(INSTALL) cc1 $(libdir)/gcc-cc1 ;fi
! 	-if [ -f cc1plus ] ; then $(INSTALL) cc1plus $(libdir)/gcc-cc1plus ;fi
! 	$(INSTALL) gnulib $(libdir)/gcc-gnulib
! 	-if [ -f /usr/bin/ranlib ] ; then (cd $(libdir); ranlib gcc-gnulib) ;fi
! 	$(INSTALL) cpp $(libdir)/gcc-cpp
! 	$(INSTALL) gcc $(bindir)
! 	-mkdir $(libdir)/gcc-include
! 	chmod ugo+rx $(libdir)/gcc-include
! 	for file in $(USER_H); do $(INSTALL) $${file} $(libdir)/gcc-include; done
! 	$(INSTALL) gcc.1 $(mandir)/gcc.$(manext)
  
  # do make -f ../gcc/Makefile maketest DIR=../gcc
  # in the intended test directory to make it a suitable test directory.
--- 508,542 ----
  	-rm -f *.dvi
  
  # Copy the files into directories where they will be run.
! install: $(libdir) $(LINKFILES)
! $(libdir): 			; -mkdir $(libdir)
! $(GCC):		$(GCCV) 	; $(MAKELINK)
! $(GCC1):	$(GCC1V) 	; $(MAKELINK)
! $(GCC1PLUS):	$(GCC1PLUSV) 	; $(MAKELINK)
! $(GNULIB):	$(GNULIBV) 	; $(MAKELINK)
! $(GCPP):	$(GCPPV) 	; $(MAKELINK)
! $(GCCMAN):	$(GCCMANV) 	; $(MAKELINK)
! $(GCCDIR):	$(GCCDIRV) 	; $(MAKELINK)
! 
! $(GCPPV):	cpp		; $(PUTFILE)
! $(GCCV):	gcc		; $(PUTFILE)
! $(GCCMANV):	gcc.1		; $(PUTFILE)
! $(GCC1V):	cc1 		; $(PUTFILEMAYBE)
! $(GCC1PLUSV):	cc1plus 	; $(PUTFILEMAYBE)
! $(GNULIBV):	gnulib		; $(PUTFILE) 		; $(RANLIBFILE)
! $(GCCDIRV):	force
! 	-mkdir $@
! 	chmod ugo+rx $@
! 	for file in $(USER_H); do $(INSTALL) $${file} $@ ; done
! 
! rdist:	install
! 	for host in ${RDISTHOSTS} ; do \
! 		rdist -c $(INSTALLFILES) $(LINKFILES) $$host ; \
! 		rsh $$host ranlib $(GNULIBV) ; \
! 		if [ -f $(libdir)/gcc-cc1plus ] ; then \
! 			rdist -c $(libdir)/gcc-cc1plus $$host ; fi ; \
! 	done
! 
  
  # do make -f ../gcc/Makefile maketest DIR=../gcc
  # in the intended test directory to make it a suitable test directory.