miniupnp/miniupnpc/Makefile

405 lines
13 KiB
Makefile
Raw Normal View History

2016-10-07 09:16:03 +00:00
# $Id: Makefile,v 1.134 2016/10/07 09:04:36 nanard Exp $
2011-09-27 20:25:35 +00:00
# MiniUPnP Project
# http://miniupnp.free.fr/
# http://miniupnp.tuxfamily.org/
# https://github.com/miniupnp/miniupnp
# (c) 2005-2018 Thomas Bernard
2011-09-27 20:25:35 +00:00
# to install use :
# $ make DESTDIR=/tmp/dummylocation install
2011-09-27 20:25:35 +00:00
# or
# $ INSTALLPREFIX=/usr/local make install
2012-04-06 14:06:30 +00:00
# or
# $ make install (default INSTALLPREFIX is /usr)
OS = $(shell $(CC) -dumpmachine)
2012-01-25 09:57:46 +00:00
VERSION = $(shell cat VERSION)
2012-01-23 23:14:43 +00:00
ifneq (, $(findstring darwin, $(OS)))
2012-01-23 23:14:43 +00:00
JARSUFFIX=mac
LIBTOOL ?= $(shell which libtool)
endif
ifneq (, $(findstring linux, $(OS)))
2012-01-25 10:07:02 +00:00
JARSUFFIX=linux
endif
ifneq (, $(findstring mingw, $(OS))$(findstring cygwin, $(OS))$(findstring msys, $(OS)))
2012-12-21 17:13:04 +00:00
JARSUFFIX=win32
endif
2012-01-23 23:14:43 +00:00
2012-10-16 04:59:05 +00:00
HAVE_IPV6 ?= yes
export HAVE_IPV6
2011-09-27 20:25:35 +00:00
CC ?= gcc
#AR = gar
2012-05-01 18:49:43 +00:00
#CFLAGS = -O -g -DDEBUG
CFLAGS ?= -O
CFLAGS += -Wall
CFLAGS += -W -Wstrict-prototypes
CFLAGS += -fno-common
CFLAGS += -DMINIUPNPC_SET_SOCKET_TIMEOUT
CFLAGS += -DMINIUPNPC_GET_SRC_ADDR
CFLAGS += -D_BSD_SOURCE
CFLAGS += -D_DEFAULT_SOURCE
ifneq (, $(findstring netbsd, $(OS)))
2016-09-03 07:34:15 +00:00
CFLAGS += -D_NETBSD_SOURCE
endif
ifeq (, $(findstring freebsd, $(OS))$(findstring darwin, $(OS)))
#CFLAGS += -D_POSIX_C_SOURCE=200112L
CFLAGS += -D_XOPEN_SOURCE=600
2015-09-04 10:16:16 +00:00
endif
2015-09-04 08:22:34 +00:00
#CFLAGS += -ansi
#CFLAGS += -DNO_GETADDRINFO
2011-09-27 20:25:35 +00:00
INSTALL = install
SH = /bin/sh
JAVA = java
# see http://code.google.com/p/jnaerator/
#JNAERATOR = jnaerator-0.9.7.jar
#JNAERATOR = jnaerator-0.9.8-shaded.jar
#JNAERATORARGS = -library miniupnpc
#JNAERATOR = jnaerator-0.10-shaded.jar
#JNAERATOR = jnaerator-0.11-shaded.jar
# https://repo1.maven.org/maven2/com/nativelibs4java/jnaerator/0.12/jnaerator-0.12-shaded.jar
JNAERATOR = jnaerator-0.12-shaded.jar
JNAERATORARGS = -mode StandaloneJar -runtime JNAerator -library miniupnpc
#JNAERATORBASEURL = http://jnaerator.googlecode.com/files/
JNAERATORBASEURL = https://repo1.maven.org/maven2/com/nativelibs4java/jnaerator/0.12
ifneq (, $(findstring sun, $(OS)))
2016-12-30 19:07:59 +00:00
LDLIBS=-lsocket -lnsl -lresolv
CFLAGS += -D__EXTENSIONS__
CFLAGS += -std=c99
endif
2011-09-27 20:25:35 +00:00
# APIVERSION is used to build SONAME
APIVERSION = 16
2011-09-27 20:25:35 +00:00
SRCS = igd_desc_parse.c miniupnpc.c minixml.c minisoap.c miniwget.c \
upnpc.c upnpcommands.c upnpreplyparse.c testminixml.c \
2014-11-01 10:40:15 +00:00
minixmlvalid.c testupnpreplyparse.c minissdpc.c \
upnperrors.c testigddescparse.c testminiwget.c \
2013-02-16 09:25:10 +00:00
connecthostport.c portlistingparse.c receivedata.c \
upnpdev.c testportlistingparse.c miniupnpcmodule.c \
minihttptestserver.c \
2013-02-16 09:25:10 +00:00
listdevices.c
2011-09-27 20:25:35 +00:00
LIBOBJS = miniwget.o minixml.o igd_desc_parse.o minisoap.o \
miniupnpc.o upnpreplyparse.o upnpcommands.o upnperrors.o \
connecthostport.o portlistingparse.o receivedata.o upnpdev.o
2011-09-27 20:25:35 +00:00
ifeq (, $(findstring amiga, $(OS)))
ifeq (, $(findstring mingw, $(OS))$(findstring cygwin, $(OS))$(findstring msys, $(OS)))
2011-09-27 20:25:35 +00:00
CFLAGS := -fPIC $(CFLAGS)
endif
2011-09-27 20:25:35 +00:00
LIBOBJS := $(LIBOBJS) minissdpc.o
endif
OBJS = $(patsubst %.c,%.o,$(SRCS))
# HEADERS to install
HEADERS = miniupnpc.h miniwget.h upnpcommands.h igd_desc_parse.h \
upnpreplyparse.h upnperrors.h miniupnpctypes.h \
portlistingparse.h \
upnpdev.h \
miniupnpc_declspec.h
2011-09-27 20:25:35 +00:00
# library names
LIBRARY = libminiupnpc.a
ifneq (, $(findstring darwin, $(OS)))
2011-09-27 20:25:35 +00:00
SHAREDLIBRARY = libminiupnpc.dylib
SONAME = $(basename $(SHAREDLIBRARY)).$(APIVERSION).dylib
CFLAGS := -D_DARWIN_C_SOURCE $(CFLAGS)
else
ifeq ($(JARSUFFIX), win32)
2012-12-21 17:13:04 +00:00
SHAREDLIBRARY = miniupnpc.dll
2013-03-23 09:08:43 +00:00
else
# Linux/BSD/etc.
SHAREDLIBRARY = libminiupnpc.so
SONAME = $(SHAREDLIBRARY).$(APIVERSION)
2012-12-21 17:13:04 +00:00
endif
endif
2011-09-27 20:25:35 +00:00
2013-02-16 09:25:10 +00:00
EXECUTABLES = upnpc-static listdevices
2011-09-27 20:25:35 +00:00
EXECUTABLES_ADDTESTS = testminixml minixmlvalid testupnpreplyparse \
2014-11-01 10:40:15 +00:00
testigddescparse testminiwget testportlistingparse
2011-09-27 20:25:35 +00:00
TESTMINIXMLOBJS = minixml.o igd_desc_parse.o testminixml.o
TESTMINIWGETOBJS = miniwget.o testminiwget.o connecthostport.o receivedata.o
TESTUPNPREPLYPARSE = testupnpreplyparse.o minixml.o upnpreplyparse.o
2014-11-01 10:18:26 +00:00
TESTPORTLISTINGPARSE = testportlistingparse.o minixml.o portlistingparse.o
2011-09-27 20:25:35 +00:00
TESTIGDDESCPARSE = testigddescparse.o igd_desc_parse.o minixml.o \
miniupnpc.o miniwget.o upnpcommands.o upnpreplyparse.o \
minisoap.o connecthostport.o receivedata.o \
portlistingparse.o
ifeq (, $(findstring amiga, $(OS)))
2011-09-27 20:25:35 +00:00
EXECUTABLES := $(EXECUTABLES) upnpc-shared
TESTMINIWGETOBJS := $(TESTMINIWGETOBJS) minissdpc.o
TESTIGDDESCPARSE := $(TESTIGDDESCPARSE) minissdpc.o
endif
2012-10-16 04:59:05 +00:00
LIBDIR ?= lib
2011-09-27 20:25:35 +00:00
# install directories
2016-09-03 07:34:15 +00:00
ifeq ($(strip $(PREFIX)),)
INSTALLPREFIX ?= /usr
else
INSTALLPREFIX ?= $(PREFIX)
endif
2011-09-27 20:25:35 +00:00
INSTALLDIRINC = $(INSTALLPREFIX)/include/miniupnpc
2012-10-16 04:59:05 +00:00
INSTALLDIRLIB = $(INSTALLPREFIX)/$(LIBDIR)
2011-09-27 20:25:35 +00:00
INSTALLDIRBIN = $(INSTALLPREFIX)/bin
INSTALLDIRMAN = $(INSTALLPREFIX)/share/man
PKGCONFIGDIR = $(INSTALLDIRLIB)/pkgconfig
2011-09-27 20:25:35 +00:00
FILESTOINSTALL = $(LIBRARY) $(EXECUTABLES)
ifeq (, $(findstring amiga, $(OS)))
FILESTOINSTALL := $(FILESTOINSTALL) $(SHAREDLIBRARY) miniupnpc.pc
2011-09-27 20:25:35 +00:00
endif
2012-04-06 14:08:43 +00:00
.PHONY: install clean depend all check test everything \
installpythonmodule updateversion
2011-09-27 20:25:35 +00:00
# validateminixml validateminiwget
all: $(LIBRARY) $(EXECUTABLES)
2012-04-06 14:08:43 +00:00
test: check
2014-11-01 10:18:26 +00:00
check: validateminixml validateminiwget validateupnpreplyparse \
2014-11-17 19:31:11 +00:00
validateportlistingparse validateigddescparse
2011-09-27 20:25:35 +00:00
everything: all $(EXECUTABLES_ADDTESTS)
pythonmodule: $(LIBRARY) miniupnpcmodule.c setup.py
MAKE=$(MAKE) python setup.py build
2011-09-27 20:25:35 +00:00
touch $@
installpythonmodule: pythonmodule
MAKE=$(MAKE) python setup.py install
2011-09-27 20:25:35 +00:00
2012-08-29 01:25:00 +00:00
pythonmodule3: $(LIBRARY) miniupnpcmodule.c setup.py
MAKE=$(MAKE) python3 setup.py build
2012-08-29 01:25:00 +00:00
touch $@
installpythonmodule3: pythonmodule3
MAKE=$(MAKE) python3 setup.py install
2012-08-29 01:25:00 +00:00
2011-09-27 20:25:35 +00:00
validateminixml: minixmlvalid
@echo "minixml validation test"
./minixmlvalid
touch $@
validateminiwget: testminiwget minihttptestserver testminiwget.sh
@echo "miniwget validation test"
./testminiwget.sh
touch $@
validateupnpreplyparse: testupnpreplyparse testupnpreplyparse.sh
@echo "upnpreplyparse validation test"
./testupnpreplyparse.sh
touch $@
2014-11-01 10:18:26 +00:00
validateportlistingparse: testportlistingparse
@echo "portlistingparse validation test"
./testportlistingparse
touch $@
2014-11-17 19:31:11 +00:00
validateigddescparse: testigddescparse
@echo "igd desc parse validation test"
./testigddescparse testdesc/new_LiveBox_desc.xml testdesc/new_LiveBox_desc.values
./testigddescparse testdesc/linksys_WAG200G_desc.xml testdesc/linksys_WAG200G_desc.values
2014-11-17 19:31:11 +00:00
touch $@
2011-09-27 20:25:35 +00:00
clean:
$(RM) $(LIBRARY) $(SHAREDLIBRARY) $(EXECUTABLES) $(OBJS) miniupnpcstrings.h
$(RM) $(EXECUTABLES_ADDTESTS)
2011-09-27 20:25:35 +00:00
# clean python stuff
2014-01-31 14:19:38 +00:00
$(RM) pythonmodule pythonmodule3
$(RM) validateminixml validateminiwget validateupnpreplyparse
2014-11-17 19:31:11 +00:00
$(RM) validateigddescparse
2014-11-01 10:40:15 +00:00
$(RM) minihttptestserver
2011-09-27 20:25:35 +00:00
$(RM) -r build/ dist/
#python setup.py clean
# clean jnaerator stuff
$(RM) _jnaerator.* java/miniupnpc_$(OS).jar
2011-09-27 20:25:35 +00:00
2013-01-09 20:06:28 +00:00
distclean: clean
$(RM) $(JNAERATOR) java/*.jar java/*.class out.errors.txt
updateversion: miniupnpc.h
cp miniupnpc.h miniupnpc.h.bak
sed 's/\(.*MINIUPNPC_API_VERSION\s\+\)[0-9]\+/\1$(APIVERSION)/' < miniupnpc.h.bak > miniupnpc.h
install: updateversion $(FILESTOINSTALL)
$(INSTALL) -d $(DESTDIR)$(INSTALLDIRINC)
$(INSTALL) -m 644 $(HEADERS) $(DESTDIR)$(INSTALLDIRINC)
$(INSTALL) -d $(DESTDIR)$(INSTALLDIRLIB)
$(INSTALL) -m 644 $(LIBRARY) $(DESTDIR)$(INSTALLDIRLIB)
ifeq (, $(findstring amiga, $(OS)))
$(INSTALL) -m 644 $(SHAREDLIBRARY) $(DESTDIR)$(INSTALLDIRLIB)/$(SONAME)
ln -fs $(SONAME) $(DESTDIR)$(INSTALLDIRLIB)/$(SHAREDLIBRARY)
$(INSTALL) -d $(DESTDIR)$(PKGCONFIGDIR)
$(INSTALL) -m 644 miniupnpc.pc $(DESTDIR)$(PKGCONFIGDIR)
2011-09-27 20:25:35 +00:00
endif
$(INSTALL) -d $(DESTDIR)$(INSTALLDIRBIN)
ifneq (, $(findstring amiga, $(OS)))
$(INSTALL) -m 755 upnpc-static $(DESTDIR)$(INSTALLDIRBIN)/upnpc
2011-09-27 20:25:35 +00:00
else
$(INSTALL) -m 755 upnpc-shared $(DESTDIR)$(INSTALLDIRBIN)/upnpc
2011-09-27 20:25:35 +00:00
endif
$(INSTALL) -m 755 external-ip.sh $(DESTDIR)$(INSTALLDIRBIN)/external-ip
ifeq (, $(findstring amiga, $(OS)))
$(INSTALL) -d $(DESTDIR)$(INSTALLDIRMAN)/man3
$(INSTALL) -m 644 man3/miniupnpc.3 $(DESTDIR)$(INSTALLDIRMAN)/man3/miniupnpc.3
ifneq (, $(findstring linux, $(OS)))
gzip -f $(DESTDIR)$(INSTALLDIRMAN)/man3/miniupnpc.3
endif
endif
install-static: updateversion $(FILESTOINSTALL)
$(INSTALL) -d $(DESTDIR)$(INSTALLDIRINC)
$(INSTALL) -m 644 $(HEADERS) $(DESTDIR)$(INSTALLDIRINC)
$(INSTALL) -d $(DESTDIR)$(INSTALLDIRLIB)
$(INSTALL) -m 644 $(LIBRARY) $(DESTDIR)$(INSTALLDIRLIB)
$(INSTALL) -d $(DESTDIR)$(INSTALLDIRBIN)
$(INSTALL) -m 755 external-ip.sh $(DESTDIR)$(INSTALLDIRBIN)/external-ip
2011-09-27 20:25:35 +00:00
cleaninstall:
$(RM) -r $(DESTDIR)$(INSTALLDIRINC)
$(RM) $(DESTDIR)$(INSTALLDIRLIB)/$(LIBRARY)
$(RM) $(DESTDIR)$(INSTALLDIRLIB)/$(SHAREDLIBRARY)
2011-09-27 20:25:35 +00:00
miniupnpc.pc: VERSION
$(RM) $@
echo "prefix=$(INSTALLPREFIX)" >> $@
echo "exec_prefix=\$${prefix}" >> $@
echo "libdir=\$${exec_prefix}/$(LIBDIR)" >> $@
echo "includedir=\$${prefix}/include/miniupnpc" >> $@
echo "" >> $@
echo "Name: miniUPnPc" >> $@
echo "Description: UPnP IGD client lightweight library" >> $@
echo "Version: $(VERSION)" >> $@
echo "Libs: -L\$${libdir} -lminiupnpc" >> $@
echo "Cflags: -I\$${includedir}" >> $@
2011-09-27 20:25:35 +00:00
depend:
makedepend -Y -- $(CFLAGS) -- $(SRCS) 2>/dev/null
$(LIBRARY): $(LIBOBJS)
ifneq (, $(findstring darwin, $(OS)))
$(LIBTOOL) -static -o $@ $?
else
2011-09-27 20:25:35 +00:00
$(AR) crs $@ $?
endif
2011-09-27 20:25:35 +00:00
$(SHAREDLIBRARY): $(LIBOBJS)
ifneq (, $(findstring darwin, $(OS)))
# $(CC) -dynamiclib $(LDFLAGS) -Wl,-install_name,$(SONAME) -o $@ $^
$(CC) -dynamiclib $(LDFLAGS) -Wl,-install_name,$(INSTALLDIRLIB)/$(SONAME) -o $@ $^
2011-09-27 20:25:35 +00:00
else
$(CC) -shared $(LDFLAGS) -Wl,-soname,$(SONAME) -o $@ $^
endif
upnpc-static: upnpc.o $(LIBRARY)
$(CC) $(LDFLAGS) -o $@ $^ $(LOADLIBES) $(LDLIBS)
2011-09-27 20:25:35 +00:00
upnpc-shared: upnpc.o $(SHAREDLIBRARY)
$(CC) $(LDFLAGS) -o $@ $^ $(LOADLIBES) $(LDLIBS)
2011-09-27 20:25:35 +00:00
listdevices: listdevices.o $(LIBRARY)
2013-02-16 09:25:10 +00:00
2011-09-27 20:25:35 +00:00
testminixml: $(TESTMINIXMLOBJS)
testminiwget: $(TESTMINIWGETOBJS)
minixmlvalid: minixml.o minixmlvalid.o
testupnpreplyparse: $(TESTUPNPREPLYPARSE)
testigddescparse: $(TESTIGDDESCPARSE)
2014-11-01 10:18:26 +00:00
testportlistingparse: $(TESTPORTLISTINGPARSE)
miniupnpcstrings.h: miniupnpcstrings.h.in updateminiupnpcstrings.sh VERSION
2011-09-27 20:25:35 +00:00
$(SH) updateminiupnpcstrings.sh
2013-03-23 09:08:43 +00:00
# ftp tool supplied with OpenBSD can download files from http.
jnaerator-%.jar:
2013-03-23 09:08:43 +00:00
wget $(JNAERATORBASEURL)/$@ || \
curl -o $@ $(JNAERATORBASEURL)/$@ || \
ftp $(JNAERATORBASEURL)/$@
2012-01-18 17:03:52 +00:00
jar: $(SHAREDLIBRARY) $(JNAERATOR)
$(JAVA) -jar $(JNAERATOR) $(JNAERATORARGS) \
miniupnpc.h miniupnpc_declspec.h upnpcommands.h upnpreplyparse.h \
igd_desc_parse.h miniwget.h upnperrors.h $(SHAREDLIBRARY) \
2012-01-23 23:14:43 +00:00
-package fr.free.miniupnp -o . -jar java/miniupnpc_$(JARSUFFIX).jar -v
mvn_install:
mvn install:install-file -Dfile=java/miniupnpc_$(JARSUFFIX).jar \
-DgroupId=com.github \
-DartifactId=miniupnp \
-Dversion=$(VERSION) \
-Dpackaging=jar \
-Dclassifier=$(JARSUFFIX) \
-DgeneratePom=true \
-DcreateChecksum=true
2011-09-27 20:25:35 +00:00
2012-01-18 17:32:28 +00:00
# make .deb packages
2012-01-18 17:37:00 +00:00
deb: /usr/share/pyshared/stdeb all
(python setup.py --command-packages=stdeb.command bdist_deb)
2012-01-18 17:32:28 +00:00
# install .deb packages
ideb:
2012-01-18 17:37:00 +00:00
(sudo dpkg -i deb_dist/*.deb)
/usr/share/pyshared/stdeb: /usr/share/doc/python-all-dev
(sudo apt-get install python-stdeb)
/usr/share/doc/python-all-dev:
(sudo apt-get install python-all-dev)
2012-01-18 17:32:28 +00:00
2011-09-27 20:25:35 +00:00
minihttptestserver: minihttptestserver.o
# DO NOT DELETE THIS LINE -- make depend depends on it.
igd_desc_parse.o: igd_desc_parse.h
miniupnpc.o: miniupnpc.h miniupnpc_declspec.h igd_desc_parse.h upnpdev.h
miniupnpc.o: minissdpc.h miniwget.h minisoap.h minixml.h upnpcommands.h
miniupnpc.o: upnpreplyparse.h portlistingparse.h miniupnpctypes.h
miniupnpc.o: connecthostport.h
2011-09-27 20:25:35 +00:00
minixml.o: minixml.h
minisoap.o: minisoap.h miniupnpcstrings.h
miniwget.o: miniupnpcstrings.h miniwget.h miniupnpc_declspec.h
miniwget.o: connecthostport.h receivedata.h
upnpc.o: miniwget.h miniupnpc_declspec.h miniupnpc.h igd_desc_parse.h
upnpc.o: upnpdev.h upnpcommands.h upnpreplyparse.h portlistingparse.h
upnpc.o: miniupnpctypes.h upnperrors.h miniupnpcstrings.h
upnpcommands.o: upnpcommands.h upnpreplyparse.h portlistingparse.h
upnpcommands.o: miniupnpc_declspec.h miniupnpctypes.h miniupnpc.h
upnpcommands.o: igd_desc_parse.h upnpdev.h
2011-09-27 20:25:35 +00:00
upnpreplyparse.o: upnpreplyparse.h minixml.h
testminixml.o: minixml.h igd_desc_parse.h
minixmlvalid.o: minixml.h
testupnpreplyparse.o: upnpreplyparse.h
minissdpc.o: minissdpc.h miniupnpc_declspec.h upnpdev.h miniupnpc.h
minissdpc.o: igd_desc_parse.h receivedata.h codelength.h
upnperrors.o: upnperrors.h miniupnpc_declspec.h upnpcommands.h
upnperrors.o: upnpreplyparse.h portlistingparse.h miniupnpctypes.h
upnperrors.o: miniupnpc.h igd_desc_parse.h upnpdev.h
testigddescparse.o: igd_desc_parse.h minixml.h miniupnpc.h
testigddescparse.o: miniupnpc_declspec.h upnpdev.h
testminiwget.o: miniwget.h miniupnpc_declspec.h
2011-09-27 20:25:35 +00:00
connecthostport.o: connecthostport.h
portlistingparse.o: portlistingparse.h miniupnpc_declspec.h miniupnpctypes.h
portlistingparse.o: minixml.h
2011-09-27 20:25:35 +00:00
receivedata.o: receivedata.h
upnpdev.o: upnpdev.h miniupnpc_declspec.h
testportlistingparse.o: portlistingparse.h miniupnpc_declspec.h
testportlistingparse.o: miniupnpctypes.h
miniupnpcmodule.o: miniupnpc.h miniupnpc_declspec.h igd_desc_parse.h
miniupnpcmodule.o: upnpdev.h upnpcommands.h upnpreplyparse.h
miniupnpcmodule.o: portlistingparse.h miniupnpctypes.h upnperrors.h
listdevices.o: miniupnpc.h miniupnpc_declspec.h igd_desc_parse.h upnpdev.h