Makefile.in 4.56 KB
Newer Older
Niels Möller's avatar
Niels Möller committed
1
2
3
4
5
6
7
8
9
10
11
# $Id$
#
# Makefile for low-level crypto library

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

# Reset VPATH
SRCDIR=@srcdir@
12
VPATH=$(SRCDIR):$(EXTRA_VPATH)
Niels Möller's avatar
Niels Möller committed
13
14

# The flags to generate a shared library
15
CPPFLAGS=$(PREFLAGS) $(DEFS) $(EXTRA_CPPFLAGS)
Niels Möller's avatar
Niels Möller committed
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
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:
55
56
		make clean ; make desTest 'CPPFLAGS=-Di386 -Umc68000 -Usparc'
		make clean ; make desTest 'CPPFLAGS=-Dvax -Umc68000 -Usparc'
Niels Möller's avatar
Niels Möller committed
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
		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

139
140
SRCS = sha.c md5.c idea.c rc4.c cast.c $(SC) $(GC)
OBJS = $(SRCS:.c=.o)
Niels Möller's avatar
Niels Möller committed
141
142
143
144
145
146

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

147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#### Remaking the Makefile and configure scripts. ####

#${srcdir}/configure: configure.in aclocal.m4
${srcdir}/configure: configure.in
	cd ${srcdir} && autoconf

# autoheader might not change config.h.in, so touch a stamp file.
${srcdir}/config.h.in: stamp-h.in

#${srcdir}/stamp-h.in: configure.in aclocal.m4 acconfig.h \
#    config.h.top config.h.bot

${srcdir}/stamp-h.in: configure.in 
	cd ${srcdir} && autoheader
	echo timestamp > ${srcdir}/stamp-h.in

config.h: stamp-h

stamp-h: config.h.in config.status
	./config.status

Makefile: Makefile.in config.status
	./config.status

config.status: configure
	./config.status --recheck
Niels Möller's avatar
Niels Möller committed
173

174
175
176
%.d: %.c
	$(SHELL) -ec '$(CC) -MM -MG $(CPPFLAGS) $(DEFS) $< \
		| sed '\''s/\($*\)\.o:/\1\.o $@ : /g'\'' > $@'
177
178

include $(SRCS:.c=.d)