--- GNUmakefile-orig	2010-08-09 14:22:42.000000000 -0400
+++ GNUmakefile	2011-02-11 09:40:54.000000000 -0500
@@ -1,10 +1,13 @@
-CXXFLAGS = -DNDEBUG -g -O2
+SO = so
+LIBLDFLAGS =
+CXXFLAGS = -DNDEBUG -g -O2 ${ARCH}
 #CXXFLAGS = -g
 # -fPIC is supported. Please report any breakage of -fPIC as a bug.
-# CXXFLAGS += -fPIC
-# the following options reduce code size, but breaks link or makes link very slow on some systems
-# CXXFLAGS += -ffunction-sections -fdata-sections
-# LDFLAGS += -Wl,--gc-sections
+CXXFLAGS += -fPIC
+# the following options reduce code size, but breaks link or makes link
+# very slow on some systems
+CXXFLAGS += -ffunction-sections -fdata-sections
+#LDFLAGS += -Wl,--gc-sections
 ARFLAGS = -cr	# ar needs the dash on OpenBSD
 RANLIB = ranlib
 CP = cp
@@ -18,9 +21,7 @@
 PREFIX = /usr
 endif
 
-ifeq ($(CXX),gcc)	# for some reason CXX is gcc on cygwin 1.1.4
 CXX = g++
-endif
 
 ifeq ($(ISX86),1)
 
@@ -36,6 +37,8 @@
 ifneq ($(GCC42_OR_LATER),0)
 ifeq ($(UNAME),Darwin)
 CXXFLAGS += -arch x86_64 -arch i386
+LIBLDFLAGS += -dynamiclib
+SO = dylib
 else
 CXXFLAGS += -march=native
 endif
@@ -143,18 +146,21 @@
 	$(MKDIR) -p $(PREFIX)/include/cryptopp $(PREFIX)/lib $(PREFIX)/bin
 	$(CP) *.h $(PREFIX)/include/cryptopp
 	$(CP) *.a $(PREFIX)/lib
-	$(CP) *.so $(PREFIX)/lib
+	$(RANLIB) $(PREFIX)/lib/libcryptopp.a
+	$(CP) *.$(SO) $(PREFIX)/lib
 	$(CP) *.exe $(PREFIX)/bin
 
 libcryptopp.a: $(LIBOBJS)
 	$(AR) $(ARFLAGS) $@ $(LIBOBJS)
 	$(RANLIB) $@
 
-libcryptopp.so: $(LIBOBJS)
-	$(CXX) -shared -o $@ $(LIBOBJS)
+so:	libcryptopp.$(SO)
+
+libcryptopp.$(SO): $(LIBOBJS)
+	$(CXX) $(CXXFLAGS) -shared $(LIBLDFLAGS) -o $@ $(LIBOBJS)
 
 cryptest.exe: libcryptopp.a $(TESTOBJS)
-	$(CXX) -o $@ $(CXXFLAGS) $(TESTOBJS) -L. -lcryptopp $(LDFLAGS) $(LDLIBS)
+	$(CXX) -o $@ $(CXXFLAGS) $(TESTOBJS) $(LDFLAGS) -L$(CURDIR)/ -lcryptopp $(LDLIBS)
 
 nolib: $(OBJS)		# makes it faster to test changes
 	$(CXX) -o ct $(CXXFLAGS) $(OBJS) $(LDFLAGS) $(LDLIBS)
