build on linux

unencrypted_transport
Gernot 4 weeks ago
parent b826a793fd
commit f76c62b575
  1. 18
      Makefile.conf
  2. 22
      src/Makefile
  3. 11
      src/pEpTransportUDP.c
  4. 3
      test/Makefile
  5. 1
      test/pEp_listener.c
  6. 1
      test/pEp_talker.c

@ -1,5 +1,5 @@
# Copyright 2021, pEp Foundation
# This file is part of pEpRCE
# Copyright 2022, pEp Foundation
# This file is part of pEpTransportUDP
# This file may be used under the terms of the GNU General Public License version 3
# see LICENSE.txt
@ -23,22 +23,22 @@ TARGETS=$(LIB_DYN) $(LIB_STATIC)
DEBUG=1
PREFIX?=$(HOME)
SYS_PREFIX=/usr
CXXFLAGS+=-std=c++17 -fPIC
CFLAGS+=-std=c17 -fPIC
# Overrides
-include $(HERE)local.conf
# Constants
CXXFLAGS+=-I$(PREFIX)/include
CFLAGS+=-I$(PREFIX)/include
LDFLAGS+=-L$(PREFIX)/lib
CXXFLAGS+=-I$(SYS_PREFIX)/include
CFLAGS+=-I$(SYS_PREFIX)/include
LDFLAGS+=-L$(SYS_PREFIX)/lib
ifneq (,$(findstring g++,$(CXX)))
CXXFLAGS+=-fdiagnostics-color=always
else ifneq (,$(findstring clang,$(CXX)))
CXXFLAGS+=-fcolor-diagnostics
ifneq (,$(findstring g++,$(CC)))
CFLAGS+=-fdiagnostics-color=always
else ifneq (,$(findstring clang,$(CC)))
CFLAGS+=-fcolor-diagnostics
endif

@ -5,21 +5,23 @@
include ../Makefile.conf
SRC_CXX=$(wildcard *.cc)
SRC_C=$(wildcard *.c)
HEADERS=$(wildcard *.hh *.hxx *.h)
OBJ_CXX=$(subst .cc,.o,$(SRC_CXX))
OBJ_C=$(subst .c,.o,$(SRC_C))
OBJECTS=$(OBJ_CXX) $(OBJ_C)
DEPENDS=$(subst .cc,.d,$(SRC_CXX))
CXXFLAGS+= -MMD -MP
OBJECTS=$(OBJ_C)
# On linux, libpEpAdapter (static-lib .a) needs to be linked into the target lib
# On macOS, this is done anyways, and the linker command `--whole-archive` is invalid
ifeq ($(BUILD_ON),Linux)
LDFLAGS+=-Wl,--whole-archive -lpEpEngine -Wl,--no-whole-archive
else
LDFLAGS+=-lpEpEngine
endif
# On linux, we need to compile position independent for the shared library linker to work
# On macOS, this seems to be done anyways.
#ifeq ($(BUILD_ON),Linux)
# LDFLAGS+=-Wl,--whole-archive -lpEpAdapter -Wl,--no-whole-archive
#else
# LDFLAGS+=-lpEpAdapter
CFLAGS += -fPIC -D_GNU_SOURCE
#endif
DEBUG ?= 1
@ -29,7 +31,7 @@ else
CFLAGS+=-DNDEBUG
endif
LDFLAGS+=-lpEpEngine
#LDFLAGS+=-lpEpEngine
CFLAGS+= -I$(PREFIX)/include
CFLAGS+= -I$(PREFIX)/include/pEp
@ -48,7 +50,7 @@ $(LIB_STATIC): $(OBJECTS)
$(AR) -rc $@ $^
$(LIB_DYN): $(OBJECTS)
$(CXX) $^ $(LDFLAGS) -shared -o $@
$(CC) $^ $(LDFLAGS) -shared -o $@
clean:
rm -f *.d.*

@ -1,3 +1,4 @@
#include <pEp/platform.h>
#include <stdio.h>
#include <stdlib.h>
//#include <pEp/map_asn1.h>
@ -7,13 +8,13 @@
#include <errno.h>
#include <string.h>
#include <sys/types.h>
//#include <sys/ioctl.h>
#include <sys/ioctl.h> // for SIOCGIFFLAGS
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h> // for getaddrinfo()
#include <netinet/in.h>
#include <net/if.h> // for IFF_BROADCAST
#include <net/if.h> // for SIOCGIFFLAGS
#include <pEp/OCTET_STRING.h>
#include <pEp/status_to_string.h>
#include "pEpTransportUDP.h"
@ -67,7 +68,7 @@ PEP_STATUS udp_startup(PEP_transport_t *transport, PEP_transport_status_code *ts
sin.sin_port = htons(atoi(SERVERPORT));
size = sizeof(sin);
inet_ntop(AF_INET,&(sin.sin_addr),ip4,INET_ADDRSTRLEN);
fprintf(stderr,"%s,%s\n",ifa->ifa_name,ip4);
fprintf(stdout,"%s,%s\n",ifa->ifa_name,ip4);
// prepare socket for sending
socki = socket(AF_INET,SOCK_DGRAM,0);
if (socki == -1) {
@ -185,13 +186,13 @@ PEP_STATUS udp_sendto(PEP_SESSION session, message *msg, PEP_transport_status_co
// udp_status = sendto(socki, s->buf, s->size, 0, (struct sockaddr *)&sin, size);
// udp_status = sendto(socki, "test", strlen("test"), 0,(struct sockaddr *)&sin, size);
udp_status = sendto(socki, cypher->longmsg, strlen(cypher->longmsg), 0, (struct sockaddr *)&sin, size);
fprintf(stderr,"Bytes sent a for longmsg: %i of %i\n", udp_status, strlen(cypher->longmsg));
fprintf(stdout,"Bytes sent a for longmsg: %i of %i\n", udp_status, strlen(cypher->longmsg));
if (udp_status==-1) perror("talker: sendto");
// we only send Sync attachments
for (bloblist_t *a = cypher->attachments; a && a->value ; a = a->next) {
if (a->mime_type && strcasecmp(a->mime_type, "application/pEp.sync") == 0){
udp_status = sendto(socki, a->value, strlen(a->value), 0, (struct sockaddr *)&sin, size);
fprintf(stderr,"Bytes sent for attachment %s: %i of %i\n", a->filename, udp_status, strlen(a->value));
fprintf(stdout,"Bytes sent for attachment %s: %i of %i\n", a->filename, udp_status, strlen(a->value));
if (udp_status==-1) perror("talker: sendto");
}
}

@ -11,6 +11,9 @@ CFLAGS:= -I../src/ $(CFLAGS)
CFLAGS+= -I$(PREFIX)/include
CFLAGS+= -I$(PREFIX)/include/pEp
CFLAGS+= -DDEBUG -g
#ifeq ($(BUILD_ON),Linux)
CFLAGS += -D_GNU_SOURCE
#endif
# Test
SRC_TEST=$(wildcard *.c)

@ -1,5 +1,6 @@
#include <stdio.h>
#include <time.h>
#include <pEp/platform.h>
#include <pEp/message.h>
#include <pEp/pEpEngine.h>
//#include <pEp/transport_status_code.h>

@ -5,6 +5,7 @@
#include <string.h>
#include <pEp/pEpEngine.h>
#include <pEp/platform.h>
#include <pEp/keymanagement.h>
#include <pEp/message.h>
#include <pEp/message_api.h>

Loading…
Cancel
Save