Skip to content

Commit ae55fe0

Browse files
author
chad-iris
committed
Allow shared target to build shared or dynamic libraries, fix install target for Darwin platforms
1 parent 090b05c commit ae55fe0

File tree

4 files changed

+62
-41
lines changed

4 files changed

+62
-41
lines changed

ChangeLog

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
2017.061: 2.19.2
2+
- Provide install target in Makefile thanks to by Pierre Duperray.
3+
- Deprecate dynamic build target, the shared target will now build
4+
shared or dynamic (Darwin) libraries depending on the system.
5+
- Limit symbols exported in shared libraries to public interfaces
6+
as defined in libmseed.map, thanks again to Pierre Duperray.
7+
- Allow tests to work on Darwin with dynamic libraries.
8+
19
2017.060: 2.19.1
210
- Derive versioning of shared/dynamic library from canonical version
311
defined as LIBMSEED_VERSION in libmseed.h.

INSTALL.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,28 @@ The library requires that C99 integer types are available on the
33
target computer. Specifically the int8_t, int16_t, int32_t, int64_t
44
and their unsigned counterpart types.
55

6-
## Unix
6+
## Unix, Linux, macOS
77

88
A simple 'make' on most Unix-like systems should build the library.
99

1010
The included Makefile should work for most Unix-like environments and
11-
most make variants; it is know to work with GNU make.
11+
most make variants. It is know to work with GNU make, which, if not the
12+
default, is sometimes installed as gmake.
1213

13-
The CC and CFLAGS environment variables can be set to control the build.
14+
The CC, CFLAGS, LDFLAGS and CPPFLAGS environment variables can be set
15+
to control the build.
1416

1517
By default a statically linked version of the library is built: 'libmseed.a'.
1618

1719
With GCC, clang or compatible build tools it is possible to build a shared
1820
library with 'make shared'.
1921

20-
## macOS
22+
A simple install method for the shared library can be invoked with
23+
'make install'. By default the installation destination is /usr/local.
24+
The install destination may be specified using the PREFIX variable, for
25+
example:
2126

22-
A static library can be compiled using the above Unix instructions,
23-
just run 'make'.
24-
25-
Using GCC, clang or compatible build tools it is possible to build a dynamic
26-
library with 'make dynamic'.
27+
make install PREFIX=/path/to/install/
2728

2829
## Windows (Win32)
2930

Makefile

Lines changed: 42 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ MAJOR_VER = $(shell grep LIBMSEED_VERSION libmseed.h | grep -Eo '[0-9]+.[0-9]+.[
1111
FULL_VER = $(shell grep LIBMSEED_VERSION libmseed.h | grep -Eo '[0-9]+.[0-9]+.[0-9]+')
1212
COMPAT_VER = $(MAJOR_VER).0.0
1313

14-
PREFIX ?= /usr/local
14+
# Default settings for install target
15+
PREFIX ?= /usr/local
1516
EXEC_PREFIX ?= $(PREFIX)
16-
LIBDIR ?= $(EXEC_PREFIX)/lib
17+
LIBDIR ?= $(EXEC_PREFIX)/lib
1718
INCLUDEDIR ?= $(PREFIX)/include
1819
DATAROOTDIR ?= $(PREFIX)/share
19-
DOCDIR ?= $(DATAROOTDIR)/doc/libmseed
20+
DOCDIR ?= $(DATAROOTDIR)/doc/libmseed
2021
MANDIR ?= $(DATAROOTDIR)/man
2122
MAN3DIR ?= $(MANDIR)/man3
2223

@@ -33,62 +34,73 @@ LIB_SO_NAME = $(LIB_SO_BASE).$(MAJOR_VER)
3334
LIB_SO = $(LIB_SO_BASE).$(FULL_VER)
3435
LIB_DYN_NAME = libmseed.dylib
3536
LIB_DYN = libmseed.$(FULL_VER).dylib
37+
LIB_FILES = Blarg
3638

3739
all: static
3840

3941
static: $(LIB_A)
4042

41-
shared: $(LIB_SO)
42-
43-
dynamic: $(LIB_DYN)
43+
# Build dynamic (.dylib) on macOS/Darwin, otherwise shared (.so)
44+
shared dynamic:
45+
ifeq ($(shell uname -s),Darwin)
46+
$(MAKE) $(LIB_DYN)
47+
else
48+
$(MAKE) $(LIB_SO)
49+
endif
4450

4551
# Build static library
4652
$(LIB_A): $(LIB_OBJS)
4753
@echo "Building static library $(LIB_A)"
48-
rm -f $(LIB_A)
49-
ar -crs $(LIB_A) $(LIB_OBJS)
54+
$(RM) -f $(LIB_A)
55+
$(AR) -crs $(LIB_A) $(LIB_OBJS)
5056

5157
# Build shared library using GCC-style options
5258
$(LIB_SO): $(LIB_DOBJS)
5359
@echo "Building shared library $(LIB_SO)"
54-
rm -f $(LIB_SO) $(LIB_SONAME) $(LIB_SO_BASE)
55-
$(CC) $(CFLAGS) $(LDFLAGS) -shared -Wl,--version-script=libmseed.map -Wl,-soname -Wl,$(LIB_SO_NAME) -o $(LIB_SO) $(LIB_DOBJS)
60+
$(RM) -f $(LIB_SO) $(LIB_SONAME) $(LIB_SO_BASE)
61+
$(CC) $(CFLAGS) $(LDFLAGS) -shared -Wl,--version-script=libmseed.map -Wl,-soname,$(LIB_SO_NAME) -o $(LIB_SO) $(LIB_DOBJS)
5662
ln -s $(LIB_SO) $(LIB_SO_BASE)
5763
ln -s $(LIB_SO) $(LIB_SO_NAME)
5864

5965
# Build dynamic library (usually for macOS)
6066
$(LIB_DYN): $(LIB_DOBJS)
6167
@echo "Building dynamic library $(LIB_DYN)"
62-
rm -f $(LIB_DYN) $(LIB_DYN_NAME)
68+
$(RM) -f $(LIB_DYN) $(LIB_DYN_NAME)
6369
$(CC) $(CFLAGS) -dynamiclib -compatibility_version $(COMPAT_VER) -current_version $(FULL_VER) -install_name $(LIB_DYN_NAME) -o $(LIB_DYN) $(LIB_DOBJS)
6470
ln -sf $(LIB_DYN) $(LIB_DYN_NAME)
6571

66-
test: static FORCE
72+
test check: static FORCE
6773
@$(MAKE) -C test test
6874

6975
clean:
70-
@rm -f $(LIB_OBJS) $(LIB_DOBJS) $(LIB_A) $(LIB_SO) $(LIB_SO_NAME) $(LIB_SO_BASE) $(LIB_DYN) $(LIB_DYN_NAME)
76+
@$(RM) -f $(LIB_OBJS) $(LIB_DOBJS) $(LIB_A) $(LIB_SO) $(LIB_SO_NAME) $(LIB_SO_BASE) $(LIB_DYN) $(LIB_DYN_NAME)
7177
@$(MAKE) -C test clean
7278
@echo "All clean."
7379

7480
install: shared
75-
mkdir -p $(DESTDIR)$(PREFIX)/include
76-
cp libmseed.h $(DESTDIR)$(PREFIX)/include
77-
mkdir -p $(DESTDIR)$(LIBDIR)/pkgconfig
78-
cp -d libmseed.so* $(DESTDIR)$(LIBDIR)
79-
cp mseed.pc.in $(DESTDIR)$(LIBDIR)/pkgconfig/mseed.pc
80-
sed -i 's|@prefix@|$(PREFIX)|g' $(DESTDIR)$(LIBDIR)/pkgconfig/mseed.pc
81-
sed -i 's|@exec_prefix@|$(EXEC_PREFIX)|g' $(DESTDIR)$(LIBDIR)/pkgconfig/mseed.pc
82-
sed -i 's|@libdir@|$(LIBDIR)|g' $(DESTDIR)$(LIBDIR)/pkgconfig/mseed.pc
83-
sed -i 's|@includedir@|$(PREFIX)/include|g' $(DESTDIR)$(LIBDIR)/pkgconfig/mseed.pc
84-
sed -i 's|@PACKAGE_NAME@|libmseed|g' $(DESTDIR)$(LIBDIR)/pkgconfig/mseed.pc
85-
sed -i 's|@PACKAGE_URL@|http://ds.iris.edu/ds/nodes/dmc/software/downloads/libmseed/|g' $(DESTDIR)$(LIBDIR)/pkgconfig/mseed.pc
86-
sed -i 's|@VERSION@|$(FULL_VER)|g' $(DESTDIR)$(LIBDIR)/pkgconfig/mseed.pc
87-
mkdir -p $(DESTDIR)$(DOCDIR)/example
88-
cp -r example $(DESTDIR)$(DOCDIR)/
89-
cp doc/libmseed-UsersGuide $(DESTDIR)$(DOCDIR)/
90-
mkdir -p $(DESTDIR)$(MAN3DIR)
91-
cp -d doc/ms*.3 $(DESTDIR)$(MAN3DIR)/
81+
@echo "Installing into $(PREFIX)"
82+
@mkdir -p $(DESTDIR)$(PREFIX)/include
83+
@cp libmseed.h $(DESTDIR)$(PREFIX)/include
84+
@mkdir -p $(DESTDIR)$(LIBDIR)/pkgconfig
85+
ifneq ("$(wildcard $(LIB_SO))","")
86+
@cp -a $(LIB_SO_BASE) $(LIB_SO_NAME) $(LIB_SO) $(DESTDIR)$(LIBDIR)
87+
endif
88+
ifneq ("$(wildcard $(LIB_DYN))","")
89+
@cp -a $(LIB_DYN_NAME) $(LIB_DYN) $(DESTDIR)$(LIBDIR)
90+
endif
91+
@sed -e 's|@prefix@|$(PREFIX)|g' \
92+
-e 's|@exec_prefix@|$(EXEC_PREFIX)|g' \
93+
-e 's|@libdir@|$(LIBDIR)|g' \
94+
-e 's|@includedir@|$(PREFIX)/include|g' \
95+
-e 's|@PACKAGE_NAME@|libmseed|g' \
96+
-e 's|@PACKAGE_URL@|http://ds.iris.edu/ds/nodes/dmc/software/downloads/libmseed/|g' \
97+
-e 's|@VERSION@|$(FULL_VER)|g' \
98+
mseed.pc.in > $(DESTDIR)$(LIBDIR)/pkgconfig/mseed.pc
99+
@mkdir -p $(DESTDIR)$(DOCDIR)/example
100+
@cp -r example $(DESTDIR)$(DOCDIR)/
101+
@cp doc/libmseed-UsersGuide $(DESTDIR)$(DOCDIR)/
102+
@mkdir -p $(DESTDIR)$(MAN3DIR)
103+
@cp -a doc/ms*.3 $(DESTDIR)$(MAN3DIR)/
92104

93105
.SUFFIXES: .c .o .lo
94106

libmseed.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
extern "C" {
2929
#endif
3030

31-
#define LIBMSEED_VERSION "2.19.1"
32-
#define LIBMSEED_RELEASE "2017.060"
31+
#define LIBMSEED_VERSION "2.19.2"
32+
#define LIBMSEED_RELEASE "2017.061"
3333

3434
/* C99 standard headers */
3535
#include <stdlib.h>

0 commit comments

Comments
 (0)