From 662825493da4efb342740fd983d4f4528c65abf1 Mon Sep 17 00:00:00 2001 From: Jose Marcial Vieira Bisneto Date: Wed, 2 Jan 2019 12:20:13 -0300 Subject: [PATCH] Dependencies: add c-libp2p and lmdb as submodules --- .gitmodules | 7 +++++++ Makefile | 7 +++++-- README.md | 8 ++++++-- blocks/Makefile | 2 +- c-libp2p | 1 + cid/Makefile | 2 +- cmd/Makefile | 4 ++-- cmd/ipfs/Makefile | 4 ++-- commands/Makefile | 2 +- commands/cli/Makefile | 2 +- core/Makefile | 2 +- datastore/Makefile | 2 +- dnslink/Makefile | 2 +- exchange/Makefile | 2 +- exchange/bitswap/Makefile | 2 +- flatfs/Makefile | 2 +- importer/Makefile | 2 +- journal/Makefile | 2 +- lmdb | 1 + main/Makefile | 8 ++++---- merkledag/Makefile | 2 +- multibase/Makefile | 2 +- namesys/Makefile | 2 +- path/Makefile | 2 +- pin/Makefile | 2 +- repo/Makefile | 2 +- repo/config/Makefile | 2 +- repo/fsrepo/Makefile | 2 +- routing/Makefile | 2 +- test/Makefile | 8 ++++---- thirdparty/ipfsaddr/Makefile | 2 +- unixfs/Makefile | 2 +- util/Makefile | 2 +- 33 files changed, 56 insertions(+), 40 deletions(-) create mode 100644 .gitmodules create mode 160000 c-libp2p create mode 160000 lmdb diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..aca394a --- /dev/null +++ b/.gitmodules @@ -0,0 +1,7 @@ +[submodule "c-libp2p"] + path = c-libp2p + url = https://github.com/Agorise/c-libp2p.git +[submodule "lmdb"] + path = lmdb + url = https://github.com/jmjatlanta/lmdb.git + branch = mdb.master diff --git a/Makefile b/Makefile index c08e474..536070f 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,8 @@ DEBUG = true export DEBUG all: - #cd ../c-libp2p; make all; + cd c-libp2p; make all; + cd lmdb/libraries/liblmdb; make all; cd blocks; make all; cd cid; make all; cd cmd; make all; @@ -27,8 +28,10 @@ all: cd util; make all; cd main; make all; cd test; make all; - + clean: + cd c-libp2p; make clean; + cd lmdb/libraries/liblmdb; make clean; cd blocks; make clean; cd cid; make clean; cd cmd; make clean; diff --git a/README.md b/README.md index be38e06..4d72d0f 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ IPFS implementation in C, (not just an API client library). * [getting started](https://github.com/ipfs/community/issues/177) * [libp2p](https://github.com/libp2p/specs) -## Prerequisites: To compile the C version you will need: +## Prerequisites: To compile the C version you will need, all included as submodules: * [lmdb](https://github.com/jmjatlanta/lmdb) * [c-protobuf](https://github.com/Agorise/c-protobuf) * [c-multihash](https://github.com/Agorise/c-multihash) @@ -21,4 +21,8 @@ IPFS implementation in C, (not just an API client library). And of course this project at https://github.com/Agorise/c-ipfs -The compilation at this point is simple, but not very flexible. Place all of these projects in a directory. Compile all (the order above is recommended) by going into each one and running "make all". +## How to compile the C version: +``` +git submodule update --init --recursive +make all +``` diff --git a/blocks/Makefile b/blocks/Makefile index f64ebc1..c3461c3 100644 --- a/blocks/Makefile +++ b/blocks/Makefile @@ -1,5 +1,5 @@ CC = gcc -CFLAGS = -O0 -I../include -I../../c-libp2p/include -I../../c-multihash/include -I../../c-multiaddr/include -I../../c-protobuf -Wall +CFLAGS = -O0 -I../include -I../c-libp2p/include -I../c-libp2p/c-multihash/include -I../c-libp2p/c-multiaddr/include -I../c-libp2p/c-protobuf -Wall ifdef DEBUG CFLAGS += -g3 diff --git a/c-libp2p b/c-libp2p new file mode 160000 index 0000000..d0c319a --- /dev/null +++ b/c-libp2p @@ -0,0 +1 @@ +Subproject commit d0c319a88cd1f2cb3a219420b5a0b930e72562e2 diff --git a/cid/Makefile b/cid/Makefile index 638d6c9..a6b2feb 100644 --- a/cid/Makefile +++ b/cid/Makefile @@ -1,5 +1,5 @@ CC = gcc -CFLAGS = -O0 -I../include -I../../c-libp2p/include -I../../c-multihash/include -I../../c-multiaddr/include -I../../c-protobuf -Wall +CFLAGS = -O0 -I../include -I../c-libp2p/include -I../c-libp2p/c-multihash/include -I../c-libp2p/c-multiaddr/include -I../c-libp2p/c-protobuf -Wall ifdef DEBUG CFLAGS += -g3 diff --git a/cmd/Makefile b/cmd/Makefile index cf0e41a..18f806c 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -1,5 +1,5 @@ CC = gcc -CFLAGS = -O0 -I../include -I../../c-libp2p/include -I../../c-multiaddr/include -I../../c-protobuf -Wall +CFLAGS = -O0 -I../include -I../c-libp2p/include -I../c-libp2p/c-multiaddr/include -I../c-libp2p/c-protobuf -Wall ifdef DEBUG CFLAGS += -g3 @@ -20,4 +20,4 @@ all: $(OBJS) clean: rm -f *.o - cd ipfs; make clean; \ No newline at end of file + cd ipfs; make clean; diff --git a/cmd/ipfs/Makefile b/cmd/ipfs/Makefile index 5dfd89b..a8692d6 100644 --- a/cmd/ipfs/Makefile +++ b/cmd/ipfs/Makefile @@ -1,5 +1,5 @@ CC = gcc -CFLAGS = -O0 -I../../include -I../../../c-libp2p/include -I../../../c-multiaddr/include -I../../../c-protobuf -Wall +CFLAGS = -O0 -I../../include -I../../c-libp2p/include -I../../c-libp2p/c-multiaddr/include -I../../c-libp2p/c-protobuf -Wall ifdef DEBUG CFLAGS += -g3 @@ -19,4 +19,4 @@ all: $(OBJS) clean: rm -f *.o - rm -f ipfs \ No newline at end of file + rm -f ipfs diff --git a/commands/Makefile b/commands/Makefile index 4ad1f1a..2b09804 100644 --- a/commands/Makefile +++ b/commands/Makefile @@ -1,5 +1,5 @@ CC = gcc -CFLAGS = -O0 -I../include -I../../c-libp2p/include -Wall -std=c99 +CFLAGS = -O0 -I../include -I../c-libp2p/include -Wall -std=c99 LFLAGS = DEPS = ../include/ipfs/commands/argument.h ../include/ipfs/commands/command_option.h \ ../include/ipfs/commands/command.h ../include/ipfs/commands/context.h \ diff --git a/commands/cli/Makefile b/commands/cli/Makefile index 8627257..15c5850 100644 --- a/commands/cli/Makefile +++ b/commands/cli/Makefile @@ -1,5 +1,5 @@ CC = gcc -CFLAGS = -O0 -I../../include -I../../../c-libp2p/include -Wall +CFLAGS = -O0 -I../../include -I../../c-libp2p/include -Wall LFLAGS = DEPS = parse.h OBJS = parse.o diff --git a/core/Makefile b/core/Makefile index 4de62f5..df9fd18 100644 --- a/core/Makefile +++ b/core/Makefile @@ -1,5 +1,5 @@ CC = gcc -CFLAGS = -O0 -I../include -I../../c-libp2p/include -I../../c-multiaddr/include -I../../c-protobuf -Wall -std=c11 +CFLAGS = -O0 -I../include -I../c-libp2p/include -I../c-libp2p/c-multiaddr/include -I../c-libp2p/c-protobuf -Wall -std=c11 ifdef DEBUG CFLAGS += -g3 diff --git a/datastore/Makefile b/datastore/Makefile index d189278..f9afe29 100644 --- a/datastore/Makefile +++ b/datastore/Makefile @@ -1,5 +1,5 @@ CC = gcc -CFLAGS = -O0 -I../include -I../../c-libp2p/include -I../../c-multihash/include -I../../c-multiaddr/include -I../../lmdb/libraries/liblmdb -I../../c-protobuf -Wall +CFLAGS = -O0 -I../include -I../c-libp2p/include -I../c-libp2p/c-multihash/include -I../c-libp2p/c-multiaddr/include -I../lmdb/libraries/liblmdb -I../c-libp2p/c-protobuf -Wall ifdef DEBUG CFLAGS += -g3 diff --git a/dnslink/Makefile b/dnslink/Makefile index eba3bf4..b952682 100644 --- a/dnslink/Makefile +++ b/dnslink/Makefile @@ -1,5 +1,5 @@ CC = gcc -CFLAGS = -O0 -I../include -I../../c-libp2p/include -I../../c-multihash/include -I../../c-multiaddr/include -I../../c-protobuf -Wall +CFLAGS = -O0 -I../include -I../c-libp2p/include -I../c-libp2p/c-multihash/include -I../c-libp2p/c-multiaddr/include -I../c-libp2p/c-protobuf -Wall ifdef DEBUG CFLAGS += -g3 diff --git a/exchange/Makefile b/exchange/Makefile index 247de14..a1afbfb 100644 --- a/exchange/Makefile +++ b/exchange/Makefile @@ -1,5 +1,5 @@ CC = gcc -CFLAGS = -O0 -I../include -I../../c-libp2p/include -std=c99 +CFLAGS = -O0 -I../include -I../c-libp2p/include -std=c99 ifdef DEBUG CFLAGS += -g3 diff --git a/exchange/bitswap/Makefile b/exchange/bitswap/Makefile index 39840ec..8a8e15c 100644 --- a/exchange/bitswap/Makefile +++ b/exchange/bitswap/Makefile @@ -1,5 +1,5 @@ CC = gcc -CFLAGS = -O0 -I../../include -I../../../c-libp2p/include -I../../../c-multiaddr/include -I../../../c-multihash/include -I../../../c-protobuf -Wall -std=c99 +CFLAGS = -O0 -I../../include -I../../c-libp2p/include -I../../c-libp2p/c-multiaddr/include -I../../c-libp2p/c-multihash/include -I../../c-libp2p/c-protobuf -Wall -std=c99 ifdef DEBUG CFLAGS += -g3 diff --git a/flatfs/Makefile b/flatfs/Makefile index 6393390..45050e7 100644 --- a/flatfs/Makefile +++ b/flatfs/Makefile @@ -1,6 +1,6 @@ CC = gcc -CFLAGS = -O0 -I../include -I../../c-libp2p/include -Wall +CFLAGS = -O0 -I../include -I../c-libp2p/include -Wall ifdef DEBUG CFLAGS += -g3 diff --git a/importer/Makefile b/importer/Makefile index a749dc7..82fc905 100644 --- a/importer/Makefile +++ b/importer/Makefile @@ -1,5 +1,5 @@ CC = gcc -CFLAGS = -O0 -I../include -I../../c-libp2p/include -I../../c-multihash/include -I../../c-multiaddr/include -I../../c-protobuf -Wall -std=c11 +CFLAGS = -O0 -I../include -I../c-libp2p/include -I../c-libp2p/c-multihash/include -I../c-libp2p/c-multiaddr/include -I../c-libp2p/c-protobuf -Wall -std=c11 ifdef DEBUG CFLAGS += -g3 diff --git a/journal/Makefile b/journal/Makefile index 7a7b1d8..e278865 100644 --- a/journal/Makefile +++ b/journal/Makefile @@ -1,5 +1,5 @@ CC = gcc -CFLAGS = -O0 -I../include -I../../c-libp2p/include -I../../c-multiaddr/include -I../../c-multihash/include -I../../c-protobuf -I../../lmdb/libraries/liblmdb -Wall -std=c99 +CFLAGS = -O0 -I../include -I../c-libp2p/include -I../c-libp2p/c-multiaddr/include -I../c-libp2p/c-multihash/include -I../c-libp2p/c-protobuf -I../lmdb/libraries/liblmdb -Wall -std=c99 ifdef DEBUG CFLAGS += -g3 diff --git a/lmdb b/lmdb new file mode 160000 index 0000000..6b62ada --- /dev/null +++ b/lmdb @@ -0,0 +1 @@ +Subproject commit 6b62ada62a10b3185b2dcd51e512dea27e5e3c8e diff --git a/main/Makefile b/main/Makefile index e7d6ecd..1a81f54 100644 --- a/main/Makefile +++ b/main/Makefile @@ -1,6 +1,6 @@ CC = gcc -CFLAGS = -O0 -I../include -I../../c-libp2p/include -I../../c-multihash/include -I../../c-multiaddr/include -I../../c-protobuf -g3 -Wall -std=c99 -LFLAGS = -L../../c-libp2p -L../../c-multihash -L../../c-multiaddr -lp2p -lm -lmultihash -lmultiaddr -lpthread -lresolv -lcurl +CFLAGS = -O0 -I../include -I../c-libp2p/include -I../c-libp2p/c-multihash/include -I../c-libp2p/c-multiaddr/include -I../c-libp2p/c-protobuf -g3 -Wall -std=c99 +LFLAGS = -L../c-libp2p -L../c-libp2p/c-multihash -L../c-libp2p/c-multiaddr -lp2p -lm -lmultihash -lmultiaddr -lpthread -lresolv -lcurl DEPS = cmd/ipfs/test_init.h repo/test_repo_bootstrap_peers.h repo/test_repo_config.h repo/test_repo_identity.h cid/test_cid.h OBJS = main.o \ ../blocks/block.o ../blocks/blockstore.o \ @@ -27,7 +27,7 @@ OBJS = main.o \ ../routing/*.o \ ../thirdparty/ipfsaddr/ipfs_addr.o \ ../unixfs/unixfs.o \ - ../../c-protobuf/protobuf.o ../../c-protobuf/varint.o \ + ../c-libp2p/c-protobuf/protobuf.o ../c-libp2p/c-protobuf/varint.o \ ../util/errs.o \ ../util/time.o \ ../util/thread_pool.o @@ -36,7 +36,7 @@ OBJS = main.o \ $(CC) -c -o $@ $< $(CFLAGS) ipfs: $(OBJS) - $(CC) -o $@ $^ $(LFLAGS) ../../lmdb/libraries/liblmdb/liblmdb.a + $(CC) -o $@ $^ $(LFLAGS) ../lmdb/libraries/liblmdb/liblmdb.a all: ipfs diff --git a/merkledag/Makefile b/merkledag/Makefile index f1bd074..7d8f62b 100644 --- a/merkledag/Makefile +++ b/merkledag/Makefile @@ -1,5 +1,5 @@ CC = gcc -CFLAGS = -O0 -I../include -I../../c-libp2p/include -I../../c-multihash/include -I../../c-multiaddr/include -I../../c-protobuf -Wall -std=c99 +CFLAGS = -O0 -I../include -I../c-libp2p/include -I../c-libp2p/c-multihash/include -I../c-libp2p/c-multiaddr/include -I../c-libp2p/c-protobuf -Wall -std=c99 ifdef DEBUG CFLAGS += -g3 diff --git a/multibase/Makefile b/multibase/Makefile index af88631..b67913b 100644 --- a/multibase/Makefile +++ b/multibase/Makefile @@ -1,5 +1,5 @@ CC = gcc -CFLAGS = -O0 -I../include -I../../c-libp2p/include -I../../c-multihash/include -Wall +CFLAGS = -O0 -I../include -I../c-libp2p/include -I../c-libp2p/c-multihash/include -Wall ifdef DEBUG CFLAGS += -g3 diff --git a/namesys/Makefile b/namesys/Makefile index 6dcef89..6668919 100644 --- a/namesys/Makefile +++ b/namesys/Makefile @@ -1,5 +1,5 @@ CC = gcc -CFLAGS = -O0 -I../include -I../../c-libp2p/include -I../../c-multihash/include -I../../c-multiaddr/include -I../../c-protobuf -Wall +CFLAGS = -O0 -I../include -I../c-libp2p/include -I../c-libp2p/c-multihash/include -I../c-libp2p/c-multiaddr/include -I../c-libp2p/c-protobuf -Wall ifdef DEBUG CFLAGS += -g3 diff --git a/path/Makefile b/path/Makefile index 022f82c..d7cd7d3 100644 --- a/path/Makefile +++ b/path/Makefile @@ -1,5 +1,5 @@ CC = gcc -CFLAGS = -O0 -I../include -I../../c-libp2p/include -I../../c-multihash/include -I../../c-multiaddr/include -I../../c-protobuf -Wall +CFLAGS = -O0 -I../include -I../c-libp2p/include -I../c-libp2p/c-multihash/include -I../c-libp2p/c-multiaddr/include -I../c-libp2p/c-protobuf -Wall ifdef DEBUG CFLAGS += -g3 diff --git a/pin/Makefile b/pin/Makefile index d0ba437..aa2f94b 100644 --- a/pin/Makefile +++ b/pin/Makefile @@ -1,5 +1,5 @@ CC = gcc -CFLAGS = -O0 -I../include -I../../c-libp2p/include -I../../c-multihash/include -I../../c-multiaddr/include -I../../c-protobuf -Wall +CFLAGS = -O0 -I../include -I../c-libp2p/include -I../c-libp2p/c-multihash/include -I../c-libp2p/c-multiaddr/include -I../c-libp2p/c-protobuf -Wall ifdef DEBUG CFLAGS += -g3 diff --git a/repo/Makefile b/repo/Makefile index 6b36978..3eb37b8 100644 --- a/repo/Makefile +++ b/repo/Makefile @@ -1,5 +1,5 @@ CC = gcc -CFLAGS = -O0 -I../include -I../../c-libp2p/include -std=c99 +CFLAGS = -O0 -I../include -I../c-libp2p/include -std=c99 ifdef DEBUG CFLAGS += -g3 diff --git a/repo/config/Makefile b/repo/config/Makefile index ba90574..0faf5b1 100644 --- a/repo/config/Makefile +++ b/repo/config/Makefile @@ -1,5 +1,5 @@ CC = gcc -CFLAGS = -O0 -I../../include -I../../../c-libp2p/include -I../../../c-multiaddr/include -I../../../c-multihash/include -I../../../c-protobuf -Wall -std=c99 +CFLAGS = -O0 -I../../include -I../../c-libp2p/include -I../../c-libp2p/c-multiaddr/include -I../../c-libp2p/c-multihash/include -I../../c-libp2p/c-protobuf -Wall -std=c99 ifdef DEBUG CFLAGS += -g3 diff --git a/repo/fsrepo/Makefile b/repo/fsrepo/Makefile index a09390d..5881ec9 100644 --- a/repo/fsrepo/Makefile +++ b/repo/fsrepo/Makefile @@ -1,5 +1,5 @@ CC = gcc -CFLAGS = -O0 -I../../include -I../../../c-libp2p/include -I../../../lmdb/libraries/liblmdb -I../../../c-protobuf -I../../../c-multiaddr/include -Wall -std=c99 +CFLAGS = -O0 -I../../include -I../../c-libp2p/include -I../../lmdb/libraries/liblmdb -I../../c-libp2p/c-protobuf -I../../c-libp2p/c-multiaddr/include -Wall -std=c99 ifdef DEBUG CFLAGS += -g3 diff --git a/routing/Makefile b/routing/Makefile index 4a6f4c8..92b67ed 100644 --- a/routing/Makefile +++ b/routing/Makefile @@ -1,5 +1,5 @@ CC = gcc -CFLAGS = -O0 -I../include -I../../c-libp2p/include -I../../c-multiaddr/include -I../../c-protobuf -Wall -std=c99 +CFLAGS = -O0 -I../include -I../c-libp2p/include -I../c-libp2p/c-multiaddr/include -I../c-libp2p/c-protobuf -Wall -std=c99 ifdef DEBUG CFLAGS += -g3 diff --git a/test/Makefile b/test/Makefile index 7e2dd66..6958854 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,6 +1,6 @@ CC = gcc -CFLAGS = -O0 -I../include -I../../c-libp2p/include -I../../c-multihash/include -I../../c-multiaddr/include -I../../c-protobuf -I../../lmdb/libraries/liblmdb -g3 -Wall -std=c99 -LFLAGS = -L../../c-libp2p -L../../c-multihash -L../../c-multiaddr -lp2p -lm -lmultihash -lmultiaddr -lpthread -lcurl +CFLAGS = -O0 -I../include -I../c-libp2p/include -I../c-libp2p/c-multihash/include -I../c-libp2p/c-multiaddr/include -I../c-libp2p/c-protobuf -I../lmdb/libraries/liblmdb -g3 -Wall -std=c99 +LFLAGS = -L../c-libp2p -L../c-libp2p/c-multihash -L../c-libp2p/c-multiaddr -lp2p -lm -lmultihash -lmultiaddr -lpthread -lcurl DEPS = cmd/ipfs/test_init.h repo/test_repo_bootstrap_peers.h repo/test_repo_config.h repo/test_repo_identity.h cid/test_cid.h OBJS = testit.o test_helper.o \ ../blocks/block.o ../blocks/blockstore.o \ @@ -30,13 +30,13 @@ OBJS = testit.o test_helper.o \ ../thirdparty/ipfsaddr/ipfs_addr.o \ ../unixfs/unixfs.o \ ../util/thread_pool.o \ - ../../c-protobuf/protobuf.o ../../c-protobuf/varint.o + ../c-libp2p/c-protobuf/protobuf.o ../c-libp2p/c-protobuf/varint.o %.o: %.c $(DEPS) $(CC) -c -o $@ $< $(CFLAGS) test_ipfs: $(OBJS) - $(CC) -o $@ $^ $(LFLAGS) ../../lmdb/libraries/liblmdb/liblmdb.a + $(CC) -o $@ $^ $(LFLAGS) ../lmdb/libraries/liblmdb/liblmdb.a all: test_ipfs diff --git a/thirdparty/ipfsaddr/Makefile b/thirdparty/ipfsaddr/Makefile index b44296b..cd6bd06 100644 --- a/thirdparty/ipfsaddr/Makefile +++ b/thirdparty/ipfsaddr/Makefile @@ -1,5 +1,5 @@ CC = gcc -CFLAGS = -O0 -I../../include -I../../../c-libp2p/include +CFLAGS = -O0 -I../../include -I../../c-libp2p/include LFLAGS = DEPS = OBJS = ipfs_addr.o diff --git a/unixfs/Makefile b/unixfs/Makefile index 07fb836..bc75524 100644 --- a/unixfs/Makefile +++ b/unixfs/Makefile @@ -1,5 +1,5 @@ CC = gcc -CFLAGS = -O0 -I../include -I../../c-libp2p/include -I../../c-multihash/include -I../../c-multiaddr/include -I../../c-protobuf -Wall +CFLAGS = -O0 -I../include -I../c-libp2p/include -I../c-libp2p/c-multihash/include -I../c-libp2p/c-multiaddr/include -I../c-libp2p/c-protobuf -Wall ifdef DEBUG CFLAGS += -g3 diff --git a/util/Makefile b/util/Makefile index 380d5b5..b3acd0f 100644 --- a/util/Makefile +++ b/util/Makefile @@ -1,5 +1,5 @@ CC = gcc -CFLAGS = -O0 -I../include -I../../c-libp2p/include -I../../c-multihash/include -I../../c-multiaddr/include -I../../c-protobuf -Wall +CFLAGS = -O0 -I../include -I../c-libp2p/include -I../c-libp2p/c-multihash/include -I../c-libp2p/c-multiaddr/include -I../c-libp2p/c-protobuf -Wall ifdef DEBUG CFLAGS += -g3