--- levmar-2.6.orig/Makefile.so	2009-12-04 13:26:31.000000000 -0800
+++ levmar-2.6/Makefile.so	2012-03-03 13:41:25.000000000 -0800
@@ -6,7 +6,8 @@
 # major & minor shared lib numbers
 MAJ=2
 MIN=2
-ODIR=sobj # where to place object files for shared lib
+# ODIR defines where to place object files for shared lib
+ODIR=sobj
 CC=gcc
 CONFIGFLAGS=-ULINSOLVERS_RETAIN_MEMORY
 #ARCHFLAGS=-march=pentium4 # YOU MIGHT WANT TO UNCOMMENT THIS FOR P4
@@ -14,14 +15,24 @@
 LAPACKLIBS_PATH=/usr/local/lib # WHEN USING LAPACK, CHANGE THIS TO WHERE YOUR COMPILED LIBS ARE!
 LIBOBJS=$(ODIR)/lm.o $(ODIR)/Axb.o $(ODIR)/misc.o $(ODIR)/lmlec.o $(ODIR)/lmbc.o $(ODIR)/lmblec.o $(ODIR)/lmbleic.o
 LIBSRCS=lm.c Axb.c misc.c lmlec.c lmbc.c lmblec.c lmbleic.c
-LAPACKLIBS=-llapack -lblas -lf2c # comment this line if you are not using LAPACK.
+DEMOBJS=lmdemo.o
+DEMOSRCS=lmdemo.c
+# -lf2c removed from LAPACKLIBS for Fedora
+# comment the following line if you are not using LAPACK.
+LAPACKLIBS=-llapack -lblas
                                  # On systems with a FORTRAN (not f2c'ed) version of LAPACK, -lf2c is
                                  # not necessary; on others, -lf2c is equivalent to -lF77 -lI77
 
 LIBS=$(LAPACKLIBS)
 
-$(ODIR)/liblevmar.so.$(MAJ).$(MIN): $(LIBOBJS)
-	$(CC) -shared -Wl,-soname,liblevmar.so.$(MAJ) -o $(ODIR)/liblevmar.so.$(MAJ).$(MIN) $(LIBOBJS) #-llapack -lblas -lf2c
+all: $(ODIR)/liblevmar.$(MAJ).$(MIN).dylib lmdemo
+
+$(ODIR)/liblevmar.$(MAJ).$(MIN).dylib: $(LIBOBJS)
+	$(CC) -shared -Wl,-install_name,@rpath/liblevmar.$(MAJ).dylib -o $(ODIR)/liblevmar.$(MAJ).$(MIN).dylib $(LIBOBJS) $(LIBS)
+
+$(ODIR)/liblevmar.dylib: $(ODIR)/liblevmar.$(MAJ).$(MIN).dylib
+	ln -s liblevmar.$(MAJ).$(MIN).dylib $(ODIR)/liblevmar.dylib
+	ln -s liblevmar.$(MAJ).$(MIN).dylib $(ODIR)/liblevmar.$(MAJ).dylib
 
 # implicit rule for generating *.o files in ODIR from *.c files
 $(ODIR)/%.o : %.c
@@ -36,14 +46,19 @@
 $(ODIR)/lmblec.o: lmblec.c lmblec_core.c levmar.h misc.h
 $(ODIR)/lmbleic.o: lmbleic.c lmbleic_core.c levmar.h misc.h
 
+lmdemo.o: levmar.h
+
+lmdemo: $(DEMOBJS) $(ODIR)/liblevmar.dylib
+	$(CC) $(LDFLAGS) $(DEMOBJS) -o lmdemo -L$(ODIR) -llevmar $(LIBS) -lm # -u MAIN__
+
 clean:
 	@rm -f $(LIBOBJS)
 
 cleanall: clean
-	@rm -f $(ODIR)/liblevmar.so.$(MAJ).$(MIN)
+	@rm -f $(ODIR)/liblevmar.$(MAJ).$(MIN).dylib
 
 depend:
-	makedepend -f Makefile $(LIBSRCS)
+	makedepend -f Makefile $(LIBSRCS) $(DEMOSRCS)
 
 # DO NOT DELETE THIS LINE -- make depend depends on it.