Makefile 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. #
  2. # OpenSSL/crypto/Makefile
  3. #
  4. DIR= fips
  5. TOP= ..
  6. CC= cc
  7. INCLUDE= -I. -I$(TOP) -I../include
  8. # INCLUDES targets sudbirs!
  9. INCLUDES= -I.. -I../.. -I../../include
  10. CFLAG= -g
  11. MAKEDEPPROG= makedepend
  12. MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
  13. MAKEFILE= Makefile
  14. RM= rm -f
  15. AR= ar r
  16. ARD= ar d
  17. TEST= fips_test_suite.c
  18. FIPS_TVDIR= testvectors
  19. FIPS_TVOK= $$HOME/fips/tv.ok
  20. FIPSCANLOC= $(FIPSLIBDIR)fipscanister.o
  21. RECURSIVE_MAKE= [ -n "$(FDIRS)" ] && for i in $(FDIRS) ; do \
  22. (cd $$i && echo "making $$target in $(DIR)/$$i..." && \
  23. $(MAKE) -e TOP=../.. DIR=$$i INCLUDES='${INCLUDES}' $$target ) || exit 1; \
  24. done;
  25. PEX_LIBS=
  26. EX_LIBS=
  27. CFLAGS= $(INCLUDE) $(CFLAG) -DHMAC_EXT=\"$${HMAC_EXT:-sha1}\"
  28. ASFLAGS= $(INCLUDE) $(ASFLAG)
  29. AFLAGS=$(ASFLAGS)
  30. LIBS=
  31. FDIRS=sha rand des aes dsa rsa dh hmac
  32. GENERAL=Makefile README fips-lib.com install.com
  33. LIB= $(TOP)/libcrypto.a
  34. SHARED_LIB= $(FIPSCANLIB)$(SHLIB_EXT)
  35. LIBSRC=fips.c
  36. LIBOBJ=fips.o
  37. FIPS_OBJ_LISTS=sha/lib hmac/lib rand/lib des/lib aes/lib dsa/lib rsa/lib dh/lib
  38. SRC= $(LIBSRC)
  39. EXHEADER=fips.h
  40. HEADER=$(EXHEADER) fips_utl.h fips_locl.h
  41. EXE=fipsld
  42. ALL= $(GENERAL) $(SRC) $(HEADER)
  43. top:
  44. @(cd ..; $(MAKE) DIRS=$(DIR) all)
  45. testapps:
  46. @if [ -z "$(THIS)" ]; then $(MAKE) -f $(TOP)/Makefile reflect THIS=$@; fi
  47. all:
  48. @if [ -z "$(FIPSLIBDIR)" ]; then \
  49. $(MAKE) -e subdirs lib fips_premain_dso$(EXE_EXT); \
  50. else \
  51. $(MAKE) -e lib fips_premain_dso$(EXE_EXT) fips_standalone_sha1$(EXE_EXT); \
  52. fi
  53. # Idea behind fipscanister.o is to "seize" the sequestered code between
  54. # known symbols for fingerprinting purposes, which would be commonly
  55. # done with ld -r start.o ... end.o. The latter however presents a minor
  56. # challenge on multi-ABI platforms. As just implied, we'd rather use ld,
  57. # but the trouble is that we don't generally know how ABI-selection
  58. # compiler flag is translated to corresponding linker flag. All compiler
  59. # drivers seem to recognize -r flag and pass it down to linker, but some
  60. # of them, including gcc, erroneously add -lc, as well as run-time
  61. # components, such as crt1.o and alike. Fortunately among those vendor
  62. # compilers which were observed to misinterpret -r flag multi-ABI ones
  63. # are equipped with smart linkers, which don't require any ABI-selection
  64. # flag and simply assume that all objects are of the same type as first
  65. # one in command line. So the idea is to identify gcc and deficient
  66. # vendor compiler drivers...
  67. fipscanister.o: fips_start.o $(LIBOBJ) $(FIPS_OBJ_LISTS) fips_end.o
  68. FIPS_ASM=""; \
  69. list="$(BN_ASM)"; for i in $$list; do FIPS_ASM="$$FIPS_ASM ../crypto/bn/$$i" ; done; \
  70. list="$(AES_ASM_OBJ)"; for i in $$list; do FIPS_ASM="$$FIPS_ASM ../crypto/aes/$$i" ; done; \
  71. list="$(DES_ENC)"; for i in $$list; do FIPS_ASM="$$FIPS_ASM ../crypto/des/$$i" ; done; \
  72. list="$(SHA1_ASM_OBJ)"; for i in $$list; do FIPS_ASM="$$FIPS_ASM ../crypto/sha/$$i" ; done; \
  73. if [ -n "$(CPUID_OBJ)" ]; then \
  74. CPUID=../crypto/$(CPUID_OBJ) ; \
  75. else \
  76. CPUID="" ; \
  77. fi ; \
  78. objs="fips_start.o $(LIBOBJ) $(FIPS_EX_OBJ) $$CPUID $$FIPS_ASM"; \
  79. for i in $(FIPS_OBJ_LISTS); do \
  80. dir=`dirname $$i`; script="s|^|$$dir/|;s| | $$dir/|g"; \
  81. objs="$$objs `sed "$$script" $$i`"; \
  82. done; \
  83. objs="$$objs fips_end.o" ; \
  84. os="`(uname -s) 2>/dev/null`"; cflags="$(CFLAGS)"; \
  85. [ "$$os" = "AIX" ] && cflags="$$cflags -Wl,-bnoobjreorder"; \
  86. if [ -n "${FIPS_SITE_LD}" ]; then \
  87. set -x; ${FIPS_SITE_LD} -r -o $@ $$objs; \
  88. elif $(CC) -dumpversion >/dev/null 2>&1; then \
  89. set -x; $(CC) $$cflags -r -nostdlib -o $@ $$objs ; \
  90. else case "$$os" in \
  91. HP-UX|OSF1|SunOS) set -x; /usr/ccs/bin/ld -r -o $@ $$objs ;; \
  92. *) set -x; $(CC) $$cflags -r -o $@ $$objs ;; \
  93. esac fi
  94. ./fips_standalone_sha1 fipscanister.o > fipscanister.o.sha1
  95. # If another exception is immediately required, assign approprite
  96. # site-specific ld command to FIPS_SITE_LD environment variable.
  97. fips_start.o: fips_canister.c
  98. $(CC) $(CFLAGS) -DFIPS_START -c -o $@ fips_canister.c
  99. fips_end.o: fips_canister.c
  100. $(CC) $(CFLAGS) -DFIPS_END -c -o $@ fips_canister.c
  101. fips_premain_dso$(EXE_EXT): fips_premain.c
  102. $(CC) $(CFLAGS) -DFINGERPRINT_PREMAIN_DSO_LOAD -o $@ fips_premain.c \
  103. $(FIPSLIBDIR)fipscanister.o ../libcrypto.a $(EX_LIBS)
  104. # this is executed only when linking with external fipscanister.o
  105. fips_standalone_sha1$(EXE_EXT): sha/fips_standalone_sha1.c
  106. $(CC) $(CFLAGS) -DFIPSCANISTER_O -o $@ sha/fips_standalone_sha1.c $(FIPSLIBDIR)fipscanister.o
  107. subdirs:
  108. @target=all; $(RECURSIVE_MAKE)
  109. files:
  110. $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
  111. @target=files; $(RECURSIVE_MAKE)
  112. links:
  113. @$(PERL) $(TOP)/util/mklink.pl ../include/openssl $(EXHEADER)
  114. @$(PERL) $(TOP)/util/mklink.pl ../test $(TEST)
  115. @target=links; $(RECURSIVE_MAKE)
  116. # lib: and $(LIB): are splitted to avoid end-less loop
  117. lib: $(LIB)
  118. @touch lib
  119. $(LIB): $(FIPSLIBDIR)fipscanister.o
  120. $(AR) $(LIB) $(FIPSLIBDIR)fipscanister.o
  121. $(RANLIB) $(LIB) || echo Never mind.
  122. $(FIPSCANLIB): $(FIPSCANLOC)
  123. $(AR) ../$(FIPSCANLIB).a $(FIPSCANLOC)
  124. if [ "$(FIPSCANLIB)" = "libfips" ]; then \
  125. $(AR) $(LIB) $(FIPSCANLOC) ; \
  126. $(RANLIB) $(LIB) || echo Never Mind. ; \
  127. fi
  128. $(RANLIB) ../$(FIPSCANLIB).a || echo Never mind.
  129. @touch lib
  130. shared: lib subdirs fips_premain_dso$(EXE_EXT)
  131. libs:
  132. @target=lib; $(RECURSIVE_MAKE)
  133. fips_test: top
  134. @target=fips_test; $(RECURSIVE_MAKE)
  135. fips_test_diff:
  136. @if diff -b -B -I '^\#' -cr -X fips-nodiff.txt $(FIPS_TVDIR) $(FIPS_TVOK) ; then \
  137. echo "FIPS diff OK" ; \
  138. else \
  139. echo "***FIPS DIFF ERROR***" ; exit 1 ; \
  140. fi
  141. install:
  142. @[ -n "$(INSTALLTOP)" ] # should be set by top Makefile...
  143. @headerlist="$(EXHEADER)"; for i in $$headerlist ;\
  144. do \
  145. (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
  146. chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
  147. done;
  148. @target=install; $(RECURSIVE_MAKE)
  149. @cp -p -f fipscanister.o fipscanister.o.sha1 fips_premain.c \
  150. fips_premain.c.sha1 \
  151. $(INSTALL_PREFIX)$(INSTALLTOP)/lib/; \
  152. chmod 0444 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/fips*
  153. lint:
  154. @target=lint; $(RECURSIVE_MAKE)
  155. depend:
  156. @[ -z "$(THIS)" ] || $(MAKEDEPEND) -- $(CFLAG) $(INCLUDE) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
  157. @[ -z "$(THIS)" ] || (set -e; target=depend; $(RECURSIVE_MAKE) )
  158. @if [ -z "$(THIS)" ]; then $(MAKE) -f $(TOP)/Makefile reflect THIS=$@; fi
  159. clean:
  160. rm -f fipscanister.o.sha1 fips_premain_dso$(EXE_EXT) fips_standalone_sha1$(EXE_EXT) \
  161. *.s *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
  162. @target=clean; $(RECURSIVE_MAKE)
  163. dclean:
  164. $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
  165. mv -f Makefile.new $(MAKEFILE)
  166. @target=dclean; $(RECURSIVE_MAKE)
  167. # DO NOT DELETE THIS LINE -- make depend depends on it.
  168. fips.o: ../include/openssl/asn1.h ../include/openssl/bio.h
  169. fips.o: ../include/openssl/crypto.h ../include/openssl/des.h
  170. fips.o: ../include/openssl/des_old.h ../include/openssl/e_os2.h
  171. fips.o: ../include/openssl/err.h ../include/openssl/evp.h
  172. fips.o: ../include/openssl/fips.h ../include/openssl/fips_rand.h
  173. fips.o: ../include/openssl/hmac.h ../include/openssl/lhash.h
  174. fips.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
  175. fips.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
  176. fips.o: ../include/openssl/ossl_typ.h ../include/openssl/rand.h
  177. fips.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
  178. fips.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
  179. fips.o: ../include/openssl/ui.h ../include/openssl/ui_compat.h fips.c
  180. fips.o: fips_locl.h