Fixed msys2 build warnings and re-activated CI Mingw64 build.

* Removed Visual Studio leftovers. Maintaining an autotools project with VS integration requires some additional overhead.

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Signed-off-by: lns <matzeton@googlemail.com>
This commit is contained in:
Toni Uhlig
2022-04-14 19:17:48 +02:00
committed by lns
parent 4775be3d85
commit c3df3a12aa
39 changed files with 469 additions and 742 deletions
+27 -8
View File
@@ -1,10 +1,14 @@
CC=@CC@
CXX=@CXX@
BUILD_MINGW=@BUILD_MINGW@
EXE_SUFFIX=@EXE_SUFFIX@
SRCHOME=../../src
CFLAGS=-g -fPIC -DPIC -I$(SRCHOME)/include @JSONC_CFLAGS@ @PCAP_INC@ @CFLAGS@
ifneq ($(OS),Windows_NT)
CFLAGS+=-fPIC -DPIC
endif
CFLAGS+=-g -I$(SRCHOME)/include @JSONC_CFLAGS@ @PCAP_INC@ @CFLAGS@
LIBNDPI=$(SRCHOME)/lib/libndpi.a
LIBS=$(LIBNDPI) @PCAP_LIB@ @LIBS@ @ADDITIONAL_LIBS@ @JSONC_LIBS@ -lpthread
LDFLAGS=@LDFLAGS@
@@ -13,24 +17,41 @@ OBJS=unit
PREFIX?=@prefix@
ifneq ($(BUILD_MINGW),)
all:
@echo 'Unit tests disabled due to mingw build.'
ifeq ($(DISABLE_NPCAP),0)
CFLAGS+=-I@srcdir@/../windows/WpdPack/Include -I@srcdir@/../windows/WpdPack/Include/pcap
else
CFLAGS+=-DDISABLE_NPCAP
endif
all: unit
ifeq ($(DISABLE_NPCAP),0)
ifneq ($(BUILD_MINGW_X64),)
LIBS+=@srcdir@/../windows/WpdPack/Lib/x64/wpcap.lib
else
LIBS+=@srcdir@/../windows/WpdPack/Lib/wpcap.lib
endif
endif
LIBS+=-Wl,-Bstatic -lpthread -Wl,-Bdynamic
else
LIBS+=-pthread
endif
all: unit$(EXE_SUFFIX)
EXECUTABLE_SOURCES := unit.c
COMMON_SOURCES := $(filter-out $(EXECUTABLE_SOURCES),$(wildcard *.c ))
unit: $(LIBNDPI) unit.o
unit$(EXE_SUFFIX): $(LIBNDPI) unit.o
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) unit.o $(LIBS) -o $@
%.o: %.c $(HEADERS) Makefile
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
clean:
/bin/rm -f *.o unit
/bin/rm -f *.o unit$(EXE_SUFFIX)
/bin/rm -f .*.o.cmd .*.o.d
/bin/rm -rf build
@@ -42,5 +63,3 @@ distdir:
distclean: clean
/bin/rm -f Makefile
endif
+15 -6
View File
@@ -29,8 +29,8 @@
#include <winsock2.h>
#include <process.h>
#include <io.h>
#define getopt getopt____
#else
#include <getopt.h>
#include <unistd.h>
#include <netinet/in.h>
#include <sys/socket.h>
@@ -39,7 +39,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <string.h>
#include <stdarg.h>
#include <search.h>
@@ -96,8 +95,8 @@ int serializerUnitTest() {
for(i=0; i<16; i++) {
char kbuf[32], vbuf[32];
snprintf(kbuf, sizeof(kbuf), "Key %d", i);
snprintf(vbuf, sizeof(vbuf), "Value %d", i);
ndpi_snprintf(kbuf, sizeof(kbuf), "Key %d", i);
ndpi_snprintf(vbuf, sizeof(vbuf), "Value %d", i);
assert(ndpi_serialize_uint32_uint32(&serializer, i, i*i) != -1);
assert(ndpi_serialize_uint32_string(&serializer, i, "Data") != -1);
assert(ndpi_serialize_string_string(&serializer, kbuf, vbuf) != -1);
@@ -112,8 +111,8 @@ int serializerUnitTest() {
for(i=0; i<4; i++) {
char kbuf[32], vbuf[32];
snprintf(kbuf, sizeof(kbuf), "Ignored");
snprintf(vbuf, sizeof(vbuf), "Item %d", i);
ndpi_snprintf(kbuf, sizeof(kbuf), "Ignored");
ndpi_snprintf(vbuf, sizeof(vbuf), "Item %d", i);
assert(ndpi_serialize_uint32_uint32(&serializer, i, i*i) != -1);
assert(ndpi_serialize_string_string(&serializer, kbuf, vbuf) != -1);
assert(ndpi_serialize_string_float(&serializer, kbuf, (float)(i*i), "%f") != -1);
@@ -325,7 +324,9 @@ int serializeProtoUnitTest(void)
/* *********************************************** */
int main(int argc, char **argv) {
#ifndef WIN32
int c;
#endif
if (ndpi_get_api_version() != NDPI_API_VERSION) {
printf("nDPI Library version mismatch: please make sure this code and the nDPI library are in sync\n");
@@ -337,6 +338,11 @@ int main(int argc, char **argv) {
if (ndpi_info_mod == NULL)
return -1;
/*
* If we want argument parsing on Windows,
* we need to re-implement it as Windows has no such function.
*/
#ifndef WIN32
while((c = getopt(argc, argv, "vh")) != -1) {
switch(c) {
case 'v':
@@ -348,6 +354,9 @@ int main(int argc, char **argv) {
return(0);
}
}
#else
verbose = 0;
#endif
/* Tests */
if (serializerUnitTest() != 0) return -1;