aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2023-12-28 08:52:35 -0300
committerEuAndreh <eu@euandre.org>2025-03-20 16:17:06 -0300
commit2bbcc453fb4013f46a61bdafea10d61aae17ec95 (patch)
tree6676f3688ccc75dd7d9fa8cde7c7fc3d074e33c5
parentRemove support files (diff)
downloadsiphash-2bbcc453fb4013f46a61bdafea10d61aae17ec95.tar.gz
siphash-2bbcc453fb4013f46a61bdafea10d61aae17ec95.tar.xz
Add complete "Makefile" for standard packaging
Also include a ".gitignore" with the derived assets. --- On the "Makefile", the canonical virtual targets implemented are: - "all": the default target name when no explicit name is given, or when one wants to build more than one target at once, such as: `make all check`. All it builds is the "libsiphash.a" library; - "check": NOOP, as there are no tests implemented; - "clean": removes the "*.o", "*.bin" and "libsiphash.a" files, which represent 100% of the generated assets; - "install": uses `$(DESTDIR)`, `$(LIBDIR)`, `$(INCLUDEDIR)` and `$(SRCDIR)` to properly place the "libsiphash.a" library, the "siphash.h" header and the "siphash.c" source in the correct place. `$(LIBDIR)`, `$(INCLUDEDIR)` and `$(SRCDIR)` are defined based on `$(PREFIX)`; - "uninstall": a perfect mirror of "install", which removes 100% of the installed artifacts.
-rw-r--r--.gitignore3
-rw-r--r--Makefile44
2 files changed, 47 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..155dfbe
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+/*.o
+/*.a
+/*.bin
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..b8784b2
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,44 @@
+.POSIX:
+PREFIX = /usr
+NAME = siphash
+LIBDIR = $(PREFIX)/lib
+INCLUDEDIR = $(PREFIX)/include
+SRCDIR = $(PREFIX)/src/$(NAME)
+
+
+all: lib$(NAME).a
+
+lib$(NAME).a: lib$(NAME).a($(NAME).o)
+lib$(NAME).a: lib$(NAME).a(halfsiphash.o)
+
+$(NAME).o: $(NAME).h
+halfsiphash.o: halfsiphash.h
+
+
+test.o: halfsiphash.h siphash.h vectors.h
+test.bin: test.o testmain.o lib$(NAME).a
+ $(CC) $(LDFLAGS) -o $@ test.o testmain.o lib$(NAME).a $(LDLIBS)
+
+
+check: test.bin
+ ./test.bin
+
+clean:
+ rm -f *.o *.a
+ rm -f test.bin
+
+
+install: all
+ mkdir -p \
+ '$(DESTDIR)$(LIBDIR)' \
+ '$(DESTDIR)$(INCLUDEDIR)' \
+ '$(DESTDIR)$(SRCDIR)'
+ cp lib$(NAME).a '$(DESTDIR)$(LIBDIR)'
+ cp $(NAME).h '$(DESTDIR)$(INCLUDEDIR)'
+ cp $(NAME).h $(NAME).c '$(DESTDIR)$(SRCDIR)'
+
+uninstall:
+ rm -rf \
+ '$(DESTDIR)$(LIBDIR)'/lib$(NAME).a \
+ '$(DESTDIR)$(INCLUDEDIR)'/$(NAME).h \
+ '$(DESTDIR)$(SRCDIR)'