1
0
Fork 0
mirror of https://github.com/BLAKE3-team/BLAKE3 synced 2024-05-28 22:06:04 +02:00

Improve build rules

- Build of portable and assembly versions separately
- test.py modified to launch the correct version
- Single rule for all programs
- Source objects for each specified by a variable
This commit is contained in:
Ismael Luceno 2022-03-20 01:06:23 +01:00
parent 993ec902a9
commit 5875d4109e
2 changed files with 28 additions and 16 deletions

View File

@ -1,7 +1,7 @@
# This Makefile is only for testing. C callers should follow the instructions
# in ./README.md to incorporate these C files into their existing build.
NAME=blake3
PROGS = blake3 blake3-asm example
CC=gcc
CFLAGS=-O3 -Wall -Wextra -std=c11 -pedantic -fstack-protector-strong -D_FORTIFY_SOURCE=2 -fPIE -fvisibility=hidden
LDFLAGS=-pie -Wl,-z,relro,-z,now
@ -46,8 +46,22 @@ ifdef BLAKE3_NO_NEON
EXTRAFLAGS += -DBLAKE3_USE_NEON=0
endif
all: blake3.c blake3_dispatch.c blake3_portable.c main.c $(TARGETS)
$(CC) $(CFLAGS) $(EXTRAFLAGS) $^ -o $(NAME) $(LDFLAGS)
all: blake3
asm: blake3-asm
common-objs = blake3.o blake3_dispatch.o blake3_portable.o
blake3-objs = main.o $(common-objs) $(TARGETS)
blake3: $(blake3-objs)
blake3-asm-objs = main.o $(common-objs) $(ASM_TARGETS)
blake3-asm: $(blake3-asm-objs)
example-objs = example.o $(common-objs) $(ASM_TARGETS)
example: $(example-objs)
$(PROGS):
$(CC) $(CFLAGS) $(EXTRAFLAGS) -o $@ $($@-objs) $(LDFLAGS)
.c.o:
$(CC) $(CFLAGS) $(EXTRAFLAGS) $($@_CFLAGS) -o $@ -c $<
@ -61,18 +75,14 @@ blake3_avx2.o_CFLAGS = -mavx2
blake3_avx512.o_CFLAGS = -mavx512f -mavx512vl
test: CFLAGS += -DBLAKE3_TESTING -fsanitize=address,undefined
test: all
./test.py
test: blake3
./test.py blake3
asm: blake3.c blake3_dispatch.c blake3_portable.c main.c $(ASM_TARGETS)
$(CC) $(CFLAGS) $(EXTRAFLAGS) $^ -o $(NAME) $(LDFLAGS)
test_asm: CFLAGS += -DBLAKE3_TESTING -fsanitize=address,undefined
test_asm: blake3-asm
./test.py blake3-asm
test_asm: CFLAGS += -DBLAKE3_TESTING -fsanitize=address,undefined
test_asm: asm
./test.py
clean:
rm -f $(PROGS) *.o
example: example.c blake3.c blake3_dispatch.c blake3_portable.c $(ASM_TARGETS)
$(CC) $(CFLAGS) $(EXTRAFLAGS) $^ -o $@ $(LDFLAGS)
clean:
rm -f $(NAME) *.o
.PHONY: clean all asm test test_asm

View File

@ -4,14 +4,16 @@ from binascii import hexlify
import json
from os import path
import subprocess
import sys
HERE = path.dirname(__file__)
TEST_VECTORS_PATH = path.join(HERE, "..", "test_vectors", "test_vectors.json")
TEST_VECTORS = json.load(open(TEST_VECTORS_PATH))
NAME = sys.argv[1] if len(sys.argv) > 1 else "blake3"
def run_blake3(args, input):
output = subprocess.run([path.join(HERE, "blake3")] + args,
output = subprocess.run([path.join(HERE, NAME)] + args,
input=input,
stdout=subprocess.PIPE,
check=True)