Support for building as a shared library, based on patches from
authorIan Lance Taylor <ian@airs.com>
Mon, 5 Feb 1996 21:17:52 +0000 (21:17 +0000)
committerIan Lance Taylor <ian@airs.com>
Mon, 5 Feb 1996 21:17:52 +0000 (21:17 +0000)
Alan Modra <alan@spri.levels.unisa.edu.au>:
* configure.in: Add AC_ARG_ENABLE for shared and commonbfdlib.
New substitutions: ALLLIBS, PICFLAG, SHLIB, SHLIB_CC,
SHLIB_CFLAGS, COMMON_SHLIB, SHLINK.
* configure: Rebuild.
* Makefile.in (ALLLIBS): New variable.
(PICFLAG, SHLIB, SHLIB_CC, SHLIB_CFLAGS): New variables.
(COMMON_SHLIB, SHLINK): New variables.
(.c.o): If PICFLAG is set, compile twice, once PIC, once normal.
(STAGESTUFF): Remove variable.
(all): Depend upon $(ALLLIBS) rather than $(TARGETLIB).
(stamp-piclist, piclist): New targets.
($(SHLIB), $(SHLINK)): New targets.
($(OFILES)): Depend upon stamp-picdir.
(disassemble.o): Build twice if PICFLAG is set.
(MOSTLYCLEAN): Add pic/*.o.
(clean): Remove $(SHLIB), $(SHLINK), piclist, and stamp-piclist.
(distclean): Remove pic and stamp-picdir.
(install): Install shared libraries.
(stamp-picdir): New target.

opcodes/ChangeLog
opcodes/Makefile.in
opcodes/configure
opcodes/configure.in

index 0ffc548157e07d70f824ba2d3b433f690976becf..75625d5a2930ce48a6a2ae9d241c456574d85133 100644 (file)
@@ -1,3 +1,32 @@
+Mon Feb  5 16:14:42 1996  Ian Lance Taylor  <ian@cygnus.com>
+
+       Support for building as a shared library, based on patches from
+       Alan Modra <alan@spri.levels.unisa.edu.au>:
+       * configure.in: Add AC_ARG_ENABLE for shared and commonbfdlib.
+       New substitutions: ALLLIBS, PICFLAG, SHLIB, SHLIB_CC,
+       SHLIB_CFLAGS, COMMON_SHLIB, SHLINK.
+       * configure: Rebuild.
+       * Makefile.in (ALLLIBS): New variable.
+       (PICFLAG, SHLIB, SHLIB_CC, SHLIB_CFLAGS): New variables.
+       (COMMON_SHLIB, SHLINK): New variables.
+       (.c.o): If PICFLAG is set, compile twice, once PIC, once normal.
+       (STAGESTUFF): Remove variable.
+       (all): Depend upon $(ALLLIBS) rather than $(TARGETLIB).
+       (stamp-piclist, piclist): New targets.
+       ($(SHLIB), $(SHLINK)): New targets.
+       ($(OFILES)): Depend upon stamp-picdir.
+       (disassemble.o): Build twice if PICFLAG is set.
+       (MOSTLYCLEAN): Add pic/*.o.
+       (clean): Remove $(SHLIB), $(SHLINK), piclist, and stamp-piclist.
+       (distclean): Remove pic and stamp-picdir.
+       (install): Install shared libraries.
+       (stamp-picdir): New target.
+
+Fri Feb  2 17:15:25 1996  Doug Evans  <dje@charmed.cygnus.com>
+
+       * sparc-dis.c (print_insn_sparc): Delete DISASM_RAW_INSN support.
+       Print unknown instruction as "unknown", rather than in hex.
+
 Tue Jan 30 14:06:08 1996  Ian Lance Taylor  <ian@cygnus.com>
 
        * dis-buf.c: Include "sysdep.h" before "dis-asm.h".
index e00011cd17b0dcba26dd32114da582abbe94834d..997239380c4149d3cf1c72ecbb5a22c0de041b35 100644 (file)
@@ -51,16 +51,23 @@ AR = @AR@
 AR_FLAGS = rc
 CC = @CC@
 CFLAGS = @CFLAGS@
-BISON = bison
 MAKEINFO = makeinfo
 RANLIB = @RANLIB@
 
+ALLLIBS = @ALLLIBS@
+
+PICFLAG = @PICFLAG@
+SHLIB = @SHLIB@
+SHLIB_CC = @SHLIB_CC@
+SHLIB_CFLAGS = @SHLIB_CFLAGS@
+COMMON_SHLIB = @COMMON_SHLIB@
+SHLINK = @SHLINK@
+
 INCDIR = $(srcdir)/../include
 BFDDIR = $(srcdir)/../bfd
 CSEARCH = -I. -I$(srcdir) -I../bfd -I$(INCDIR) -I$(BFDDIR)
 DEP = mkdep
 
-
 TARGETLIB = libopcodes.a
 
 # To circumvent a Sun make VPATH bug, each file listed here
@@ -87,21 +94,20 @@ FLAGS_TO_PASS = \
        "MAKEINFO=$(MAKEINFO)" \
        "INSTALL=$(INSTALL)" \
        "INSTALL_DATA=$(INSTALL_DATA)" \
-       "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \
-       "BISON=$(BISON)"
+       "INSTALL_PROGRAM=$(INSTALL_PROGRAM)"
 
 ALL_CFLAGS = $(CSEARCH) @HDEFINES@ $(CFLAGS)
 
 .c.o:
+       if [ -n "$(PICFLAG)" ]; then \
+         $(CC) -c $(PICFLAG) $(ALL_CFLAGS) $< -o pic/$@; \
+       else true; fi
        $(CC) -c $(ALL_CFLAGS) $<
 
 # C source files that correspond to .o's.
 CFILES = i386-dis.c z8k-dis.c m68k-dis.c mips-dis.c ns32k-dis.c ppc-dis.c
 
-STAGESTUFF = $(TARGETLIB) $(OFILES)
-
-all: $(TARGETLIB) 
-
+all: $(ALLLIBS)
 
 .NOEXPORT:
 
@@ -120,7 +126,43 @@ $(TARGETLIB): $(OFILES)
         $(AR) $(AR_FLAGS) $(TARGETLIB) $(OFILES)
         $(RANLIB) $(TARGETLIB)
 
+stamp-piclist: Makefile
+       rm -f tpiclist
+       if [ -n "$(PICFLAG)" ]; then \
+         echo $(OFILES) | sed -e 's,\([^ ][^ ]*\),pic/\1,g' > tpiclist; \
+       else \
+         echo $(OFILES) > tpiclist; \
+       fi
+       $(srcdir)/../move-if-change tpiclist piclist
+       touch stamp-piclist
+
+piclist: stamp-piclist ; @true
+
+$(SHLIB): stamp-picdir $(OFILES) piclist
+       rm -f $(SHLIB)
+       if [ "$(COMMON_SHLIB)" != "yes" ]; then \
+         $(SHLIB_CC) $(SHLIB_CFLAGS) -o $(SHLIB) `cat piclist`; \
+       else \
+         lobjs=`cat ../libiberty/required-list ../libiberty/needed-list`; \
+         if [ -n "$(PICFLAG)" ]; then \
+           lobjs=`echo $$lobjs | sed -e 's,\([^ ][^ ]*\),pic/\1,g'`; \
+         fi; \
+         lobjs=`echo $$lobjs | sed -e 's,\([^ ][^ ]*\),../libiberty/\1,g'`; \
+         $(SHLIB_CC) $(SHLIB_CFLAGS) -o $(SHLIB) \
+               `sed -e 's,\([^ ][^ ]*\),../bfd/\1,g' ../bfd/piclist` \
+               `cat piclist` $$lobjs; \
+       fi
+
+$(SHLINK): $(SHLIB)
+       rm -f $(SHLINK)
+       ln -sf `echo $(SHLIB) | sed -e 's,^\.\./bfd/,,'` $(SHLINK)
+
+$(OFILES): stamp-picdir
+
 disassemble.o: disassemble.c $(INCDIR)/dis-asm.h
+       if [ -n "$(PICFLAG)" ]; then \
+         $(CC) -c @archdefs@ $(PICFLAG) $(ALL_CFLAGS) $(srcdir)/disassemble.c -o pic/disassemble.o; \
+       else true; fi
        $(CC) -c @archdefs@ $(ALL_CFLAGS) $(srcdir)/disassemble.c
 
 a29k-dis.o: a29k-dis.c $(INCDIR)/dis-asm.h $(INCDIR)/opcode/a29k.h
@@ -152,14 +194,15 @@ tags etags: TAGS
 TAGS: force
        etags $(INCDIR)/*.h $(srcdir)/*.h $(srcdir)/*.c
 
-MOSTLYCLEAN = *.o core *.E *.p *.ip config.log
+MOSTLYCLEAN = *.o core *.E *.p *.ip config.log pic/*.o
 mostlyclean:
        rm -rf $(MOSTLYCLEAN)
 clean:
-       rm -f *.a $(MOSTLYCLEAN)
+       rm -f *.a $(MOSTLYCLEAN) $(SHLIB) $(SHLINK) piclist stamp-piclist
 distclean: clean
-       rm -rf Makefile config.status TAGS config.cache config.h
-clobber realclean: distclean
+       rm -rf Makefile config.status TAGS config.cache config.h stamp-h \
+              pic stamp-picdir
+clobber realclean maintainer-clean: distclean
 
 # Mark everything as depending on config.status, since the timestamp on
 # sysdep.h might actually move backwards if we reconfig and relink it
@@ -184,9 +227,20 @@ roll:
 #
 force:
 
-install:
-       $(INSTALL_DATA) $(TARGETLIB) $(libdir)/libopcodes.a
-       $(RANLIB) $(libdir)/libopcodes.a
+install: $(ALLLIBS)
+       for f in $(ALLLIBS); do \
+         bf=`echo $$f | sed -e 's,^\.\./bfd/,,'`; \
+         rm -f $(libdir)/$$bf; \
+         if [ "$$f" = "$(SHLINK)" ]; then \
+           ln -sf `echo $(SHLIB) | sed -e 's,^\.\./bfd/,,'` $(libdir)/$$bf; \
+         elif [ "$$f" = "$(SHLIB)" ]; then \
+           $(INSTALL_PROGRAM) $$f $(libdir)/$$bf; \
+         else \
+           $(INSTALL_DATA) $$f $(libdir)/$$bf; \
+           $(RANLIB) $(libdir)/$$bf; \
+           chmod a-x $(libdir)/$$bf; \
+         fi; \
+       done
 
 Makefile: Makefile.in config.status
        CONFIG_FILES=Makefile CONFIG_HEADERS= $(SHELL) ./config.status
@@ -201,6 +255,11 @@ config.status : configure $(srcdir)/../bfd/configure.host $(srcdir)/../bfd/confi
 dep: $(CFILES)
        mkdep $(CFLAGS) $?
 
+stamp-picdir:
+       if [ -n "$(PICFLAG)" ] && [ ! -d pic ]; then \
+         mkdir pic; \
+       else true; fi
+       touch stamp-picdir
 
 # What appears below is generated by a hacked mkdep using gcc -MM.
 
index b73a75c29be4249a21a93778f311e409c2041370..f3bea807a81eed0738193e8bfccabded1bcc60c3 100755 (executable)
@@ -1,7 +1,7 @@
 #! /bin/sh
 
 # Guess values for system-dependent variables and create Makefiles.
-# Generated automatically using autoconf version 2.6 
+# Generated automatically using autoconf version 2.7 
 # Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc.
 #
 # This configure script is free software; the Free Software Foundation
@@ -13,6 +13,10 @@ ac_default_prefix=/usr/local
 # Any additions from configure.in:
 ac_help="$ac_help
   --enable-targets        alternative target configurations"
+ac_help="$ac_help
+  --enable-shared         build shared opcodes library"
+ac_help="$ac_help
+  --enable-commonbfdlib   build shared BFD/opcodes/libiberty library"
 
 # Initialize some variables set by options.
 # The variables have the same names as the options, with
@@ -332,7 +336,7 @@ EOF
     verbose=yes ;;
 
   -version | --version | --versio | --versi | --vers)
-    echo "configure generated by autoconf version 2.6"
+    echo "configure generated by autoconf version 2.7"
     exit 0 ;;
 
   -with-* | --with-*)
@@ -545,6 +549,24 @@ if test "${enable_targets+set}" = set; then
   *)        enable_targets=$enableval ;;
 esac
 fi
+# Check whether --enable-shared or --disable-shared was given.
+if test "${enable_shared+set}" = set; then
+  enableval="$enable_shared"
+  case "${enableval}" in
+  yes) shared=true ;;
+  no)  shared=false ;;
+  *)   { echo "configure: error: bad value ${enableval} for opcodes shared option" 1>&2; exit 1; } ;;
+esac
+fi
+# Check whether --enable-commonbfdlib or --disable-commonbfdlib was given.
+if test "${enable_commonbfdlib+set}" = set; then
+  enableval="$enable_commonbfdlib"
+  case "${enableval}" in
+  yes) commonbfdlib=true ;;
+  no)  commonbfdlib=false ;;
+  *)   { echo "configure: error: bad value ${enableval} for opcodes commonbfdlib option" 1>&2; exit 1; } ;;
+esac
+fi
 
 
 
@@ -659,6 +681,22 @@ fi
 
 # host-specific stuff:
 
+ALLIBS='$(TARGETLIB)'
+PICFLAG=
+SHLIB=
+SHLINK=
+if test "${shared}" = "true"; then
+  ALLLIBS='$(TARGETLIB) $(SHLIB) $(SHLINK)'
+  PICFLAG=-fpic
+  if test "${commonbfdlib}" = "true"; then
+    SHLIB=../bfd/libbfd.so.`sed -e 's/[^0-9]*\([0-9.]*\).*/\1/' ${srcdir}/../bfd/VERSION`
+    SHLINK=../bfd/libbfd.so
+  else
+    SHLIB=libopcodes.so.`sed -e 's/[^0-9]*\([0-9.]*\).*/\1/' ${srcdir}/../bfd/VERSION`
+    SHLINK=libopcodes.so
+  fi
+fi
+
 . ${srcdir}/../bfd/configure.host
 
 # Extract the first word of "gcc", so it can be a program name with args.
@@ -854,6 +892,28 @@ test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
 test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
 
 
+if test "${shared}" = "true"; then
+  if test "${GCC}" != "yes" && test "${shared_non_gcc}" != "yes"; then
+    echo "configure: warning: opcodes --enable-shared only supported when using gcc" 1>&2
+    shared=false
+    PICFLAG=
+    SHLIB=
+  fi
+fi
+
+
+
+
+
+
+if test "${commonbfdlib}" = "true"; then
+  COMMON_SHLIB=yes
+else
+  COMMON_SHLIB=
+fi
+
+
+
 echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
 # On Suns, sometimes $CPP names a directory.
 if test -n "$CPP" && test -d "$CPP"; then
@@ -869,7 +929,7 @@ else
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp.
   cat > conftest.$ac_ext <<EOF
-#line 873 "configure"
+#line 933 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
@@ -883,7 +943,7 @@ else
   rm -rf conftest*
   CPP="${CC-cc} -E -traditional-cpp"
   cat > conftest.$ac_ext <<EOF
-#line 887 "configure"
+#line 947 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
@@ -916,7 +976,7 @@ if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 920 "configure"
+#line 980 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
@@ -1129,7 +1189,7 @@ do
     echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
     exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
   -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
-    echo "$CONFIG_STATUS generated by autoconf version 2.6"
+    echo "$CONFIG_STATUS generated by autoconf version 2.7"
     exit 0 ;;
   -help | --help | --hel | --he | --h)
     echo "\$ac_cs_usage"; exit 0 ;;
@@ -1141,10 +1201,12 @@ ac_given_srcdir=$srcdir
 ac_given_INSTALL="$INSTALL"
 
 trap 'rm -fr `echo "Makefile config.h:config.in" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
+EOF
+cat >> $CONFIG_STATUS <<EOF
 
 # Protect against being on the right side of a sed subst in config.status.
-sed 's/%@/@@/; s/@%/@@/; s/%g$/@g/; /@g$/s/[\\\\&%]/\\\\&/g;
- s/@@/%@/; s/@@/@%/; s/@g$/%g/' > conftest.subs <<\CEOF
+sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
+ s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
 $ac_vpsub
 $extrasub
 s%@CFLAGS@%$CFLAGS%g
@@ -1189,6 +1251,13 @@ s%@AR@%$AR%g
 s%@RANLIB@%$RANLIB%g
 s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
 s%@INSTALL_DATA@%$INSTALL_DATA%g
+s%@ALLLIBS@%$ALLLIBS%g
+s%@PICFLAG@%$PICFLAG%g
+s%@SHLIB@%$SHLIB%g
+s%@SHLIB_CC@%$SHLIB_CC%g
+s%@SHLIB_CFLAGS@%$SHLIB_CFLAGS%g
+s%@COMMON_SHLIB@%$COMMON_SHLIB%g
+s%@SHLINK@%$SHLINK%g
 s%@CPP@%$CPP%g
 s%@archdefs@%$archdefs%g
 s%@BFD_MACHINES@%$BFD_MACHINES%g
index 1ef7c5d1704bd47ba18b9980c4a26f0e86fe1783..f68f0982c24ed69d7b899ea4925e4a690790bd24 100644 (file)
@@ -26,6 +26,20 @@ AC_ARG_ENABLE(targets,
   no)       enable_targets= ;;
   *)        enable_targets=$enableval ;;
 esac])dnl
+AC_ARG_ENABLE(shared,
+[  --enable-shared         build shared opcodes library],
+[case "${enableval}" in
+  yes) shared=true ;;
+  no)  shared=false ;;
+  *)   AC_MSG_ERROR([bad value ${enableval} for opcodes shared option]) ;;
+esac])dnl
+AC_ARG_ENABLE(commonbfdlib,
+[  --enable-commonbfdlib   build shared BFD/opcodes/libiberty library],
+[case "${enableval}" in
+  yes) commonbfdlib=true ;;
+  no)  commonbfdlib=false ;;
+  *)   AC_MSG_ERROR([bad value ${enableval} for opcodes commonbfdlib option]) ;;
+esac])dnl
 
 AC_CONFIG_HEADER(config.h:config.in)
 
@@ -37,16 +51,57 @@ fi
 
 # host-specific stuff:
 
+ALLIBS='$(TARGETLIB)'
+PICFLAG=
+SHLIB=
+SHLINK=
+if test "${shared}" = "true"; then
+  ALLLIBS='$(TARGETLIB) $(SHLIB) $(SHLINK)'
+  PICFLAG=-fpic
+  if test "${commonbfdlib}" = "true"; then
+changequote(,)dnl
+    SHLIB=../bfd/libbfd.so.`sed -e 's/[^0-9]*\([0-9.]*\).*/\1/' ${srcdir}/../bfd/VERSION`
+changequote([,])dnl
+    SHLINK=../bfd/libbfd.so
+  else
+changequote(,)dnl
+    SHLIB=libopcodes.so.`sed -e 's/[^0-9]*\([0-9.]*\).*/\1/' ${srcdir}/../bfd/VERSION`
+changequote([,])dnl
+    SHLINK=libopcodes.so
+  fi
+fi
+
 . ${srcdir}/../bfd/configure.host
 
 AC_PROG_CC
 AC_SUBST(CFLAGS)
 AC_SUBST(HDEFINES)
-AR=${AR-ar}
-AC_SUBST(AR)
+AC_CHECK_PROG(AR, ar, ar, :)
 AC_PROG_RANLIB
 AC_PROG_INSTALL
 
+if test "${shared}" = "true"; then
+  if test "${GCC}" != "yes" && test "${shared_non_gcc}" != "yes"; then
+    AC_MSG_WARN([opcodes --enable-shared only supported when using gcc])
+    shared=false
+    PICFLAG=
+    SHLIB=
+  fi
+fi
+
+AC_SUBST(ALLLIBS)
+AC_SUBST(PICFLAG)
+AC_SUBST(SHLIB)
+AC_SUBST(SHLIB_CC)
+AC_SUBST(SHLIB_CFLAGS)
+if test "${commonbfdlib}" = "true"; then
+  COMMON_SHLIB=yes
+else
+  COMMON_SHLIB=
+fi
+AC_SUBST(COMMON_SHLIB)
+AC_SUBST(SHLINK)
+
 AC_CHECK_HEADERS(string.h strings.h)
 
 # target-specific stuff:
@@ -90,11 +145,13 @@ if test x${all_targets} = xfalse ; then
        archdefs="$archdefs -DARCH_$ad"
        case "$arch" in
        bfd_a29k_arch)          ta="$ta a29k-dis.o" ;;
+       bfd_alliant_arch)       ;;
        bfd_alpha_arch)         ta="$ta alpha-dis.o" ;;
 # start-sanitize-arc
        bfd_arc_arch)           ta="$ta arc-dis.o arc-opc.o" ;;
 # end-sanitize-arc
        bfd_arm_arch)           ta="$ta arm-dis.o" ;;
+       bfd_convex_arch)        ;;
        bfd_h8300_arch)         ta="$ta h8300-dis.o" ;;
        bfd_h8500_arch)         ta="$ta h8500-dis.o" ;;
        bfd_hppa_arch)          ta="$ta hppa-dis.o" ;;
@@ -106,16 +163,19 @@ if test x${all_targets} = xfalse ; then
        bfd_mips_arch)          ta="$ta mips-dis.o mips-opc.o" ;;
        bfd_ns32k_arch)         ta="$ta ns32k-dis.o" ;;
        bfd_powerpc_arch)       ta="$ta ppc-dis.o ppc-opc.o" ;;
+       bfd_pyramid_arch)       ;;
+       bfd_romp_arch)          ;;
        bfd_rs6000_arch)        ta="$ta ppc-dis.o ppc-opc.o" ;;
-       bfd_sh_arch)            ta="$ta sh-dis.o" ;;
 # start-sanitize-rce
        bfd_rce_arch)           ta="$ta rce-dis.o" ;;
 # end-sanitize-rce
+       bfd_sh_arch)            ta="$ta sh-dis.o" ;;
        bfd_sparc_arch)         ta="$ta sparc-dis.o sparc-opc.o" ;;
+       bfd_tahoe_arch)         ;;
        bfd_vax_arch)           ;;
+       bfd_w65_arch)           ta="$ta w65-dis.o" ;;
        bfd_we32k_arch)         ;;
        bfd_z8k_arch)           ta="$ta z8k-dis.o" ;;
-       bfd_w65_arch)           ta="$ta w65-dis.o" ;;
 
        "")                     ;;
        *)              AC_MSG_ERROR(*** unknown target architecture $arch) ;;