blob: c4848041993a54d33a319aced749f27f3dbfeb15 (
plain)
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
|
.POSIX:
.SUFFIXES:
VERSION = 0.1.0
PREFIX = /usr/local
LIBDIR = $(PREFIX)/lib
INCDIR = $(PREFIX)/include
AS = gcc
CC = gcc
ASFLAGS = -Isrc -Wa,--fatal-warnings
CFLAGS = -std=c11 -O2 -Wall -Wextra -Iinclude
LDLIBS = -lcurl
BUILD = build
SRC = src/util.S src/cep.S src/json.S src/csv.S src/models.S \
src/http.S src/client.S
OBJ = $(BUILD)/util.o $(BUILD)/cep.o $(BUILD)/json.o $(BUILD)/csv.o \
$(BUILD)/models.o $(BUILD)/http.o $(BUILD)/client.o
LIB = $(BUILD)/libcepis.a
SO = $(BUILD)/libcepis.so.$(VERSION)
DRIVER = $(BUILD)/test_cepis
DEMO = $(BUILD)/cepis-demo
.PHONY: help test lint build check clean format install valgrind asan demo
help:
@echo 'cepis $(VERSION) - x86-64 assembly client for https://cep.is'
@echo
@echo 'targets:'
@echo ' build assemble the static and shared libraries'
@echo ' test run the suite against a local HTTP server'
@echo ' valgrind run the same suite under valgrind'
@echo ' asan run the same suite under AddressSanitizer'
@echo ' lint read-only checks: assemble with warnings fatal,'
@echo ' compile the header and driver with -Wall -Wextra,'
@echo ' reject tabs/trailing whitespace/over-long lines'
@echo ' check lint, then test, then build'
@echo ' demo build the example command-line client'
@echo ' clean remove $(BUILD)'
@echo ' install install the library and header under $(PREFIX)'
build: $(LIB) $(SO)
$(BUILD)/util.o: src/util.S src/abi.inc src/defs.inc
@mkdir -p $(BUILD)
$(AS) $(ASFLAGS) -c -o $@ src/util.S
$(BUILD)/cep.o: src/cep.S src/abi.inc src/defs.inc
@mkdir -p $(BUILD)
$(AS) $(ASFLAGS) -c -o $@ src/cep.S
$(BUILD)/json.o: src/json.S src/abi.inc src/defs.inc
@mkdir -p $(BUILD)
$(AS) $(ASFLAGS) -c -o $@ src/json.S
$(BUILD)/csv.o: src/csv.S src/abi.inc src/defs.inc
@mkdir -p $(BUILD)
$(AS) $(ASFLAGS) -c -o $@ src/csv.S
$(BUILD)/models.o: src/models.S src/abi.inc src/defs.inc
@mkdir -p $(BUILD)
$(AS) $(ASFLAGS) -c -o $@ src/models.S
$(BUILD)/http.o: src/http.S src/abi.inc src/defs.inc
@mkdir -p $(BUILD)
$(AS) $(ASFLAGS) -c -o $@ src/http.S
$(BUILD)/client.o: src/client.S src/abi.inc src/defs.inc
@mkdir -p $(BUILD)
$(AS) $(ASFLAGS) -c -o $@ src/client.S
$(LIB): $(OBJ)
@mkdir -p $(BUILD)
ar rcs $@ $(OBJ)
$(SO): $(OBJ)
$(CC) -shared -Wl,-soname,libcepis.so.0 -o $@ $(OBJ) $(LDLIBS)
$(DRIVER): tests/test_cepis.c tests/abi_probe.S $(LIB) include/cepis.h
$(CC) $(CFLAGS) -o $@ tests/test_cepis.c tests/abi_probe.S $(LIB) \
$(LDLIBS)
$(BUILD)/test_cepis_asan: tests/test_cepis.c tests/abi_probe.S $(LIB) include/cepis.h
$(CC) $(CFLAGS) -g -fsanitize=address,undefined -fno-omit-frame-pointer \
-o $@ tests/test_cepis.c tests/abi_probe.S $(LIB) $(LDLIBS)
$(DEMO): examples/demo.c $(LIB) include/cepis.h
$(CC) $(CFLAGS) -o $@ examples/demo.c $(LIB) $(LDLIBS)
demo: $(DEMO)
test: $(DRIVER)
sh tests/run.sh $(DRIVER)
asan: $(BUILD)/test_cepis_asan
sh tests/run.sh $(BUILD)/test_cepis_asan
valgrind: $(DRIVER)
sh tests/run.sh $(DRIVER) valgrind --error-exitcode=9 --leak-check=full \
--show-leak-kinds=definite,indirect --errors-for-leak-kinds=definite
lint: $(OBJ) $(DRIVER)
$(CC) $(CFLAGS) -fsyntax-only -x c include/cepis.h
sh tools/style.sh
check: lint test build
format:
@echo 'no formatter for assembly; tools/style.sh is the style check'
clean:
rm -rf $(BUILD)
install: build
mkdir -p $(DESTDIR)$(LIBDIR) $(DESTDIR)$(INCDIR)
cp $(LIB) $(DESTDIR)$(LIBDIR)/libcepis.a
cp $(SO) $(DESTDIR)$(LIBDIR)/libcepis.so.$(VERSION)
ln -sf libcepis.so.$(VERSION) $(DESTDIR)$(LIBDIR)/libcepis.so.0
ln -sf libcepis.so.0 $(DESTDIR)$(LIBDIR)/libcepis.so
cp include/cepis.h $(DESTDIR)$(INCDIR)/cepis.h
|