From d3858ffc26aba7530d05b44f87fcce1b94f3f5b6 Mon Sep 17 00:00:00 2001 From: Radu Iliescu Date: Thu, 29 Nov 2018 07:15:27 -0500 Subject: [PATCH] Makefile: refactor include files Now major include files are comming from main Makefile, module need to add just their specific include path. To work make the include path absolute. --- Makefile | 3 ++- conn/Makefile | 3 +-- crypto/Makefile | 3 +-- crypto/encoding/Makefile | 4 +--- db/Makefile | 3 +-- hashmap/Makefile | 3 +-- identify/Makefile | 2 +- net/Makefile | 2 +- nodeio/Makefile | 2 +- os/Makefile | 3 +-- peer/Makefile | 3 +-- record/Makefile | 3 +-- routing/Makefile | 6 +++--- secio/Makefile | 2 +- swarm/Makefile | 2 +- test/Makefile | 4 ++-- utils/Makefile | 2 +- yamux/Makefile | 4 ++-- 18 files changed, 23 insertions(+), 31 deletions(-) diff --git a/Makefile b/Makefile index ec9a46e..1017faf 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,8 @@ DEBUG = true export DEBUG -LINKER_FLAGS= +ROOT= $(shell pwd) +export INCLUDE = -I$(ROOT)/include -I$(ROOT)/../c-protobuf -I$(ROOT)/../c-multihash/include -I$(ROOT)/../c-multiaddr/include OBJS = \ conn/*.o \ diff --git a/conn/Makefile b/conn/Makefile index 1e7d7aa..2e05e2c 100644 --- a/conn/Makefile +++ b/conn/Makefile @@ -1,5 +1,5 @@ CC = gcc -CFLAGS = -O0 -I../include -I../../c-protobuf -I../../c-multihash/include -I../../c-multiaddr/include -g3 +CFLAGS = $(INCLUDE) -O0 -g3 LFLAGS = DEPS = OBJS = dialer.o transport_dialer.o connection.o tcp_transport_dialer.o session.o @@ -7,7 +7,6 @@ OBJS = dialer.o transport_dialer.o connection.o tcp_transport_dialer.o session.o %.o: %.c $(DEPS) $(CC) -c -o $@ $< $(CFLAGS) - all: $(OBJS) clean: diff --git a/crypto/Makefile b/crypto/Makefile index 18867a3..8b511e5 100644 --- a/crypto/Makefile +++ b/crypto/Makefile @@ -1,5 +1,5 @@ CC = gcc -CFLAGS = -O0 -I../include -I../../c-protobuf -I../../c-multihash/include -g3 +export CFLAGS = $(INCLUDE) -O0 -g3 LFLAGS = DEPS = OBJS = rsa.o sha256.o sha512.o sha1.o key.o peerutils.o ephemeral.o aes.o @@ -7,7 +7,6 @@ OBJS = rsa.o sha256.o sha512.o sha1.o key.o peerutils.o ephemeral.o aes.o %.o: %.c $(DEPS) $(CC) -c -o $@ $< $(CFLAGS) - all: $(OBJS) cd encoding; make all; diff --git a/crypto/encoding/Makefile b/crypto/encoding/Makefile index 7eda9dd..3719318 100644 --- a/crypto/encoding/Makefile +++ b/crypto/encoding/Makefile @@ -1,5 +1,4 @@ CC = gcc -CFLAGS = -O0 -I../../include -g3 -std=c99 LFLAGS = DEPS = ../../include/libp2p/crypto/encoding/base58.h ../../include/libp2p/crypto/encoding/base64.h \ ../../include/libp2p/crypto/encoding/x509.h ../../include/libp2p/crypto/encoding/base16.h \ @@ -7,9 +6,8 @@ DEPS = ../../include/libp2p/crypto/encoding/base58.h ../../include/libp2p/crypto OBJS = base58.o base64.o x509.o base16.o base32.o %.o: %.c $(DEPS) - $(CC) -c -o $@ $< $(CFLAGS) + $(CC) -c -o $@ $< $(CFLAGS) -std=c99 - all: $(OBJS) clean: diff --git a/db/Makefile b/db/Makefile index ab7f456..8a24d0f 100644 --- a/db/Makefile +++ b/db/Makefile @@ -1,5 +1,5 @@ CC = gcc -CFLAGS = -O0 -I../include -I../../c-protobuf -I../../c-multihash/include -I../../c-multiaddr/include -g3 -std=c99 +CFLAGS = $(INCLUDE) -O0 -g3 -std=c99 LFLAGS = DEPS = OBJS = datastore.o filestore.o @@ -7,7 +7,6 @@ OBJS = datastore.o filestore.o %.o: %.c $(DEPS) $(CC) -c -o $@ $< $(CFLAGS) - all: $(OBJS) clean: diff --git a/hashmap/Makefile b/hashmap/Makefile index 96e40f3..0acbb2c 100644 --- a/hashmap/Makefile +++ b/hashmap/Makefile @@ -1,5 +1,5 @@ CC = gcc -CFLAGS = -O0 -I../include -g3 +CFLAGS = $(INCLUDE) -O0 -g3 LFLAGS = DEPS = OBJS = hashmap.o @@ -7,7 +7,6 @@ OBJS = hashmap.o %.o: %.c $(DEPS) $(CC) -c -o $@ $< $(CFLAGS) - all: $(OBJS) clean: diff --git a/identify/Makefile b/identify/Makefile index e15ce81..22677db 100644 --- a/identify/Makefile +++ b/identify/Makefile @@ -1,5 +1,5 @@ CC = gcc -CFLAGS = -O0 -Wall -Werror -I../include -I../../c-protobuf -std=c11 +CFLAGS = $(INCLUDE) -O0 -Wall -Werror -std=c11 ifdef DEBUG CFLAGS += -g3 diff --git a/net/Makefile b/net/Makefile index 59d703b..65c150f 100644 --- a/net/Makefile +++ b/net/Makefile @@ -1,5 +1,5 @@ CC = gcc -CFLAGS = -O0 -Wall -I../include -I../../c-protobuf -I../../c-multiaddr/include +CFLAGS = $(INCLUDE) -O0 -Wall ifdef DEBUG CFLAGS += -g3 diff --git a/nodeio/Makefile b/nodeio/Makefile index b3e63f4..876a573 100644 --- a/nodeio/Makefile +++ b/nodeio/Makefile @@ -1,5 +1,5 @@ CC = gcc -CFLAGS = -O0 -Wall -I../include -I../../c-protobuf +CFLAGS = $(INCLUDE) -O0 -Wall ifdef DEBUG CFLAGS += -g3 diff --git a/os/Makefile b/os/Makefile index 6e1faaf..1bf8853 100644 --- a/os/Makefile +++ b/os/Makefile @@ -1,5 +1,5 @@ CC = gcc -CFLAGS = -O0 -I../include -I../../c-protobuf -I../../c-multihash/include -I../../c-multiaddr/include -g3 +CFLAGS = $(INCLUDE) -O0 -g3 LFLAGS = DEPS = OBJS = utils.o memstream.o @@ -7,7 +7,6 @@ OBJS = utils.o memstream.o %.o: %.c $(DEPS) $(CC) -c -o $@ $< $(CFLAGS) - all: $(OBJS) clean: diff --git a/peer/Makefile b/peer/Makefile index c41dcbb..af36362 100644 --- a/peer/Makefile +++ b/peer/Makefile @@ -1,5 +1,5 @@ CC = gcc -CFLAGS = -O0 -I../include -I../../c-protobuf -I../../c-multihash/include -I../../c-multiaddr/include -g3 -std=c11 +CFLAGS = $(INCLUDE) -O0 -g3 -std=c11 LFLAGS = DEPS = OBJS = peer.o peerstore.o providerstore.o @@ -7,7 +7,6 @@ OBJS = peer.o peerstore.o providerstore.o %.o: %.c $(DEPS) $(CC) -c -o $@ $< $(CFLAGS) - all: $(OBJS) clean: diff --git a/record/Makefile b/record/Makefile index 280325b..bca5d02 100644 --- a/record/Makefile +++ b/record/Makefile @@ -1,5 +1,5 @@ CC = gcc -CFLAGS = -O0 -I../include -I../../c-protobuf -I../../c-multihash/include -I../../c-multiaddr/include -g3 +CFLAGS = $(INCLUDE) -O0 -g3 LFLAGS = DEPS = OBJS = record.o message.o message_handler.o @@ -7,7 +7,6 @@ OBJS = record.o message.o message_handler.o %.o: %.c $(DEPS) $(CC) -c -o $@ $< $(CFLAGS) - all: $(OBJS) clean: diff --git a/routing/Makefile b/routing/Makefile index f71a960..18bfa0f 100644 --- a/routing/Makefile +++ b/routing/Makefile @@ -1,6 +1,6 @@ DHT_DIR = dht CC = gcc -CFLAGS = -O0 -I../include -I../../c-multiaddr/include -I$(DHT_DIR) -g3 +CFLAGS = $(INCLUDE) -I$(DHT_DIR) -O0 -g3 LFLAGS = DEPS = # $(DHT_DIR)/dht.h OBJS = kademlia.o dht.o dht_protocol.o @@ -21,5 +21,5 @@ kademlia_test: $(OBJS) clean: rm -f kademlia_test $(OBJS) - #dht.c - #rm -rf $(DHT_DIR) +#dht.c +#rm -rf $(DHT_DIR) diff --git a/secio/Makefile b/secio/Makefile index 8542bbd..59a0167 100644 --- a/secio/Makefile +++ b/secio/Makefile @@ -1,5 +1,5 @@ CC = gcc -CFLAGS = -O0 -Wall -I../include -I../../c-protobuf -I../../c-multiaddr/include -std=c99 +CFLAGS = $(INCLUDE) -O0 -Wall -std=c99 ifdef DEBUG CFLAGS += -g3 diff --git a/swarm/Makefile b/swarm/Makefile index cd43de1..c5bf8d0 100644 --- a/swarm/Makefile +++ b/swarm/Makefile @@ -1,5 +1,5 @@ CC = gcc -CFLAGS = -O0 -Wall -I../include -I../../c-protobuf -I../../c-multiaddr/include -std=c99 +CFLAGS = $(INCLUDE) -O0 -Wall -std=c99 ifdef DEBUG CFLAGS += -g3 diff --git a/test/Makefile b/test/Makefile index c53b6d0..24b8431 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,5 +1,5 @@ CC = gcc -CFLAGS = -O0 -I../include -I. -I../../c-multihash/include -I../../c-multiaddr/include -std=c11 +CFLAGS = $(INCLUDE) -O0 -std=c11 ifdef DEBUG CFLAGS += -g3 @@ -14,7 +14,7 @@ OBJS = testit.o ../../c-protobuf/protobuf.o ../../c-protobuf/varint.o ../libp2p. testit_libp2p: $(OBJS) $(DEPS) $(CC) -o $@ $(OBJS) $(LFLAGS) -lp2p -lm -lmultihash -lmultiaddr -lpthread - + all_others: cd ../crypto; make all; cd ../thirdparty; make all; diff --git a/utils/Makefile b/utils/Makefile index 653f98c..5e9d048 100644 --- a/utils/Makefile +++ b/utils/Makefile @@ -1,5 +1,5 @@ CC = gcc -CFLAGS = -O0 -Wall -I../include -I../../c-multiaddr/include -std=c99 +CFLAGS = $(INCLUDE) -O0 -Wall -std=c99 ifdef DEBUG CFLAGS += -g3 diff --git a/yamux/Makefile b/yamux/Makefile index ff0165b..942a128 100644 --- a/yamux/Makefile +++ b/yamux/Makefile @@ -1,5 +1,5 @@ CC = gcc -CFLAGS = -O0 -Wall -Werror -I../include -I../../c-protobuf -std=c11 +CFLAGS = $(INCLUDE) -O0 -Wall -Werror -std=c11 ifdef DEBUG CFLAGS += -g3 @@ -19,4 +19,4 @@ clean: rm -f test test: all test.o - $(CC) -o test test.o $(OBJS) $(CFLAGS) \ No newline at end of file + $(CC) -o test test.o $(OBJS) $(CFLAGS)