liboping.pc: Let configure create the pkg-config file.
authorFlorian Forster <ff@octo.it>
Thu, 25 Sep 2014 19:23:10 +0000 (12:23 -0700)
committerFlorian Forster <ff@octo.it>
Thu, 25 Sep 2014 19:23:10 +0000 (12:23 -0700)
.gitignore
configure.ac
src/Makefile.am
src/liboping.pc.in [new file with mode: 0644]

index c8c5e41..b9cb926 100644 (file)
@@ -28,7 +28,7 @@ src/mans/*.3
 src/mans/*.8
 src/oping
 src/noping
-src/oping.pc
+src/liboping.pc
 *.bs
 *.la
 *.lo
index ee99bfb..ac067e9 100644 (file)
@@ -48,6 +48,12 @@ LT_INIT([dlopen])
 # pkg-config interface
 PKG_INSTALLDIR
 
+AC_ARG_WITH(pkgconfigdir,
+           AC_HELP_STRING([--with-pkgconfigdir], [Use the specified pkgconfig dir (default is libdir/pkgconfig)]),
+           [pkgconfigdir="${withval}"],
+           [pkgconfigdir='${libdir}/pkgconfig'])
+AC_SUBST([pkgconfigdir])
+
 # Checks for header files.
 AC_HEADER_STDC
 AC_HEADER_TIME
@@ -164,12 +170,16 @@ AC_TYPE_UINT16_T
 AC_TYPE_UINT32_T
 AC_TYPE_UINT8_T
 
+LIBOPING_PC_LIBS_PRIVATE=''
+
 socket_needs_socket="no"
 AC_CHECK_FUNCS(socket, [],
        AC_CHECK_LIB(socket, socket,
                [socket_needs_socket="yes"],
                AC_MSG_ERROR(cannot find socket)))
-AM_CONDITIONAL(BUILD_WITH_LIBSOCKET, test "x$socket_needs_socket" = "xyes")
+if test "x$socket_needs_socket" = "xyes"; then
+       LIBOPING_PC_LIBS_PRIVATE="${LIBOPING_PC_LIBS_PRIVATE} -lsocket"
+fi
 
 # Under Solaris, the `xnet' library provides `recvmsg' which complies with the
 # X/Open CAE Specification.
@@ -179,7 +189,11 @@ if test "x$with_libxnet" = "xyes"
 then
        CPPFLAGS="$CPPFLAGS -D_XPG4_2 -D__EXTENSIONS__"
 fi
-AM_CONDITIONAL(BUILD_WITH_LIBXNET, test "x$with_libxnet" = "xyes")
+if test "x$with_libxnet" = "xyes"; then
+       LIBOPING_PC_LIBS_PRIVATE="${LIBOPING_PC_LIBS_PRIVATE} -lxnet"
+fi
+
+AC_SUBST(LIBOPING_PC_LIBS_PRIVATE)
 
 nanosleep_needs_rt="no"
 AC_CHECK_FUNCS(nanosleep, [],
@@ -253,5 +267,5 @@ AC_FUNC_MALLOC
 AC_FUNC_STRERROR_R
 AC_CHECK_FUNCS([gettimeofday memset modf select socket sqrt strcasecmp strdup strerror strncasecmp strtoul])
 
-AC_CONFIG_FILES([Makefile src/Makefile src/mans/Makefile bindings/Makefile])
+AC_CONFIG_FILES([Makefile src/Makefile src/liboping.pc src/mans/Makefile bindings/Makefile])
 AC_OUTPUT
index 65d7adb..ec4c398 100644 (file)
@@ -25,29 +25,9 @@ liboping_la_SOURCES = oping.h liboping.c
 
 liboping_la_CPPFLAGS = $(AM_CPPFLAGS)
 liboping_la_LDFLAGS = $(AM_LDFLAGS) -version-info @LIBOPING_CURRENT@:@LIBOPING_REVISION@:@LIBOPING_AGE@
-liboping_la_LIBADD =
-if BUILD_WITH_LIBSOCKET
-liboping_la_LIBADD += -lsocket
-endif
-if BUILD_WITH_LIBXNET
-liboping_la_LIBADD += -lxnet
-endif
-
-oping.pc:
-       echo 'prefix=$(prefix)'                 >  $@
-       echo 'exec_prefix=$(exec_prefix)'       >> $@
-       echo 'includedir=$(includedir)'         >> $@
-       echo 'libdir=$(libdir)'                 >> $@
-       echo                                    >> $@
-       echo 'Name: $(PACKAGE_TARNAME)'         >> $@
-       echo 'Description: $(PACKAGE_NAME)'     >> $@
-       echo 'URL: $(PACKAGE_URL)'              >> $@
-       echo 'Version: $(PACKAGE_VERSION)'      >> $@
-       echo 'Cflags: -I${includedir}'          >> $@
-       echo 'Libs: -L${libdir} -loping'        >> $@
-       echo 'Libs.private: $(AM_LDFLAGS) $(LIBS) $(liboping_la_LIBADD)'        >> $@
+liboping_la_LIBADD = $(LIBOPING_PC_LIBS_PRIVATE)
 
-pkgconfig_DATA = oping.pc
+pkgconfig_DATA = liboping.pc
 
 MOSTLYCLEANFILES = $(pkgconfig_DATA)
 
diff --git a/src/liboping.pc.in b/src/liboping.pc.in
new file mode 100644 (file)
index 0000000..5016623
--- /dev/null
@@ -0,0 +1,12 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+includedir=@includedir@
+libdir=@libdir@
+
+Name: @PACKAGE_NAME@
+Description: C/C++ library to generate ICMP ECHO_REQUESTs
+URL: @PACKAGE_URL@
+Version: @PACKAGE_VERSION@
+Cflags: -I${includedir}
+Libs: -L${libdir} -loping
+Libs.private: @LIBOPING_PC_LIBS_PRIVATE@