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 
  16 include $(SRC)/cmd/Makefile.cmd
  17 include $(SRC)/test/Makefile.com
  18 include $(SRC)/cmd/Makefile.ctf
  19 
  20 ALGS = sha1 sha256 sha384 sha512
  21 CRYPTO = pkcs kcf
  22 
  23 PROGS_pkcs = $(ALGS:%=%_pkcs)
  24 PROGS_kcf = $(ALGS:%=%_kcf)
  25 PROGS = $(PROGS_pkcs) $(PROGS_kcf)
  26 
  27 ROOTOPTPKG = $(ROOT)/opt/crypto-tests
  28 TESTROOT = $(ROOTOPTPKG)/tests/digest
  29 TESTDIR_pkcs = $(TESTROOT)/pkcs
  30 TESTDIR_kcf = $(TESTROOT)/kcf
  31 
  32 COMMONDIR = ../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 
  39 OBJS_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 
  44 CSTD = $(CSTD_GNU99)
  45 
  46 CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
  47 CPPFLAGS += -I$(COMMONDIR) -I$(SRC)/common/crypto
  48 
  49 LINTFLAGS += -xerroff=E_NAME_USED_NOT_DEF2
  50 LINTFLAGS += -xerroff=E_NAME_DEF_NOT_USED2
  51 
  52 $(PROGS_pkcs) := LDLIBS += -lpkcs11 -lcryptoutil
  53 
  54 CMDS_pkcs = $(ALGS:%=$(TESTDIR_pkcs)/%)
  55 CMDS_kcf = $(ALGS:%=$(TESTDIR_kcf)/%)
  56 CMDS = $(CMDS_pkcs) $(CMDS_kcf)
  57 
  58 $(CMDS) := FILEMODE = 0555
  59 
  60 all: $(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 
  77 install: all $(CMDS)
  78 
  79 lint: $(CRYPTO:%=lint_%)
  80 lint_pkcs: $(ALGS:%=lint_pkcs_%)
  81 lint_kcf: $(ALGS_kcf:%=lint_kcf_%)
  82 
  83 lint_pkcs_%:
  84         $(LINT.c) main.c $(@:lint_pkcs_%=%.c) $(OBJS_COMMON:%.o=%.c) $(LDLIBS)
  85 
  86 lint_pcf_%:
  87         $(LINT.c) main.c $(@:lint_kcf_%=%.c) $(OBJS_COMMON:%.o=%.c) $(LDLIBS)
  88 
  89 clobber: clean
  90         -$(RM) $(PROGS)
  91 
  92 clean:
  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)