Permalink
Browse files

Added target for shared liubrary creation

Added target for install
Fixes #593
  • Loading branch information...
lucaderi committed Aug 25, 2018
1 parent 2f83375 commit a98c0a81be86936e96be7d2312ae11ef85b785b2
Showing with 57 additions and 119 deletions.
  1. +1 −6 Makefile.am
  2. +1 −1 autogen.sh
  3. +3 −1 configure.seed
  4. +0 −10 libndpi.pc.in
  5. +0 −75 libndpi.sym
  6. +0 −26 src/lib/Makefile
  7. +49 −0 src/lib/Makefile.in
  8. +3 −0 tests/result/ssdp-m-search.pcap.out
@@ -1,8 +1,3 @@
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = src/lib example tests
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libndpi.pc
EXTRA_DIST = libndpi.sym autogen.sh
EXTRA_DIST = autogen.sh
@@ -5,7 +5,7 @@ NDPI_MINOR="5"
NDPI_PATCH="0"
NDPI_VERSION_SHORT="$NDPI_MAJOR.$NDPI_MINOR.$NDPI_PATCH"
rm -f configure config.h config.h.in src/lib/Makefile.in
rm -f configure config.h config.h.in
AUTOCONF=$(command -v autoconf)
AUTOMAKE=$(command -v automake)
@@ -10,6 +10,7 @@ AC_PROG_CC
AM_PROG_CC_C_O
AX_PTHREAD
NDPI_VERSION_SHORT="@NDPI_VERSION_SHORT@"
NDPI_MAJOR="@NDPI_MAJOR@"
NDPI_MINOR="@NDPI_MINOR@"
NDPI_PATCH="@NDPI_PATCH@"
@@ -127,12 +128,13 @@ AC_ARG_ENABLE([debug-messages],
AC_CHECK_LIB(pthread, pthread_setaffinity_np, AC_DEFINE_UNQUOTED(HAVE_PTHREAD_SETAFFINITY_NP, 1, [libc has pthread_setaffinity_np]))
AC_CONFIG_FILES([Makefile example/Makefile tests/Makefile libndpi.pc src/include/ndpi_define.h])
AC_CONFIG_FILES([Makefile example/Makefile tests/Makefile src/include/ndpi_define.h src/lib/Makefile])
AC_CONFIG_HEADERS(src/include/ndpi_config.h)
AC_SUBST(GIT_RELEASE)
AC_SUBST(NDPI_MAJOR)
AC_SUBST(NDPI_MINOR)
AC_SUBST(NDPI_PATCH)
AC_SUBST(NDPI_VERSION_SHORT)
AC_SUBST(SVN_DATE)
AC_SUBST(JSON_C_LIB)
AC_SUBST(PCAP_INC)

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.
@@ -0,0 +1,49 @@
#
# Simple non-autotools dependent makefile
#
# ./autogen.sh
# cd src/lib
# make Makefile
#
#
# Installation directories
#
prefix = /usr/local

This comment has been minimized.

@hlein

hlein Oct 8, 2018

This results in libraries being installed under /usr/local/lib/ (and headers under /usr/local/include/...) regardless of what --prefix is passed at configure-time. This really messes with packaging for distributions who want --prefix=/usr to be respected. Unless I am missing some way that src/lib/Makefile.in can be auto-re-generated?

libdir = ${prefix}/lib
includedir = ${prefix}/include/ndpi
CFLAGS += -fPIC -DPIC -I../include -Ithird_party/include -DNDPI_LIB_COMPILATION -g
RANLIB = ranlib
OBJECTS = $(patsubst protocols/%.c, protocols/%.o, $(wildcard protocols/*.c)) $(patsubst third_party/src/%.c, third_party/src/%.o, $(wildcard third_party/src/*.c)) ndpi_main.o
HEADERS = $(wildcard ../include/*.h)
NDPI_LIB_STATIC = libndpi.a
NDPI_LIB_SHARED_BASE = libndpi.so
NDPI_LIB_SHARED = $(NDPI_LIB_SHARED_BASE).@NDPI_VERSION_SHORT@

This comment has been minimized.

@dsokoloski

dsokoloski Sep 11, 2018

Contributor

Never try to set the interface numbers so that they correspond to the release number of your package. This is an abuse that only fosters misunderstanding of the purpose of library versions.
Shared Library Versioning

NDPI_LIBS = $(NDPI_LIB_STATIC) $(NDPI_LIB_SHARED)
all: $(NDPI_LIBS)
ndpi_main.c: ndpi_content_match.c.inc
$(NDPI_LIB_STATIC): $(OBJECTS)
ar rc $@ $(OBJECTS)
$(RANLIB) $@
$(NDPI_LIB_SHARED): $(OBJECTS)
gcc -shared -fPIC -o $@ $(OBJECTS)
ln -Fs $(NDPI_LIB_SHARED) $(NDPI_LIB_SHARED_BASE)
%.o: %.c $(HEADERS) Makefile
$(CC) $(CFLAGS) -c $< -o $@
clean:
/bin/rm -f $(NDPI_LIB_STATIC) $(OBJECTS) *.o *.so *.lo
install: $(NDPI_LIBS)
mkdir -p $(DESTDIR)$(libdir)
cp $(NDPI_LIBS) $(DESTDIR)$(libdir)/
ln -Fs $(DESTDIR)$(libdir)/$(NDPI_LIB_SHARED) $(DESTDIR)$(libdir)/$(NDPI_LIB_SHARED_BASE)

This comment has been minimized.

@hlein

hlein Oct 8, 2018

Hooray for DESTDIR support!

...However, including $(DESTDIR) in the target of the symlink is not right. It should be OK to make it a relative link to pwd:

ln -Fs $(NDPI_LIB_SHARED) $(DESTDIR)$(libdir)/$(NDPI_LIB_SHARED_BASE)

mkdir -p $(DESTDIR)$(includedir)
cp ../include/*.h $(DESTDIR)$(includedir)
@@ -0,0 +1,3 @@
SSDP 19 1197 1
1 UDP 192.168.242.8:42253 -> 192.168.242.255:32412 [proto: 12/SSDP][cat: System/18][19 pkts/1197 bytes -> 0 pkts/0 bytes]

0 comments on commit a98c0a8

Please sign in to comment.