Merge pull request #4 from barak/upstream
[liboping.git] / src / Makefile.am
1 AUTOMAKE_OPTIONS = foreign no-dependencies
2
3 SUBDIRS = mans
4
5 if COMPILER_IS_GCC
6 AM_CFLAGS = -Wall -Werror
7 endif
8
9 include_HEADERS = oping.h
10 lib_LTLIBRARIES = liboping.la
11
12 # version-info: current:revision:age
13 #
14 # * If the library source code has changed at all since the last update, then
15 #   increment revision (‘c:r:a’ becomes ‘c:r+1:a’).
16 # * If any interfaces have been added, removed, or changed since the last
17 #   update, increment current, and set revision to 0.
18 # * If any interfaces have been added since the last public release, then
19 #   increment age.
20 # * If any interfaces have been removed since the last public release, then
21 #   set age to 0. 
22 #
23 # <http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html>
24 liboping_la_SOURCES = oping.h liboping.c
25
26 liboping_la_CPPFLAGS = $(AM_CPPFLAGS)
27 liboping_la_LDFLAGS = $(AM_LDFLAGS) -version-info @LIBOPING_CURRENT@:@LIBOPING_REVISION@:@LIBOPING_AGE@
28 liboping_la_LIBADD =
29 if BUILD_WITH_LIBSOCKET
30 liboping_la_LIBADD += -lsocket
31 endif
32 if BUILD_WITH_LIBXNET
33 liboping_la_LIBADD += -lxnet
34 endif
35
36 oping.pc:
37         echo 'prefix=$(prefix)'                 >  $@
38         echo 'exec_prefix=$(exec_prefix)'       >> $@
39         echo 'includedir=$(includedir)'         >> $@
40         echo 'libdir=$(libdir)'                 >> $@
41         echo                                    >> $@
42         echo 'Name: $(PACKAGE_TARNAME)'         >> $@
43         echo 'Description: $(PACKAGE_NAME)'     >> $@
44         echo 'URL: $(PACKAGE_URL)'              >> $@
45         echo 'Version: $(PACKAGE_VERSION)'      >> $@
46         echo 'Cflags: -I${includedir}'          >> $@
47         echo 'Libs: -L${libdir} -loping'        >> $@
48         echo 'Libs.private: $(AM_LDFLAGS) $(LIBS) $(liboping_la_LIBADD)'        >> $@
49
50 pkgconfig_DATA = oping.pc
51
52 MOSTLYCLEANFILES = $(pkgconfig_DATA)
53
54 bin_PROGRAMS = oping
55
56 oping_SOURCES = oping.c
57 oping_LDADD = liboping.la -lm
58 if BUILD_WITH_LIBRT
59 oping_LDADD += -lrt
60 endif
61
62 if BUILD_WITH_LIBNCURSES
63 bin_PROGRAMS += noping
64
65 noping_SOURCES = oping.c
66 noping_CPPFLAGS = $(AM_CPPFLAGS) -DUSE_NCURSES=1
67 noping_LDADD = liboping.la -lm $(NCURSES_LIB)
68 if BUILD_WITH_LIBRT
69 noping_LDADD += -lrt
70 endif
71 endif # BUILD_WITH_LIBNCURSES
72
73 install-exec-hook:
74         @if test "x0" = "x$$UID"; then \
75                 if test "xLinux" = "x`uname -s`"; then \
76                         echo "Setting CAP_NET_RAW capability on binaries."; \
77                         setcap cap_net_raw=ep $(DESTDIR)$(bindir)/oping || true; \
78                         setcap cap_net_raw=ep $(DESTDIR)$(bindir)/noping || true; \
79                 else \
80                         echo "Setting set-UID bit on binaries."; \
81                         chmod u+s $(DESTDIR)$(bindir)/oping || true; \
82                         chmod u+s $(DESTDIR)$(bindir)/noping || true; \
83                 fi; \
84         fi