small cleanup, makefile preparation for calcdiff

This commit is contained in:
cathugger 2019-12-22 22:01:26 +02:00
parent 451c9610aa
commit 9032811fc5
No known key found for this signature in database
GPG Key ID: 9BADDA2DAF6F01A8
3 changed files with 52 additions and 38 deletions

View File

@ -15,9 +15,9 @@ ED25519_amd64_64_24k= \
$(patsubst @SRCDIR@/%.c,%.c.o,$(wildcard @SRCDIR@/ed25519/amd64-64-24k/*.c)) \ $(patsubst @SRCDIR@/%.c,%.c.o,$(wildcard @SRCDIR@/ed25519/amd64-64-24k/*.c)) \
$(patsubst @SRCDIR@/%.s,%.s.o,$(wildcard @SRCDIR@/ed25519/amd64-64-24k/*.s)) $(patsubst @SRCDIR@/%.s,%.s.o,$(wildcard @SRCDIR@/ed25519/amd64-64-24k/*.s))
ED25519_donna= ED25519_donna=
ED25519OBJ= $(ED25519_@ED25519IMPL@) ED25519_OBJ= $(ED25519_@ED25519IMPL@)
MAINOBJ= \ MAIN_OBJ= \
main.c.o \ main.c.o \
worker.c.o \ worker.c.o \
yaml.c.o \ yaml.c.o \
@ -28,73 +28,86 @@ MAINOBJ= \
base64_to.c.o \ base64_to.c.o \
base64_from.c.o \ base64_from.c.o \
ioutil.c.o \ ioutil.c.o \
$(ED25519OBJ) \ $(ED25519_OBJ) \
keccak.c.o keccak.c.o
TEST_BASE64OBJ= \ UTIL_CALCDIFF_OBJ= \
calcdiff.c.o
TEST_BASE64_OBJ= \
test_base64.c.o \ test_base64.c.o \
base64_to.c.o \ base64_to.c.o \
base64_from.c.o base64_from.c.o
TEST_BASE32OBJ= \ TEST_BASE32_OBJ= \
test_base32.c.o \ test_base32.c.o \
base32_to.c.o \ base32_to.c.o \
base32_from.c.o base32_from.c.o
TEST_BASE16OBJ= \ TEST_BASE16_OBJ= \
test_base16.c.o \ test_base16.c.o \
base16_to.c.o \ base16_to.c.o \
base16_from.c.o base16_from.c.o
TEST_ED25519OBJ= \ TEST_ED25519_OBJ= \
test_ed25519.c.o \ test_ed25519.c.o \
base16_to.c.o \ base16_to.c.o \
base16_from.c.o \ base16_from.c.o \
$(ED25519OBJ) $(ED25519_OBJ)
ALLO= $(sort \ ALL_O= $(sort \
$(MAINOBJ) \ $(MAIN_OBJ) \
$(TEST_BASE64OBJ) \ $(TEST_BASE64_OBJ) \
$(TEST_BASE32OBJ) \ $(TEST_BASE32_OBJ) \
$(TEST_BASE16OBJ) \ $(TEST_BASE16_OBJ) \
$(TEST_ED25519OBJ) \ $(TEST_ED25519_OBJ) \
$(ED25519_ref10) \ $(ED25519_ref10) \
$(ED25519_amd64_51_30k) \ $(ED25519_amd64_51_30k) \
$(ED25519_amd64_64_24k)) $(ED25519_amd64_64_24k))
ALLC= $(patsubst %.c.o,%.c,$(filter %.c.o %.c,$(ALLO))) ALL_C= $(patsubst %.c.o,%.c,$(filter %.c.o %.c,$(ALL_O)))
CLEANO= $(filter %.o,$(ALLO)) CLEAN_O= $(filter %.o,$(ALL_O))
MAINLIB= -lpthread -lsodium @MAINLIB@ MAIN_LIB= -lpthread -lsodium @MAINLIB@
TEST_ED25519LIB= -lsodium TEST_ED25519_LIB= -lsodium
ALLTGTS= mkp224o test_base64 test_base32 test_base16 test_ed25519 MAIN_TGT= mkp224o
ALLEXE= $(patsubst %,%@EXEEXT@,$(ALLTGTS)) UTIL_TGT= calcdiff
TEST_TGT= test_base64 test_base32 test_base16 test_ed25519
MAIN_EXE= $(patsubst %,%@EXEEXT@,$(MAIN_TGT))
UTIL_EXE= $(patsubst %,%@EXEEXT@,$(UTIL_TGT))
TEST_EXE= $(patsubst %,%@EXEEXT@,$(TEST_TGT))
ALL_EXE= $(MAIN_EXE) $(UTIL_EXE) $(TEST_EXE)
.PHONY: default all clean distclean depend .PHONY: default all clean distclean depend
default: mkp224o@EXEEXT@ default: $(MAIN_EXE)
all: $(ALLEXE) all: $(ALL_EXE)
mkp224o@EXEEXT@: $(MAINOBJ) mkp224o@EXEEXT@: $(MAIN_OBJ)
$(CC) $(LDFLAGS) $(CFLAGS) -o $@.tmp $^ $(MAINLIB) && $(MV) $@.tmp $@ $(CC) $(LDFLAGS) $(CFLAGS) -o $@.tmp $^ $(MAIN_LIB) && $(MV) $@.tmp $@
test_base64@EXEEXT@: $(TEST_BASE64OBJ) calcdiff@EXEEXT@: $(UTIL_CALCDIFF_OBJ)
$(CC) $(LDFLAGS) $(CFLAGS) -o $@.tmp $^ && $(MV) $@.tmp $@ $(CC) $(LDFLAGS) $(CFLAGS) -o $@.tmp $^ && $(MV) $@.tmp $@
test_base32@EXEEXT@: $(TEST_BASE32OBJ) test_base64@EXEEXT@: $(TEST_BASE64_OBJ)
$(CC) $(LDFLAGS) $(CFLAGS) -o $@.tmp $^ && $(MV) $@.tmp $@ $(CC) $(LDFLAGS) $(CFLAGS) -o $@.tmp $^ && $(MV) $@.tmp $@
test_base16@EXEEXT@: $(TEST_BASE16OBJ) test_base32@EXEEXT@: $(TEST_BASE32_OBJ)
$(CC) $(LDFLAGS) $(CFLAGS) -o $@.tmp $^ && $(MV) $@.tmp $@ $(CC) $(LDFLAGS) $(CFLAGS) -o $@.tmp $^ && $(MV) $@.tmp $@
test_ed25519@EXEEXT@: $(TEST_ED25519OBJ) test_base16@EXEEXT@: $(TEST_BASE16_OBJ)
$(CC) $(LDFLAGS) $(CFLAGS) -o $@.tmp $^ $(TEST_ED25519LIB) && $(MV) $@.tmp $@ $(CC) $(LDFLAGS) $(CFLAGS) -o $@.tmp $^ && $(MV) $@.tmp $@
test_ed25519@EXEEXT@: $(TEST_ED25519_OBJ)
$(CC) $(LDFLAGS) $(CFLAGS) -o $@.tmp $^ $(TEST_ED25519_LIB) && $(MV) $@.tmp $@
clean: clean:
$(RM) $(CLEANO) $(RM) $(CLEAN_O)
$(RM) $(ALLEXE) $(RM) $(ALL_EXE)
distclean: clean distclean: clean
$(RM) -r autom4te.cache $(RM) -r autom4te.cache
@ -102,7 +115,7 @@ distclean: clean
$(RM) Makefile $(RM) Makefile
depend: depend:
cd "@SRCDIR@" && makedepend -Y -fMakefile.in -o.c.o -- $(CSTD) $(ED25519_DEFS) -- $(ALLC) cd "@SRCDIR@" && makedepend -Y -fMakefile.in -o.c.o -- $(CSTD) $(ED25519_DEFS) -- $(ALL_C)
VPATH=@SRCDIR@ VPATH=@SRCDIR@
@ -424,7 +437,7 @@ test_ed25519.c.o: ed25519/ed25519-donna/ed25519-donna-64bit-x86-32bit.h
test_ed25519.c.o: ed25519/ed25519-donna/ed25519-donna-32bit-sse2.h test_ed25519.c.o: ed25519/ed25519-donna/ed25519-donna-32bit-sse2.h
test_ed25519.c.o: ed25519/ed25519-donna/ed25519-donna-64bit-sse2.h test_ed25519.c.o: ed25519/ed25519-donna/ed25519-donna-64bit-sse2.h
test_ed25519.c.o: ed25519/ed25519-donna/ed25519-donna-impl-sse2.h test_ed25519.c.o: ed25519/ed25519-donna/ed25519-donna-impl-sse2.h
test_ed25519.c.o: ed25519/ed25519-donna/ed25519-donna-impl-base.h test_ed25519.c.o: ed25519/ed25519-donna/ed25519-donna-impl-base.h testutil.h
vec.c.o: vec.h vec.c.o: vec.h
worker.c.o: types.h likely.h vec.h base32.h keccak.h ed25519/ed25519.h worker.c.o: types.h likely.h vec.h base32.h keccak.h ed25519/ed25519.h
worker.c.o: ed25519/ref10/ed25519.h ed25519/ref10/ge.h ed25519/ref10/fe.h worker.c.o: ed25519/ref10/ed25519.h ed25519/ref10/ge.h ed25519/ref10/fe.h

View File

@ -6,6 +6,7 @@
#include "types.h" #include "types.h"
#include "base16.h" #include "base16.h"
#include "ed25519/ed25519.h" #include "ed25519/ed25519.h"
#include "testutil.h"
struct pktest { struct pktest {
const char *seed; const char *seed;
@ -26,11 +27,6 @@ struct pktest {
}, },
}; };
#define WARN(test) if (!(test)) \
fprintf(stderr, "check failed @ %d: %s\n", (int)__LINE__, #test)
#define WARNF(test) if (!(test) && (fprintf(stderr, "check failed @ %d: %s\n", (int)__LINE__, #test), 1))
#define SEEDBYTES 32 #define SEEDBYTES 32
#define SECRETKEYBYTES 64 #define SECRETKEYBYTES 64
#define PUBLICKEYBYTES 32 #define PUBLICKEYBYTES 32

5
testutil.h Normal file
View File

@ -0,0 +1,5 @@
#define WARN(test) if (!(test)) \
fprintf(stderr, "check failed @ %d: %s\n", (int)__LINE__, #test)
#define WARNF(test) if (!(test) && ((void) fprintf(stderr, "check failed @ %d: %s\n", (int)__LINE__, #test), 1))