summaryrefslogtreecommitdiff
blob: 8d536b927566983fd1da515f6e47a93a9a8c03bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@

top_srcdir=@top_srcdir@
top_builddir=@top_builddir@

CC = @CC@
CXX = @CXX@
LIBTOOL = @LIBTOOL@

CFLAGS = @CFLAGS@
CXXFLAGS = @CXXFLAGS@
LDFLAGS = @LDFLAGS@

LTCC = $(LIBTOOL) --mode=compile --tag=CC $(CC)
LTCXX = $(LIBTOOL) --mode=compile --tag=CXX $(CXX)
LTLD = $(LIBTOOL) --mode=link --tag=CXX $(CXX)

NS_S_PR_CFLAGS = $(shell pkg-config --cflags nss nspr)
NS_S_PR_LIBS = $(shell pkg-config --libs nss nspr)

SRCS = $(shell find "$(top_srcdir)" -name examples -prune -o -type f '(' -name '*.cpp' -o -name '*.c' -not -name '*Test*' ')')
LTOBJS = $(subst .c,.lo,$(subst .cpp,.lo,$(SRCS)))

HDRS = $(top_srcdir)/cshim/mq/xa.h $(shell find "$(top_srcdir)"/cshim -type f -name 'mq*.h')
INSTHDRS = $(subst $(top_srcdir)/cshim,$(DESTDIR)$(includedir),$(HDRS))

LTLIBRARY = libmqcrt.la
INSTLTLIBRARY = $(DESTDIR)$(libdir)/$(LTLIBRARY)

.SUFFIXES:
.SUFFIXES: .cpp .c .lo

default: all

all: $(LTLIBRARY)

Makefile: Makefile.in
	$(top_builddir)/config.status $@

.cpp.lo:
	$(LTCXX) -o $@ $(NS_S_PR_CFLAGS) $(CXXFLAGS) -c $<

.c.lo:
	$(LTCC) -o $@ $(NS_S_PR_CFLAGS) $(CFLAGS) -c $<

VERSIONNUMBER = $(shell { echo '#include "cshim/mqversion.h"'; echo '-version-number MQ_VMAJOR:MQ_VMINOR:MQ_VMICRO'; } | ${CC} -E - | grep version-number)

$(LTLIBRARY): $(LTOBJS)
	version=` \
	 { echo '#include "cshim/mqversion.h"' \
	 ; echo '-version-number MQ_VMAJOR:MQ_VMINOR:MQ_VMICRO' \
	 ; } \
	 | ${CC} -E - \
	 | grep version-number \
	` \
	&& $(LTLD) -o $@ --no-undefined $${version} $(CXXFLAGS) $(NS_S_PR_LIBS) $(LDFLAGS) -rpath $(libdir) $?

$(INSTLTLIBRARY): $(LTLIBRARY)
	$(top_srcdir)/install-sh -d "$(dir $@)"
	$(LIBTOOL) --mode=install cp $(LTLIBRARY) $@

$(DESTDIR)$(includedir)/%: $(top_srcdir)/cshim/%
	$(top_srcdir)/install-sh -d "$(dir $@)"
	cp -f "$<" "$@"

install: $(INSTLTLIBRARY) $(INSTHDRS)