summaryrefslogtreecommitdiff
path: root/testsuite/Makefile.in
blob: 73a61685dfc1dcd498aace7fb2127e4999f80add (plain)
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
@SET_MAKE@

srcdir = @srcdir@
VPATH = @srcdir@

top_srcdir = @top_srcdir@

include ../config.make

PRE_CPPFLAGS = -I.. -I$(top_srcdir)
PRE_LDFLAGS = -L..

TS_NETTLE_SOURCES = aes-test.c arcfour-test.c arctwo-test.c \
		    blowfish-test.c cast128-test.c \
	            base16-test.c base64-test.c \
		    camellia-test.c chacha-test.c \
		    cnd-memcpy-test.c \
		    des-test.c des3-test.c \
		    md2-test.c md4-test.c md5-test.c md5-compat-test.c \
		    memeql-test.c memxor-test.c gosthash94-test.c \
		    ripemd160-test.c hkdf-test.c \
		    salsa20-test.c \
		    sha1-test.c sha224-test.c sha256-test.c \
		    sha384-test.c sha512-test.c sha512-224-test.c sha512-256-test.c \
		    sha3-permute-test.c sha3-224-test.c sha3-256-test.c \
		    sha3-384-test.c sha3-512-test.c \
		    shake256-test.c \
		    serpent-test.c twofish-test.c version-test.c \
		    knuth-lfib-test.c \
		    cbc-test.c cfb-test.c ctr-test.c gcm-test.c eax-test.c ccm-test.c \
		    cmac-test.c siv-test.c \
		    poly1305-test.c chacha-poly1305-test.c \
		    hmac-test.c umac-test.c \
		    meta-hash-test.c meta-cipher-test.c\
		    meta-aead-test.c meta-armor-test.c \
		    buffer-test.c yarrow-test.c xts-test.c pbkdf2-test.c

TS_HOGWEED_SOURCES = sexp-test.c sexp-format-test.c \
		     rsa2sexp-test.c sexp2rsa-test.c \
		     bignum-test.c random-prime-test.c \
		     pkcs1-test.c pkcs1-sec-decrypt-test.c \
		     pss-test.c rsa-sign-tr-test.c \
		     pss-mgf1-test.c rsa-pss-sign-tr-test.c \
		     rsa-test.c rsa-encrypt-test.c rsa-keygen-test.c \
		     rsa-sec-decrypt-test.c \
		     rsa-compute-root-test.c \
		     dsa-test.c dsa-keygen-test.c \
		     curve25519-dh-test.c curve448-dh-test.c \
		     ecc-mod-test.c ecc-modinv-test.c ecc-redc-test.c \
		     ecc-sqrt-test.c \
		     ecc-dup-test.c ecc-add-test.c \
		     ecc-mul-g-test.c ecc-mul-a-test.c \
		     ecdsa-sign-test.c ecdsa-verify-test.c \
		     ecdsa-keygen-test.c ecdh-test.c \
		     eddsa-compress-test.c eddsa-sign-test.c \
		     eddsa-verify-test.c ed25519-test.c ed448-test.c \
		     gostdsa-sign-test.c gostdsa-verify-test.c \
		     gostdsa-keygen-test.c

TS_SOURCES = $(TS_NETTLE_SOURCES) $(TS_HOGWEED_SOURCES)
CXX_SOURCES = cxx-test.cxx

TS_NETTLE = $(TS_NETTLE_SOURCES:.c=$(EXEEXT))
TS_HOGWEED = $(TS_HOGWEED_SOURCES:.c=$(EXEEXT))
TS_C = $(TS_NETTLE) @IF_HOGWEED@ $(TS_HOGWEED)
TS_CXX = @IF_CXX@ $(CXX_SOURCES:.cxx=$(EXEEXT))
TARGETS = $(TS_C) $(TS_CXX)
TS_SH = sexp-conv-test pkcs1-conv-test nettle-pbkdf2-test symbols-test
TS_ALL = $(TARGETS) $(TS_SH) @IF_DLOPEN_TEST@ dlopen-test$(EXEEXT)
EXTRA_SOURCES = sha1-huge-test.c
EXTRA_TARGETS = $(EXTRA_SOURCES:.c=$(EXEEXT))


# Includes all C source files, regardless of configuration
SOURCES = $(TS_SOURCES) $(EXTRA_SOURCES) testutils.c dlopen-test.c

DISTFILES = $(SOURCES) $(CXX_SOURCES) Makefile.in .test-rules.make \
	    test-rules.stamp \
	    $(TS_SH) setup-env teardown-env \
	    gold-bug.txt testutils.h sha3.awk

all: $(EXTRA_TARGETS)

%.$(OBJEXT): %.c
	$(COMPILE) -c $< && $(DEP_PROCESS)

%.$(OBJEXT): %.cxx
	$(COMPILE_CXX) -c $< && $(DEP_PROCESS)

# BSD (and Solaris) make doesn't allow extra dependencies together one
# single-suffix rules, which makes it impossible or almost impossible
# to use suffix rules to build the test executables. So we use an
# explicit rule for each and every executable.

LIB_HOGWEED = @IF_HOGWEED@ -lhogweed
TEST_OBJS = testutils.$(OBJEXT) ../nettle-internal.$(OBJEXT) \
	    $(LIB_HOGWEED) -lnettle $(LIBS)

../nettle-internal.$(OBJEXT):
	( cd .. && $(MAKE) nettle-internal.$(OBJEXT) )

# Special target, to omit linking with libnettle
dlopen-test$(EXEEXT): dlopen-test.$(OBJEXT) testutils.$(OBJEXT)
	$(LINK) dlopen-test.$(OBJEXT) -ldl -o dlopen-test$(EXEEXT)

.PHONY: test-rules
test-rules:
	(for f in $(TS_NETTLE) $(TS_HOGWEED) $(EXTRA_TARGETS) ; do \
	  echo $$f'$$(EXEEXT): '$$f'.$$(OBJEXT)' ; \
	  echo '	$$(LINK) '$$f'.$$(OBJEXT) $$(TEST_OBJS) -o '$$f'$$(EXEEXT)' ; \
	  echo ; \
	done ; \
	for f in $(TS_CXX) ; do \
	  echo $$f'$$(EXEEXT): '$$f'.$$(OBJEXT)' ; \
	  echo '	$$(LINK_CXX) '$$f'.$$(OBJEXT) $$(TEST_OBJS) -o '$$f'$$(EXEEXT)' ; \
	  echo ; \
	done) > $(srcdir)/.test-rules.make

$(srcdir)/.test-rules.make: $(srcdir)/test-rules.stamp

# Updates the stamp file *first*, so that this rule isn't triggered
# again and again by the recursive $(MAKE).
$(srcdir)/test-rules.stamp: Makefile.in
	echo stamp > $(srcdir)/test-rules.stamp
	$(MAKE) test-rules

include $(srcdir)/.test-rules.make

$(TARGETS) $(EXTRA_TARGETS): testutils.$(OBJEXT) ../nettle-internal.$(OBJEXT) \
	../libnettle.stamp @IF_HOGWEED@ ../libhogweed.stamp

# For use as, e.g.,
#
#   make check EMULATOR='$(VALGRIND)'
#   make check EMULATOR='$(VALGRIND) --log-fd=3' 3>valgrind.log

# --partial-loads-ok=yes is needed for memxor's handling of unaligned
# data.
VALGRIND = valgrind --error-exitcode=1 --leak-check=full --show-reachable=yes @IF_ASM@ --partial-loads-ok=yes

# The PATH update is for windows dlls, DYLD_LIBRARY_PATH is for OSX.
check: $(TS_ALL)
	LD_LIBRARY_PATH=../.lib PATH="../.lib:$$PATH" DYLD_LIBRARY_PATH=../.lib \
	  srcdir="$(srcdir)" \
	  EMULATOR="$(EMULATOR)" NM="$(NM)" EXEEXT="$(EXEEXT)" \
          $(top_srcdir)/run-tests $(TS_ALL)


Makefile: $(srcdir)/Makefile.in ../config.status
	cd .. && $(SHELL) ./config.status testsuite/$@

install uninstall:
	true

distdir: $(DISTFILES)
	cp $? $(distdir)

clean:
	-rm -f $(TARGETS) $(EXTRA_TARGETS) dlopen-test$(EXEEXT) \
		*.$(OBJEXT) *.$(OBJEXT).d test.in test1.out test2.out

distclean: clean
	-rm -f Makefile *.d

tags:
	etags -o $(srcdir)/TAGS --include $(top_srcdir) $(srcdir)/*.c $(srcdir)/*.h

# Includes dependency files for everything, including objects which
# the current configuration will not build.
DEP_FILES = $(SOURCES:.c=.$(OBJEXT).d) $(CXX_SOURCES:.cxx=.$(OBJEXT).d)
-include $(DEP_FILES)