diff options
| author | Murilo Ijanc <[email protected]> | 2026-07-26 12:56:51 -0300 |
|---|---|---|
| committer | Murilo Ijanc <[email protected]> | 2026-07-26 12:56:59 -0300 |
| commit | b7b08a7d29d84de187dd8a55e0c94de66b07a572 (patch) | |
| tree | 7e55661d3eca3cf3b16aada6e87eabee68802fb9 /Makefile | |
| download | asm-71409185985cad3e8bab55d9e58fd77255bbf6a4.tar.gz | |
Initial importv0.1.0
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 121 |
1 files changed, 121 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c484804 --- /dev/null +++ b/Makefile @@ -0,0 +1,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 |