[gnu.bash.bug] For the NeXT

laplante@iro.umontreal.ca (Pierre Laplante) (09/26/89)

I have the following error when compiling on a NeXT running mach 0.9.

Script started on Tue Sep 26 11:30:13 1989
habitant> make
cc  -g -Bstatic -o bash shell.o y.tab.o general.o make_cmd.o print_cmd.o dispose_cmd.o execute_cmd.o variables.o builtins.o copy_cmd.o flags.o jobs.o subst.o glob.o hash.o mailcheck.o test.o trap.o alias.o alloc-files/malloc.o  braces.o unwind_prot.o  bas
hline.o version.o  readline/libreadline.a /usr/lib/libtermcap.a  
ld: multiple definitions of symbol _realloc
ld: multiple definitions of symbol _malloc
ld: multiple definitions of symbol _free
Undefined symbols:
 lmodt
 lmult
 ldivt

*** Exit 1
Stop.

Here is the Makefile


habitant> cat Makfiler
Makfiler: No such file or directory
habitant> cat Makefile
## -*- text -*- ####################################################
#                                                                  #
# Makefile for bash, the Bourne Again SHell.                       #
#                                                                  #
# Do:                                                              #
#       make            To make `bash' in current directory        #
#       make install    To make bash and install it in DESTDIR     #
#       make newversion To update the version of the shell         #
#       make distribution  If you are a wizard                     #
#       make bash.tar.Z If you are a normal person                 #
#       make clone      To make a clone of the bash distribution.  #
#                                                                  #
# The file `config.h' contains some defines for controlling        #
#  various features.                                               #
#                                                                  #
#                                                                  #
####################################################################

# Here is a rule for making .o files from .c files that doesn't force
# the type of the machine (like -sun3) into the flags.
.c.o:
        $(CC) -c $(CFLAGS) $(CPPFLAGS) $*.c

# Of course, you cannot do this the first time through...
#SHELL=/usr/gnu/bin/bash
SHELL=/bin/sh

# FLAGS THAT REFER TO THE DESTINATION SYSTEM
####################################################################
#
#  The variables in this box can (and should) be changed to match the
#  system that you are compiling the shell on.
#
# The mailing address of you, the local maintainer.  This *must* be
# enclosed in double quotes.  Until I make a better Makefile.
MAINTAINER = '"bfox@ai.mit.edu"'

# Destination installation directory.  The shell is copied here if
# you do a `make install'.  The directory name does NOT end in a slash.
DESTDIR = /usr/local/bin

# The name of the target hardware.  It makes a difference.  If your
# machine doesn't seem to be represented by one of the machines here,
# try one and see how well you do.
# Use i386 for PC type 386 boxes. (Compaq, etc.)
# SUN3, SUN4, SUN386i, VAX, SONY, CONVEX, HP, HP9KS300, i386, NeXT, AIX,
# ATT3B, ATT386
TARGET = NeXT

# The name of the target operating system.  There isn't such a big
# difference between SUNOS3 and Bsd.  But there might be in the future.
# SUNOS3, SUNOS4, SYSV, Bsd, HPUX, UNIXPC
OS = BSD

# You only need this if you are hacking the shell in a location
# that doesn't do enough backups, or does a poor job.  In that
# case, BACKUP_DIR should be the name of a directory on another
# device (i.e. different than the one you are building the shell
# on), and you should do `make backup' at least once a day.
BACKUP_DIR = /home/gogol/bash

#
####################################################################

# FLAGS THAT REFER TO THE COMPILATION PROCESS
####################################################################
#
# PROFILE_FLAGS is either -pg, to generate profiling info for use
# with gprof, or nothing (the default).
PROFILE_FLAGS=

# HP-UX compilation requires the BSD library.
#LOCAL_LIBS = -lBSD

# Xenix requires -lx -ldir.  It is also required in the readline Makefile.
#LOCAL_LIBS = -lx -ldir

GCC_SUNOS4_FLAG = -Bstatic
DEBUG_FLAGS = $(PROFILE_FLAGS) -g $(GCC_SUNOS4_FLAG)
LDFLAGS = $(DEBUG_FLAGS)
CFLAGS  = $(DEBUG_FLAGS) -D${TARGET} -DTARGET=${TARGET} -D${OS}
CPPFLAGS= -I$(LIBSRC)

# If you don't have Bison use "yacc".  Otherwise use "bison -y".
BISON = bison -y

# If you don't have Gcc use cc.
CC = cc

####################################################################

# These are required for sending bug reports.
SYSTEM_NAME = '"$(TARGET)"'
OS_NAME = '"$(OS)"'

# The name of this program.
PROGRAM = bash

# The default primary and secondary prompts.
PPROMPT = '"${PROGRAM}\\$$ "'
SPROMPT = '"${PROGRAM}>"'

# The group of configuration flags.  These are for shell.c
CFG_FLAGS = -DMAINTAINER=$(MAINTAINER) -DPPROMPT=$(PPROMPT)\
            -DSPROMPT=$(SPROMPT) -DOS_NAME=$(OS_NAME)\
            -DSYSTEM_NAME=$(SYSTEM_NAME)

# The directory which contains the source for malloc.  The name must
# end in a slash, as in `./alloc-files/'
ALLOC_SOURCE = ./alloc-files/

# Our malloc.
MALLOC = $(ALLOC_SOURCE)malloc.o
MALLOC_FLAGS = -Drcheck -Dbotch=programming_error
#MALLOC= $(ALLOC_SOURCE)malloc.o
#ALLOCA= $(ALLOC_SOURCE)alloca.o

ALLOC_HEADERS = $(ALLOC_SOURCE)getpagesize.h
ALLOC_FILES = $(ALLOC_SOURCE)malloc.c $(ALLOC_SOURCE)alloca.c\
              $(ALLOC_SOURCE)i386-alloca.s

# Anticipated library for alloca if you do not use an alloc from this package.
# E.g. "-lPW" for AT&T 3B's.  The AT&T 6386 systems can use i386-alloca.o.
# If you are using gcc, then leave ALLOCA_LIB undefined, as __builtin_alloca
# will do the trick.
#ALLOCA_LIB = -lPW
ALLOCA_LIB =

# If your system doesn't have a sys_siglist, then define SIGLIST
# as siglist.o
#SIGLIST = siglist.o

RM = rm
AR = ar
RANLIB = ranlib

# Support libraries required.  Termcap and Readline.
# We would like to use GNU's termcap library.  Where is it?
# If you don't have -ltermcap, you might try -lcurses.
TERMCAP = /usr/lib/libtermcap.a
READLINE= ./readline/libreadline.a

# The source code for the support libraries.
LIBSRC = ./
HISTORY_SOURCE  = $(LIBSRC)readline/history.c $(LIBSRC)readline/history.h
RLIBSRC = $(LIBSRC)readline/
READLINE_SOURCE = $(RLIBSRC)readline.c $(RLIBSRC)readline.h\
                  $(RLIBSRC)chardefs.h $(RLIBSRC)keymaps.h\
                  $(RLIBSRC)funmap.c $(RLIBSRC)emacs_keymap.c\
                  $(RLIBSRC)vi_keymap.c $(RLIBSRC)keymaps.c\
                  $(HISTORY_SOURCE)
TERMCAP_SOURCE  =

READLINE_DOC    = $(RLIBSRC)readline.texinfo\
                  $(RLIBSRC)inc-readline.texinfo
HISTORY_DOC     = $(RLIBSRC)history.texinfo\
                  $(RLIBSRC)inc-history.texinfo
TERMCAP_DOC     =

LIBRARY_SOURCE  = $(READLINE_SOURCE) $(TERMCAP_SOURCE)
LIBRARY_DOC     = $(READLINE_DOC) $(HISTORY_DOC) $(TERMCAP_DOC)
LIBRARY_SUPPORT = $(RLIBSRC)Makefile $(RLIBSRC)ChangeLog
LIBRARY_TAR     = $(LIBRARY_SOURCE) $(LIBRARY_DOC) $(LIBRARY_SUPPORT)

# The order is important.  Most dependent first.
LIBRARIES = $(READLINE) $(TERMCAP)

CSOURCES = shell.c parse.y general.c make_cmd.c print_cmd.c\
           dispose_cmd.c execute_cmd.c variables.c builtins.c\
           copy_cmd.c flags.c subst.c glob.c hash.c mailcheck.c\
           test.c trap.c jobs.c nojobs.c $(ALLOC_FILES) braces.c\
           unwind_prot.c siglist.c bashline.c version.c

HSOURCES = shell.h flags.h trap.h hash.h jobs.h builtins.h alias.c \
           alias.h general.h variables.h config.h $(ALLOC_HEADERS) \
           version.h quit.h

SOURCES  = $(CSOURCES) $(HSOURCES)

OBJECTS  = shell.o y.tab.o general.o make_cmd.o print_cmd.o\
           dispose_cmd.o execute_cmd.o variables.o builtins.o copy_cmd.o\
           flags.o jobs.o subst.o glob.o hash.o mailcheck.o test.o\
           trap.o alias.o $(MALLOC) $(ALLOCA) braces.o unwind_prot.o\
           $(SIGLIST) bashline.o version.o

# Documentation for the shell.
DOCDIR = ./documentation/
BASHDOCS = $(DOCDIR)*.texinfo $(DOCDIR)texinfo.tex
DOCUMENTATION = README FEATURES $(BASHDOCS) $(LIBRARY_DOCS)

# Some example files
EXAMPLES = examples/*

SUPPORT = COPYING Makefile newversion.c make-tarfile mail-shell inform \
          $(DOCUMENTATION) ChangeLog .distribution $(EXAMPLES)

MAIL = shell-mail

# BAGGAGE consists of things that you want to keep with the shell for some
# reason, but don't actually use; old source code, etc.
BAGGAGE = longest_signal_desc.c

THINGS_TO_TAR = $(SOURCES) $(LIBRARY_TAR) $(SUPPORT) $(BAGGAGE)

$(PROGRAM):     .build $(OBJECTS) $(LIBRARIES) Makefile
        $(CC) $(LDFLAGS) -o $(PROGRAM) $(OBJECTS) \
                $(LIBRARIES) $(LOCAL_LIBS) $(ALLOCA_LIB)
        $(RM) .make

.build:         newversion.aux  .make $(SOURCES)
        if newversion.aux -build; then mv -f newversion.h version.h; fi

.make:
        touch .make

version.h:      newversion.aux
        if newversion.aux -build; then mv -f newversion.h version.h; fi

shell.h:        general.h variables.h config.h
                touch shell.h

y.tab.c:        parse.y shell.h
                -if test -f y.tab.h; then mv -f y.tab.h old-y.tab.h; fi
                $(BISON) -d parse.y
                -if cmp -s old-y.tab.h y.tab.h; then mv old-y.tab.h y.tab.h; fi

$(READLINE):    $(READLINE_SOURCE)
                (cd $(RLIBSRC); $(MAKE) $(MFLAGS) CC='$(CC)'\
                        CFLAGS='$(CFLAGS) -DSHELL')

$(TERMCAP):     $(TERMCAP_SOURCE)
                (cd $(LIBSRC); $(MAKE) $(MFLAGS) CC='$(CC)'\
                        CFLAGS='$(CFLAGS) -I.')

shell.o:        shell.h flags.h shell.c
                $(CC) $(CFG_FLAGS) $(CFLAGS) $(CPPFLAGS) -c shell.c

braces.o:       braces.c
                $(CC) $(CFLAGS) -DSHELL -c braces.c

keymaps.c:      emacs_keymap.c vi_keymap.c
                touch keymaps.c

$(MALLOC):      $(ALLOC_FILES)
                $(CC) -I$(ALLOC_SOURCE) $(CFLAGS) $(MALLOC_FLAGS) -c $*.c &&\
                mv `basename $*`.o $(MALLOC)

#$(ALLOCA):     $(ALLOC_FILES)
#               $(CC) -I$(ALLOC_SOURCE) $(CFLAGS) -o $(ALLOCA) -c $*.c

bashline.o:     bashline.c config.h $(RLIBSRC)readline.h
                $(CC) -I../ $(CFLAGS) $(CPPFLAGS) -c bashline.c

bashline.o:     variables.h builtins.h
jobs.o:         jobs.c nojobs.c jobs.h config.h
version.o:      version.h version.c .build
general.o:      general.c shell.h
y.tab.h:        y.tab.c
alias.o:        alias.h alias.c
subst.o:        subst.c shell.h
make_cmd.o:     shell.h config.h make_cmd.c
print_cmd.o:    shell.h y.tab.h print_cmd.c
execute_cmd.o:  shell.h y.tab.h builtins.h flags.h config.h execute_cmd.c
dispose_cmd.o:  shell.h dispose_cmd.c
copy_cmd.o:     shell.h copy_cmd.c
builtins.o:     shell.h flags.h trap.h builtins.h jobs.h config.h builtins.c
flags.o:        flags.h flags.c config.h
hash.o:         hash.h hash.c
trap.o:         shell.h trap.h config.h trap.c
variables.o:    variables.h flags.h

$(PROGRAM).tar: $(THINGS_TO_TAR) .distribution
        make-tarfile $(PROGRAM) `cat .distribution` $(THINGS_TO_TAR)

$(PROGRAM).tar.Z:       $(PROGRAM).tar
                compress -f $(PROGRAM).tar

clone:
        mkdir clone; \
        (cd clone; for i in $(THINGS_TO_TAR); \
          do file=`basename $$i`; \
           dir=`echo $$i | sed "s/$$file\$$//" | sed 's@\(.*\)/\$$@\1@'`; \
           if [ "$$dir" = "" ]; then dir="."; fi; \
           if [ "$$dir" != "." ]; then \
              if [ ! -d "$$dir" ]; then mkdir "$$dir"; fi; \
              if [ "$$file" = Makefile ]; \
                then cp ../$$i $$i; \
               else ln -s ../../$$i $$i; \
              fi; \
           else if [ "$$file" = Makefile ]; then cp ../$$i $$i; \
                 else ln -s ../$$i $$i; fi; \
           fi; \
          done)

# Make `backup' be a link to a directory on another device.
backup:         $(PROGRAM).tar.Z
                if [ ! -h backup ]; then ln -s $(BACKUP_DIR) backup; fi
                cp $(PROGRAM).tar.Z backup/$(PROGRAM).tar.Z

install:        $(PROGRAM)
                -mv $(DESTDIR)/$(PROGRAM) $(DESTDIR)/$(PROGRAM).old
                cp $(PROGRAM) $(DESTDIR)/$(PROGRAM)
                rm -f installed-$(PROGRAM)
                ln -s $(DESTDIR)/$(PROGRAM) installed-$(PROGRAM)

mailable:       distribution
                /bin/rm -rf uuencoded
                mkdir uuencoded
                $(SHELL) -c 'f=$(PROGRAM)-`cat .distribution`.tar.Z;uuencode $$f $$f | split -800 - uuencoded/$$f.uu.'

.distribution:  newversion.aux
                newversion.aux -dist `$(PROGRAM) -c 'echo $$BASH_VERSION'`

distribution:   $(PROGRAM).tar.Z .distribution
                cp $(PROGRAM).tar.Z $(PROGRAM)-`cat .distribution`.tar.Z

newversion.aux: newversion.c
                $(CC) -g -o newversion.aux newversion.c

newversion:     newversion.aux
                rm -f .build
                newversion.aux -dist
                mv -f newversion.h version.h
                make $(PROGRAM)

documentation:
                (cd $(DOCDIR); makeinfo *.texinfo)

tags:           $(SOURCES) $(LIBRARY_SOURCE)
                etags $(SOURCES) $(LIBRARY_SOURCE)
clean:
                rm -f $(OBJECTS) $(PROGRAM) y.tab.c y.tab.h newversion.aux
                (cd $(LIBSRC); rm *.o *.a)
dist-clean:
                rm -f $(OBJECTS) $(PROGRAM) y.tab.c newversion.aux
                rm -rf uuencoded
habitant> 

script done on Tue Sep 26 11:31:05 1989

-- 

Pierre Laplante	 				
Universite de Montreal, Dep. I.R.O. X-220, C.P. 6128, succursale A
Montreal (Quebec) H3C 3J7, (514) 343-6830, laplante@iro.umontreal.ca 

jacob@gore.com (Jacob Gore) (09/26/89)

/ gnu.bash.bug / laplante@iro.umontreal.ca (Pierre Laplante) / Sep 26, 1989 /
> I have the following error when compiling on a NeXT running mach 0.9.
> 
> Script started on Tue Sep 26 11:30:13 1989
> habitant> make
> cc  -g -Bstatic -o bash shell.o y.tab.o general.o make_cmd.o print_cmd.o
> dispose_cmd.o execute_cmd.o variables.o builtins.o copy_cmd.o flags.o
> jobs.o subst.o glob.o hash.o mailcheck.o test.o trap.o alias.o
> alloc-files/malloc.o  braces.o unwind_prot.o  bashline.o version.o
> readline/libreadline.a /usr/lib/libtermcap.a  
> ld: multiple definitions of symbol _realloc
> ld: multiple definitions of symbol _malloc
> ld: multiple definitions of symbol _free
> Undefined symbols:
>  lmodt
>  lmult
>  ldivt

NeXT's cc, by default, links with the shared library /lib/libsys_s.a, and
the loader does not allow symbols in .o files to overrule those in shared
libraries (in 0.9, anyway -- I don't know about 1.0 yet).  Using
/lib/libc.a instead should get rid of the "multiple definitions" problem.
I don't know about the undefined symbols.

I just use the version of malloc in the shared library (just set MALLOC and
MALLOC_FLAGS to nothing in the Makefile).

Jacob
--
Jacob Gore		Jacob@Gore.Com			boulder!gore!jacob