SRB2/libs/miniupnpc/Makefile.mingw

182 lines
5.3 KiB
Text
Raw Permalink Normal View History

2023-12-30 16:35:35 +00:00
# $Id: Makefile.mingw,v 1.35 2022/10/16 05:28:15 nanard Exp $
2014-03-15 16:59:03 +00:00
# Miniupnp project.
2023-12-30 16:35:35 +00:00
# http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
# (c) 2005-2020 Thomas Bernard
2014-03-15 16:59:03 +00:00
# This Makefile is made for MinGW
#
2023-12-30 16:35:35 +00:00
# To cross compile on a *nix machine :
# make -f Makefile.mingw DLLWRAP=mingw32-dllwrap CC=mingw32-gcc AR=mingw32-ar WINDRES=mingw32-windres
#
SRCDIR = src
INCDIR = include
CC ?= gcc
SETUP_COMPILER_FLAG?=
2014-03-15 16:59:03 +00:00
DLLWRAP = dllwrap
2023-12-30 16:35:35 +00:00
WINDRES = windres
2014-03-15 16:59:03 +00:00
SH = /bin/sh
2023-12-30 16:35:35 +00:00
ZIP = zip
ifeq ($(OS),Windows_NT)
RM = del
else
RM = rm -f
endif
CFLAGS ?= -Os
CFLAGS += -Wall
CFLAGS += -W -Wstrict-prototypes
CPPFLAGS += -DNDEBUG -D_WIN32_WINNT=0x501
CPPFLAGS += -Iinclude
CPPFLAGS += -I.
# -liphlpapi is needed for GetBestRoute() and GetIpAddrTable()
LDLIBS = -lws2_32 -liphlpapi
2014-03-15 16:59:03 +00:00
PYTHON=\utils\python25\python
OBJS=miniwget.o minixml.o igd_desc_parse.o minisoap.o \
2023-12-30 16:35:35 +00:00
minissdpc.o \
2014-03-15 16:59:03 +00:00
miniupnpc.o upnpreplyparse.o upnpcommands.o upnperrors.o \
2023-12-30 16:35:35 +00:00
connecthostport.o portlistingparse.o receivedata.o \
upnpdev.o addr_is_reserved.o
OBJSDLL=$(addprefix dll-, $(OBJS)) winres.o
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
ifneq ($(CI_COMMIT_SHORT_SHA),)
COMMITREF=$(CI_COMMIT_SHORT_SHA)
else
COMMITREF=$(shell git rev-parse --short HEAD)
endif
endif
DISTFILE:=$(shell echo "miniupnpc-bin-win32-`cat VERSION`-$(COMMITREF).zip")
LIBDIR ?= lib
# install directories
ifeq ($(strip $(PREFIX)),)
INSTALLPREFIX ?= /usr
else
INSTALLPREFIX ?= $(PREFIX)
endif
.PHONY: all dist clean
all: $(BINARIES)
dist: $(DISTFILE)
2014-03-15 16:59:03 +00:00
clean:
2023-12-30 16:35:35 +00:00
$(RM) miniupnpcstrings.h
$(RM) *.o
2014-03-15 16:59:03 +00:00
$(RM) *.exe
2023-12-30 16:35:35 +00:00
$(RM) miniupnpc.dll miniupnpc.lib miniupnpc.dll.def
2014-03-15 16:59:03 +00:00
$(RM) libminiupnpc.a
2023-12-30 16:35:35 +00:00
$(RM) $(DISTFILE)
$(DISTFILE): $(BINARIES)
$(ZIP) $@ *.exe *.dll *.lib *.def *.a LICENSE README Changelog.txt
2014-03-15 16:59:03 +00:00
libminiupnpc.a: $(OBJS)
$(AR) cr $@ $?
pythonmodule: libminiupnpc.a
2023-12-30 16:35:35 +00:00
$(PYTHON) setupmingw32.py build $(SETUP_COMPILER_FLAG)
2014-03-15 16:59:03 +00:00
$(PYTHON) setupmingw32.py install --skip-build
2023-12-30 16:35:35 +00:00
$(PYTHON) setupmingw32.py bdist_wheel --skip-build
2014-03-15 16:59:03 +00:00
2023-12-30 16:35:35 +00:00
miniupnpc.dll: miniupnpc.def $(OBJSDLL)
$(DLLWRAP) -k --driver-name $(CC) \
2014-03-15 16:59:03 +00:00
--def miniupnpc.def \
--output-def miniupnpc.dll.def \
--implib miniupnpc.lib -o $@ \
$(OBJSDLL) $(LDLIBS)
miniupnpc.lib: miniupnpc.dll
2023-12-30 16:35:35 +00:00
%.o: $(SRCDIR)/%.c
$(CC) $(CFLAGS) $(CPPFLAGS) -DMINIUPNP_STATICLIB -c -o $@ $<
2014-03-15 16:59:03 +00:00
2023-12-30 16:35:35 +00:00
dll-%.o: $(SRCDIR)/%.c
$(CC) $(CFLAGS) $(CPPFLAGS) -DMINIUPNP_EXPORTS -c -o $@ $<
2014-03-15 16:59:03 +00:00
2023-12-30 16:35:35 +00:00
%-shared.o: $(SRCDIR)/%.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
2014-03-15 16:59:03 +00:00
2023-12-30 16:35:35 +00:00
# --enable-stdcall-fixup
%-static.exe: %.o libminiupnpc.a
$(CC) -static -o $@ $^ $(LDLIBS)
2014-03-15 16:59:03 +00:00
2023-12-30 16:35:35 +00:00
%-shared.exe: %-shared.o miniupnpc.lib
2014-03-15 16:59:03 +00:00
$(CC) -o $@ $^ $(LDLIBS)
2023-12-30 16:35:35 +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)
wingenminiupnpcstrings.exe: wingenminiupnpcstrings.c
$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $^
miniupnpcstrings.h: miniupnpcstrings.h.in wingenminiupnpcstrings.exe VERSION
.\wingenminiupnpcstrings.exe $< $@ rc_version.h
rc_version.h: miniupnpcstrings.h
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)"|' > $@
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 $@
endif
miniupnpc.pc: VERSION
$(RM) $@
echo "prefix=$(INSTALLPREFIX)" >> $@
echo "exec_prefix=\$${prefix}" >> $@
echo "libdir=\$${exec_prefix}/$(LIBDIR)" >> $@
echo "includedir=\$${prefix}/include" >> $@
echo "" >> $@
echo "Name: miniUPnPc" >> $@
echo "Description: UPnP IGD client lightweight library" >> $@
echo "Version: $(shell cat VERSION)" >> $@
echo "Libs: -L\$${libdir} -lminiupnpc" >> $@
echo "Cflags: -I\$${includedir}" >> $@
winres.o: miniupnpc.rc rc_version.h
$(WINDRES) -D INTERNAL_NAME=\\\"miniupnpc.dll\\0\\\" -i $< -o $@
2014-03-15 16:59:03 +00:00
2023-12-30 16:35:35 +00:00
testminixml.exe: testminixml.o minixml.o igd_desc_parse.o
$(CC) -static -o $@ $^
2014-03-15 16:59:03 +00:00
2023-12-30 16:35:35 +00:00
minixml.o: $(SRCDIR)/minixml.c $(SRCDIR)/minixml.h
2014-03-15 16:59:03 +00:00
2023-12-30 16:35:35 +00:00
upnpc.o: include/miniwget.h $(SRCDIR)/minisoap.h include/miniupnpc.h include/igd_desc_parse.h
upnpc.o: include/upnpreplyparse.h include/upnpcommands.h include/upnperrors.h miniupnpcstrings.h
2014-03-15 16:59:03 +00:00
2023-12-30 16:35:35 +00:00
miniwget.o: $(SRCDIR)/miniwget.c include/miniwget.h miniupnpcstrings.h $(SRCDIR)/connecthostport.h
2014-03-15 16:59:03 +00:00
2023-12-30 16:35:35 +00:00
minisoap.o: $(SRCDIR)/minisoap.c $(SRCDIR)/minisoap.h miniupnpcstrings.h
2014-03-15 16:59:03 +00:00
2023-12-30 16:35:35 +00:00
miniupnpc.o: $(SRCDIR)/miniupnpc.c include/miniupnpc.h $(SRCDIR)/minisoap.h \
include/miniwget.h $(SRCDIR)/minixml.h $(SRCDIR)/addr_is_reserved.h
2014-03-15 16:59:03 +00:00
2023-12-30 16:35:35 +00:00
igd_desc_parse.o: $(SRCDIR)/igd_desc_parse.c include/igd_desc_parse.h
2014-03-15 16:59:03 +00:00
2023-12-30 16:35:35 +00:00
upnpreplyparse.o: $(SRCDIR)/upnpreplyparse.c include/upnpreplyparse.h $(SRCDIR)/minixml.h
2014-03-15 16:59:03 +00:00
2023-12-30 16:35:35 +00:00
upnpcommands.o: $(SRCDIR)/upnpcommands.c include/upnpcommands.h include/upnpreplyparse.h \
include/miniupnpc.h include/portlistingparse.h
2014-03-15 16:59:03 +00:00
2023-12-30 16:35:35 +00:00
minissdpc.o: $(SRCDIR)/minissdpc.c $(SRCDIR)/minissdpc.h $(SRCDIR)/receivedata.h
2014-03-15 16:59:03 +00:00
2023-12-30 16:35:35 +00:00
upnpdev.o: $(SRCDIR)/upnpdev.c include/upnpdev.h
2014-03-15 16:59:03 +00:00