2012-06-23 22:47:50 +00:00
|
|
|
# $Id: Makefile,v 1.96 2012/06/23 22:30:42 nanard Exp $
|
2011-09-27 20:25:35 +00:00
|
|
|
# MiniUPnP Project
|
|
|
|
# http://miniupnp.free.fr/
|
2012-06-23 22:47:50 +00:00
|
|
|
# http://miniupnp.tuxfamily.org/
|
|
|
|
# https://github.com/miniupnp/miniupnp
|
|
|
|
# (c) 2005-2012 Thomas Bernard
|
2011-09-27 20:25:35 +00:00
|
|
|
# to install use :
|
|
|
|
# $ PREFIX=/tmp/dummylocation make install
|
|
|
|
# or
|
|
|
|
# $ INSTALLPREFIX=/usr/local make install
|
2012-04-06 14:06:30 +00:00
|
|
|
# or
|
2011-09-27 20:25:35 +00:00
|
|
|
# make install (will go to /usr/bin, /usr/lib, etc...)
|
|
|
|
OS = $(shell uname -s)
|
2012-01-25 09:57:46 +00:00
|
|
|
VERSION = $(shell cat VERSION)
|
2012-01-23 23:14:43 +00:00
|
|
|
|
|
|
|
ifeq ($(OS), Darwin)
|
|
|
|
JARSUFFIX=mac
|
|
|
|
endif
|
2012-01-25 10:07:02 +00:00
|
|
|
ifeq ($(OS), Linux)
|
|
|
|
JARSUFFIX=linux
|
|
|
|
endif
|
2012-12-21 17:13:04 +00:00
|
|
|
ifneq (,$(findstring NT-5.1,$(OS)))
|
|
|
|
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
|
2012-06-23 22:52:51 +00:00
|
|
|
CFLAGS += -DMINIUPNPC_GET_SRC_ADDR
|
2012-05-01 18:49:43 +00:00
|
|
|
CFLAGS += -D_BSD_SOURCE -D_POSIX_C_SOURCE=1
|
|
|
|
CFLAGS += -ansi
|
2011-09-27 20:25:35 +00:00
|
|
|
# -DNO_GETADDRINFO
|
|
|
|
INSTALL = install
|
|
|
|
SH = /bin/sh
|
|
|
|
JAVA = java
|
|
|
|
# see http://code.google.com/p/jnaerator/
|
2012-01-18 16:51:22 +00:00
|
|
|
JNAERATOR = jnaerator-0.9.7.jar
|
2012-02-12 13:22:32 +00:00
|
|
|
JNAERATORBASEURL = http://jnaerator.googlecode.com/files/
|
2011-09-27 20:25:35 +00:00
|
|
|
#following libs are needed on Solaris
|
|
|
|
#LDLIBS=-lsocket -lnsl -lresolv
|
|
|
|
|
|
|
|
# APIVERSION is used to build SONAME
|
2012-06-23 22:49:09 +00:00
|
|
|
APIVERSION = 9
|
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 \
|
|
|
|
minixmlvalid.c testupnpreplyparse.c minissdpc.c \
|
|
|
|
upnperrors.c testigddescparse.c testminiwget.c \
|
2013-01-09 20:01:39 +00:00
|
|
|
connecthostport.c portlistingparse.c receivedata.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
|
|
|
|
|
|
|
|
ifneq ($(OS), AmigaOS)
|
|
|
|
CFLAGS := -fPIC $(CFLAGS)
|
|
|
|
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 \
|
|
|
|
declspec.h
|
|
|
|
|
|
|
|
# library names
|
|
|
|
LIBRARY = libminiupnpc.a
|
|
|
|
ifeq ($(OS), Darwin)
|
|
|
|
SHAREDLIBRARY = libminiupnpc.dylib
|
|
|
|
SONAME = $(basename $(SHAREDLIBRARY)).$(APIVERSION).dylib
|
|
|
|
CFLAGS := -DMACOSX -D_DARWIN_C_SOURCE $(CFLAGS)
|
2012-04-06 14:06:30 +00:00
|
|
|
else
|
2012-12-21 17:13:04 +00:00
|
|
|
ifeq ($(OS), Linux)
|
2011-09-27 20:25:35 +00:00
|
|
|
SHAREDLIBRARY = libminiupnpc.so
|
|
|
|
SONAME = $(SHAREDLIBRARY).$(APIVERSION)
|
|
|
|
endif
|
2012-12-21 17:13:04 +00:00
|
|
|
ifeq ($(JARSUFFIX), win32)
|
|
|
|
SHAREDLIBRARY = miniupnpc.dll
|
|
|
|
endif
|
|
|
|
endif
|
2011-09-27 20:25:35 +00:00
|
|
|
|
|
|
|
EXECUTABLES = upnpc-static
|
|
|
|
EXECUTABLES_ADDTESTS = testminixml minixmlvalid testupnpreplyparse \
|
|
|
|
testigddescparse testminiwget
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
ifneq ($(OS), AmigaOS)
|
|
|
|
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
|
|
|
|
INSTALLPREFIX ?= $(PREFIX)/usr
|
|
|
|
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
|
2011-12-31 19:06:17 +00:00
|
|
|
INSTALLDIRMAN = $(INSTALLPREFIX)/share/man
|
2011-09-27 20:25:35 +00:00
|
|
|
|
|
|
|
FILESTOINSTALL = $(LIBRARY) $(EXECUTABLES)
|
|
|
|
ifneq ($(OS), AmigaOS)
|
|
|
|
FILESTOINSTALL := $(FILESTOINSTALL) $(SHAREDLIBRARY)
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
2012-04-06 14:08:43 +00:00
|
|
|
.PHONY: install clean depend all check test everything \
|
2012-01-07 10:40:50 +00:00
|
|
|
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
|
|
|
|
|
2011-09-27 20:25:35 +00:00
|
|
|
check: validateminixml validateminiwget
|
|
|
|
|
|
|
|
everything: all $(EXECUTABLES_ADDTESTS)
|
|
|
|
|
|
|
|
pythonmodule: $(LIBRARY) miniupnpcmodule.c setup.py
|
|
|
|
python setup.py build
|
|
|
|
touch $@
|
|
|
|
|
|
|
|
installpythonmodule: pythonmodule
|
|
|
|
python setup.py install
|
|
|
|
|
2012-08-29 01:25:00 +00:00
|
|
|
pythonmodule3: $(LIBRARY) miniupnpcmodule.c setup.py
|
|
|
|
python3 setup.py build
|
|
|
|
touch $@
|
|
|
|
|
|
|
|
installpythonmodule3: pythonmodule3
|
|
|
|
python3 setup.py install
|
|
|
|
|
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 $@
|
|
|
|
|
|
|
|
clean:
|
|
|
|
$(RM) $(LIBRARY) $(SHAREDLIBRARY) $(EXECUTABLES) $(OBJS) miniupnpcstrings.h
|
|
|
|
# clean python stuff
|
2012-08-29 01:25:00 +00:00
|
|
|
$(RM) pythonmodule pythonmodule3 validateminixml validateminiwget
|
2011-09-27 20:25:35 +00:00
|
|
|
$(RM) -r build/ dist/
|
|
|
|
#python setup.py clean
|
2012-01-07 10:33:21 +00:00
|
|
|
# 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
|
|
|
|
|
2012-01-07 10:35:45 +00:00
|
|
|
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)
|
2011-09-27 20:25:35 +00:00
|
|
|
$(INSTALL) -d $(INSTALLDIRINC)
|
|
|
|
$(INSTALL) -m 644 $(HEADERS) $(INSTALLDIRINC)
|
|
|
|
$(INSTALL) -d $(INSTALLDIRLIB)
|
|
|
|
$(INSTALL) -m 644 $(LIBRARY) $(INSTALLDIRLIB)
|
|
|
|
ifneq ($(OS), AmigaOS)
|
|
|
|
$(INSTALL) -m 644 $(SHAREDLIBRARY) $(INSTALLDIRLIB)/$(SONAME)
|
|
|
|
ln -fs $(SONAME) $(INSTALLDIRLIB)/$(SHAREDLIBRARY)
|
|
|
|
endif
|
|
|
|
$(INSTALL) -d $(INSTALLDIRBIN)
|
|
|
|
ifeq ($(OS), AmigaOS)
|
|
|
|
$(INSTALL) -m 755 upnpc-static $(INSTALLDIRBIN)/upnpc
|
|
|
|
else
|
|
|
|
$(INSTALL) -m 755 upnpc-shared $(INSTALLDIRBIN)/upnpc
|
|
|
|
endif
|
|
|
|
$(INSTALL) -m 755 external-ip.sh $(INSTALLDIRBIN)/external-ip
|
2011-12-31 19:06:17 +00:00
|
|
|
ifneq ($(OS), AmigaOS)
|
|
|
|
$(INSTALL) -d $(INSTALLDIRMAN)/man3
|
|
|
|
$(INSTALL) man3/miniupnpc.3 $(INSTALLDIRMAN)/man3/miniupnpc.3
|
|
|
|
endif
|
|
|
|
|
2011-09-27 20:25:35 +00:00
|
|
|
|
|
|
|
cleaninstall:
|
|
|
|
$(RM) -r $(INSTALLDIRINC)
|
|
|
|
$(RM) $(INSTALLDIRLIB)/$(LIBRARY)
|
|
|
|
$(RM) $(INSTALLDIRLIB)/$(SHAREDLIBRARY)
|
|
|
|
|
|
|
|
depend:
|
|
|
|
makedepend -Y -- $(CFLAGS) -- $(SRCS) 2>/dev/null
|
|
|
|
|
|
|
|
$(LIBRARY): $(LIBOBJS)
|
|
|
|
$(AR) crs $@ $?
|
|
|
|
|
|
|
|
$(SHAREDLIBRARY): $(LIBOBJS)
|
|
|
|
ifeq ($(OS), Darwin)
|
2012-02-12 13:21:56 +00:00
|
|
|
# $(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) $(LDLIBS)
|
|
|
|
$(CC) $(LDFLAGS) -o $@ $^
|
|
|
|
|
|
|
|
upnpc-shared: upnpc.o $(SHAREDLIBRARY) $(LDLIBS)
|
|
|
|
$(CC) $(LDFLAGS) -o $@ $^
|
|
|
|
|
|
|
|
testminixml: $(TESTMINIXMLOBJS)
|
|
|
|
|
|
|
|
testminiwget: $(TESTMINIWGETOBJS)
|
|
|
|
|
|
|
|
minixmlvalid: minixml.o minixmlvalid.o
|
|
|
|
|
|
|
|
testupnpreplyparse: $(TESTUPNPREPLYPARSE)
|
|
|
|
|
|
|
|
testigddescparse: $(TESTIGDDESCPARSE)
|
|
|
|
|
2012-01-19 11:31:42 +00:00
|
|
|
miniupnpcstrings.h: miniupnpcstrings.h.in updateminiupnpcstrings.sh VERSION
|
2011-09-27 20:25:35 +00:00
|
|
|
$(SH) updateminiupnpcstrings.sh
|
|
|
|
|
2012-01-18 16:51:22 +00:00
|
|
|
jnaerator-0.9.8-shaded.jar:
|
2012-02-12 13:22:32 +00:00
|
|
|
wget $(JNAERATORBASEURL)/$@ || curl -o $@ $(JNAERATORBASEURL)/$@
|
2012-01-18 16:51:22 +00:00
|
|
|
|
|
|
|
jnaerator-0.9.7.jar:
|
2012-02-12 13:22:32 +00:00
|
|
|
wget $(JNAERATORBASEURL)/$@ || curl -o $@ $(JNAERATORBASEURL)/$@
|
2012-01-18 16:51:22 +00:00
|
|
|
|
2012-01-18 17:03:52 +00:00
|
|
|
jnaerator-0.9.3.jar:
|
2012-02-12 13:22:32 +00:00
|
|
|
wget $(JNAERATORBASEURL)/$@ || curl -o $@ $(JNAERATORBASEURL)/$@
|
2012-01-18 17:03:52 +00:00
|
|
|
|
|
|
|
jar: $(SHAREDLIBRARY) $(JNAERATOR)
|
2012-02-12 13:22:32 +00:00
|
|
|
$(JAVA) -jar $(JNAERATOR) -library miniupnpc \
|
|
|
|
miniupnpc.h 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 \
|
2012-02-12 13:22:32 +00:00
|
|
|
-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 declspec.h igd_desc_parse.h minissdpc.h miniwget.h
|
|
|
|
miniupnpc.o: minisoap.h minixml.h upnpcommands.h upnpreplyparse.h
|
|
|
|
miniupnpc.o: portlistingparse.h miniupnpctypes.h connecthostport.h
|
|
|
|
miniupnpc.o: receivedata.h
|
|
|
|
minixml.o: minixml.h
|
|
|
|
minisoap.o: minisoap.h miniupnpcstrings.h
|
|
|
|
miniwget.o: miniupnpcstrings.h miniwget.h declspec.h connecthostport.h
|
|
|
|
miniwget.o: receivedata.h
|
|
|
|
upnpc.o: miniwget.h declspec.h miniupnpc.h igd_desc_parse.h upnpcommands.h
|
|
|
|
upnpc.o: upnpreplyparse.h portlistingparse.h miniupnpctypes.h upnperrors.h
|
|
|
|
upnpcommands.o: upnpcommands.h upnpreplyparse.h portlistingparse.h declspec.h
|
|
|
|
upnpcommands.o: miniupnpctypes.h miniupnpc.h igd_desc_parse.h
|
|
|
|
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.h declspec.h igd_desc_parse.h codelength.h
|
|
|
|
upnperrors.o: upnperrors.h declspec.h upnpcommands.h upnpreplyparse.h
|
|
|
|
upnperrors.o: portlistingparse.h miniupnpctypes.h miniupnpc.h
|
|
|
|
upnperrors.o: igd_desc_parse.h
|
|
|
|
testigddescparse.o: igd_desc_parse.h minixml.h miniupnpc.h declspec.h
|
|
|
|
testminiwget.o: miniwget.h declspec.h
|
|
|
|
connecthostport.o: connecthostport.h
|
|
|
|
receivedata.o: receivedata.h
|