-@WX_LIBRARY_NAME_STATIC@: $(OBJECTS)
- @$(INSTALL) -d ./lib
- $(AR) $(AROPTIONS) ./lib/$@ $(OBJECTS)
- $(RANLIB) ./lib/$@
-
-@WX_LIBRARY_NAME_STATIC_GL@: glcanvas.o
- @$(INSTALL) -d ./lib
- $(AR) $(AROPTIONS) ./lib/$@ glcanvas.o
- $(RANLIB) ./lib/$@
-
-@WX_LIBRARY_NAME_SHARED@: $(OBJECTS)
- @$(INSTALL) -d ./lib
- $(SHARED_LD) ./lib/$@ $(BURNT_LIBRARY_NAME) $(OBJECTS) $(EXTRALIBS)
-
-@WX_LIBRARY_NAME_SHARED_GL@: glcanvas.o @WX_LIBRARY_NAME_SHARED@
- @$(INSTALL) -d ./lib
- $(SHARED_LD) ./lib/$@ $(BURNT_LIBRARY_NAME_GL) glcanvas.o ./lib/@WX_LIBRARY_NAME_SHARED@ $(EXTRALIBS) $(OPENGLLIBS)
-
-./lib/lib@WX_LIBRARY@-$(WX_MAJOR_VERSION_NUMBER).$(WX_MINOR_VERSION_NUMBER).r: ./lib/lib@WX_LIBRARY@-$(WX_MAJOR_VERSION_NUMBER).$(WX_MINOR_VERSION_NUMBER).rsrc
- $(DEREZ) $^ $(DEREZFLAGS) > $@
-
-./lib/lib@WX_LIBRARY@-$(WX_MAJOR_VERSION_NUMBER).$(WX_MINOR_VERSION_NUMBER).rsrc: $(MACRESOURCES)
- $(REZ) $(REZFLAGS) $^ -o $@
-
-CREATE_LINKS: @WX_LIBRARY_NAME_SHARED@
- @$(RM) ./lib/@WX_LIBRARY_LINK1@
- @$(RM) ./lib/@WX_LIBRARY_LINK2@
- @$(RM) ./lib/@WX_LIBRARY_LINK3@
- cd lib \
+$(build_libdir)/@WX_LIBRARY_NAME_STATIC@: $(OBJECTS)
+ @$(INSTALL) -d $(build_libdir)
+ @$(RM) $@
+ $(AR) $(AROPTIONS) $@ $(OBJECTS)
+ $(RANLIB) $@
+
+$(build_libdir)/@WX_LIBRARY_NAME_STATIC_GL@: glcanvas.o
+ @$(INSTALL) -d $(build_libdir)
+ @$(RM) $@
+ $(AR) $(AROPTIONS) $@ glcanvas.o
+ $(RANLIB) $@
+
+$(build_libdir)/@WX_LIBRARY_NAME_SHARED@: $(OBJECTS)
+ @$(INSTALL) -d $(build_libdir)
+ $(SHARED_LD) $@ $(SONAME_FLAGS) $(OBJECTS) $(EXTRALIBS)
+
+# NB: we used to have "-L$(build_libdir) @WXCONFIG_LIBS@" in the SHARED_LD line
+# but this seems to result in problems with libwx_gtk being linked in twice
+$(build_libdir)/@WX_LIBRARY_NAME_SHARED_GL@: glcanvas.o $(build_libdir)/@WX_LIBRARY_NAME_SHARED@
+ @$(INSTALL) -d $(build_libdir)
+ $(SHARED_LD) $@ $(SONAME_FLAGS_GL) glcanvas.o $(EXTRALIBS) $(OPENGLLIBS)
+
+$(build_libdir)/@WX_RESOURCES_MACOSX_DATA@: $(MACRESOURCES)
+ @$(INSTALL) -d $(build_libdir)
+ $(RESCOMP) -d __UNIX__ -useDF $^ -o $@
+
+$(build_libdir)/@WX_LIBRARY_LINK1@: $(build_libdir)/@WX_LIBRARY_NAME_SHARED@
+ @$(RM) $(build_libdir)/@WX_LIBRARY_LINK1@
+ @$(RM) $(build_libdir)/@WX_LIBRARY_LINK2@
+ cd $(build_libdir) \