File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / miniupnpc / Makefile.mingw
Revision 1.1.1.3 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Wed Sep 27 11:21:37 2023 UTC (8 months, 2 weeks ago) by misho
Branches: miniupnpc, elwix, MAIN
CVS tags: v2_2_5p0, HEAD
Version 2.2.5p0

    1: # $Id: Makefile.mingw,v 1.1.1.3 2023/09/27 11:21:37 misho Exp $
    2: # Miniupnp project.
    3: # http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
    4: # (c) 2005-2020 Thomas Bernard
    5: # This Makefile is made for MinGW
    6: #
    7: # To cross compile on a *nix machine :
    8: # make -f Makefile.mingw DLLWRAP=mingw32-dllwrap CC=mingw32-gcc AR=mingw32-ar WINDRES=mingw32-windres
    9: #
   10: SRCDIR = src
   11: INCDIR = include
   12: 
   13: CC ?= gcc
   14: SETUP_COMPILER_FLAG?=
   15: DLLWRAP = dllwrap
   16: WINDRES = windres
   17: SH = /bin/sh
   18: ZIP = zip
   19: ifeq ($(OS),Windows_NT)
   20: RM = del
   21: else
   22: RM = rm -f
   23: endif
   24: 
   25: CFLAGS ?= -Os
   26: CFLAGS += -Wall
   27: CFLAGS += -W -Wstrict-prototypes
   28: 
   29: CPPFLAGS += -DNDEBUG -D_WIN32_WINNT=0x501
   30: CPPFLAGS += -Iinclude
   31: CPPFLAGS += -I.
   32: 
   33: # -liphlpapi is needed for GetBestRoute() and GetIpAddrTable()
   34: LDLIBS = -lws2_32 -liphlpapi
   35: 
   36: PYTHON=\utils\python25\python
   37: OBJS=miniwget.o minixml.o igd_desc_parse.o minisoap.o \
   38:      minissdpc.o \
   39:      miniupnpc.o upnpreplyparse.o upnpcommands.o upnperrors.o \
   40:      connecthostport.o portlistingparse.o receivedata.o \
   41:      upnpdev.o addr_is_reserved.o
   42: OBJSDLL=$(addprefix dll-, $(OBJS)) winres.o
   43: BINARIES=upnpc-static.exe upnpc-shared.exe \
   44:          listdevices-static.exe listdevices-shared.exe \
   45:          miniupnpc.dll libminiupnpc.a \
   46:          testminixml.exe
   47: ifneq ($(GITHUB_SHA),)
   48: COMMITREF=$(GITHUB_SHA)
   49: else
   50: ifneq ($(CI_COMMIT_SHORT_SHA),)
   51: COMMITREF=$(CI_COMMIT_SHORT_SHA)
   52: else
   53: COMMITREF=$(shell git rev-parse --short HEAD)
   54: endif
   55: endif
   56: DISTFILE:=$(shell echo "miniupnpc-bin-win32-`cat VERSION`-$(COMMITREF).zip")
   57: 
   58: LIBDIR ?= lib
   59: # install directories
   60: ifeq ($(strip $(PREFIX)),)
   61: INSTALLPREFIX ?= /usr
   62: else
   63: INSTALLPREFIX ?= $(PREFIX)
   64: endif
   65: 
   66: .PHONY:	all dist clean
   67: 
   68: all:	$(BINARIES)
   69: 
   70: dist:	$(DISTFILE)
   71: 
   72: clean:
   73: 	$(RM) miniupnpcstrings.h
   74: 	$(RM) *.o
   75: 	$(RM) *.exe
   76: 	$(RM) miniupnpc.dll miniupnpc.lib miniupnpc.dll.def
   77: 	$(RM) libminiupnpc.a
   78: 	$(RM) $(DISTFILE)
   79: 
   80: $(DISTFILE):	$(BINARIES)
   81: 	$(ZIP) $@ *.exe *.dll *.lib *.def *.a LICENSE README Changelog.txt
   82: 
   83: libminiupnpc.a:	$(OBJS)
   84: 	$(AR) cr $@ $?
   85: 
   86: pythonmodule:	libminiupnpc.a
   87: 	$(PYTHON) setupmingw32.py build $(SETUP_COMPILER_FLAG)
   88: 	$(PYTHON) setupmingw32.py install --skip-build
   89: 	$(PYTHON) setupmingw32.py bdist_wheel --skip-build
   90: 
   91: miniupnpc.dll:	miniupnpc.def $(OBJSDLL)
   92: 	$(DLLWRAP) -k --driver-name $(CC) \
   93: 	--def miniupnpc.def \
   94: 	--output-def miniupnpc.dll.def \
   95: 	--implib miniupnpc.lib -o $@ \
   96: 	$(OBJSDLL) $(LDLIBS)
   97: 
   98: miniupnpc.lib:	miniupnpc.dll
   99: 
  100: %.o:	$(SRCDIR)/%.c
  101: 	$(CC) $(CFLAGS) $(CPPFLAGS) -DMINIUPNP_STATICLIB -c -o $@ $<
  102: 
  103: dll-%.o:	$(SRCDIR)/%.c
  104: 	$(CC) $(CFLAGS) $(CPPFLAGS) -DMINIUPNP_EXPORTS -c -o $@ $<
  105: 
  106: %-shared.o:	$(SRCDIR)/%.c
  107: 	$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
  108: 
  109: # --enable-stdcall-fixup
  110: %-static.exe:	%.o libminiupnpc.a
  111: 	$(CC) -static -o $@ $^ $(LDLIBS)
  112: 
  113: %-shared.exe:	%-shared.o miniupnpc.lib
  114: 	$(CC) -o $@ $^ $(LDLIBS)
  115: 
  116: # To make miniupnpcstrings.h from miniupnpcstrings.h.in we either
  117: # use a custom executable (if running make under windows) or use
  118: # sed (if cross compiling from another platform).
  119: ifeq ($(OS),Windows_NT)
  120: wingenminiupnpcstrings.exe:	wingenminiupnpcstrings.c
  121: 	$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $^
  122: 
  123: miniupnpcstrings.h: miniupnpcstrings.h.in wingenminiupnpcstrings.exe VERSION
  124: 	.\wingenminiupnpcstrings.exe $< $@ rc_version.h
  125: 
  126: rc_version.h:	miniupnpcstrings.h
  127: else
  128: miniupnpcstrings.h:	miniupnpcstrings.h.in VERSION
  129: 	sed 's|OS_STRING ".*"|OS_STRING "Windows/Mingw32"|' $< | \
  130: 	sed 's|MINIUPNPC_VERSION_STRING ".*"|MINIUPNPC_VERSION_STRING "$(shell cat VERSION)"|' > $@
  131: 
  132: rc_version.h:	VERSION
  133: 	echo "#define LIBMINIUPNPC_DOTTED_VERSION \"$(shell cat VERSION)\"" > $@.tmp
  134: 	echo "#define LIBMINIUPNPC_MAJOR_VERSION $(shell cat VERSION|cut -d. -f1)" >> $@.tmp
  135: 	echo "#define LIBMINIUPNPC_MINOR_VERSION $(shell cat VERSION|cut -d. -f2)" >> $@.tmp
  136: 	echo "#define LIBMINIUPNPC_MICRO_VERSION $(shell cat VERSION|cut -d. -f3)" >> $@.tmp
  137: 	mv $@.tmp $@
  138: endif
  139: 
  140: miniupnpc.pc:	VERSION
  141: 	$(RM) $@
  142: 	echo "prefix=$(INSTALLPREFIX)" >> $@
  143: 	echo "exec_prefix=\$${prefix}" >> $@
  144: 	echo "libdir=\$${exec_prefix}/$(LIBDIR)" >> $@
  145: 	echo "includedir=\$${prefix}/include" >> $@
  146: 	echo "" >> $@
  147: 	echo "Name: miniUPnPc" >> $@
  148: 	echo "Description: UPnP IGD client lightweight library" >> $@
  149: 	echo "Version: $(shell cat VERSION)" >> $@
  150: 	echo "Libs: -L\$${libdir} -lminiupnpc" >> $@
  151: 	echo "Cflags: -I\$${includedir}" >> $@
  152: 
  153: winres.o:	miniupnpc.rc rc_version.h
  154: 	$(WINDRES) -D INTERNAL_NAME=\\\"miniupnpc.dll\\0\\\" -i $< -o $@
  155: 
  156: testminixml.exe:	testminixml.o minixml.o igd_desc_parse.o
  157: 	$(CC) -static -o $@ $^
  158: 
  159: minixml.o:	$(SRCDIR)/minixml.c $(SRCDIR)/minixml.h
  160: 
  161: upnpc.o:	include/miniwget.h $(SRCDIR)/minisoap.h include/miniupnpc.h include/igd_desc_parse.h
  162: upnpc.o:	include/upnpreplyparse.h include/upnpcommands.h include/upnperrors.h miniupnpcstrings.h
  163: 
  164: miniwget.o:	$(SRCDIR)/miniwget.c include/miniwget.h miniupnpcstrings.h $(SRCDIR)/connecthostport.h
  165: 
  166: minisoap.o:	$(SRCDIR)/minisoap.c $(SRCDIR)/minisoap.h miniupnpcstrings.h
  167: 
  168: miniupnpc.o:	$(SRCDIR)/miniupnpc.c include/miniupnpc.h $(SRCDIR)/minisoap.h \
  169: 	include/miniwget.h $(SRCDIR)/minixml.h $(SRCDIR)/addr_is_reserved.h
  170: 
  171: igd_desc_parse.o:	$(SRCDIR)/igd_desc_parse.c include/igd_desc_parse.h
  172: 
  173: upnpreplyparse.o:	$(SRCDIR)/upnpreplyparse.c include/upnpreplyparse.h $(SRCDIR)/minixml.h
  174: 
  175: upnpcommands.o:	$(SRCDIR)/upnpcommands.c include/upnpcommands.h include/upnpreplyparse.h \
  176: 	include/miniupnpc.h include/portlistingparse.h
  177: 
  178: minissdpc.o:	$(SRCDIR)/minissdpc.c $(SRCDIR)/minissdpc.h $(SRCDIR)/receivedata.h
  179: 
  180: upnpdev.o:	$(SRCDIR)/upnpdev.c include/upnpdev.h
  181: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>