diff --git a/src/Makefile b/src/Makefile
index 8a88035..2f191af 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -91,10 +91,10 @@ install:
 	cp META.in META
 	$(OCAMLFIND) install num META
 	rm -f META
-	$(INSTALL_DATA) $(TOINSTALL) $(STDLIBDIR)
+	$(INSTALL_DATA) $(TOINSTALL) $(DESTDIR)$(STDLIBDIR)
 ifeq "$(SUPPORTS_SHARED_LIBRARIES)" "true"
-	$(INSTALL_DIR) $(STDLIBDIR)/stublibs
-	$(INSTALL_DLL) $(TOINSTALL_STUBS) $(STDLIBDIR)/stublibs
+	$(INSTALL_DIR) $(DESTDIR)$(STDLIBDIR)/stublibs
+	$(INSTALL_DLL) $(TOINSTALL_STUBS) $(DESTDIR)$(STDLIBDIR)/stublibs
 endif
 
 findlib-install:
@@ -106,9 +106,9 @@ findlib-uninstall:
 	$(OCAMLFIND) remove num
 
 uninstall: findlib-uninstall
-	cd $(STDLIBDIR) && rm -f $(TOINSTALL)
+	cd $(DESTDIR)$(STDLIBDIR) && rm -f $(TOINSTALL)
 ifeq "$(SUPPORTS_SHARED_LIBRARIES)" "true"
-	cd $(STDLIBDIR)/stublibs && rm -f $(TOINSTALL_STUBS) 
+	cd $(DESTDIR)$(STDLIBDIR)/stublibs && rm -f $(TOINSTALL_STUBS) 
 endif
 
 clean:
diff --git a/toplevel/Makefile b/toplevel/Makefile
index 8c91b0b..48a73ce 100644
--- a/toplevel/Makefile
+++ b/toplevel/Makefile
@@ -1,6 +1,7 @@
 OCAMLC=ocamlc
 OCAMLDEP=ocamldep
 OCAMLFIND=ocamlfind
+STDLIBDIR=$(shell $(OCAMLC) -where)
 
 CAMLCFLAGS=-I ../src -I +compiler-libs \
            -w +a-4-9-41-42-44-45-48 -warn-error A \
@@ -22,10 +23,10 @@ TOINSTALL=\
   num_top.cma num_top.cmi num_top_printers.cmi
 
 install:
-	$(OCAMLFIND) install num-top META $(TOINSTALL)
+	$(OCAMLFIND) install -destdir $(DESTDIR)$(STDLIBDIR) num-top META $(TOINSTALL)
 
 uninstall:
-	$(OCAMLFIND) remove num-top
+	$(OCAMLFIND) remove -destdir $(DESTDIR)$(STDLIBDIR) num-top
 
 clean:
 	rm -f *.cm[ioxta] *.cmx[as] *.cmti
