That's great. I would like to fold the changes into the current c50-fixes branch and make sure the fixed code will still compile on other platforms. Can anyone give me access to an account on a MacOS X machine with gcc 3.1 installed for testing purposes?
On Wed, Feb 19, 2003 at 04:42:27PM -0800, Jason Arnold wrote: > Wei and All, > As a followup to my previous post > (http://www.escribe.com/software/crypto/m2475.html), I believe that I > have successfully built and installed Crypto++ 5.0 on Mac OS X 10.2.3 > (Jaguar) using the Apple Developer Tools December 2002 gcc 3.1 compiler. > It passes the verification tests (cryptest.exe v) and the RSA key test > (cryptest.exe g) Besides the code tweak listed in my previous post, one > must do four things to get it to properly build and run: > > 1. Mac OS X uses mach-o files, not ELF files as it's executable format. > As per the man page for libtool(1), libtool replaces ar and ranlib on > OS X. So you need to edit the GNUmakefile entry for libcryptopp.a so > that instead of this: > > libcryptopp.a: $(LIBOBJS) > $(AR) $(ARFLAGS) $@ $(LIBOBJS) > $(RANLIB) $@ > > it reads: > > libcryptopp.a: $(LIBOBJS) > libtool -static -o $@ $(LIBOBJS) > $(RANLIB) $@ > > And in fact I think that the RANLIB line is unnecessary (but does not hurt). > > 2. The following CFLAGS worked for me: > > CXXFLAGS = -g -no-cpp-precomp -Wno-deprecated -fPIC > > Note that there is a line which states > > ifeq ($(UNAME),Darwin) # -fpic conflicts with inline asm in ... > CXX = g++ > CXXFLAGS += -fno-pic > > In this case the -fno-pic is a bad idea; at least for building on OS X > it seems to be necessary to have -fPIC. > > 3. It appears that my powerpc did not detect as big endian so it > defaulted to little endian. To fix this, edit config.h and just above > the line which says > > #ifndef IS_BIG_ENDIAN > > add a line saying #define IS_BIG_ENDIAN. > > 4. Finally, I found that the OS-supplied blocking random number > generator failed the verification test. Therefore, near the bottom of > config.h, comment out the line saying > > #define BLOCKING_RNG_AVAILABLE > > in the #if (defined(__FreeBSD__) ...) block. > > > And that should do it. Hope this helps... I have attached a diff with > these changes. > > -Jason > > > -- > /****************************************************************************** > > Jason Arnold / Sandia National Laboratories > jdarnol @ ca . sandia . gov / (925) 294-3693 > > ******************************************************************************/ > > diff -C 5 crypto50/GNUmakefile crypto50-osx/GNUmakefile > *** crypto50/GNUmakefile Fri Aug 30 18:17:12 2002 > --- crypto50-osx/GNUmakefile Wed Feb 19 13:50:06 2003 > *************** > *** 1,23 **** > # can't use -fno-rtti yet because it causes problems with exception handling in > GCC 2.95.2 > ! CXXFLAGS = -g > # uncomment the next two lines to do a release build > # CXXFLAGS = -O2 -DNDEBUG -ffunction-sections -fdata-sections > # LDFLAGS = -Wl,--gc-sections > ARFLAGS = -cr # ar needs the dash on OpenBSD > RANLIB = ranlib > UNAME = $(shell uname) > > ifeq ($(UNAME),) # for DJGPP, where uname doesn't exist > CXXFLAGS += -mbnu210 > else > CXXFLAGS += -pipe > endif > > ifeq ($(UNAME),Darwin) # -fpic conflicts with inline asm in integer.cpp on > i386 > ! CXX = c++ > ! CXXFLAGS += -fno-pic > endif > > ifeq ($(UNAME),SunOS) > LDLIBS = -lnsl -lsocket > endif > --- 1,26 ---- > # can't use -fno-rtti yet because it causes problems with exception handling in > GCC 2.95.2 > ! CXXFLAGS = -g -Wno-deprecated -no-cpp-precomp > # uncomment the next two lines to do a release build > # CXXFLAGS = -O2 -DNDEBUG -ffunction-sections -fdata-sections > # LDFLAGS = -Wl,--gc-sections > ARFLAGS = -cr # ar needs the dash on OpenBSD > RANLIB = ranlib > + LIBTOOL = libtool > + LTFLAGS = -static > + > UNAME = $(shell uname) > > ifeq ($(UNAME),) # for DJGPP, where uname doesn't exist > CXXFLAGS += -mbnu210 > else > CXXFLAGS += -pipe > endif > > ifeq ($(UNAME),Darwin) # -fpic conflicts with inline asm in integer.cpp on > i386 > ! CXX = g++ > ! CXXFLAGS += -fPIC > endif > > ifeq ($(UNAME),SunOS) > LDLIBS = -lnsl -lsocket > endif > *************** > *** 41,51 **** > > clean: > $(RM) cryptest.exe libcryptopp.a $(LIBOBJS) $(TESTOBJS) > > libcryptopp.a: $(LIBOBJS) > ! $(AR) $(ARFLAGS) $@ $(LIBOBJS) > $(RANLIB) $@ > > cryptest.exe: libcryptopp.a $(TESTOBJS) > $(CXX) -o $@ $(CXXFLAGS) $(TESTOBJS) -L. -lcryptopp $(LDFLAGS) $(LDLIBS) > > --- 44,54 ---- > > clean: > $(RM) cryptest.exe libcryptopp.a $(LIBOBJS) $(TESTOBJS) > > libcryptopp.a: $(LIBOBJS) > ! $(LIBTOOL) $(LTFLAGS) -o $@ $(LIBOBJS) > $(RANLIB) $@ > > cryptest.exe: libcryptopp.a $(TESTOBJS) > $(CXX) -o $@ $(CXXFLAGS) $(TESTOBJS) -L. -lcryptopp $(LDFLAGS) $(LDLIBS) > > diff -C 5 crypto50/config.h crypto50-osx/config.h > *** crypto50/config.h Fri Aug 30 18:59:32 2002 > --- crypto50-osx/config.h Wed Feb 19 13:52:44 2003 > *************** > *** 6,15 **** > --- 6,19 ---- > // define this if running on a big-endian CPU > #if !defined(IS_LITTLE_ENDIAN) && (defined(__sparc) || defined(__sparc__) || > defined(__hppa__) || defined(__PPC__) || defined(__mips__) || (defined(__MWERKS__) > && !defined(__INTEL__))) > # define IS_BIG_ENDIAN > #endif > > + #if defined(__MACH__) // Mac OS X > + # define IS_BIG_ENDIAN > + #endif > + > // define this if running on a little-endian CPU > // big endian will be assumed if IS_LITTLE_ENDIAN is not defined > #ifndef IS_BIG_ENDIAN > # define IS_LITTLE_ENDIAN > #endif > *************** > *** 225,235 **** > # define OS_RNG_AVAILABLE > #endif > > #if (defined(__FreeBSD__) || defined(__linux__) || defined(__MACH__)) > # define NONBLOCKING_RNG_AVAILABLE > ! # define BLOCKING_RNG_AVAILABLE > # define OS_RNG_AVAILABLE > #endif > > #ifdef __unix__ > # define HAS_PTHREADS > --- 229,239 ---- > # define OS_RNG_AVAILABLE > #endif > > #if (defined(__FreeBSD__) || defined(__linux__) || defined(__MACH__)) > # define NONBLOCKING_RNG_AVAILABLE > ! // define BLOCKING_RNG_AVAILABLE > # define OS_RNG_AVAILABLE > #endif > > #ifdef __unix__ > # define HAS_PTHREADS
