Makefile.in 4.17 KB
Newer Older
Niels Möller's avatar
Niels Möller committed
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
# $Id$
#
# Makefile for low-level crypto library

CC=@CC@
CPP=@CPP@
RANLIB=@RANLIB@
AR=ar

# Reset VPATH
SRCDIR=@srcdir@
VPATH=$(SRCDIR):$(SRCDIR)/../include

CRYPTO_INCLUDES=$(SRCDIR)/../include

# Additional C preprocessor flags
PREFLAGS=$(EXTRA_CPP_FLAGS) -I$(CRYPTO_INCLUDES) -I. -I$(SRCDIR) $(DEFINES)

# The flags to generate a shared library
CFLAGS=$(PREFLAGS) $(OTHERFLAGS) $(EXTRA_CFLAGS)
LDFLAGS=@LDFLAGS@

default: algorithms.a

### Magic Makefile for descore

# Interesting defines are sparc, mc68000, vax and i386
# Rely on gcc defining them appropriately.
# CPPFLAGS=	-Dsparc		# use 6+8 general regs
# CPPFLAGS=	-Dmc68000	# use 3+4 addr (1+4 live), and 3+3 data regs
# CPPFLAGS=	-Dvax		# use 6+0 general regs
# CPPFLAGS=	-Di386		# use 3+0 regs, and 3+0 normal variables

CODEGEN.c=	$(CC) $(CFLAGS) $(CPPFLAGS) -S
COMPILE.c=	$(CC) $(CFLAGS) $(CPPFLAGS) -c
LINK.c=		$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)

# hand-entered files that go into the library
SC=		desKerb.c desUtil.c desQuick.c
SO=		desKerb.o desUtil.o desQuick.o

# special generated files
GH=		parity.h rotors.h keymap.h
GC=		desSmallFips.c desSmallCore.c desQuickFips.c desQuickCore.c
GI=		desSmallFips.i desSmallCore.i desQuickFips.i desQuickCore.i
GO=		desSmallFips.o desSmallCore.o desQuickFips.o desQuickCore.o

O=		$(SO) $(GO)

# prefer compilation from .i if .i exists
#.SUFFIXES:
#.SUFFIXES:	.i .o .c $(SUFFIXES)

desTest:	desCore.a desTest.o
		$(LINK.c) -o $@ desTest.o desCore.a
		./desTest

# test all performance enhancement flags
sure:
		make clean ; make desTest 'CPPFLAGS=-Di386    -Umc68000 -Usparc'
		make clean ; make desTest 'CPPFLAGS=-Dvax     -Umc68000 -Usparc'
		make clean ; make desTest 'CPPFLAGS=-Dmc68000 -Usparc'
		make clean ; make desTest 'CPPFLAGS=-Dsparc   -Umc68000'
		make clean ; make desTest

clean:
	-rm -f *.o *.i *.x *.a ./desTest
	-rm -f $(GC) $(GH) desdata

depend:

desCore.a:	$O
		$(AR) cru $@ $O
		$(RANLIB) $@

desdata.o:	desinfo.h $(SRCDIR)/../include/des.h
desUtil.o:	$(GH)
$(SO):		$(SRCDIR)/../include/des.h
$(GI):		desCode.h $(SRCDIR)/../include/des.h Makefile
desTest.o:	$(SRCDIR)/../include/des.h

$(GH):		desdata
		./desdata $@ > $@

desdata:	desdata.o
		$(LINK.c) -o $@ desdata.o

# new rules  (note: tr|sed|tr is NOT necessary,  just there so .i is readable)
.c.i:
	$(CPP) $(CFLAGS) $(CPPFLAGS) $< > $*.x
	@tr ';'\\012 \\012';' < $*.x |			\
	 sed	-e 's/[ 	][ 	]*/ /g'		\
		-e 's/^ //'				\
		-e 's/ $$//'				\
		-e '/^$$/d'				\
		-e '/^[^;]/s/^/;/'			\
		-e 's/#[^;]*;//g'			\
		-e 's/\([){]\) *\(register\)/\1;\2/g'	\
		-e 's/\([[(]\) /\1/g'			\
		-e 's/ \([])]\)/\1/g'			\
		-e 's/\([^]+0123 ]\) =/\1  =/g'		\
		-e 's/}/};;/g'				\
		-e 's/ *; */;/g'			\
		-e 's/;;;*/;;/g'			\
		-e '1s/^;*//' |				\
	 tr ';'\\012 \\012';' > $@
	@echo ""  >> $@
#	@echo "}" >> $@			# last definition must be a procedure

#		-e 's/\(;[kmxyz][0-9]*\)\([^;]*=\)/\1  \2/g'

.i.o:
		$(CODEGEN.c) $<
		$(COMPILE.c) $*.s

# slowest to quickest
desSmallFips.c:
		@echo '#include "desCode.h"' > $@
		@echo \
'ENCRYPT(DesSmallFipsEncrypt,TEMPSMALL,LOADFIPS,KEYMAPSMALL,SAVEFIPS)' >> $@
		@echo \
'DECRYPT(DesSmallFipsDecrypt,TEMPSMALL,LOADFIPS,KEYMAPSMALL,SAVEFIPS)' >> $@
desSmallCore.c:
		@echo '#include "desCode.h"' > $@
		@echo \
'ENCRYPT(DesSmallCoreEncrypt,TEMPSMALL,LOADCORE,KEYMAPSMALL,SAVECORE)' >> $@
		@echo \
'DECRYPT(DesSmallCoreDecrypt,TEMPSMALL,LOADCORE,KEYMAPSMALL,SAVECORE)' >> $@
desQuickFips.c:
		@echo '#include "desCode.h"' > $@
		@echo \
'ENCRYPT(DesQuickFipsEncrypt,TEMPQUICK,LOADFIPS,KEYMAPQUICK,SAVEFIPS)' >> $@
		@echo \
'DECRYPT(DesQuickFipsDecrypt,TEMPQUICK,LOADFIPS,KEYMAPQUICK,SAVEFIPS)' >> $@
desQuickCore.c:
		@echo '#include "desCode.h"' > $@
		@echo \
'ENCRYPT(DesQuickCoreEncrypt,TEMPQUICK,LOADCORE,KEYMAPQUICK,SAVECORE)' >> $@
		@echo \
'DECRYPT(DesQuickCoreDecrypt,TEMPQUICK,LOADCORE,KEYMAPQUICK,SAVECORE)' >> $@

### End of rules for desCore

# BEGIN NATIONAL SECURITY
MASS_DESTRUCTION_OBJS = idea.o rc4.o cast.o $(O)
# END NATIONAL SECURITY

OBJS = $(MASS_DESTRUCTION_OBJS) sha.o md5.o

algorithms.a: $(OBJS)
	rm -f algorithms.a
	$(AR) cru algorithms.a $(OBJS)
	$(RANLIB) algorithms.a

Makefile: $(SRCDIR)/Makefile.in config.status
	CONFIG_FILES=Makefile CONFIG_HEADERS="" ./config.status
	@echo "Run make again"
	@exit 1