2015-09-18 16:11:56 +00:00
|
|
|
# $Id: Makefile.mingw,v 1.21 2015/09/18 12:45:16 nanard Exp $
|
2011-09-27 20:25:35 +00:00
|
|
|
# Miniupnp project.
|
2018-04-26 20:13:06 +00:00
|
|
|
# http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
|
2020-11-05 12:24:59 +00:00
|
|
|
# (c) 2005-2020 Thomas Bernard
|
2011-09-27 20:25:35 +00:00
|
|
|
# This Makefile is made for MinGW
|
|
|
|
#
|
2018-04-26 20:13:06 +00:00
|
|
|
# To cross compile on a *nix machine :
|
|
|
|
# make -f Makefile.mingw DLLWRAP=mingw32-dllwrap CC=mingw32-gcc AR=mingw32-ar
|
|
|
|
#
|
2015-10-26 10:04:47 +00:00
|
|
|
CC ?= gcc
|
2019-04-25 15:11:53 +00:00
|
|
|
SETUP_COMPILER_FLAG?=
|
2018-04-26 20:13:06 +00:00
|
|
|
DLLWRAP = dllwrap
|
2020-11-30 00:21:26 +00:00
|
|
|
WINDRES = windres
|
2018-04-26 20:13:06 +00:00
|
|
|
SH = /bin/sh
|
2020-11-05 12:24:59 +00:00
|
|
|
ZIP = zip
|
2018-04-26 20:13:06 +00:00
|
|
|
ifeq ($(OS),Windows_NT)
|
|
|
|
RM = del
|
|
|
|
else
|
|
|
|
RM = rm -f
|
|
|
|
endif
|
2011-09-27 20:25:35 +00:00
|
|
|
#CFLAGS = -Wall -g -DDEBUG -D_WIN32_WINNT=0X501
|
2021-01-27 12:14:33 +00:00
|
|
|
CFLAGS = -Wall -W -Wstrict-prototypes -Os -DNDEBUG -D_WIN32_WINNT=0X501
|
2011-09-27 20:25:35 +00:00
|
|
|
LDLIBS = -lws2_32 -liphlpapi
|
|
|
|
# -lwsock32
|
2013-02-06 13:57:49 +00:00
|
|
|
# -liphlpapi is needed for GetBestRoute() and GetIpAddrTable()
|
2011-09-27 20:25:35 +00:00
|
|
|
PYTHON=\utils\python25\python
|
|
|
|
OBJS=miniwget.o minixml.o igd_desc_parse.o minisoap.o \
|
2015-09-15 22:12:43 +00:00
|
|
|
minissdpc.o \
|
2011-09-27 20:25:35 +00:00
|
|
|
miniupnpc.o upnpreplyparse.o upnpcommands.o upnperrors.o \
|
2015-09-15 22:08:52 +00:00
|
|
|
connecthostport.o portlistingparse.o receivedata.o \
|
2020-09-23 22:08:55 +00:00
|
|
|
upnpdev.o addr_is_reserved.o
|
2020-11-30 00:21:26 +00:00
|
|
|
OBJSDLL=$(addprefix dll-, $(OBJS)) winres.o
|
2020-11-05 12:24:59 +00:00
|
|
|
BINARIES=upnpc-static.exe upnpc-shared.exe \
|
|
|
|
listdevices-static.exe listdevices-shared.exe \
|
|
|
|
miniupnpc.dll libminiupnpc.a \
|
|
|
|
testminixml.exe
|
|
|
|
ifneq ($(GITHUB_SHA),)
|
|
|
|
COMMITREF=$(GITHUB_SHA)
|
|
|
|
else
|
|
|
|
COMMITREF=$(shell git rev-parse --short HEAD)
|
|
|
|
endif
|
|
|
|
DISTFILE:=$(shell echo "miniupnpc-bin-win32-`cat VERSION`-$(COMMITREF).zip")
|
|
|
|
|
|
|
|
.PHONY: all dist clean
|
|
|
|
|
|
|
|
all: $(BINARIES)
|
2011-09-27 20:25:35 +00:00
|
|
|
|
2020-11-05 12:24:59 +00:00
|
|
|
dist: $(DISTFILE)
|
2011-09-27 20:25:35 +00:00
|
|
|
|
|
|
|
clean:
|
2020-04-02 16:45:46 +00:00
|
|
|
$(RM) miniupnpcstrings.h
|
|
|
|
$(RM) *.o
|
2018-04-26 20:13:06 +00:00
|
|
|
$(RM) *.exe
|
2020-04-02 16:45:46 +00:00
|
|
|
$(RM) miniupnpc.dll miniupnpc.lib miniupnpc.dll.def
|
2018-04-26 20:13:06 +00:00
|
|
|
$(RM) libminiupnpc.a
|
2011-09-27 20:25:35 +00:00
|
|
|
|
2020-11-05 12:24:59 +00:00
|
|
|
$(DISTFILE): $(BINARIES)
|
|
|
|
$(ZIP) $@ *.exe *.dll *.lib *.def *.a LICENSE README Changelog.txt
|
|
|
|
|
2011-09-27 20:25:35 +00:00
|
|
|
libminiupnpc.a: $(OBJS)
|
|
|
|
$(AR) cr $@ $?
|
|
|
|
|
|
|
|
pythonmodule: libminiupnpc.a
|
2019-04-25 15:11:53 +00:00
|
|
|
$(PYTHON) setupmingw32.py build $(SETUP_COMPILER_FLAG)
|
2011-09-27 20:25:35 +00:00
|
|
|
$(PYTHON) setupmingw32.py install --skip-build
|
2019-04-25 16:06:41 +00:00
|
|
|
$(PYTHON) setupmingw32.py bdist_wheel --skip-build
|
2011-09-27 20:25:35 +00:00
|
|
|
|
2020-04-02 16:45:46 +00:00
|
|
|
miniupnpc.dll: miniupnpc.def $(OBJSDLL)
|
2018-04-26 20:13:06 +00:00
|
|
|
$(DLLWRAP) -k --driver-name $(CC) \
|
2011-09-27 20:25:35 +00:00
|
|
|
--def miniupnpc.def \
|
|
|
|
--output-def miniupnpc.dll.def \
|
|
|
|
--implib miniupnpc.lib -o $@ \
|
|
|
|
$(OBJSDLL) $(LDLIBS)
|
|
|
|
|
|
|
|
miniupnpc.lib: miniupnpc.dll
|
|
|
|
|
2020-04-02 16:45:46 +00:00
|
|
|
%.o: %.c
|
2014-06-01 10:22:35 +00:00
|
|
|
$(CC) $(CFLAGS) -DMINIUPNP_STATICLIB -c -o $@ $<
|
2011-09-27 20:25:35 +00:00
|
|
|
|
2020-04-02 16:45:46 +00:00
|
|
|
dll-%.o: %.c
|
|
|
|
$(CC) $(CFLAGS) -DMINIUPNP_EXPORTS -c -o $@ $<
|
2011-09-27 20:25:35 +00:00
|
|
|
|
2020-04-02 16:45:46 +00:00
|
|
|
%-shared.o: %.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
2011-09-27 20:25:35 +00:00
|
|
|
|
2020-04-02 16:45:46 +00:00
|
|
|
# --enable-stdcall-fixup
|
|
|
|
%-static.exe: %.o libminiupnpc.a
|
2020-04-05 22:09:52 +00:00
|
|
|
$(CC) -static -o $@ $^ $(LDLIBS)
|
2011-09-27 20:25:35 +00:00
|
|
|
|
2020-04-02 16:45:46 +00:00
|
|
|
%-shared.exe: %-shared.o miniupnpc.lib
|
2016-01-17 18:33:13 +00:00
|
|
|
$(CC) -o $@ $^ $(LDLIBS)
|
|
|
|
|
2018-04-26 20:13:06 +00:00
|
|
|
# To make miniupnpcstrings.h from miniupnpcstrings.h.in we either
|
|
|
|
# use a custom executable (if running make under windows) or use
|
|
|
|
# sed (if cross compiling from another platform).
|
|
|
|
ifeq ($(OS),Windows_NT)
|
2020-04-02 16:45:46 +00:00
|
|
|
wingenminiupnpcstrings.exe: wingenminiupnpcstrings.c
|
|
|
|
$(CC) $(CFLAGS) -o $@ $^
|
2020-11-30 00:37:19 +00:00
|
|
|
|
|
|
|
miniupnpcstrings.h: miniupnpcstrings.h.in wingenminiupnpcstrings.exe VERSION
|
|
|
|
wingenminiupnpcstrings.exe $< $@ rc_version.h
|
|
|
|
|
|
|
|
rc_version.h: miniupnpcstrings.h
|
2018-04-26 20:13:06 +00:00
|
|
|
else
|
|
|
|
miniupnpcstrings.h: miniupnpcstrings.h.in VERSION
|
|
|
|
sed 's|OS_STRING ".*"|OS_STRING "Windows/Mingw32"|' $< | \
|
|
|
|
sed 's|MINIUPNPC_VERSION_STRING ".*"|MINIUPNPC_VERSION_STRING "$(shell cat VERSION)"|' > $@
|
2020-11-30 00:21:26 +00:00
|
|
|
|
|
|
|
rc_version.h: VERSION
|
|
|
|
echo "#define LIBMINIUPNPC_DOTTED_VERSION \"$(shell cat VERSION)\"" > $@.tmp
|
|
|
|
echo "#define LIBMINIUPNPC_MAJOR_VERSION $(shell cat VERSION|cut -d. -f1)" >> $@.tmp
|
|
|
|
echo "#define LIBMINIUPNPC_MINOR_VERSION $(shell cat VERSION|cut -d. -f2)" >> $@.tmp
|
|
|
|
echo "#define LIBMINIUPNPC_MICRO_VERSION $(shell cat VERSION|cut -d. -f3)" >> $@.tmp
|
|
|
|
mv $@.tmp $@
|
2018-04-26 20:13:06 +00:00
|
|
|
endif
|
2011-09-27 20:25:35 +00:00
|
|
|
|
2020-11-30 00:21:26 +00:00
|
|
|
winres.o: miniupnpc.rc rc_version.h
|
|
|
|
$(WINDRES) -D INTERNAL_NAME=\\\"miniupnpc.dll\\0\\\" -i $< -o $@
|
|
|
|
|
2020-11-05 12:24:59 +00:00
|
|
|
testminixml.exe: testminixml.o minixml.o igd_desc_parse.o
|
|
|
|
$(CC) -static -o $@ $^
|
|
|
|
|
2015-09-15 22:01:54 +00:00
|
|
|
minixml.o: minixml.c minixml.h
|
2011-09-27 20:25:35 +00:00
|
|
|
|
2015-10-26 10:04:47 +00:00
|
|
|
upnpc.o: miniwget.h minisoap.h miniupnpc.h igd_desc_parse.h
|
2015-09-15 22:01:54 +00:00
|
|
|
upnpc.o: upnpreplyparse.h upnpcommands.h upnperrors.h miniupnpcstrings.h
|
2011-09-27 20:25:35 +00:00
|
|
|
|
|
|
|
miniwget.o: miniwget.c miniwget.h miniupnpcstrings.h connecthostport.h
|
|
|
|
|
|
|
|
minisoap.o: minisoap.c minisoap.h miniupnpcstrings.h
|
|
|
|
|
2020-09-23 22:08:55 +00:00
|
|
|
miniupnpc.o: miniupnpc.c miniupnpc.h minisoap.h miniwget.h minixml.h \
|
|
|
|
addr_is_reserved.h
|
2011-09-27 20:25:35 +00:00
|
|
|
|
|
|
|
igd_desc_parse.o: igd_desc_parse.c igd_desc_parse.h
|
|
|
|
|
|
|
|
upnpreplyparse.o: upnpreplyparse.c upnpreplyparse.h minixml.h
|
|
|
|
|
|
|
|
upnpcommands.o: upnpcommands.c upnpcommands.h upnpreplyparse.h miniupnpc.h portlistingparse.h
|
|
|
|
|
2015-09-18 16:11:56 +00:00
|
|
|
minissdpc.o: minissdpc.c minissdpc.h receivedata.h
|
2015-09-15 22:08:52 +00:00
|
|
|
|
|
|
|
upnpdev.o: upnpdev.c upnpdev.h
|
|
|
|
|