forked from EdgeApp/airbitz-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
155 lines (124 loc) · 4.87 KB
/
Makefile
File metadata and controls
155 lines (124 loc) · 4.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# Build settings:
WORK_DIR ?= build
INSTALL_PATH ?= /usr/local
# Set latest Git revision as Version
ifeq (,$(wildcard src/Version.h))
$(shell cp "src/Version.h.in" "src/Version.h")
endif
GIT_REV = $(shell git rev-parse --short HEAD)
SRC_REV = $(shell grep -o "\".*\"" src/Version.h)
GIT_REV_COMPARE = $(shell [ $(GIT_REV) != $(SRC_REV) ] && echo true)
ifeq ($(GIT_REV_COMPARE),true)
$(shell sed -i '/#define ABC_VERSION ".*"/c\#define ABC_VERSION "$(GIT_REV)"' src/Version.h )
endif
# Set DEFAULT_HIDDENBITSKEY in CLI if passed as variable
ifneq (,$(HIDDENBITSKEY))
$(shell sed -i '/#define DEFAULT_HIDDENBITSKEY ".*"/c\#define DEFAULT_HIDDENBITSKEY "$(HIDDENBITSKEY)"' cli/Main.cpp )
endif
# Compiler options:
CFLAGS += -D_GNU_SOURCE -DDEBUG -g -Wall -fPIC -std=c99
CXXFLAGS += -D_GNU_SOURCE -DDEBUG -g -Wall -fPIC -std=c++11
deps = jansson libbitcoin libcurl libgit2 libqrencode libsecp256k1 libssl libzmq protobuf-lite zlib
LIBS := $(shell pkg-config --libs --static $(deps)) \
-lsodium \
-lcsv -lm
# Do not use -lpthread on Android:
ifneq (,$(findstring android,$(CC)))
CFLAGS += -DANDROID
CXXFLAGS += -DANDROID
LIBS := $(filter-out -lpthread,$(LIBS)) -llog
endif
# Source files:
abc_sources = \
$(wildcard abcd/*.cpp abcd/*/*.cpp abcd/*/*/*.cpp src/*.cpp) \
$(wildcard minilibs/libbitcoin-client/*.cpp) \
minilibs/git-sync/sync.c \
minilibs/scrypt/crypto_scrypt.c \
codegen/paymentrequest.pb.cpp
cli_sources = $(wildcard cli/*.cpp cli/*/*.cpp)
test_sources = $(wildcard test/*.cpp)
generated_headers = \
codegen/paymentrequest.pb.h
# Objects:
abc_objects = $(addprefix $(WORK_DIR)/, $(addsuffix .o, $(basename $(abc_sources))))
cli_objects = $(addprefix $(WORK_DIR)/, $(addsuffix .o, $(basename $(cli_sources))))
test_objects = $(addprefix $(WORK_DIR)/, $(addsuffix .o, $(basename $(test_sources))))
# Adjustable verbosity:
V ?= 0
ifeq ($V,0)
RUN = @echo Making $@...;
endif
# Targets:
all: $(WORK_DIR)/abc-cli check format-check
libabc.a: $(WORK_DIR)/libabc.a
libabc.so: $(WORK_DIR)/libabc.so
$(WORK_DIR)/libabc.a: $(abc_objects)
$(RUN) $(RM) $@; $(AR) rcs $@ $^
$(WORK_DIR)/libabc.so: $(abc_objects)
$(RUN) $(CXX) -shared -Wl,-soname=libabc.so -o $@ $^ $(LDFLAGS) $(LIBS)
$(WORK_DIR)/abc-cli: $(cli_objects) $(WORK_DIR)/libabc.a
$(RUN) $(CXX) -o $@ $^ $(LDFLAGS) $(LIBS)
$(WORK_DIR)/abc-test: $(test_objects) $(WORK_DIR)/libabc.a
$(RUN) $(CXX) -o $@ $^ $(LDFLAGS) $(LIBS)
check: $(WORK_DIR)/abc-test
$(RUN) $<
format:
@astyle --options=astyle-options -Q --suffix=none --recursive --exclude=build --exclude=codegen --exclude=deps --exclude=minilibs "*.cpp" "*.hpp" "*.h"
format-check:
ifneq (, $(shell which astyle))
@astyle --options=astyle-options -Q --suffix=none --recursive --exclude=build --exclude=codegen --exclude=deps --exclude=minilibs "*.cpp" "*.hpp" "*.h" \
--dry-run | sed -n '/Formatted/s/Formatted/Needs formatting:/p'
endif
doc: cli/doc/abc-cli.html cli/doc/abc-cli.1
cli/doc/abc-cli.html: cli/doc/abc-cli.pod
$(RUN) pod2html --infile=$< --outfile=$@ --noindex
cli/doc/abc-cli.1: cli/doc/abc-cli.pod
$(RUN) pod2man $< $@
clean:
$(RM) -r $(WORK_DIR) codegen
install: $(WORK_DIR)/libabc.a $(WORK_DIR)/abc-cli cli/doc/abc-cli.1
make doc
install -d $(INSTALL_PATH)/lib
install -d $(INSTALL_PATH)/bin
install -d $(INSTALL_PATH)/include
install -d $(INSTALL_PATH)/share/man/man1
install -d $(INSTALL_PATH)/share/bash-completion/completions
install $(WORK_DIR)/libabc.a $(INSTALL_PATH)/lib
install $(WORK_DIR)/abc-cli $(INSTALL_PATH)/bin
install src/ABC.h $(INSTALL_PATH)/include
install cli/doc/abc-cli.1 $(INSTALL_PATH)/share/man/man1
install cli/abc-cli-bash-completion.sh $(INSTALL_PATH)/share/bash-completion/completions
uninstall:
rm -f $(INSTALL_PATH)/lib/libabc.a
rm -f $(INSTALL_PATH)/bin/abc-cli
rm -f $(INSTALL_PATH)/include/ABC.h
rm -f $(INSTALL_PATH)/share/man/man1/abc-cli.1
rm -f $(INSTALL_PATH)/share/bash-completion/completions/abc-cli-bash-completion.sh
tar:
make
make doc
mkdir -p abctar abctar/lib abctar/bin abctar/include abctar/share/man/man1 abctar/share/bash-completion/completions
cp $(WORK_DIR)/libabc.a abctar/lib
cp $(WORK_DIR)/abc-cli abctar/bin
cp src/ABC.h abctar/include
cp cli/doc/abc-cli.1 abctar/share/man/man1
cp cli/abc-cli-bash-completion.sh abctar/share/bash-completion/completions
tar -cvf abc.tar abctar
gzip -f abc.tar
rm -rf abctar
# Automatic dependency rules:
$(WORK_DIR)/%.o: %.c | $(generated_headers)
@mkdir -p $(dir $@)
$(RUN) $(CC) -c -MD $(CFLAGS) -o $@ $<
$(WORK_DIR)/%.o: %.cpp | $(generated_headers)
@mkdir -p $(dir $@)
$(RUN) $(CXX) -c -MD $(CXXFLAGS) -o $@ $<
include $(wildcard $(WORK_DIR)/*/*.d $(WORK_DIR)/*/*/*.d $(WORK_DIR)/*/*/*/*.d)
%.h: ;
%.hpp: ;
# Protobuf files:
codegen/paymentrequest.pb.h codegen/paymentrequest.pb.cc: abcd/bitcoin/spend/paymentrequest.proto
@mkdir -p $(dir $@)
$(RUN) protoc --cpp_out=$(dir $@) --proto_path=$(dir $<) $<
codegen/paymentrequest.pb.cpp: codegen/paymentrequest.pb.cc
@cp $^ $@