Hi all,

The attached patch adds a autoconf check to use libtool and rewrites the
Makefile.am automake inputs to create libtool libraries.  These are
linked into a new libopenocd library that is installed and used by the
openocd application.

Future patches can install those header files that contain public
interfaces to the library, but this is a first step on the road to
exposing some of the OpenOCD internals.

This patch should create libraries portably across all platforms; after
all, that is exactly what libtool was designed to do.  That said, I
wanted to post it here (before I change the build in such a big way) to
see if some folks will try it and provide feedback.

Cheers,

Zach

Index: src/helper/Makefile.am
===================================================================
--- src/helper/Makefile.am	(revision 1611)
+++ src/helper/Makefile.am	(working copy)
@@ -5,7 +5,7 @@
 	-DPKGLIBDIR=\"$(pkglibdir)\"
 
 METASOURCES = AUTO
-noinst_LIBRARIES = libhelper.a
+noinst_LTLIBRARIES = libhelper.la
 
 if ECOSBOARD
 CONFIGFILES = 
@@ -13,19 +13,19 @@
 CONFIGFILES = options.c jim.c jim-eventloop.c 
 endif
 
-
-
-libhelper_a_SOURCES = binarybuffer.c $(CONFIGFILES) configuration.c log.c command.c time_support.c \
+libhelper_la_SOURCES = \
+	binarybuffer.c $(CONFIGFILES) configuration.c \
+	log.c command.c time_support.c \
 	replacements.c fileio.c startup_tcl.c
 
 if IOUTIL
-libhelper_a_SOURCES += ioutil.c
+libhelper_la_SOURCES += ioutil.c
 endif
 
-libhelper_a_CFLAGS =
+libhelper_la_CFLAGS =
 if IS_MINGW
 # FD_* macros are sloppy with their signs on MinGW32 platform
-libhelper_a_CFLAGS += -Wno-sign-compare
+libhelper_la_CFLAGS += -Wno-sign-compare
 endif
 
 noinst_HEADERS = binarybuffer.h configuration.h types.h log.h command.h \
Index: src/pld/Makefile.am
===================================================================
--- src/pld/Makefile.am	(revision 1611)
+++ src/pld/Makefile.am	(working copy)
@@ -4,8 +4,8 @@
 	-I$(top_srcdir)/src/jtag
 
 METASOURCES = AUTO
-noinst_LIBRARIES = libpld.a
+noinst_LTLIBRARIES = libpld.la
 noinst_HEADERS = pld.h xilinx_bit.h virtex2.h
-libpld_a_SOURCES = pld.c xilinx_bit.c virtex2.c
+libpld_la_SOURCES = pld.c xilinx_bit.c virtex2.c
 
 MAINTAINERCLEANFILES = Makefile.in
Index: src/jtag/Makefile.am
===================================================================
--- src/jtag/Makefile.am	(revision 1611)
+++ src/jtag/Makefile.am	(working copy)
@@ -3,7 +3,7 @@
 	-I$(top_srcdir)/src/target
 
 METASOURCES = AUTO
-noinst_LIBRARIES = libjtag.a
+noinst_LTLIBRARIES = libjtag.la
 
 if BITBANG
 BITBANGFILES = bitbang.c
@@ -109,8 +109,12 @@
 ARMJTAGEWFILES =
 endif
 
-libjtag_a_SOURCES = jtag.c $(BITBANGFILES) $(PARPORTFILES) $(DUMMYFILES) $(FT2232FILES) $(AMTJTAGACCELFILES) $(EP93XXFILES) \
-	$(AT91RM9200FILES) $(GW16012FILES) $(BITQFILES) $(PRESTOFILES) $(USBPROGFILES) $(ECOSBOARDFILES) $(JLINKFILES) $(RLINKFILES) $(VSLLINKFILES) $(ARMJTAGEWFILES)
+libjtag_la_SOURCES = jtag.c \
+	$(BITBANGFILES) $(PARPORTFILES) $(DUMMYFILES) \
+	$(FT2232FILES) $(AMTJTAGACCELFILES) $(EP93XXFILES) \
+	$(AT91RM9200FILES) $(GW16012FILES) $(BITQFILES) \
+	$(PRESTOFILES) $(USBPROGFILES) $(ECOSBOARDFILES) \
+	$(JLINKFILES) $(RLINKFILES) $(VSLLINKFILES) $(ARMJTAGEWFILES)
 
 noinst_HEADERS = bitbang.h jtag.h bitq.h rlink/dtc_cmd.h rlink/ep1_cmd.h rlink/rlink.h rlink/st7.h
 
Index: src/target/Makefile.am
===================================================================
--- src/target/Makefile.am	(revision 1611)
+++ src/target/Makefile.am	(working copy)
@@ -11,8 +11,9 @@
 	-I$(top_srcdir)/src/xsvf
 
 METASOURCES = AUTO
-noinst_LIBRARIES = libtarget.a
-libtarget_a_SOURCES = target.c register.c breakpoints.c armv4_5.c embeddedice.c etm.c arm7tdmi.c arm9tdmi.c \
+noinst_LTLIBRARIES = libtarget.la
+libtarget_la_SOURCES = target.c register.c breakpoints.c \
+	armv4_5.c embeddedice.c etm.c arm7tdmi.c arm9tdmi.c \
 	arm_jtag.c arm7_9_common.c algorithm.c arm920t.c arm720t.c armv4_5_mmu.c armv4_5_cache.c arm_disassembler.c \
 	arm966e.c arm926ejs.c feroceon.c etb.c xscale.c arm_simulator.c image.c armv7m.c cortex_m3.c cortex_a8.c arm_adi_v5.c \
 	etm_dummy.c $(OOCD_TRACE_FILES) target_request.c trace.c arm11.c arm11_dbgtap.c mips32.c mips_m4k.c \
Index: src/xsvf/Makefile.am
===================================================================
--- src/xsvf/Makefile.am	(revision 1611)
+++ src/xsvf/Makefile.am	(working copy)
@@ -4,8 +4,8 @@
 	-I$(top_srcdir)/src/jtag
 
 METASOURCES = AUTO
-noinst_LIBRARIES = libxsvf.a
+noinst_LTLIBRARIES = libxsvf.la
 noinst_HEADERS = xsvf.h
-libxsvf_a_SOURCES = xsvf.c
+libxsvf_la_SOURCES = xsvf.c
 
 MAINTAINERCLEANFILES = Makefile.in
Index: src/flash/Makefile.am
===================================================================
--- src/flash/Makefile.am	(revision 1611)
+++ src/flash/Makefile.am	(working copy)
@@ -4,8 +4,8 @@
 	-I$(top_srcdir)/src/target
 
 METASOURCES = AUTO
-noinst_LIBRARIES = libflash.a
-libflash_a_SOURCES = \
+noinst_LTLIBRARIES = libflash.la
+libflash_la_SOURCES = \
 	flash.c lpc2000.c cfi.c non_cfi.c at91sam7.c at91sam7_old.c \
 	str7x.c str9x.c aduc702x.c nand.c nand_ecc.c \
 	lpc3180_nand_controller.c stellaris.c str9xpec.c stm32x.c tms470.c \
Index: src/svf/Makefile.am
===================================================================
--- src/svf/Makefile.am	(revision 1611)
+++ src/svf/Makefile.am	(working copy)
@@ -4,8 +4,8 @@
 	-I$(top_srcdir)/src/jtag
 
 METASOURCES = AUTO
-noinst_LIBRARIES = libsvf.a
+noinst_LTLIBRARIES = libsvf.la
 noinst_HEADERS = svf.h
-libsvf_a_SOURCES = svf.c
+libsvf_la_SOURCES = svf.c
 
 MAINTAINERCLEANFILES = Makefile.in
Index: src/server/Makefile.am
===================================================================
--- src/server/Makefile.am	(revision 1611)
+++ src/server/Makefile.am	(working copy)
@@ -6,23 +6,23 @@
 	-DPKGLIBDIR=\"$(pkglibdir)\"
 
 METASOURCES = AUTO
-noinst_LIBRARIES = libserver.a
+noinst_LTLIBRARIES = libserver.la
 noinst_HEADERS = server.h telnet_server.h gdb_server.h
-libserver_a_SOURCES = server.c telnet_server.c gdb_server.c
+libserver_la_SOURCES = server.c telnet_server.c gdb_server.c
 
 if HTTPD
-libserver_a_SOURCES += httpd.c
+libserver_la_SOURCES += httpd.c
 endif
 
-libserver_a_CFLAGS =
+libserver_la_CFLAGS =
 if IS_MINGW
 # FD_* macros are sloppy with their signs on MinGW32 platform
-libserver_a_CFLAGS += -Wno-sign-compare
+libserver_la_CFLAGS += -Wno-sign-compare
 endif
 
 # tcl server addons
 noinst_HEADERS += tcl_server.h
-libserver_a_SOURCES += tcl_server.c
+libserver_la_SOURCES += tcl_server.c
 
 if HTTPD
 nobase_dist_pkglib_DATA = $(wildcard $(srcdir)/httpd/*.tcl $(srcdir)/httpd/*.css $(srcdir)/httpd/menu_cuts/*.png)
Index: src/Makefile.am
===================================================================
--- src/Makefile.am	(revision 1611)
+++ src/Makefile.am	(working copy)
@@ -1,3 +1,6 @@
+SUBDIRS = helper jtag xsvf svf target server flash pld
+
+lib_LTLIBRARIES = libopenocd.la
 bin_PROGRAMS = openocd
 
 if ECOSBOARD
@@ -6,8 +9,11 @@
 MAINFILE = main.c
 endif
 
-openocd_SOURCES = $(MAINFILE) openocd.c
+openocd_SOURCES = $(MAINFILE) 
+openocd_LDADD = libopenocd.la
 
+libopenocd_la_SOURCES = openocd.c
+
 # set the include path found by configure
 AM_CPPFLAGS = \
 	-I$(top_srcdir)/src \
@@ -21,22 +27,21 @@
 	-I$(top_srcdir)/src/pld
 
 # pass path to prefix path
-openocd_CPPFLAGS = \
+libopenocd_la_CPPFLAGS = \
  -DPKGLIBDIR=\"$(pkglibdir)\" \
  -DPKGBLDDATE=\"`date +%F-%R`\"
 
 if RELEASE
-openocd_CPPFLAGS += -DRELSTR=\"Release\" -DPKGBLDREV=\"\"
+libopenocd_la_CPPFLAGS += -DRELSTR=\"Release\" -DPKGBLDREV=\"\"
 else
-openocd_CPPFLAGS += -DRELSTR=\"svn:\" -DPKGBLDREV=\"`$(top_srcdir)/guess-rev.sh $(top_srcdir)`\"
+libopenocd_la_CPPFLAGS += -DRELSTR=\"svn:\" -DPKGBLDREV=\"`$(top_srcdir)/guess-rev.sh $(top_srcdir)`\"
 endif
 
 # add default CPPFLAGS
-openocd_CPPFLAGS += $(AM_CPPFLAGS) $(CPPFLAGS)
+libopenocd_la_CPPFLAGS += $(AM_CPPFLAGS) $(CPPFLAGS)
 
 # the library search path.
-openocd_LDFLAGS = $(all_libraries) 
-SUBDIRS = helper jtag xsvf svf target server flash pld
+libopenocd_la_LDFLAGS = $(all_libraries) 
 
 if IS_MINGW
 MINGWLDADD = -lwsock32
@@ -72,16 +77,19 @@
 endif
 endif
 
-openocd_LDADD = $(top_builddir)/src/xsvf/libxsvf.a $(top_builddir)/src/svf/libsvf.a \
-	$(top_builddir)/src/target/libtarget.a $(top_builddir)/src/jtag/libjtag.a \
-	$(top_builddir)/src/helper/libhelper.a \
-	$(top_builddir)/src/server/libserver.a $(top_builddir)/src/helper/libhelper.a \
-	$(top_builddir)/src/flash/libflash.a $(top_builddir)/src/target/libtarget.a \
-	$(top_builddir)/src/pld/libpld.a \
+libopenocd_la_LIBADD = \
+	$(top_builddir)/src/xsvf/libxsvf.la \
+	$(top_builddir)/src/svf/libsvf.la \
+	$(top_builddir)/src/pld/libpld.la \
+	$(top_builddir)/src/jtag/libjtag.la \
+	$(top_builddir)/src/flash/libflash.la \
+	$(top_builddir)/src/target/libtarget.la \
+	$(top_builddir)/src/server/libserver.la \
+	$(top_builddir)/src/helper/libhelper.la \
 	$(FTDI2232LIB) $(MINGWLDADD) $(LIBUSB)
 
 if HTTPD
-openocd_LDADD += -lmicrohttpd
+libopenocd_la_LIBADD += -lmicrohttpd
 endif
 
 nobase_dist_pkglib_DATA = \
Index: configure.in
===================================================================
--- configure.in	(revision 1611)
+++ configure.in	(working copy)
@@ -783,6 +783,7 @@
 AC_PROG_CC
 AM_PROG_CC_C_O
 AC_PROG_RANLIB
+AC_PROG_LIBTOOL
 
 # Look for environ alternatives.  Possibility #1: is environ in unistd.h?
 AC_MSG_CHECKING([for environ in unistd.h])
Index: Makefile.am
===================================================================
--- Makefile.am	(revision 1611)
+++ Makefile.am	(working copy)
@@ -20,6 +20,7 @@
 	config.h.in \
 	config.h.in~ \
 	compile \
+	ltmain.sh \
 	missing \
 	aclocal.m4 \
 	install-sh
_______________________________________________
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development

Reply via email to