1HC_VERS = 1.22
2CHANGEME1 = 1 # put PACKAGER = EBUILD|RPM etc here
3CHANGEME2 = 2
4CHANGEME3 = 3
5INSTALL_PATH = ${STAGEDIR}${PREFIX}/bin
6MAN_INSTALL_PATH = ${STAGEDIR}${PREFIX}/man/man1
7DOC_INSTALL_PATH = ${STAGEDIR}${PREFIX}/share/doc/hashcash
8MAKEDEPEND = makedepend
9MSLIB = mslib
10# here you can choose the regexp style your system has
11# default is POSIX
12# 	REGEXP = -DREGEXP_POSIX
13# if no POSIX regexp support, try BSD
14# 	REGEXP = -DREGEXP_BSD
15# if no POSIX or BSD, disable, still have builtin basic wildcard support
16# 	REGEXP =
17REGEXP=-DREGEXP_POSIX
18COPT_DEBUG = -g -DDEBUG
19#COPT_GENERIC = -O3
20COPT_GNU = -O3 -funroll-loops
21COPT_X86 = -O3 -funroll-loops -march=pentium-mmx -mmmx \
22	-D_REENTRANT -D_THREAD_SAFE -fPIC
23COPT_MINGW = -O3 -funroll-loops -march=pentium-mmx -mmmx \
24        -D_REENTRANT -D_THREAD_SAFE
25COPT_G3_OSX = -O3 -funroll-loops -fno-inline -mcpu=750 -faltivec
26COPT_PPC_LINUX = -O3 -funroll-loops -fno-inline -mcpu=604e -maltivec \
27	-mabi=altivec
28LIB=.a
29# request static link of -lcrypto only
30LIBCRYPTO=/usr/lib/libcrypto.a
31EXES = hashcash$(EXE) sha1$(EXE) sha1test$(EXE)
32INSTALL = install
33POD2MAN = pod2man
34POD2HTML = pod2html
35POD2TEXT = pod2text
36DELETE = rm -f
37ETAGS = etags
38FASTLIBS = libfastmint.o fastmint_mmx_standard_1.o fastmint_mmx_compact_1.o \
39	fastmint_ansi_compact_1.o fastmint_ansi_standard_1.o \
40	fastmint_ansi_compact_2.o fastmint_ansi_standard_2.o \
41	fastmint_altivec_standard_1.o fastmint_altivec_standard_2.o \
42	fastmint_altivec_compact_2.o fastmint_ansi_ultracompact_1.o \
43	fastmint_library.o
44OBJS = libsha1.o libhc.o sdb.o lock.o utct.o random.o sstring.o \
45	getopt.o $(FASTLIBS)
46LIBOBJS = libhc.o libsha1.o utct.o sdb.o lock.o sstring.o random.o $(FASTLIBS)
47EXEOBJS = hashcash.o
48
49DIST = ../dist.csh
50
51default:	help generic
52
53help:
54	@echo "make <platform> where platform is:"
55	@echo "    x86, mingw, mingw-dll, g3-osx, ppc-linux, gnu, generic, debug"
56	@echo "or to link with openSSL for SHA1 rather than builtin:"
57	@echo "    x86-openssl, g3-osx-openssl, ppc-linux-openssl, "
58	@echo "    gnu-openssl, generic-openssl, debug-openssl"
59	@echo "other make targets are docs, install, clean, distclean, docclean"
60	@echo ""
61	@echo "(doing make generic by default)"
62	@echo ""
63
64generic:
65	$(MAKE) "CFLAGS=$(CFLAGS) $(REGEXP) $(COPT_GENERIC) $(COPT)" build
66
67debug:
68	$(MAKE) "CFLAGS=$(CFLAGS) $(REGEXP) $(COPT_DEBUG) $(COPT)" build
69
70gnu:
71	$(MAKE) "CFLAGS=$(CFLAGS) $(REGEXP) $(COPT_GNU) $(COPT)" "CC=gcc" build
72
73x86:
74	$(MAKE) "CFLAGS=$(CFLAGS) $(REGEXP) $(COPT_X86) $(COPT)" build
75
76g3-osx:
77	$(MAKE) "CFLAGS=$(CFLAGS) $(REGEXP) $(COPT_G3_OSX) $(COPT)" build
78
79ppc-linux:
80	$(MAKE) "CFLAGS=$(CFLAGS) $(REGEXP) $(COPT_PPC_LINUX) $(COPT)" build
81
82# mingw windows targets (cross compiler, or native)
83
84mingw:
85	$(MAKE) "LIB=.lib" "CC=gcc" "EXE=.exe" "CFLAGS=$(COPT_MINGW) -DMONOLITHIC $(COPT)" build
86
87mingw-dll:
88	$(MAKE) "CC=gcc" "EXE=.exe" "CFLAGS=$(COPT_MINGW) $(COPT)" build-dll
89
90
91# openSSL versions of targets
92
93x86-openssl:
94	$(MAKE) x86 "CFLAGS=$(CFLAGS) -DOPENSSL" "LDFLAGS=$(LDFLAGS) $(LIBCRYPTO)"
95
96g3-osx-openssl:
97	$(MAKE) g3-osx "CFLAGS=$(CFLAGS) -DOPENSSL" "LDFLAGS=$(LDFLAGS) $(LIBCRYPTO)"
98
99ppc-linux-openssl:
100	$(MAKE) ppc-linux "CFLAGS=$(CFLAGS) -DOPENSSL" "LDFLAGS=$(LDFLAGS) $(LIBCRYPTO)"
101
102gnu-openssl:
103	$(MAKE) gnu "CFLAGS=$(CFLAGS) -DOPENSSL" "LDFLAGS=$(LDFLAGS) $(LIBCRYPTO)"
104
105generic-openssl:
106	$(MAKE) generic "CFLAGS=$(CFLAGS) -DOPENSSL" "LDFLAGS=$(LDFLAGS) $(LIBCRYPTO)"
107
108debug-openssl:
109	$(MAKE) debug "CFLAGS=$(CFLAGS) -DOPENSSL" "LDFLAGS=$(LDFLAGS) $(LIBCRYPTO)"
110
111
112build:	hashcash$(EXE) sha1$(EXE)
113
114build-dll:      hashcash-dll$(EXE) sha1$(EXE)
115
116hashcash$(EXE):	hashcash.o getopt.o libhashcash$(LIB)
117	$(CC) hashcash.o getopt.o libhashcash$(LIB) -o $@ $(LDFLAGS)
118
119sha1$(EXE):	sha1.o libsha1.o
120	$(CC) sha1.o libsha1.o -o $@ $(LDFLAGS)
121
122example$(EXE):	example.o getopt.o libhashcash$(LIB)
123	$(CC) example.o getopt.o libhashcash$(LIB) $(LIBCRYPTO) -o $@ $(LDFLAGS)
124
125hashcash-dll$(EXE):   $(EXEOBJS) hashcash.dll
126	$(CC) $(EXEOBJS) hashcash.dll -o $@ $(LDFLAGS)
127
128sha1test$(EXE):	sha1test.o libsha1.o
129	$(CC) sha1test.o libsha1.o -o $@ $(LDFLAGS)
130
131all:	$(EXES)
132
133libhashcash$(LIB):	$(LIBOBJS)
134	$(DELETE) $@
135	$(AR) rcs $@ $(LIBOBJS)
136
137hashcash.dll:   $(LIBOBJS)
138	$(CC) -shared -o hashcash.dll $(LIBOBJS) \
139	-Wl,--output-def,hashcash.def,--out-implib,libhashcash.a
140	$(MSLIB) /machine:x86 /def:hashcash.def
141
142docs:	hashcash.1 hashcash.html hashcash.txt sha1-hashcash.1 \
143	sha1-hashcash.html sha1-hashcash.txt
144
145hashcash.1:	hashcash.pod
146	$(POD2MAN) -s 1 -c hashcash -r $(HC_VERS) $? > $@
147
148hashcash.html:	hashcash.pod
149	$(POD2HTML) --title hashcash $? > $@
150	$(DELETE) pod2htm*
151
152hashcash.txt: hashcash.pod
153	$(POD2TEXT) $? > $@
154
155sha1-hashcash.1:	sha1-hashcash.pod
156	$(POD2MAN) -s 1 -c sha1 -r $(HC_VERS) $? > $@
157
158sha1-hashcash.html:	sha1-hashcash.pod
159	$(POD2HTML) --title sha1 $? > $@
160	$(DELETE) pod2htm*
161
162sha1-hashcash.txt: sha1-hashcash.pod
163	$(POD2TEXT) $? > $@
164
165install:	hashcash sha1 hashcash.1 sha1-hashcash.1
166	$(INSTALL) -d $(INSTALL_PATH)
167	$(INSTALL) hashcash sha1 $(INSTALL_PATH)
168	$(INSTALL) -d $(MAN_INSTALL_PATH)
169	$(INSTALL) -m 644 hashcash.1 sha1-hashcash.1 $(MAN_INSTALL_PATH)
170	$(INSTALL) -d $(DOC_INSTALL_PATH)
171	$(INSTALL) -m 644 README LICENSE CHANGELOG $(DOC_INSTALL_PATH)
172
173depend:
174	$(MAKEDEPEND) -- -Y *.c *.h
175
176docclean:
177	$(DELETE) hashcash.txt hashcash.1 hashcash.html pod2htm*
178	$(DELETE) sha1-hashcash.txt sha1-hashcash.1 sha1-hashcash.html
179
180clean:
181	$(DELETE) *.o *~
182
183distclean:
184	$(DELETE) *.o *~ $(EXES) hashcash-dll.* *.db *.bak TAGS core*
185	$(DELETE) *.bak test/* *.dll *.lib *.exe *.a *.sdb
186
187tags:
188	$(ETAGS) *.c *.h
189
190dist:
191	$(DIST)
192
193# DO NOT DELETE
194
195example.o: sstring.h sdb.h hashcash.h getopt.h
196fastmint_altivec_compact_2.o: libfastmint.h hashcash.h
197fastmint_altivec_standard_1.o: libfastmint.h hashcash.h
198fastmint_altivec_standard_2.o: libfastmint.h hashcash.h
199fastmint_ansi_compact_1.o: libfastmint.h hashcash.h
200fastmint_ansi_compact_2.o: libfastmint.h hashcash.h
201fastmint_ansi_standard_1.o: libfastmint.h hashcash.h
202fastmint_ansi_standard_2.o: libfastmint.h hashcash.h
203fastmint_ansi_ultracompact_1.o: libfastmint.h hashcash.h
204fastmint_library.o: sha1.h types.h libfastmint.h hashcash.h
205fastmint_mmx_compact_1.o: libfastmint.h hashcash.h
206fastmint_mmx_standard_1.o: libfastmint.h hashcash.h
207getopt.o: getopt.h
208hashcash.o: sdb.h utct.h random.h hashcash.h libfastmint.h sstring.h getopt.h
209hashcash.o: sha1.h types.h
210libfastmint.o: random.h sha1.h types.h libfastmint.h hashcash.h
211libhc.o: hashcash.h utct.h libfastmint.h sha1.h types.h random.h sstring.h
212libsha1.o: sha1.h types.h
213lock.o: lock.h
214random.o: random.h sha1.h types.h
215sdb.o: types.h lock.h sdb.h utct.h
216sha1.o: sha1.h types.h
217sha1test.o: sha1.h types.h
218sstring.o: sstring.h
219utct.o: sstring.h utct.h
220libfastmint.o: hashcash.h
221sha1.o: types.h
222