Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
79 lines (61 loc) · 1.6 KB
/
Copy pathMakefile
File metadata and controls
79 lines (61 loc) · 1.6 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
CC = gcc
AR = ar
ARFLAGS = rcs
CFLAGS = -std=c11 -Wall -Wextra -Wpedantic -O2
CPPFLAGS = -Iinclude
# Core library sources
SRC = \
src/web3c_abi.c \
src/web3c_hex.c \
src/web3c_keccak.c \
src/web3c_tx.c \
src/web3c_rlp.c
OBJ = $(SRC:.c=.o)
LIB = libweb3c.a
# Test sources and binaries
TEST_SRCS = \
tests/test_abi.c \
tests/test_keccak.c \
tests/test_selector.c \
tests/test_tx.c \
tests/test_rlp.c
TEST_BINS = $(TEST_SRCS:.c=)
# Example sources and binaries
EXAMPLE_SRCS = \
examples/simple_encode.c \
examples/erc20_transfer_calldata.c \
examples/abi_types_demo.c \
examples/setdata_bytes_calldata.c \
examples/tx_legacy_demo.c \
examples/tx_legacy_rlp_demo.c
EXAMPLE_BINS = $(EXAMPLE_SRCS:.c=)
.PHONY: all tests test examples clean
# Default: only build the static library
all: $(LIB) tests examples
# Build static library
$(LIB): $(OBJ)
$(AR) $(ARFLAGS) $@ $^
# Generic rule for building objects
%.o: %.c
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
# Build test binaries (each test links against libweb3c)
tests/%: tests/%.c $(LIB)
$(CC) $(CPPFLAGS) $(CFLAGS) $^ -o $@
# Build example binaries (each example links against libweb3c)
examples/%: examples/%.c $(LIB)
$(CC) $(CPPFLAGS) $(CFLAGS) $^ -o $@
# Build all examples
examples: $(EXAMPLE_BINS)
# Build all tests (but do not run them)
tests: $(TEST_BINS)
# Build and run test suite
test: $(LIB) tests
@echo "Running tests..."
@./tests/test_abi
@./tests/test_keccak
@./tests/test_selector
@./tests/test_tx
@./tests/test_rlp
@echo "All tests passed."
clean:
rm -f $(OBJ) $(LIB) $(TEST_BINS) $(EXAMPLE_BINS)