Convert to autotools
authorKeith Packard <keithp@keithp.com>
Fri, 20 Jul 2012 18:47:58 +0000 (11:47 -0700)
committerKeith Packard <keithp@keithp.com>
Fri, 20 Jul 2012 19:18:27 +0000 (12:18 -0700)
Installs libstlink for others to use

Signed-off-by: Keith Packard <keithp@keithp.com>
Makefile [deleted file]
Makefile.am [new file with mode: 0644]
configure.ac [new file with mode: 0644]
flash/Makefile [deleted file]
flash/Makefile.am [new file with mode: 0644]
gdbserver/Makefile [deleted file]
gdbserver/Makefile.am [new file with mode: 0644]
src/Makefile.am [new file with mode: 0644]
stlink.pc.in [new file with mode: 0644]

diff --git a/Makefile b/Makefile
deleted file mode 100644 (file)
index 4bb0608..0000000
--- a/Makefile
+++ /dev/null
@@ -1,58 +0,0 @@
-# make ... for both stlink v1 and stlink v2 support
-##
-VPATH=src
-
-SOURCES_LIB=stlink-common.c stlink-usb.c stlink-sg.c uglylogging.c
-OBJS_LIB=$(SOURCES_LIB:.c=.o)
-TEST_PROGRAMS=test_usb test_sg
-LDFLAGS=-L. -lstlink 
-
-# libusb location
-LDFLAGS+=`pkg-config --libs libusb-1.0`
-CFLAGS+=`pkg-config --cflags libusb-1.0`
-
-CFLAGS+=-g
-CFLAGS+=-DDEBUG=1
-CFLAGS+=-std=gnu99
-CFLAGS+=-Wall -Wextra
-
-
-LIBRARY=libstlink.a
-
-all:  $(LIBRARY) flash gdbserver $(TEST_PROGRAMS)
-
-$(LIBRARY): $(OBJS_LIB)
-       @echo "objs are $(OBJS_LIB)"
-       $(AR) -cr $@ $^
-       @echo "done making library"
-       
-
-test_sg: test_sg.o $(LIBRARY)
-       @echo "building test_sg"
-       $(CC) test_sg.o $(LDFLAGS) -o $@
-
-test_usb: test_usb.o $(LIBRARY)
-       @echo "building test_usb"
-       $(CC) test_usb.o $(LDFLAGS) -o $@
-       @echo "done linking"
-
-%.o: %.c
-       @echo "building $^ into $@"
-       $(CC) $(CFLAGS) -c $^ -o $@
-       @echo "done compiling"
-
-clean:
-       rm -rf $(OBJS_LIB)
-       rm -rf $(LIBRARY)
-       rm -rf test_usb*
-       rm -rf test_sg*
-       $(MAKE) -C flash clean
-       $(MAKE) -C gdbserver clean
-       
-flash:
-       $(MAKE) -C flash
-
-gdbserver:
-       $(MAKE) -C gdbserver CONFIG_USE_LIBSG="$(CONFIG_USE_LIBSG)"
-
-.PHONY: clean all flash gdbserver
diff --git a/Makefile.am b/Makefile.am
new file mode 100644 (file)
index 0000000..dbaa8fc
--- /dev/null
@@ -0,0 +1,6 @@
+SUBDIRS=src gdbserver flash
+
+EXTRA_DIST=stlink.pc.in
+
+pkgconfigdir=$(libdir)/pkgconfig
+pkgconfig_DATA = stlink.pc
diff --git a/configure.ac b/configure.ac
new file mode 100644 (file)
index 0000000..a1964c1
--- /dev/null
@@ -0,0 +1,45 @@
+AC_PREREQ(2.60)
+AC_INIT([stlink], 0.1)
+AC_CONFIG_SRCDIR([README])
+AM_INIT_AUTOMAKE([foreign dist-bzip2])
+AM_MAINTAINER_MODE
+
+LIBST_CURRENT=0
+LIBST_REVISION=0
+LIBST_AGE=0
+AC_SUBST(LIBST_CURRENT)
+AC_SUBST(LIBST_REVISION)
+
+LIBST_VERSION_INFO="$LIBST_CURRENT:$LIBST_REVISION:$LIBST_AGE"
+AC_SUBST(LIBST_VERSION_INFO)
+
+AC_CONFIG_HEADERS(config.h)
+
+AC_PROG_CC_C99
+AC_PROG_INSTALL
+AC_PROG_LN_S
+AM_PROG_LIBTOOL
+AC_PROG_MAKE_SET
+PKG_PROG_PKG_CONFIG
+
+WARN_CFLAGS=""
+if test "x$GCC" = "xyes"; then
+       WARN_CFLAGS="-Wall -Wpointer-arith -Wstrict-prototypes \
+       -Wmissing-prototypes -Wmissing-declarations \
+       -Wnested-externs -fno-strict-aliasing"
+       AC_DEFINE_UNQUOTED(HAVE_WARNING_CPP_DIRECTIVE,1,
+       [Can use #warning in C files])
+fi
+AC_SUBST(WARN_CFLAGS)
+
+PKG_CHECK_MODULES(LIBUSB, libusb-1.0)
+
+AC_SUBST(LIBUSB_LIBS)
+AC_SUBST(LIBUSB_CFLAGS)
+
+AC_OUTPUT([
+Makefile
+stlink.pc
+src/Makefile
+gdbserver/Makefile
+flash/Makefile])
diff --git a/flash/Makefile b/flash/Makefile
deleted file mode 100644 (file)
index 5345dcb..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-CFLAGS+=-g
-CFLAGS+=-DDEBUG
-CFLAGS+=-std=gnu99
-CFLAGS+=-Wall -Wextra
-CFLAGS+=-I../src
-
-LDFLAGS=-L.. -lstlink
-
-# libusb location
-LDFLAGS+=`pkg-config --libs libusb-1.0`
-CFLAGS+=`pkg-config --cflags libusb-1.0`
-
-SRCS=main.c
-OBJS=$(SRCS:.c=.o)
-
-NAME=st-flash
-
-all: $(NAME)
-
-$(NAME): $(OBJS) ../libstlink.a
-       $(CC) $(CFLAGS) -o $(NAME) $(OBJS) $(LDFLAGS)
-
-%.o: %.c
-       $(CC) $(CFLAGS) -c $^ -o $@
-
-clean:
-       rm -f $(OBJS)
-       rm -f $(NAME)
-
-.PHONY: clean all
diff --git a/flash/Makefile.am b/flash/Makefile.am
new file mode 100644 (file)
index 0000000..180dde0
--- /dev/null
@@ -0,0 +1,7 @@
+bin_PROGRAMS=st-flash
+
+AM_CFLAGS = -I${top_srcdir}/src $(LIBUSB_CFLAGS) $(WARN_CFLAGS)
+
+st_flash_LDADD = ${top_builddir}/src/libstlink.la
+
+st_flash_SOURCES = main.c
diff --git a/gdbserver/Makefile b/gdbserver/Makefile
deleted file mode 100644 (file)
index bd5c73d..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-PRG := st-util
-OBJS = gdb-remote.o gdb-server.o
-
-CFLAGS+=-g -Wall -Werror -std=gnu99 -I../src
-LDFLAGS=-L.. -lstlink
-
-# libusb location
-LDFLAGS+=`pkg-config --libs libusb-1.0`
-CFLAGS+=`pkg-config --cflags libusb-1.0`
-
-all: $(PRG)
-
-$(PRG): $(OBJS) ../libstlink.a
-       $(CC) -o $@  $^ $(LDFLAGS)
-
-clean:
-       rm -rf $(OBJS)
-       rm -rf $(PRG)
-
-.PHONY: clean all
diff --git a/gdbserver/Makefile.am b/gdbserver/Makefile.am
new file mode 100644 (file)
index 0000000..3fd86c8
--- /dev/null
@@ -0,0 +1,7 @@
+bin_PROGRAMS=st-util
+
+AM_CFLAGS = -I${top_srcdir}/src $(LIBUSB_CFLAGS) $(WARN_CFLAGS)
+
+st_util_LDADD = ${top_builddir}/src/libstlink.la
+
+st_util_SOURCES = gdb-remote.c gdb-server.c gdb-remote.h
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644 (file)
index 0000000..fc7c5e2
--- /dev/null
@@ -0,0 +1,22 @@
+
+AM_CFLAGS = $(LIBUSB_CFLAGS) $(WARN_CFLAGS) -DDEBUG=1
+
+libstlink_la_SOURCES = \
+       stlink-common.c \
+       stlink-common.h \
+       stlink-sg.c \
+       stlink-sg.h \
+       stlink-usb.c \
+       stlink-usb.h \
+       uglylogging.c
+
+libstlink_la_LIBADD = $(LIBUSB_LIBS)
+
+lib_LTLIBRARIES = libstlink.la
+
+libstlinkdir=$(includedir)/stlink
+
+libstlink_HEADERS=\
+       stlink-common.h \
+       stlink-sg.h \
+       stlink-usb.h
\ No newline at end of file
diff --git a/stlink.pc.in b/stlink.pc.in
new file mode 100644 (file)
index 0000000..0ed63f3
--- /dev/null
@@ -0,0 +1,14 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+sysconfdir=@sysconfdir@
+localstatedir=@localstatedir@
+PACKAGE=@PACKAGE@
+
+Name: ST-link
+Description: ST micro programming library and tools
+Version: @VERSION@
+Libs: -L${libdir} -lstlink
+Libs.private: @LIBUSB_LIBS@
+Cflags: -I${includedir}/stlink