From 1425f72c38fe23a9d3fcda583a7da1e7315acfc3 Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Wed, 17 Jan 2018 18:42:47 +0100 Subject: build system improved --- code/ecp/Makefile | 15 +++++++++++- code/ecp/Makefile.fe310 | 3 ++- code/ecp/Makefile.posix | 3 ++- code/ecp/config_fe310.h | 7 +++++- code/ecp/config_posix.h | 7 +++++- code/ecp/core.c | 2 -- code/ecp/core.h | 49 +++++++++++++++++++------------------ code/ecp/crypto/chacha/Makefile | 5 +--- code/ecp/crypto/compat/Makefile | 5 +--- code/ecp/crypto/crypto.c | 1 - code/ecp/crypto/crypto.h | 2 -- code/ecp/crypto/curve25519/Makefile | 5 +--- code/ecp/crypto/poly1305/Makefile | 5 +--- code/ecp/crypto/sha/Makefile | 5 +--- code/ecp/crypto/test/Makefile | 17 ++++++------- code/ecp/fe310/transport.c | 5 +--- code/ecp/htable/htable.c | 2 -- code/ecp/msgq.h | 3 --- code/ecp/platform.sh | 16 ++++++++++++ code/ecp/posix/transport.c | 2 -- code/ecp/posix/transport.h | 2 -- code/ecp/rbuf.c | 2 -- code/ecp/rbuf_recv.c | 2 -- code/ecp/rbuf_send.c | 2 -- code/ecp/timer.c | 2 -- code/ecp/timer.h | 6 ----- code/ecp/vconn/vconn.c | 5 ++-- code/fe310/eos/ecp.h | 1 + code/platform | 14 ----------- code/test/Makefile | 2 +- code/test/vid/Makefile | 2 +- code/util/Makefile | 2 +- 32 files changed, 90 insertions(+), 111 deletions(-) create mode 100755 code/ecp/platform.sh delete mode 100755 code/platform (limited to 'code') diff --git a/code/ecp/Makefile b/code/ecp/Makefile index 1b16f39..a62e6f0 100644 --- a/code/ecp/Makefile +++ b/code/ecp/Makefile @@ -2,7 +2,7 @@ include Makefile.platform CFLAGS=$(CFLAGS_PL) $(PIC) -I. obj = core.o timer.o $(obj_rbuf) -subdirs = crypto $(vconn) $(htable) $(platform) +subdirs = crypto platform $(htable) $(vconn) %.o: %.c $(CC) $(CFLAGS) -c $< @@ -16,6 +16,19 @@ all: $(obj) (cd $$i && $(MAKE) && cd ..) || exit; \ done +install: all + mkdir -p build-$(platform)/ + install libecpcore.a build-$(platform)/ + install crypto/libecpcr.a build-$(platform)/ + install platform/libecptm.a build-$(platform)/ + install platform/libecptr.a build-$(platform)/ + if [ -f htable/libecpht.a ]; then \ + install htable/libecpht.a build-$(platform)/; \ + fi + if [ -f vconn/libecpvconn.a ]; then \ + install vconn/libecpvconn.a build-$(platform)/; \ + fi + clean: for i in $(subdirs); do \ (cd $$i && $(MAKE) clean && cd ..) || exit; \ diff --git a/code/ecp/Makefile.fe310 b/code/ecp/Makefile.fe310 index 130566b..e753571 100644 --- a/code/ecp/Makefile.fe310 +++ b/code/ecp/Makefile.fe310 @@ -1,6 +1,7 @@ +platform=fe310 + htable= vconn=vconn -platform=fe310 rbuf_obj= FE310_HOME=/opt/my/freedom-e-sdk diff --git a/code/ecp/Makefile.posix b/code/ecp/Makefile.posix index 2680875..c83e050 100644 --- a/code/ecp/Makefile.posix +++ b/code/ecp/Makefile.posix @@ -1,6 +1,7 @@ +platform=posix + htable=htable vconn=vconn -platform=posix obj_rbuf=rbuf.o rbuf_send.o rbuf_recv.o msgq.o CFLAGS_PL=-O3 diff --git a/code/ecp/config_fe310.h b/code/ecp/config_fe310.h index fc95c26..ff61012 100644 --- a/code/ecp/config_fe310.h +++ b/code/ecp/config_fe310.h @@ -1 +1,6 @@ -#define ECP_DEBUG 1 \ No newline at end of file +#ifndef _ECP_CONFIG +#define _ECP_CONFIG + +#define ECP_DEBUG 1 + +#endif \ No newline at end of file diff --git a/code/ecp/config_posix.h b/code/ecp/config_posix.h index ad67d8a..51babef 100644 --- a/code/ecp/config_posix.h +++ b/code/ecp/config_posix.h @@ -1,5 +1,10 @@ +#ifndef _ECP_CONFIG +#define _ECP_CONFIG + #define ECP_WITH_PTHREAD 1 #define ECP_WITH_HTABLE 1 #define ECP_WITH_RBUF 1 #define ECP_WITH_MSGQ 1 -#define ECP_DEBUG 1 \ No newline at end of file +#define ECP_DEBUG 1 + +#endif \ No newline at end of file diff --git a/code/ecp/core.c b/code/ecp/core.c index 3f77c6f..2631f13 100644 --- a/code/ecp/core.c +++ b/code/ecp/core.c @@ -1,7 +1,5 @@ #include "core.h" -#include - int ecp_dhkey_generate(ECPContext *ctx, ECPDHKey *key) { int rv; diff --git a/code/ecp/core.h b/code/ecp/core.h index 0248814..244df4d 100644 --- a/code/ecp/core.h +++ b/code/ecp/core.h @@ -1,3 +1,14 @@ +#include +#include +#include +#include + +#include "config.h" + +#ifdef ECP_WITH_PTHREAD +#include +#endif + #define ECP_OK 0 #define ECP_ITER_NEXT 1 @@ -84,20 +95,6 @@ #define ecp_conn_is_reg(conn) ((conn->flags) & ECP_CONN_FLAG_REG) #define ecp_conn_is_open(conn) ((conn->flags) & ECP_CONN_FLAG_OPEN) -#include "config.h" - -#include -#include -#include - -struct ECPBuffer; -struct ECP2Buffer; -struct ECPContext; -struct ECPSocket; -struct ECPConnection; -struct ECPSeqItem; -struct ECPFragIter; - // typedef long ssize_t; typedef uint32_t ecp_ack_t; @@ -134,11 +131,22 @@ typedef uint32_t ecp_seq_t; #define ECP_SIZE_PLD_RAW_BUF(X,T,P) (ECP_SIZE_PLD(X,T)+((P) ? ((P)->pcount+1)*(ECP_SIZE_PKT_HDR+ECP_SIZE_MSG_BUF(T,P)+ECP_AEAD_SIZE_TAG) : 0)) #define ECP_SIZE_PKT_RAW_BUF(X,T,P) (ECP_SIZE_PLD_RAW_BUF(X,T,P)+ECP_SIZE_PKT_HDR+ECP_AEAD_SIZE_TAG) -#ifdef ECP_WITH_PTHREAD -#include +#ifdef ECP_DEBUG +#include +#define DPRINT(cnd, format, ...) { if (cnd) { fprintf (stderr, format, __VA_ARGS__); } } +#else +#define DPRINT(cnd, format, ...) {} #endif -#include "posix/transport.h" +struct ECPBuffer; +struct ECP2Buffer; +struct ECPContext; +struct ECPSocket; +struct ECPConnection; +struct ECPSeqItem; +struct ECPFragIter; + +#include "platform/transport.h" #include "crypto/crypto.h" #include "timer.h" @@ -146,13 +154,6 @@ typedef uint32_t ecp_seq_t; #include "rbuf.h" #endif -#ifdef ECP_DEBUG -#include -#define DPRINT(cnd, format, ...) { if (cnd) { fprintf (stderr, format, __VA_ARGS__); } } -#else -#define DPRINT(cnd, format, ...) {} -#endif - typedef int ecp_rng_t (void *, size_t); typedef int ecp_conn_handler_new_t (struct ECPSocket *s, struct ECPConnection *p, unsigned char *msg, size_t sz, struct ECPConnection **c); diff --git a/code/ecp/crypto/chacha/Makefile b/code/ecp/crypto/chacha/Makefile index e64aac3..1bafa7f 100644 --- a/code/ecp/crypto/chacha/Makefile +++ b/code/ecp/crypto/chacha/Makefile @@ -4,14 +4,11 @@ CFLAGS=$(CFLAGS_PL) $(PIC) -I../include -D__BEGIN_HIDDEN_DECLS= -D__END_HIDDEN_D obj = chacha.o -all: libchacha.a +all: $(obj) dep: all %.o: %.c $(CC) $(CFLAGS) -c $< -libchacha.a: $(obj) - $(AR) rcs $@ $(obj) - clean: rm -f *.o *.a diff --git a/code/ecp/crypto/compat/Makefile b/code/ecp/crypto/compat/Makefile index 9e96d9e..fc32fe7 100644 --- a/code/ecp/crypto/compat/Makefile +++ b/code/ecp/crypto/compat/Makefile @@ -5,14 +5,11 @@ getentropy = getentropy_osx obj = explicit_bzero.o timingsafe_memcmp.o timingsafe_bcmp.o # arc4random.o arc4random_uniform.o $(getentropy).o -all: libcompat.a +all: $(obj) dep: all %.o: %.c $(CC) $(CFLAGS) -c $< -libcompat.a: $(obj) - $(AR) rcs $@ $(obj) - clean: rm -f *.o *.a diff --git a/code/ecp/crypto/crypto.c b/code/ecp/crypto/crypto.c index f57e8d8..81bf3cc 100644 --- a/code/ecp/crypto/crypto.c +++ b/code/ecp/crypto/crypto.c @@ -1,6 +1,5 @@ #include -#include #include static int dh_mkpair(ecp_dh_public_t *pub, ecp_dh_private_t *priv, ecp_rng_t *rand_buf) { diff --git a/code/ecp/crypto/crypto.h b/code/ecp/crypto/crypto.h index 7bd27d5..86b072c 100644 --- a/code/ecp/crypto/crypto.h +++ b/code/ecp/crypto/crypto.h @@ -1,5 +1,3 @@ -#include - #define CURVE25519_SIZE_KEY 32 #define CHACHA20_SIZE_KEY 32 #define POLY1305_SIZE_TAG 16 diff --git a/code/ecp/crypto/curve25519/Makefile b/code/ecp/crypto/curve25519/Makefile index 5799e0e..e9c2c1b 100644 --- a/code/ecp/crypto/curve25519/Makefile +++ b/code/ecp/crypto/curve25519/Makefile @@ -4,14 +4,11 @@ CFLAGS=$(CFLAGS_PL) $(PIC) -I../include -D__BEGIN_HIDDEN_DECLS= -D__END_HIDDEN_D obj = curve25519.o curve25519-generic.o -all: libcurve25519.a +all: $(obj) dep: all %.o: %.c $(CC) $(CFLAGS) -c $< -libcurve25519.a: $(obj) - $(AR) rcs $@ $(obj) - clean: rm -f *.o *.a diff --git a/code/ecp/crypto/poly1305/Makefile b/code/ecp/crypto/poly1305/Makefile index 5751602..418e3a5 100644 --- a/code/ecp/crypto/poly1305/Makefile +++ b/code/ecp/crypto/poly1305/Makefile @@ -4,14 +4,11 @@ CFLAGS=$(CFLAGS_PL) $(PIC) -I../include -D__BEGIN_HIDDEN_DECLS= -D__END_HIDDEN_D obj = poly1305.o -all: libpoly1305.a +all: $(obj) dep: all %.o: %.c $(CC) $(CFLAGS) -c $< -libpoly1305.a: $(obj) - $(AR) rcs $@ $(obj) - clean: rm -f *.o *.a diff --git a/code/ecp/crypto/sha/Makefile b/code/ecp/crypto/sha/Makefile index 4dc3f39..b775c83 100644 --- a/code/ecp/crypto/sha/Makefile +++ b/code/ecp/crypto/sha/Makefile @@ -4,14 +4,11 @@ CFLAGS=$(CFLAGS_PL) $(PIC) -I../include -D__BEGIN_HIDDEN_DECLS= -D__END_HIDDEN_D obj = sha1dgst.o sha1_one.o sha256.o sha512.o -all: libsha.a +all: $(obj) dep: all %.o: %.c $(CC) $(CFLAGS) -c $< -libsha.a: $(obj) - $(AR) rcs $@ $(obj) - clean: rm -f *.o *.a diff --git a/code/ecp/crypto/test/Makefile b/code/ecp/crypto/test/Makefile index 8ea463d..ae19e4b 100644 --- a/code/ecp/crypto/test/Makefile +++ b/code/ecp/crypto/test/Makefile @@ -2,10 +2,7 @@ include ../../Makefile.platform CFLAGS=$(CFLAGS_PL) -I.. -I../include LDFLAGS=$(LDFLAGS_PL) -aead_dep=../compat/explicit_bzero.o ../compat/timingsafe_memcmp.o ../compat/timingsafe_bcmp.o \ - ../chacha/chacha.o ../poly1305/poly1305.o ../curve25519/curve25519.o ../curve25519/curve25519-generic.o \ - ../sha/sha512.o ../e_chacha20poly1305.o -dsa_dep=../*/*.a +dep=../e_chacha20poly1305.o ../curve25519/*.o ../chacha/*.o ../poly1305/*.o ../sha/*.o ../compat/*.o %.o: %.c @@ -14,22 +11,22 @@ dsa_dep=../*/*.a all: aead aead_enc aead_dec ed25519 ed25519_sign ed25519_open aead: aead.o - $(CC) $(LDFLAGS) -o $@ $< $(aead_dep) + $(CC) $(LDFLAGS) -o $@ $< $(dep) aead_enc: aead_enc.o - $(CC) $(LDFLAGS) -o $@ $< $(aead_dep) + $(CC) $(LDFLAGS) -o $@ $< $(dep) aead_dec: aead_dec.o - $(CC) $(LDFLAGS) -o $@ $< $(aead_dep) + $(CC) $(LDFLAGS) -o $@ $< $(dep) ed25519: ed25519.o - $(CC) $(LDFLAGS) -o $@ $< $(dsa_dep) + $(CC) $(LDFLAGS) -o $@ $< $(dep) ed25519_sign: ed25519_sign.o - $(CC) $(LDFLAGS) -o $@ $< $(dsa_dep) + $(CC) $(LDFLAGS) -o $@ $< $(dep) ed25519_open: ed25519_open.o - $(CC) $(LDFLAGS) -o $@ $< $(dsa_dep) + $(CC) $(LDFLAGS) -o $@ $< $(dep) clean: diff --git a/code/ecp/fe310/transport.c b/code/ecp/fe310/transport.c index 99a1b10..5bffda9 100644 --- a/code/ecp/fe310/transport.c +++ b/code/ecp/fe310/transport.c @@ -1,11 +1,8 @@ -#include -#include +#include #include #include -#include - static int t_addr_eq(ECPNetAddr *addr1, ECPNetAddr *addr2) { if (addr1->port != addr2->port) return 0; if (memcmp(addr1->host, addr2->host, sizeof(addr1->host)) != 0) return 0; diff --git a/code/ecp/htable/htable.c b/code/ecp/htable/htable.c index 6330ef8..77f5a35 100644 --- a/code/ecp/htable/htable.c +++ b/code/ecp/htable/htable.c @@ -1,7 +1,5 @@ #include -#include - #include "hashtable.h" static void *h_create(ECPContext *ctx) { diff --git a/code/ecp/msgq.h b/code/ecp/msgq.h index 41e819b..a81ff36 100644 --- a/code/ecp/msgq.h +++ b/code/ecp/msgq.h @@ -1,8 +1,5 @@ #ifdef ECP_WITH_MSGQ -#include -#include - #define ECP_MSGQ_MAX_MSG 32 #define ECP_MSGQ_ERR_MAX_MSG -110 diff --git a/code/ecp/platform.sh b/code/ecp/platform.sh new file mode 100755 index 0000000..b265bd7 --- /dev/null +++ b/code/ecp/platform.sh @@ -0,0 +1,16 @@ +#!/bin/sh +# + +BASEDIR=$(dirname $0) + +if [ -z $1 ]; then + echo usage $0 "" + exit 1 +fi + +PLATFORM=$1 + +rm -f $BASEDIR/platform +ln -sf ./$PLATFORM $BASEDIR/platform +ln -sf ./config_$PLATFORM.h $BASEDIR/config.h +ln -sf ./Makefile.$PLATFORM $BASEDIR/Makefile.platform diff --git a/code/ecp/posix/transport.c b/code/ecp/posix/transport.c index bdd166a..5415db6 100644 --- a/code/ecp/posix/transport.c +++ b/code/ecp/posix/transport.c @@ -1,10 +1,8 @@ #include -#include #include #include #include #include -#include #include diff --git a/code/ecp/posix/transport.h b/code/ecp/posix/transport.h index c35e13e..6d6d219 100644 --- a/code/ecp/posix/transport.h +++ b/code/ecp/posix/transport.h @@ -1,5 +1,3 @@ -#include - #define ECP_IPv4_ADDR_SIZE 4 typedef int ECPNetSock; diff --git a/code/ecp/rbuf.c b/code/ecp/rbuf.c index d24ac23..e05aedc 100644 --- a/code/ecp/rbuf.c +++ b/code/ecp/rbuf.c @@ -1,7 +1,5 @@ #include "core.h" -#include - int ecp_rbuf_init(ECPRBuffer *rbuf, ECPRBMessage *msg, unsigned int msg_size) { rbuf->msg = msg; if (msg_size) { diff --git a/code/ecp/rbuf_recv.c b/code/ecp/rbuf_recv.c index c262f1d..7a74921 100644 --- a/code/ecp/rbuf_recv.c +++ b/code/ecp/rbuf_recv.c @@ -1,7 +1,5 @@ #include "core.h" -#include - #define ACK_RATE 8 #define ACK_MASK_FIRST ((ecp_ack_t)1 << (ECP_SIZE_ACKB - 1)) diff --git a/code/ecp/rbuf_send.c b/code/ecp/rbuf_send.c index 61b29af..e42a85b 100644 --- a/code/ecp/rbuf_send.c +++ b/code/ecp/rbuf_send.c @@ -1,7 +1,5 @@ #include "core.h" -#include - #define NACK_RATE_UNIT 10000 static ssize_t flush_send(ECPConnection *conn, ECPTimerItem *ti) { diff --git a/code/ecp/timer.c b/code/ecp/timer.c index 16a6ad0..f8d710b 100644 --- a/code/ecp/timer.c +++ b/code/ecp/timer.c @@ -1,7 +1,5 @@ #include "core.h" -#include - int ecp_timer_create(ECPTimer *timer) { int rv = ECP_OK; timer->head = -1; diff --git a/code/ecp/timer.h b/code/ecp/timer.h index 8863226..9c80007 100644 --- a/code/ecp/timer.h +++ b/code/ecp/timer.h @@ -2,12 +2,6 @@ #define ECP_ERR_MAX_TIMER -110 -#include - -#ifdef ECP_WITH_PTHREAD -#include -#endif - struct ECPTimerItem; typedef ssize_t ecp_timer_retry_t (struct ECPConnection *, struct ECPTimerItem *); diff --git a/code/ecp/vconn/vconn.c b/code/ecp/vconn/vconn.c index 4023aa9..a11f8fd 100644 --- a/code/ecp/vconn/vconn.c +++ b/code/ecp/vconn/vconn.c @@ -1,7 +1,6 @@ -#include "core.h" -#include "vconn.h" +#include -#include +#include "vconn.h" #ifdef ECP_WITH_PTHREAD static pthread_mutex_t key_perma_mutex; diff --git a/code/fe310/eos/ecp.h b/code/fe310/eos/ecp.h index 9cc84db..e4722e8 100644 --- a/code/fe310/eos/ecp.h +++ b/code/fe310/eos/ecp.h @@ -1,3 +1,4 @@ +#include #include int ecp_init(ECPContext *ctx); diff --git a/code/platform b/code/platform deleted file mode 100755 index 0781395..0000000 --- a/code/platform +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -# - -BASEDIR=$(dirname $0) - -if [ -z $1 ]; then - echo usage $0 "" - exit 1 -fi - -PLATFORM=$1 - -ln -sf ./Makefile.$PLATFORM $BASEDIR/ecp/Makefile.platform -ln -sf ./config_$PLATFORM.h $BASEDIR/ecp/config.h \ No newline at end of file diff --git a/code/test/Makefile b/code/test/Makefile index 13fa476..0db3126 100644 --- a/code/test/Makefile +++ b/code/test/Makefile @@ -2,7 +2,7 @@ include ../ecp/Makefile.platform CFLAGS=$(CFLAGS_PL) -I../ecp -I../util -Wno-int-to-void-pointer-cast LDFLAGS=$(LDFLAGS_PL) -dep=../ecp/libecpcore.a ../ecp/crypto/libecpcr.a ../ecp/htable/libecpht.a ../ecp/posix/libecptr.a ../ecp/posix/libecptm.a ../ecp/vconn/libecpvconn.a ../util/libecputil.a +dep=../ecp/build-posix/*.a ../util/libecputil.a %.o: %.c $(CC) $(CFLAGS) -c $< diff --git a/code/test/vid/Makefile b/code/test/vid/Makefile index 0abb572..b3943c0 100644 --- a/code/test/vid/Makefile +++ b/code/test/vid/Makefile @@ -2,7 +2,7 @@ LIBVPX_HOME=/Users/majstor/src/libvpx CFLAGS=-D_V4L2_KERNEL_ -I/usr/src/linux-headers-$(uname -r) -I$(LIBVPX_HOME) -I/opt/local/include/SDL2 -I../../core -I../../vconn -I../../util LDFLAGS=-L$(LIBVPX_HOME) -L/opt/local/lib -dep=../../ecp/libecpcore.a ../../ecp/crypto/libecpcr.a ../../ecp/htable/libecpht.a ../../ecp/posix/libecptr.a ../../ecp/posix/libecptm.a ../../vconn/libecpvconn.a ../../util/libecputil.a ../init.o +dep=../../ecp/build-posix/*.a ../../util/libecputil.a ../init.o all: client cap diff --git a/code/util/Makefile b/code/util/Makefile index a896fc2..6e7227b 100644 --- a/code/util/Makefile +++ b/code/util/Makefile @@ -3,7 +3,7 @@ CFLAGS=$(CFLAGS_PL) -I../ecp LDFLAGS=$(LDFLAGS_PL) obj=util.o -dep=../ecp/libecpcore.a ../ecp/crypto/libecpcr.a ../ecp/htable/libecpht.a ../ecp/posix/libecptr.a ../ecp/posix/libecptm.a ./libecputil.a +dep=../ecp/build-posix/*.a ./libecputil.a %.o: %.c %.h -- cgit v1.2.3