--- RooFitCore.orig/GNUmakefile.standalone	2005-04-04 07:59:12.000000000 -0700
+++ RooFitCore.new/GNUmakefile.standalone	2005-06-08 17:46:17.000000000 -0700
@@ -32,6 +32,7 @@
  #     lib   - make libRooFitCore.a                                          #
  #     shlib - make libRooFitCore.so                                         #
  #    winlib - make libRooFitCore.dll (for CygWin)                           #
+ #     dylib - make libRooFitCore.dylib (for Mac OS X)                       #
  #     clean - delete all intermediate and final build objects               #
  #                                                                           #
  ############################################################################# 
@@ -39,7 +40,7 @@
 
 # --- External configuration ----------------------------------
 CC       = g++
-CCFLAGS  = -O3 -Wall -Wno-parentheses
+CCFLAGS  = -O2 -Wall -Wno-parentheses
 MFLAGS   = -MM
 INCLUDES =
 WORKDIR  = tmp/
@@ -49,13 +50,15 @@
 
 # Internal configuration
 PACKAGE=RooFitCore
-LD_LIBRARY_PATH:=$(ROOTSYS)/lib:$(LD_LIBRARY_PATH)
+MAJOR  = $(shell echo @VERSION@ | awk -F "." '{printf("%d",$$1)}')
+MINOR  = $(shell echo @VERSION@ | awk -F "." '{printf("%d",$$2)}')
+REVIS  = $(shell echo @VERSION@ | awk -F "." '{printf("%d",$$3)}')
+
 OBJDIR=$(WORKDIR)/objects/
 INCDIR=$(WORKDIR)/$(PACKAGE)/
 VPATH=$(INCDIR) $(OBJDIR)
 #LDFLAGS  = -shared
-INCLUDES += -I.. -I$(WORKDIR)/ -I$(ROOTSYS)/include
-ROOTSYS  ?= ERROR_RootSysIsNotDefined
+INCLUDES += -I.. -I$(WORKDIR)/ $(shell root-config --cflags)
 RDLLIST   = $(filter-out $(PACKAGE)_LinkDef.rdl,$(wildcard *.rdl))
 SKIPLIST  = makedocs.cc RooIntegratorTest.cc
 CINTFILE  = $(PACKAGE)Cint.cc
@@ -63,9 +66,10 @@
 LIBFILE   = $(LIBDIR)/lib$(PACKAGE).a
 SHLIBFILE = $(LIBDIR)/lib$(PACKAGE).so
 DLLIBFILE = $(LIBDIR)/lib$(PACKAGE).dll
+DYLIBFILE = $(LIBDIR)/lib$(PACKAGE).dylib
 UNAME = $(shell uname)
 
-default: shlib
+default: dylib
 
 # List of all includes files to copy from rdl
 HHLIST=$(patsubst %.rdl,%.hh,$(RDLLIST))
@@ -104,9 +108,7 @@
 	@mkdir -p $(OBJDIR)
 	@cp *.hh $(INCDIR)
 	@echo "Running rootcint"
-	@ROOTSYS=$(ROOTSYS)
-	@export ROOTSYS
-	@cd $(INCDIR) ; $(ROOTSYS)/bin/rootcint -f $(CINTFILE) -c $(INCLUDES) $(HHLIST) $(PACKAGE)_LinkDef.hh
+	@cd $(INCDIR) ; rootcint -f $(CINTFILE) -c $(INCLUDES) $(HHLIST) $(PACKAGE)_LinkDef.hh
 	@echo "Compiling $(CINTFILE)"
 	@$(CC) $(CCFLAGS) -c $(INCDIR)/$(CINTFILE) -o $(OBJDIR)/$(CINTOBJ) $(INCLUDES)
 
@@ -121,7 +123,7 @@
 $(SHLIBFILE): $(OLIST) $(patsubst %.cc,%.o,$(OBJDIR)/$(CINTFILE))
 	@echo "Making $(SHLIBFILE)"
 	@rm -f $(SHLIBFILE)
-	@$(CC) $(addprefix $(OBJDIR)/,$(OLIST) $(patsubst %.cc,%.o,$(CINTFILE))) -shared -o $(SHLIBFILE)
+	@$(CC) $(addprefix $(OBJDIR)/,$(OLIST) $(patsubst %.cc,%.o,$(CINTFILE))) -bundle -undefined dynamic_lookup -o $(SHLIBFILE)
 
 # Rule to combine objects into a windows shared library
 $(DLLIBFILE): $(OLIST) $(patsubst %.cc,%.o,$(OBJDIR)/$(CINTFILE))
@@ -129,17 +131,29 @@
 	@rm -f $(DLLIBFILE)
 	$(CC) -Wl,--export-all-symbols -Wl,--export-dynamic -Wl,--enable-auto-import -Wl,-Bdynamic -shared --enable-auto-image-base -Wl,-soname -o $(DLLIBFILE) -Wl,--whole-archive $(addprefix $(OBJDIR)/,$(OLIST) $(patsubst %.cc,%.o,$(CINTFILE))) -Wl,--no-whole-archive -L$(ROOTSYS)/lib -lCore -lCint -lHist -lGraf -lGraf3d -lTree -lRint -lPostscript -lMatrix -lMinuit -lPhysics -lHtml -lm
 
+# Rule to combine objects into a Mac OS X shared library
+$(DYLIBFILE): $(OLIST) $(patsubst %.cc,%.o,$(OBJDIR)/$(CINTFILE))
+	@echo "Making $(SHLIBFILE)"
+	@rm -f $(SHLIBFILE)
+	@$(CC) $(addprefix $(OBJDIR)/,$(OLIST) $(patsubst %.cc,%.o,$(CINTFILE))) \
+	-dynamiclib -single_module -undefined dynamic_lookup \
+	-o $(subst .dylib,.$(MAJOR).$(MINOR).dylib,$@) \
+	-install_name $(subst $(LIBDIR),@PREFIX@/lib/root,$(subst .dylib,.$(MAJOR).dylib,$@)) \
+	-compatibility_version $(MAJOR) -current_version $(MAJOR).$(MINOR).$(REVIS) \
+
 # Useful build targets
 lib: $(LIBFILE) 
 shlib: $(SHLIBFILE)
 winlib: $(DLLIBFILE)
+dylib: $(DYLIBFILE) $(SHLIBFILE)
 clean:
 	rm -f $(OBJDIR)/*
 	rm -f $(INCDIR)/*
 	rm -f $(LIBFILE)
 	rm -f $(SHLIBFILE)
 	rm -f $(DLLIBFILE)
+	rm -f $(DYLIBFILE)
 
-.PHONY : winlib shlib lib default clean
+.PHONY : dylib winlib shlib lib default clean
 
 -include $(addprefix $(INCDIR)/,$(DLIST))
