~ubuntu-branches/debian/squeeze/pycryptopp/squeeze

« back to all changes in this revision

Viewing changes to cryptopp/GNUmakefile

  • Committer: Bazaar Package Importer
  • Author(s): Zooko O'Whielacronx
  • Date: 2009-06-22 22:20:50 UTC
  • Revision ID: james.westby@ubuntu.com-20090622222050-hbqmn50dt2kvoz5o
Tags: upstream-0.5.14
ImportĀ upstreamĀ versionĀ 0.5.14

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
CXXFLAGS = -DNDEBUG -g -O2
 
2
#CXXFLAGS = -g
 
3
# -fPIC is supported. Please report any breakage of -fPIC as a bug.
 
4
# CXXFLAGS += -fPIC
 
5
# the following options reduce code size, but breaks link or makes link very slow on some systems
 
6
# CXXFLAGS += -ffunction-sections -fdata-sections
 
7
# LDFLAGS += -Wl,--gc-sections
 
8
ARFLAGS = -cr   # ar needs the dash on OpenBSD
 
9
RANLIB = ranlib
 
10
CP = cp
 
11
MKDIR = mkdir
 
12
EGREP = egrep
 
13
UNAME = $(shell uname)
 
14
ISX86 = $(shell uname -m | $(EGREP) -c "i.86|x86|i86|amd64")
 
15
ISMINGW = $(shell uname | $(EGREP) -c "MINGW32")
 
16
 
 
17
# Default prefix for make install
 
18
ifeq ($(PREFIX),)
 
19
PREFIX = /usr
 
20
endif
 
21
 
 
22
ifeq ($(CXX),gcc)       # for some reason CXX is gcc on cygwin 1.1.4
 
23
CXX = g++
 
24
endif
 
25
 
 
26
ifeq ($(ISX86),1)
 
27
 
 
28
GCC42_OR_LATER = $(shell $(CXX) --version 2>&1 | $(EGREP) -c "\(GCC\) (4.[2-9]|[5-9])")
 
29
INTEL_COMPILER = $(shell $(CXX) --version 2>&1 | $(EGREP) -c "\(ICC\)")
 
30
GAS210_OR_LATER = $(shell echo "" | $(AS) -v 2>&1 | $(EGREP) -c "GNU assembler version (2\.[1-9][0-9]|[3-9])")
 
31
GAS217_OR_LATER = $(shell echo "" | $(AS) -v 2>&1 | $(EGREP) -c "GNU assembler version (2\.1[7-9]|2\.[2-9]|[3-9])")
 
32
 
 
33
ifneq ($(GCC42_OR_LATER),0)
 
34
ifneq ($(UNAME),Darwin)
 
35
CXXFLAGS += -march=native -mtune=native
 
36
endif
 
37
endif
 
38
 
 
39
ifneq ($(INTEL_COMPILER),0)
 
40
# "internal error: backend signals" occurs on some x86 inline assembly with ICC 9 and some x64 inline assembly with ICC 11
 
41
# if you want to use Crypto++'s assembly code with ICC, try enabling it on individual files
 
42
CXXFLAGS += -DCRYPTOPP_DISABLE_ASM
 
43
endif
 
44
 
 
45
ifeq ($(GAS210_OR_LATER),0)     # .intel_syntax wasn't supported until GNU assembler 2.10
 
46
CXXFLAGS += -DCRYPTOPP_DISABLE_ASM
 
47
else
 
48
ifeq ($(GAS217_OR_LATER),0)
 
49
CXXFLAGS += -DCRYPTOPP_DISABLE_SSSE3
 
50
endif
 
51
ifeq ($(UNAME),SunOS)
 
52
CXXFLAGS += -Wa,--divide        # allow use of "/" operator
 
53
endif
 
54
endif
 
55
 
 
56
endif   # ISX86
 
57
 
 
58
ifeq ($(ISMINGW),1)
 
59
LDLIBS += -lws2_32
 
60
endif
 
61
 
 
62
ifeq ($(UNAME),)        # for DJGPP, where uname doesn't exist
 
63
CXXFLAGS += -mbnu210
 
64
else
 
65
CXXFLAGS += -pipe
 
66
endif
 
67
 
 
68
ifeq ($(UNAME),Linux)
 
69
LDFLAGS += -pthread
 
70
endif
 
71
 
 
72
ifeq ($(UNAME),Darwin)
 
73
AR = libtool
 
74
ARFLAGS = -static -o
 
75
CXX = c++
 
76
IS_GCC2 = $(shell $(CXX) -v 2>&1 | $(EGREP) -c gcc-932)
 
77
ifeq ($(IS_GCC2),1)
 
78
CXXFLAGS += -fno-coalesce-templates -fno-coalesce-static-vtables
 
79
LDLIBS += -lstdc++
 
80
LDFLAGS += -flat_namespace -undefined suppress -m
 
81
endif
 
82
endif
 
83
 
 
84
ifeq ($(UNAME),SunOS)
 
85
LDLIBS += -lnsl -lsocket
 
86
ifeq ($(CXX),CC)        # override flags for CC (Solaris native C++ compiler)
 
87
CXXFLAGS = -DNDEBUG -O -g0 -native -template=no%extdef -m$(shell isainfo -b)
 
88
LDFLAGS =
 
89
ifeq ($(ISX86),1)
 
90
# SSE2 intrinsics should work in Sun Studio 12, but we're not using SSE2 intrinsics anymore
 
91
# CXXFLAGS += -xarch=sse2 -D__SSE2__
 
92
endif
 
93
endif
 
94
endif
 
95
 
 
96
SRCS = $(wildcard *.cpp)
 
97
ifeq ($(SRCS),)                         # workaround wildcard function bug in GNU Make 3.77
 
98
SRCS = $(shell echo *.cpp)
 
99
endif
 
100
 
 
101
OBJS = $(SRCS:.cpp=.o)
 
102
# test.o needs to be after bench.o for cygwin 1.1.4 (possible ld bug?)
 
103
TESTOBJS = bench.o bench2.o test.o validat1.o validat2.o validat3.o adhoc.o datatest.o regtest.o fipsalgt.o dlltest.o
 
104
LIBOBJS = $(filter-out $(TESTOBJS),$(OBJS))
 
105
 
 
106
DLLSRCS = algebra.cpp algparam.cpp asn.cpp basecode.cpp cbcmac.cpp channels.cpp cryptlib.cpp des.cpp dessp.cpp dh.cpp dll.cpp dsa.cpp ec2n.cpp eccrypto.cpp ecp.cpp eprecomp.cpp files.cpp filters.cpp fips140.cpp fipstest.cpp gf2n.cpp gfpcrypt.cpp hex.cpp hmac.cpp integer.cpp iterhash.cpp misc.cpp modes.cpp modexppc.cpp mqueue.cpp nbtheory.cpp oaep.cpp osrng.cpp pch.cpp pkcspad.cpp pubkey.cpp queue.cpp randpool.cpp rdtables.cpp rijndael.cpp rng.cpp rsa.cpp sha.cpp simple.cpp skipjack.cpp strciphr.cpp trdlocal.cpp
 
107
DLLOBJS = $(DLLSRCS:.cpp=.export.o)
 
108
LIBIMPORTOBJS = $(LIBOBJS:.o=.import.o)
 
109
TESTIMPORTOBJS = $(TESTOBJS:.o=.import.o)
 
110
DLLTESTOBJS = dlltest.dllonly.o
 
111
 
 
112
all: cryptest.exe
 
113
 
 
114
test: cryptest.exe
 
115
        ./cryptest.exe v
 
116
 
 
117
clean:
 
118
        $(RM) cryptest.exe libcryptopp.a $(LIBOBJS) $(TESTOBJS) cryptopp.dll libcryptopp.dll.a libcryptopp.import.a cryptest.import.exe dlltest.exe $(DLLOBJS) $(LIBIMPORTOBJS) $(TESTIMPORTOBJS) $(DLLTESTOBJS)
 
119
 
 
120
install:
 
121
        $(MKDIR) -p $(PREFIX)/include/cryptopp $(PREFIX)/lib $(PREFIX)/bin
 
122
        $(CP) *.h $(PREFIX)/include/cryptopp
 
123
        $(CP) *.a $(PREFIX)/lib
 
124
        $(CP) *.exe $(PREFIX)/bin
 
125
 
 
126
libcryptopp.a: $(LIBOBJS)
 
127
        $(AR) $(ARFLAGS) $@ $(LIBOBJS)
 
128
        $(RANLIB) $@
 
129
 
 
130
cryptest.exe: libcryptopp.a $(TESTOBJS)
 
131
        $(CXX) -o $@ $(CXXFLAGS) $(TESTOBJS) -L. -lcryptopp $(LDFLAGS) $(LDLIBS)
 
132
 
 
133
nolib: $(OBJS)          # makes it faster to test changes
 
134
        $(CXX) -o ct $(CXXFLAGS) $(OBJS) $(LDFLAGS) $(LDLIBS)
 
135
 
 
136
dll: cryptest.import.exe dlltest.exe
 
137
 
 
138
cryptopp.dll: $(DLLOBJS)
 
139
        $(CXX) -shared -o $@ $(CXXFLAGS) $(DLLOBJS) $(LDFLAGS) $(LDLIBS) -Wl,--out-implib=libcryptopp.dll.a
 
140
 
 
141
libcryptopp.import.a: $(LIBIMPORTOBJS)
 
142
        $(AR) $(ARFLAGS) $@ $(LIBIMPORTOBJS)
 
143
        $(RANLIB) $@
 
144
 
 
145
cryptest.import.exe: cryptopp.dll libcryptopp.import.a $(TESTIMPORTOBJS)
 
146
        $(CXX) -o $@ $(CXXFLAGS) $(TESTIMPORTOBJS) -L. -lcryptopp.dll -lcryptopp.import $(LDFLAGS) $(LDLIBS)
 
147
 
 
148
dlltest.exe: cryptopp.dll $(DLLTESTOBJS)
 
149
        $(CXX) -o $@ $(CXXFLAGS) $(DLLTESTOBJS) -L. -lcryptopp.dll $(LDFLAGS) $(LDLIBS)
 
150
 
 
151
adhoc.cpp: adhoc.cpp.proto
 
152
ifeq ($(wildcard adhoc.cpp),)
 
153
        cp adhoc.cpp.proto adhoc.cpp
 
154
else
 
155
        touch adhoc.cpp
 
156
endif
 
157
 
 
158
%.dllonly.o : %.cpp
 
159
        $(CXX) $(CXXFLAGS) -DCRYPTOPP_DLL_ONLY -c $< -o $@
 
160
 
 
161
%.import.o : %.cpp
 
162
        $(CXX) $(CXXFLAGS) -DCRYPTOPP_IMPORTS -c $< -o $@
 
163
 
 
164
%.export.o : %.cpp
 
165
        $(CXX) $(CXXFLAGS) -DCRYPTOPP_EXPORTS -c $< -o $@
 
166
 
 
167
%.o : %.cpp
 
168
        $(CXX) $(CXXFLAGS) -c $<