Skip to content

Commit aa46a5e

Browse files
committed
Port to Dune
1 parent 792a454 commit aa46a5e

File tree

7 files changed

+79
-120
lines changed

7 files changed

+79
-120
lines changed

.depend

Lines changed: 0 additions & 3 deletions
This file was deleted.

.gitignore

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,9 @@
1-
Makefile.config
2-
3-
testdbm.byte
4-
testdbm.opt
1+
_build
2+
.merlin
3+
dbm.install
4+
c-flags.sexp
5+
c-library-flags.sexp
56

67
# general patterns
78

8-
*.o
9-
*.a
10-
*.so
11-
*.obj
12-
*.lib
13-
*.dll
14-
*.cm[ioxat]
15-
*.cmx[as]
16-
*.cmti
17-
*.annot
18-
*.exe
199
*.sw[po]

META

Lines changed: 0 additions & 5 deletions
This file was deleted.

Makefile

Lines changed: 25 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -11,78 +11,31 @@
1111
# #
1212
#########################################################################
1313

14-
-include Makefile.config
14+
JBUILDER?=jbuilder
15+
RM?=rm
1516

16-
OCAMLC=ocamlc
17-
OCAMLOPT=ocamlopt
18-
OCAMLMKLIB=ocamlmklib
19-
OCAMLDEP=ocamldep
20-
OCAMLRUN=ocamlrun
21-
O=o
22-
A=a
23-
SO=so
17+
# Legacy items kept to allow installation
2418
LIBDIR=`ocamlc -where`
2519
STUBLIBDIR=$(LIBDIR)/stublibs
26-
27-
28-
all: libcamldbm.$(A) dbm.cma dbm.cmxa dbm.cmxs
29-
30-
dbm.cma: dbm.cmo
31-
$(OCAMLMKLIB) -o dbm -oc camldbm -linkall dbm.cmo $(DBM_LINK)
32-
33-
dbm.cmxa: dbm.cmx
34-
$(OCAMLMKLIB) -o dbm -oc camldbm -linkall dbm.cmx $(DBM_LINK)
35-
36-
dbm.cmxs: dbm.cmxa libcamldbm.$(A)
37-
$(OCAMLOPT) -shared -o dbm.cmxs -I . dbm.cmxa
38-
39-
libcamldbm.$(A): cldbm.$(O)
40-
$(OCAMLMKLIB) -oc camldbm cldbm.$(O) $(DBM_LINK)
41-
42-
.SUFFIXES: .ml .mli .cmi .cmo .cmx .$(O)
43-
44-
.mli.cmi:
45-
$(OCAMLC) -c $(COMPFLAGS) $<
46-
47-
.ml.cmo:
48-
$(OCAMLC) -c $(COMPFLAGS) $<
49-
50-
.ml.cmx:
51-
$(OCAMLOPT) -c $(COMPFLAGS) $<
52-
53-
.c.$(O):
54-
$(OCAMLC) -c -ccopt "$(DBM_INCLUDES)" -ccopt "$(DBM_DEFINES)" $<
55-
56-
depend:
57-
$(OCAMLDEP) *.ml *.mli > .depend
58-
59-
install::
60-
if test -f dllcamldbm.$(SO); then mkdir $(STUBLIBDIR) || echo Ok; cp dllcamldbm.$(SO) $(STUBLIBDIR)/; fi
61-
cp libcamldbm.$(A) $(LIBDIR)/
62-
cd $(LIBDIR) && ranlib libcamldbm.$(A)
63-
cp dbm.cma dbm.cmxa dbm.cmi dbm.mli $(LIBDIR)/
64-
cp dbm.$(A) $(LIBDIR)/
65-
cd $(LIBDIR) && ranlib dbm.$(A)
66-
if test -f dbm.cmxs; then cp dbm.cmxs $(LIBDIR)/; fi
67-
68-
clean::
69-
rm -f *.cm* *.$(O) *.$(A) *.$(SO) Makefile.config
70-
71-
testdbm.byte: dbm.cma testdbm.ml
72-
$(OCAMLC) -o $@ dbm.cma testdbm.ml
73-
74-
testdbm.opt: dbm.cmxa testdbm.ml
75-
$(OCAMLOPT) -ccopt -L. -o $@ dbm.cmxa testdbm.ml
76-
77-
clean::
78-
rm -f testdbm.byte testdbm.opt testdatabase.*
79-
80-
test: testdbm.byte testdbm.opt
81-
rm -f testdatabase.*
82-
ocamlrun -I . ./testdbm.byte
83-
rm -f testdatabase.*
84-
./testdbm.opt
85-
rm -f testdatabase.*
86-
87-
88-
include .depend
20+
A=`ocamlc -config | sed -ne 's/ext_lib: //p'`
21+
SO=`ocamlc -config | sed -ne 's/ext_dll: //p'`
22+
ROOT=_build/install/default
23+
24+
all:
25+
$(JBUILDER) build @install
26+
27+
install:
28+
if test -f $(ROOT)/lib/stublibs/dlldbm_stubs$(SO); then mkdir $(STUBLIBDIR) || echo Ok; cp $(ROOT)/lib/stublibs/dlldbm_stubs$(SO) $(STUBLIBDIR)/; fi
29+
cp $(ROOT)/lib/dbm/libdbm_stubs$(A) $(LIBDIR)/
30+
# cd $(LIBDIR) && ranlib libdbm_stubs$(A)
31+
cp $(ROOT)/lib/dbm/dbm.cma $(ROOT)/lib/dbm/dbm.cmxa $(ROOT)/lib/dbm/dbm.cmi $(ROOT)/lib/dbm/dbm.mli $(LIBDIR)/
32+
cp $(ROOT)/lib/dbm/dbm$(A) $(LIBDIR)/
33+
# cd $(LIBDIR) && ranlib dbm$(A)
34+
if test -f $(ROOT)/lib/dbm/dbm.cmxs; then cp $(ROOT)/lib/dbm/dbm.cmxs $(LIBDIR)/; fi
35+
36+
clean:
37+
$(RM) -f *.sexp
38+
$(JBUILDER) clean
39+
40+
test:
41+
$(JBUILDER) runtest --force

configure

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,16 @@ if test $? -ne 0; then
2020
exit 2
2121
fi
2222

23-
echo "Configuring for OCaml version $version"
24-
echo
23+
if [ "$1" = "--quiet" ] ; then
24+
QUIET=1
25+
else
26+
QUIET=0
27+
fi
2528

26-
stdlib=`ocamlc -where`
29+
if [ $QUIET -eq 0 ] ; then
30+
echo "Configuring for OCaml version $version"
31+
echo
32+
fi
2733

2834
# This slightly strange looking command will prefer c_compiler for versions
2935
# of OCaml which have it, but will fallback to bytecode_c_compiler otherwise
@@ -88,22 +94,22 @@ if test "$dbm_include" = "not found" || test "$dbm_link" = "not found"; then
8894
exit 2
8995
fi
9096

91-
echo "Configuration for the \"camldbm\" library:"
92-
echo " headers found in ......... $dbm_include"
93-
echo " options for compiling .... $dbm_defines"
94-
echo " options for linking ...... $dbm_link"
95-
echo
96-
echo "Configuration successful"
97-
echo
97+
if [ $QUIET -eq 0 ] ; then
98+
echo "Configuration for the \"camldbm\" library:"
99+
echo " headers found in ......... $dbm_include"
100+
echo " options for compiling .... $dbm_defines"
101+
echo " options for linking ...... $dbm_link"
102+
echo
103+
echo "Configuration successful"
104+
echo
105+
fi
98106

99107
if test "$dbm_include" = "/usr/include"; then
100108
dbm_include=""
101109
else
102110
dbm_include="-I$dbm_include"
103111
fi
104112

105-
echo "OCAML_STDLIB=$stdlib" > Makefile.config
106-
echo "DBM_INCLUDES=$dbm_include" >> Makefile.config
107-
echo "DBM_LINK=$dbm_link" >> Makefile.config
108-
echo "DBM_DEFINES=$dbm_defines" >> Makefile.config
113+
echo "($dbm_include $dbm_defines)" > c-flags.sexp
114+
echo "($dbm_link)" > c-library-flags.sexp
109115

dbm.opam

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
opam-version: "1.2"
2+
version: "1.2"
23
maintainer: "https://github.com/ocaml/opam-repository/issues"
34
authors: ["Francois Rouaix"]
45
homepage: "https://github.com/ocaml/dbm"
56
bug-reports: "https://github.com/ocaml/dbm/issues"
67
dev-repo: "https://github.com/ocaml/dbm.git"
78
license: "LGPL-v2 with OCaml linking exception"
89
build: [
9-
["mkdir" "-p" "%{lib}%/dbm"]
10-
["./configure"]
1110
[make "all"]
1211
[make "test"]
1312
]
14-
depends: ["ocamlfind"]
13+
depends: ["jbuilder" {build & >= "1.0+beta17"}]
1514
depexts: [
1615
[["debian"] ["libgdbm-dev"]]
1716
[["ubuntu"] ["libgdbm-dev"]]
@@ -23,11 +22,3 @@ depexts: [
2322
[["osx" "homebrew"] ["gdbm"]]
2423
[["archlinux"] ["gdbm"]]
2524
]
26-
install: [
27-
[make "install" "STUBLIBDIR=%{lib}%/stublibs" "LIBDIR=%{lib}%/dbm"]
28-
["cp" "META" "%{lib}%/dbm"]
29-
]
30-
remove: [
31-
["rm" "-f" "%{lib}%/stublibs/dllcamldbm.so"]
32-
["ocamlfind" "remove" "dbm"]
33-
]

jbuild

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
(jbuild_version 1)
2+
3+
(library
4+
((name dbm)
5+
(public_name dbm)
6+
(synopsis "Access to GDBM/NDBM databases")
7+
(modules (dbm))
8+
(c_names (cldbm))
9+
(c_flags (:include c-flags.sexp))
10+
(c_library_flags (:include c-library-flags.sexp))
11+
(wrapped false)))
12+
13+
(rule
14+
((targets (c-flags.sexp c-library-flags.sexp))
15+
(deps (configure))
16+
(mode fallback)
17+
(action (run "sh" "-c" "./configure --quiet"))))
18+
19+
(executable
20+
((name testdbm)
21+
(modules testdbm)
22+
(libraries (dbm))))
23+
24+
(alias
25+
((name runtest)
26+
(deps (testdbm.exe))
27+
(action (run ${<}))))

0 commit comments

Comments
 (0)