$NetBSD: patch-Makefile,v 1.3 2022/05/04 08:56:02 jaapb Exp $ Make native code compilation optional and use INSTALL_* macros --- Makefile.orig 2021-10-09 14:48:02.000000000 +0000 +++ Makefile @@ -11,7 +11,7 @@ # # ######################################################################### -include Makefile.config +-include Makefile.config OCAMLC=ocamlc OCAMLOPT=ocamlopt @@ -21,11 +21,18 @@ OCAMLRUN=ocamlrun O=o A=a SO=so -LIBDIR=`ocamlc -where` -STUBLIBDIR=$(LIBDIR)/stublibs +HAS_OCAMLOPT?= $(shell if which ocamlopt >/dev/null; then echo yes; else echo no; fi) -all: libcamldbm.$(A) dbm.cma dbm.cmxa dbm.cmxs +TARGETS := libcamldbm.$(A) dbm.cma +FILES := META dllcamldbm.$(SO) libcamldbm.$(A) dbm.cma dbm.cmi dbm.mli + +ifeq ($(HAS_OCAMLOPT),yes) + TARGETS += dbm.cmxa dbm.cmxs + FILES += dbm.cmxa dbm.cmxs dbm.cmx dbm.$(A) +endif + +all: $(TARGETS) dbm.cma: dbm.cmo $(OCAMLMKLIB) -o dbm -oc camldbm -linkall dbm.cmo $(DBM_LINK) @@ -57,13 +64,13 @@ depend: $(OCAMLDEP) *.ml *.mli > .depend install:: - if test -f dllcamldbm.$(SO); then mkdir $(STUBLIBDIR) || echo Ok; cp dllcamldbm.$(SO) $(STUBLIBDIR)/; fi - cp libcamldbm.$(A) $(LIBDIR)/ + if test -f dllcamldbm.$(SO); then $(BSD_INSTALL_LIB_DIR) $(STUBLIBDIR) || echo Ok; $(BSD_INSTALL_LIB) dllcamldbm.$(SO) $(STUBLIBDIR)/; fi + $(BSD_INSTALL_LIB) libcamldbm.$(A) $(LIBDIR)/ cd $(LIBDIR) && ranlib libcamldbm.$(A) - cp dbm.cmx dbm.cma dbm.cmxa dbm.cmi dbm.mli $(LIBDIR)/ - cp dbm.$(A) $(LIBDIR)/ + $(BSD_INSTALL_DATA) dbm.cmx dbm.cma dbm.cmxa dbm.cmi dbm.mli $(LIBDIR)/ + $(BSD_INSTALL_DATA) dbm.$(A) $(LIBDIR)/ cd $(LIBDIR) && ranlib dbm.$(A) - if test -f dbm.cmxs; then cp dbm.cmxs $(LIBDIR)/; fi + if test -f dbm.cmxs; then $(BSD_INSTALL_DATA) dbm.cmxs $(LIBDIR)/; fi clean:: rm -f *.cm* *.$(O) *.$(A) *.$(SO) @@ -77,12 +84,16 @@ testdbm.opt: dbm.cmxa testdbm.ml clean:: rm -f testdbm.byte testdbm.opt testdatabase.* -test: testdbm.byte testdbm.opt +test:: testdbm.byte rm -f testdatabase.* ocamlrun -I . ./testdbm.byte rm -f testdatabase.* + +ifeq ($(HAS_OCAMLOPT),yes) +test:: testdbm.opt + rm -f testdatabase.* ./testdbm.opt rm -f testdatabase.* - +endif include .depend