xref: /illumos-gate/usr/src/test/crypto-tests/tests/digest/Makefile (revision 3c30f56df862431210f98c7c8f13cf1362b9c574)
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 2018, Joyent, Inc.
14#
15
16include $(SRC)/cmd/Makefile.cmd
17include $(SRC)/test/Makefile.com
18include $(SRC)/cmd/Makefile.ctf
19
20ALGS = sha1 sha256 sha384 sha512
21CRYPTO = pkcs kcf
22
23PROGS_pkcs = $(ALGS:%=%_pkcs)
24PROGS_kcf = $(ALGS:%=%_kcf)
25PROGS = $(PROGS_pkcs) $(PROGS_kcf)
26
27ROOTOPTPKG = $(ROOT)/opt/crypto-tests
28TESTROOT = $(ROOTOPTPKG)/tests/digest
29TESTDIR_pkcs = $(TESTROOT)/pkcs
30TESTDIR_kcf = $(TESTROOT)/kcf
31
32COMMONDIR = ../common
33
34$(CRYPTO:%=sha1_%)	:= OBJS = sha1.o
35$(CRYPTO:%=sha256_%)	:= OBJS = sha256.o
36$(CRYPTO:%=sha384_%)	:= OBJS = sha384.o
37$(CRYPTO:%=sha512_%)	:= OBJS = sha512.o
38
39OBJS_COMMON	= $(COMMONDIR)/testfuncs.o
40$(PROGS_pkcs)	:= OBJS_COMMON += $(COMMONDIR)/cryptotest_pkcs.o
41$(PROGS_kcf)	:= OBJS_COMMON += $(COMMONDIR)/cryptotest_kcf.o
42$(PROGS)	:= OBJS += main.o
43
44CSTD = $(CSTD_GNU99)
45
46CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
47CPPFLAGS += -I$(COMMONDIR) -I$(SRC)/common/crypto
48
49LINTFLAGS += -xerroff=E_NAME_USED_NOT_DEF2
50LINTFLAGS += -xerroff=E_NAME_DEF_NOT_USED2
51
52$(PROGS_pkcs) := LDLIBS += -lpkcs11 -lcryptoutil
53
54CMDS_pkcs = $(ALGS:%=$(TESTDIR_pkcs)/%)
55CMDS_kcf = $(ALGS:%=$(TESTDIR_kcf)/%)
56CMDS = $(CMDS_pkcs) $(CMDS_kcf)
57
58$(CMDS) := FILEMODE = 0555
59
60all: $(PROGS)
61
62$(COMMONDIR)/%.o:
63$(PROGS): main.o
64
65%_pkcs: %.o
66	$(LINK.c) -o $@ $(OBJS) $(OBJS_COMMON) $(LDLIBS)
67	$(POST_PROCESS)
68
69%_kcf: %.o
70	$(LINK.c) -o $@ $(OBJS) $(OBJS_COMMON) $(LDLIBS)
71	$(POST_PROCESS)
72
73%.o: %.c
74	$(COMPILE.c) -o $@ $<
75	$(POST_PROCESS_O)
76
77install: all $(CMDS)
78
79lint: $(CRYPTO:%=lint_%)
80lint_pkcs: $(ALGS:%=lint_pkcs_%)
81lint_kcf: $(ALGS_kcf:%=lint_kcf_%)
82
83lint_pkcs_%:
84	$(LINT.c) main.c $(@:lint_pkcs_%=%.c) $(OBJS_COMMON:%.o=%.c) $(LDLIBS)
85
86lint_pcf_%:
87	$(LINT.c) main.c $(@:lint_kcf_%=%.c) $(OBJS_COMMON:%.o=%.c) $(LDLIBS)
88
89clobber: clean
90	-$(RM) $(PROGS)
91
92clean:
93	-$(RM) $(ALGS:%=%.o) main.o
94
95$(CMDS): $(TESTDIR_pkcs) $(TESTDIR_kcf) $(PROGS)
96
97$(TESTDIR_pkcs) $(TESTDIR_kcf):
98	$(INS.dir)
99	@echo Cmds: $(CMDS)
100
101$(TESTROOT)/pkcs/%: %_pkcs
102	$(INS.rename)
103
104$(TESTROOT)/kcf/%: %_kcf
105	$(INS.rename)
106