This repository has been archived by the owner on May 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
69 lines (56 loc) · 1.9 KB
/
Makefile
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
SRCS := $(shell find cmd hash record scanner store -name '*.go')
BINS := binprint snapcat
# Default target is the cli
all: $(BINS)
LIBGIT2 := vendor/gopkg.in/libgit2/git2go.v27/vendor/libgit2
LIBGIT2PC := $(LIBGIT2)/build/libgit2.pc
# some static analysis tools require setting this ourselves because they don't
# understand how to use build tags
PKG_CONFIG_PATH := $(dir $(LIBGIT2PC))
binprint: $(SRCS) $(LIBGIT2PC)
go build -o $@ --tags "static" ./cmd/binprint
# this won't work on macos because it a static version of crt0 doesn't actually exist
# go build -ldflags '-v -extldflags "-static"' -o $@ --tags "static" ./cli
snapcat: cmd/snapcat/main.go
go build -o $@ ./$(^D)
unused: $(LIBGIT2PC)
PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) unused ./...
test:
go test --tags "static" -v ./...
$(LIBGIT2)/CMakeLists.txt:
git submodule update --init $(@D)
$(LIBGIT2PC): $(LIBGIT2)/CMakeLists.txt
mkdir -p $(@D) $(LIBGIT2)/install/lib
cd $(@D) && \
cmake -DTHREADSAFE=ON \
-DBUILD_CLAR=OFF \
-DUSE_SSH=OFF \
-DUSE_HTTPS=OFF \
-DCURL=OFF \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_C_FLAGS=-fPIC \
-DCMAKE_INSTALL_PREFIX=../install \
-DCMAKE_BUILD_TYPE="MinSizeRel" \
.. && \
cmake --build . --target install
clean:
rm -f $(BINS) $(LIBGIT2PC)
.randomblob:
dd if=/dev/urandom of=$@ bs=512k count=1000
validate-hashes: binprint .randomblob
time md5sum .randomblob
time ./binprint hash md5 .randomblob
time shasum .randomblob
time ./binprint hash sha1 .randomblob
time shasum -a 256 .randomblob
time ./binprint hash sha256 .randomblob
time shasum -a 384 .randomblob
time ./binprint hash sha384 .randomblob
time shasum -a 512 .randomblob
time ./binprint hash sha512 .randomblob
time git hash-object .randomblob
time ./binprint hash git .randomblob
time ./binprint hash hwy64 .randomblob
time ./binprint hash hwy128 .randomblob
time ./binprint hash hwy256 .randomblob
time ./binprint hash all .randomblob