xref: /illumos-gate/usr/src/test/crypto-tests/tests/Makefile.crypto (revision 1769817e9676d2db341d2b6828c199f0eabac823)
1#
2# This file and its contents are supplied under the terms of the
3# Common Development and Distribution License ("CDDL"), version 1.0.
4# You may only use this file in accordance with the terms of version
5# 1.0 of the CDDL.
6#
7# A full copy of the text of the CDDL should have accompanied this
8# source.  A copy of the CDDL is also available via the Internet at
9# http://www.illumos.org/license/CDDL.
10#
11
12#
13# Copyright (c) 2012 by Delphix. All rights reserved.
14# Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
15# Copyright 2019 Joyent, Inc.
16# Copyright 2020 Oxide Computer Company
17#
18
19include $(SRC)/cmd/Makefile.cmd
20include $(SRC)/test/Makefile.com
21include $(SRC)/cmd/Makefile.ctf
22
23PROGS_32 = $(CRYPTO:%=$(BASEPROG)_32_%)
24PROGS_64 = $(CRYPTO:%=$(BASEPROG)_64_%)
25PROGS = $(PROGS_32) $(PROGS_64)
26
27COMMON_OBJS_32 = $(COMMON_OBJS:%.o=%.32.o)
28COMMON_OBJS_64 = $(COMMON_OBJS:%.o=%.64.o)
29
30# Some tests may only be relevant for PKCS#11 or KCF.  One can use
31# a statement like 'CRYPTO_kcf = $(POUND_SIGN)' in a test's Makefile to
32# disable creation of tests for a given framework.  For an example, see
33# modes/aes/cbc_pad/Makefile
34$(CRYPTO_pkcs)PROGS_pkcs = $(BASEPROG:%=%_32_pkcs) $(BASEPROG:%=%_64_pkcs)
35$(CRYPTO_kcf)PROGS_kcf = $(BASEPROG:%=%_32_kcf) $(BASEPROG:%=%_64_kcf)
36
37# $(TESTROOT) must be set by whatever includes this file
38$(CRYPTO_pkcs)TESTDIR_pkcs = $(TESTROOT)/pkcs
39$(CRYPTO_kcf)TESTDIR_kcf = $(TESTROOT)/kcf
40
41COMMONDIR = $(SRC)/test/crypto-tests/tests/common
42$(PROGS_32) := OBJS += $(BASEPROG:%=%.32.o) $(COMMON_OBJS_32)
43$(PROGS_64) := OBJS += $(BASEPROG:%=%.64.o) $(COMMON_OBJS_64)
44$(PROGS_32) := OBJS += $(COMMONDIR)/testfuncs.32.o
45$(PROGS_64) := OBJS += $(COMMONDIR)/testfuncs.64.o
46$(PROGS_64) := LDLIBS.cmd = $(LDLIBS64)
47$(CRYPTO_pkcs)$(BASEPROG)_32_pkcs := OBJS += $(COMMONDIR)/cryptotest_pkcs.32.o
48$(CRYPTO_pkcs)$(BASEPROG)_64_pkcs := OBJS += $(COMMONDIR)/cryptotest_pkcs.64.o
49$(CRYPTO_kcf)$(BASEPROG)_32_kcf	:= OBJS += $(COMMONDIR)/cryptotest_kcf.32.o
50$(CRYPTO_kcf)$(BASEPROG)_64_kcf	:= OBJS += $(COMMONDIR)/cryptotest_kcf.64.o
51
52$(CRYPTO_pkcs)$(PROGS_pkcs)	:= LDLIBS += -lpkcs11 -lcryptoutil
53
54CSTD = $(CSTD_GNU99)
55
56$(CRYPTO_pkcs)CMDS_pkcs = $(PROGS_pkcs:%_pkcs=$(TESTDIR_pkcs)/%)
57$(CRYPTO_kcf)CMDS_kcf = $(PROGS_kcf:%_kcf=$(TESTDIR_kcf)/%)
58CMDS = $(CMDS_pkcs) $(CMDS_kcf)
59
60$(CMDS) := FILEMODE = 0555
61
62CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
63CPPFLAGS += -I$(COMMONDIR) -I$(SRC)/common/crypto/
64
65all: $(PROGS)
66
67%_32_pkcs: %.32.o $(COMMON_OBJS_32)
68	$(LINK.c) $(OBJS) -o $@ $(LDLIBS)
69	$(POST_PROCESS)
70
71%_64_pkcs: %.64.o $(COMMON_OBJS_64)
72	$(LINK64.c) $(OBJS) -o $@ $(LDLIBS)
73	$(POST_PROCESS)
74
75%_32_kcf: %.32.o $(COMMON_OBJS_32)
76	$(LINK.c) $(OBJS) -o $@ $(LDLIBS)
77	$(POST_PROCESS)
78
79%_64_kcf: %.64.o $(COMMON_OBJS_64)
80	$(LINK64.c) $(OBJS) -o $@ $(LDLIBS)
81	$(POST_PROCESS)
82
83%.32.o: %.c
84	$(COMPILE.c) -o $@ $<
85	$(POST_PROCESS_O)
86
87%.64.o: %.c
88	$(COMPILE64.c) -o $@ $<
89	$(POST_PROCESS_O)
90
91install: all $(CMDS)
92
93clobber: clean
94	-$(RM) $(PROGS)
95
96clean:
97	-$(RM) *.o $(COMMON_OBJS_32) $(COMMON_OBJS_64) $(PROGS)
98
99$(CMDS): $(TESTDIR_pkcs) $(TESTDIR_kcf) $(PROGS)
100
101$(TESTDIR_pkcs) $(TESTDIR_kcf):
102	$(INS.dir)
103
104$(TESTDIR_pkcs)/%_32: %_32_pkcs
105	$(INS.rename)
106
107$(TESTDIR_pkcs)/%_64: %_64_pkcs
108	$(INS.rename)
109
110$(TESTDIR_kcf)/%_32: %_32_kcf
111	$(INS.rename)
112
113$(TESTDIR_kcf)/%_64: %_64_kcf
114	$(INS.rename)
115