1# Makefile.am for libcoap
2#
3# Copyright (C) 2010-2015 Olaf Bergmann <bergmann@tzi.org>
4#           (C)      2015 Carsten Schoenert <c.schoenert@t-online.de>
5#
6# This file is part of the CoAP C library libcoap. Please see README and
7# COPYING for terms of use.
8
9## Place generated object files (.o) into the same directory as their source
10## files, in order to avoid collisions when non-recursive make is used.
11AUTOMAKE_OPTIONS = subdir-objects
12
13ACLOCAL_AMFLAGS = ${ACLOCAL_FLAGS} -I m4
14
15## Additional files for the distribution archive
16EXTRA_DIST = \
17  CONTRIBUTE \
18  TODO \
19  $(pkgconfig_DATA).in \
20  libcoap-$(LIBCOAP_API_VERSION).map \
21  libcoap-$(LIBCOAP_API_VERSION).sym \
22  examples/coap_list.h \
23  tests/test_options.h \
24  tests/test_pdu.h \
25  tests/test_error_response.h \
26  tests/test_sendqueue.h \
27  tests/test_uri.h \
28  tests/test_wellknown.h
29
30AM_CFLAGS = -I @top_builddir@/include/coap/ $(WARNING_CFLAGS) -std=c99
31
32SUBDIRS = . $(DOC_DIR) tests examples
33
34## Define a libtool archive target "libcoap-@LIBCOAP_API_VERSION@.la", with
35## @LIBCOAP_API_VERSION@ substituted into the generated Makefile at configure
36## time.
37## The libtool archive file (.la) will be installed into the directory named
38## by the predefined variable $(bindir), along with the actual shared library
39## file (.so).
40lib_LTLIBRARIES = libcoap-@LIBCOAP_API_VERSION@.la
41
42libcoap_@LIBCOAP_API_VERSION@_la_CFLAGS = \
43  -fPIC \
44  -fPIE \
45  $(AM_CFLAGS)
46
47## Define the source file list for the "libcoap.la" target.
48## Note that it is not necessary to list header files which are already listed
49## elsewhere in a _HEADERS variable assignment.
50libcoap_@LIBCOAP_API_VERSION@_la_SOURCES = \
51  src/address.c \
52  src/async.c \
53  src/block.c \
54  src/coap_io.c \
55  src/coap_time.c \
56  src/debug.c \
57  src/encode.c \
58  src/hashkey.c \
59  src/mem.c \
60  src/net.c \
61  src/option.c \
62  src/pdu.c \
63  src/resource.c \
64  src/str.c \
65  src/subscribe.c \
66  src/uri.c
67
68## Define the list of public header files and their install location.
69## The list defined here will be used within the include/Makefile.am
70## and is only a variable because the content is needed also for the
71## generating of the symbol mapping file.
72libcoap_includedir = $(includedir)/coap/
73libcoap_include_HEADERS = \
74   include/coap/address.h \
75   include/coap/async.h \
76   include/coap/bits.h \
77   include/coap/block.h \
78   include/coap/coap.h \
79   include/coap/coap_io.h \
80   include/coap/coap_time.h \
81   include/coap/debug.h \
82   include/coap/encode.h \
83   include/coap/hashkey.h \
84   include/coap/libcoap.h \
85   include/coap/mem.h \
86   include/coap/net.h \
87   include/coap/option.h \
88   include/coap/pdu.h \
89   include/coap/prng.h \
90   include/coap/resource.h \
91   include/coap/str.h \
92   include/coap/subscribe.h \
93   include/coap/uri.h \
94   include/coap/uthash.h \
95   include/coap/utlist.h
96
97# If there is a API change to something $(LIBCOAP_API_VERSION) > 1 the install
98# prefix for the header files has to change to not conflict the older version
99# if the user want's to install both versions. There will be something used like
100# libcoap_include_HEADERS = \
101#   include/coap-$(LIBCOAP_API_VERSION)/*
102
103
104## Instruct libtool to include API version information in the generated shared
105## library file (.so). The library ABI version will later defined in configure.ac,
106## so that all version information is kept in one place.
107libcoap_@LIBCOAP_API_VERSION@_la_LDFLAGS =					\
108  -version-info $(LT_LIBCOAP_CURRENT):$(LT_LIBCOAP_REVISION):$(LT_LIBCOAP_AGE)	\
109  @libcoap_SYMBOLS@ \
110  -pie
111
112CTAGS_IGNORE=-I "coap_packet_extract_pbuf coap_pdu_from_pbuf"
113
114.PHONY:	update-map-file check_ctags
115
116# This helper is called by libcoap-$(LIBCOAP_API_VERSION).{map,sym} to see if
117# configure has detected a usable version of the ctags program and aborts if not.
118check_ctags:
119	@if [ "$(CTAGS_PROG)" = "" ]; then \
120		echo ;\
121		echo "There was no ctags program found by the configure script!" ;\
122		echo "ctags is needed for running this target! Please note the warning about the missed ctags program of the configure script." ;\
123		echo ;\
124		exit 1;\
125	fi
126
127## Helper target to generate the symbol table needed by libtool.
128## The .map format is used when ld supports linker scripts, otherwise
129## it must fall back to a plain symbol file.
130update-map-file: libcoap-$(LIBCOAP_API_VERSION).map libcoap-$(LIBCOAP_API_VERSION).sym
131
132libcoap-$(LIBCOAP_API_VERSION).map: check_ctags $(libcoap_include_HEADERS)
133	( echo "VER_$(LIBCOAP_API_VERSION) {" ; \
134	echo "global:" ; \
135	ctags $(CTAGS_IGNORE) -f - --c-kinds=p $(libcoap_include_HEADERS) | awk '/^coap_/ { print "  " $$1 ";" }' | sort ; \
136	echo "local:" ; \
137	echo "  *;" ; \
138	echo "};" ) > $@.new
139	mv $@.new $@
140
141libcoap-$(LIBCOAP_API_VERSION).sym: check_ctags $(libcoap_include_HEADERS)
142	( ctags $(CTAGS_IGNORE) -f - --c-kinds=p $(libcoap_include_HEADERS) | awk '/^coap_/ { print $$1 }' | sort ) \
143	> $@.new
144	mv $@.new $@
145
146## Install the generated pkg-config file (.pc) into the expected location for
147## architecture-dependent package configuration information.  Occasionally,
148## pkg-config files are also used for architecture-independent data packages,
149## in which case the correct install location would be $(datadir)/pkgconfig.
150pkgconfigdir = $(libdir)/pkgconfig
151pkgconfig_DATA = libcoap-$(LIBCOAP_API_VERSION).pc
152
153## Define an independent executable script for inclusion in the distribution
154## archive.  However, it will not be installed on an end user's system due to
155## the noinst_ prefix.
156dist_noinst_SCRIPTS = autogen.sh
157
158