[gnu.utils.bug] GNU Make 3.56 vs Stellar & Convex / Makefiles for multiple machines

montnaro@sprite.crd.ge.com (Skip Montanaro) (09/29/89)

I just got GNU Make 3.56 from prep. It compiled and ran successfully on a
Sun-3 (built under SunOS 3.5, run under 3.5 & 4.0.1), but doesn't work on
our Convex C240 or on our Stellar GS1000, both of which ran 3.54 and 3.55
with no hitches.

For the Convex, I defined "-DNO_MINUS_C_MINUS_O -DNLIST_NAME_UNION". The
Convex builds cleanly, but doesn't appear to get the value of variables from
the environment. Executing

	./gmake-convex -n clean

gives

	rm -f make- /*.o core

instead of 

	rm -f make-convex convex/*.o core

for the GNUmakefile that appears at the end of this note.

For the Stellar, I defined "-DUSG -DUSGr3" (same flags I used for building
GNU Make 3.5[45]). It does not build cleanly. I get the following error
message when compiling glob.c:

    "../glob.c", line 303: Error: struct/union member required.
    make-stellar: *** [stellar/glob.o] Error 1

This arises due to the new #define for d_ino placed near the top of glob.c:

    #if	defined(USGr3) || defined(DIRENT)

    #include <dirent.h>
    #	if	!defined(d_ino) && !defined(d_fileno)
    #define	d_ino	d_fileno
    ^^^^^^^^^^^^^^^^^^^^^^^^ this'n right here
    #	endif
    #define direct dirent
    #define	D_NAMLEN(d) strlen((d)->d_name)

    #else	/* Not USGr3 and not DIRENT.  */

    #define D_NAMLEN(d) ((d)->d_namlen)
    #	ifdef	USG
    #include "ndir.h"   /* Get ndir.h from the Emacs distribution.  */
    #	else	/* Not USG.  */
    #include <sys/dir.h>
    #	endif	/* USG.  */

    #endif	/* USGr3 or DIRENT.  */

Stellar uses d_ino as the inode field in a dirent struct, not d_fileno. I
have no other Sys V machines around to compare with, so I don't know if
Stellar is quirky or the #define is incorrect.

If I turn off USGr3 and copy ndir.h from the Emacs directory tree, Make
builds okay, but I get a number of wierd error messages:

    % ./gmake-stellar clean
    gmake-stellar: *** No way to make target `clean'.  Stop.

Again, this is using the GNUmakefile that appears at the end of this note.
If I explicitly name the Makefile on the command line, it works okay:

    % ./gmake-stellar clean -f GNUmakefile
    rm -f make-stellar stellar/*.o core

Using the following small makefile (call it mkfile.tst)

    objs := glob.o commands.o job.o dir.o file.o load.o misc.o main.o read.o \
	   remake.o remote.o rule.o implicit.o default.o variable.o expand.o \
	   function.o vpath.o version.o arscan.o ar.o alloca.o

    archobjs := $(objs:%.o=$(ARCH)/%.o)

    make-$(ARCH): $(archobjs)
	    $(CC) $(LDFLAGS) $(archobjs) $(LOADLIBES) -o make-$(ARCH)

    $(ARCH)/%.o : %.c
	    cd $(ARCH) ; $(CC) $(CFLAGS) -c -I.. ../$<

I get the following error message:

    % ./gmake-stellar -n -f mkfile.tst 
    gmake-stellar: *** No way to make target `stellar/glob.o'.  Stop.

even though there is clearly a pattern rule defining how to make .o files in
the stellar subdirectory from .c files in the current directory. (ARCH is
defined as stellar and exported.)

If you turn on debugging with -d, it appears from the emitted messages that
Make is considering mkfile.tst as a target:

    % ./gmake-stellar -n -f mkfile.tst -d
    GNU Make version 3.56, by Richard Stallman and Roland McGrath.
    Copyright (C) 1988, 1989 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.
    There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
    PARTICULAR PURPOSE.

    Reading makefiles...
    Updating makefiles....
     Considering target file `mkfile.tst'.
      Looking for an implicit rule for `mkfile.tst'.
      Trying pattern rule with stem `mkfile.tst'.
      Trying implicit dependency `mkfile.tst,v'.
      Trying pattern rule with stem `mkfile.tst'.
      Trying implicit dependency `RCS/mkfile.tst,v'.
      Trying pattern rule with stem `mkfile.tst'.
      Trying implicit dependency `s.mkfile.tst'.
      Trying pattern rule with stem `mkfile.tst'.
      Trying implicit dependency `SCCS/s.mkfile.tst'.
      Trying pattern rule with stem `mkfile.tst'.
      Trying implicit dependency `mkfile.tst.o'.
      ...

Here's my GNUmakefile. I modified the distributed Makefile so that I can
build all architectures I'm interested in from a single source directory. We
rely on the variable ARCH, defined either in the user's environment or on
the Make command line, to direct Make to build the correct version. I
convinced our system managers some time ago to make sure a version of the
Sun shell script, arch, is installed on all our UNIX machines. We normally
just set ARCH from our .login or .profile. Others may find this Makefile
useful.

# Skip Montanaro - 7/10/89
# modified for building separate versions for different architectures in the
# same directory

# Skip Montanaro - 8/31/89
# modified for version 3.55

# Skip Montanaro - 9/1/89
# added gmake shell script target

# Skip Montanaro - 9/27/89
# merged 3.56 changes in where appropriate

# Copyright (C) 1988, 1989 Free Software Foundation, Inc.
# This file is part of GNU Make.
# 
# GNU Make is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 1, or (at your option)
# any later version.
#
# GNU Make is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with GNU Make; see the file COPYING.  If not, write to
# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.

#
#	Makefile for GNU Make
#

# Define nothing for BSD, USG for System V,
# and USGr3 (as well as USG) for SVR3.
# If you have a USG hybrid with <sys/wait.h> and wait3, define HAVE_SYS_WAIT.
# If you are USG but have sys_siglist, define HAVE_SIGLIST.
# If you are USG, and not USGr3, but have dup2, define HAVE_DUP2.
# If your `cc' command doesn't grok -o options with -c (true for
# many 4.2 BSD derivatives), define NO_MINUS_C_MINUS_O.
defines-convex = -DNO_MINUS_C_MINUS_O
defines-stellar = -DUSG
defines = $(defines-$(ARCH))

CFLAGS = $(defines) -g
LDFLAGS = -g

# Define UMAX here to use Encore's inq_stats call.  If the load average is in a
# symbol in /dev/kmem, define KERNEL_FILE_NAME if not "/vmunix", LDAV_SYMBOL if
# not "_avenrun", LDAV_TYPE if not `long int', and LDAV_CVT to convert the
# LDAV_TYPE value from LDAV_SYMBOL (in `load') to a double if this is not
# "(double) load".  If a `struct nlist' (as defined in <nlist.h>) has a `n_un'
# union, rather than a simple `n_name' member, define NLIST_NAME_UNION.  If the
# `n_name' member of a `struct nlist' is an array that must be copied into,
# define NLIST_NAME_ARRAY.  Otherwise, define NO_LDAV.
LOAD_AVG-convex = -DNLIST_NAME_UNION
LOAD_AVG = $(LOAD_AVG-$(ARCH))

# If you don't want archive support, comment these out.
ARCHIVES = arscan.o ar.o
ARCHIVES_SRC = arscan.c ar.c

# If your system needs extra libraries loaded in, define them here.
# System V probably need -lPW for alloca.
LOADLIBES =

# If your system doesn't have alloca, or the one provided is bad,
# get it from the Emacs distribution and define these.
ALLOCA := alloca.o
ALLOCASRC := alloca.c

# If there are remote execution facilities defined,
# enable them with switches here (see remote-*.c).
REMOTE =

# Any extra object files your system needs.
extras =

# Directory to install `make' in.
bindir = $(prefix)/usr/local/bin
# Directory to install the man page in.
mandir = $(prefix)/usr/local/man/man1
# Number to put on the man page filename.
manext = 1

objs = glob.o commands.o job.o dir.o file.o load.o misc.o main.o read.o \
       remake.o remote.o rule.o implicit.o default.o variable.o expand.o \
       function.o vpath.o version.o $(ARCHIVES) $(ALLOCA) $(extras)

archobjs = ${objs:%.o=$(ARCH)/%.o}

srcs = glob.c commands.c job.c dir.c file.c load.c misc.c main.c read.c \
       remake.c remote.c rule.c implicit.c default.c variable.c expand.c \
       function.c vpath.c version.c $(ALLOCASRC) $(ARCHIVES_SRC) \
       commands.h dep.h file.h job.h make.h rule.h variable.h

.SUFFIXES:
.SUFFIXES: .o .c .h .ps .dvi .texinfo

.PHONY: all doc
all: make-$(ARCH) gmake
doc: make-info make.dvi

# Take your pick.
makeinfo = emacs -batch make.texinfo -f texinfo-format-buffer -f save-buffer
#makeinfo = makeinfo make.texinfo

make-info: make.texinfo
	$(makeinfo)


make.dvi: make.texinfo
	-tex make.texinfo
	texindex make.cp make.fn make.ky make.pg make.tp make.vr
	-tex make.texinfo

make.ps: make.dvi
	dvi2ps make.dvi > make.ps

make-$(ARCH): init $(archobjs)
	$(CC) $(LDFLAGS) $(archobjs) $(LOADLIBES) -o make-$(ARCH)

init :
	@(mkdir $(ARCH) >/dev/null 2>&1 ; exit 0)

remake :
	mv make-$(ARCH) make-$(ARCH).old
	make-$(ARCH).old $(MFLAGS)

make: $(objs)
	$(CC) $(LDFLAGS) $(objs) $(LOADLIBES) -o make.new
	mv -f make.new make

$(ARCH)/load.o : load.c make.h commands.h 
	cd $(ARCH) ; $(CC) $(CFLAGS) $(LOAD_AVG) -c -I.. ../load.c
$(ARCH)/remote.o : remote.c remote-stub.c make.h commands.h 
	cd $(ARCH) ; $(CC) $(CFLAGS) $(REMOTE) -c -I.. ../remote.c

$(ARCH)/%.o : %.c
	cd $(ARCH) ; $(CC) $(CFLAGS) -c -I.. ../$<

TAGS: $(srcs)
	etags -tw $(srcs)
tags: $(srcs)
	ctags -tw $(srcs)

.PHONY: install
install: $(bindir)/make $(mandir)/make.$(manext)

$(bindir)/make: make
	cp make $@.new
	mv $@.new $@

$(mandir)/make.$(manext): make.man
	@(mkdir $(mandir) >/dev/null 2>&1 ; exit 0)
	cp make.man $@

.PHONY: clean realclean
clean:
	-rm -f make-$(ARCH) $(ARCH)/*.o core

realclean: clean
	-rm -f TAGS tags make.info* make-* make.dvi
	-rm -f make.?? make.??s make.log make.toc make.*aux

% : %.sh
	rm -f $@
	cat $< > $@
	chmod a+x $@

# Automatically generated dependencies.
glob.o : glob.c 
commands.o : commands.c make.h dep.h commands.h file.h variable.h job.h 
job.o : job.c make.h commands.h job.h file.h variable.h 
dir.o : dir.c make.h 
file.o : file.c make.h commands.h dep.h file.h variable.h 
load.o : load.c make.h commands.h job.h 
misc.o : misc.c make.h dep.h 
main.o : main.c make.h commands.h dep.h file.h variable.h job.h 
read.o : read.c make.h commands.h dep.h file.h variable.h 
remake.o : remake.c make.h commands.h job.h dep.h file.h 
remote.o : remote.c remote-stub.c make.h commands.h 
rule.o : rule.c make.h commands.h dep.h file.h variable.h rule.h 
implicit.o : implicit.c make.h rule.h dep.h file.h 
default.o : default.c make.h rule.h dep.h file.h commands.h variable.h 
variable.o : variable.c make.h commands.h variable.h dep.h file.h 
expand.o : expand.c make.h commands.h file.h variable.h 
function.o : function.c make.h variable.h dep.h commands.h job.h 
vpath.o : vpath.c make.h file.h variable.h 
version.o : version.c 
arscan.o : arscan.c 
ar.o : ar.c make.h file.h