diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..3aa538a --- /dev/null +++ b/.gitattributes @@ -0,0 +1,4 @@ +# Default behaviour, for if core.autocrlf isn't set +* text=auto + +configure text eol=lf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ed7c97f --- /dev/null +++ b/.gitignore @@ -0,0 +1,19 @@ +Makefile.config + +testdbm.byte +testdbm.opt + +# general patterns + +*.o +*.a +*.so +*.obj +*.lib +*.dll +*.cm[ioxat] +*.cmx[as] +*.cmti +*.annot +*.exe +*.sw[po] diff --git a/Makefile b/Makefile index eab9b37..e14744c 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ # # ######################################################################### -include Makefile.config +-include Makefile.config OCAMLC=ocamlc OCAMLOPT=ocamlopt @@ -66,7 +66,7 @@ install:: if test -f dbm.cmxs; then cp dbm.cmxs $(LIBDIR)/; fi clean:: - rm -f *.cm* *.$(O) *.$(A) *.$(SO) + rm -f *.cm* *.$(O) *.$(A) *.$(SO) Makefile.config testdbm.byte: dbm.cma testdbm.ml $(OCAMLC) -o $@ dbm.cma testdbm.ml diff --git a/Makefile.config b/Makefile.config deleted file mode 100644 index 998989d..0000000 --- a/Makefile.config +++ /dev/null @@ -1,4 +0,0 @@ -OCAML_STDLIB=/home/xleroy/.opam/4.03.0/lib/ocaml -DBM_INCLUDES= -DBM_LINK=-lgdbm_compat -lgdbm -DBM_DEFINES=-DDBM_USES_GDBM_NDBM diff --git a/configure b/configure index 9a3d094..2df6033 100755 --- a/configure +++ b/configure @@ -25,6 +25,10 @@ echo stdlib=`ocamlc -where` +# This slightly strange looking command will prefer c_compiler for versions +# of OCaml which have it, but will fallback to bytecode_c_compiler otherwise +CC=${CC:-`ocamlc -config | tr -d '\r' | sed -ne 's/.*c_compiler: //p' | head -n 1`} + hasgot() { rm -f hasgot.c (echo "#include <$2>" @@ -36,7 +40,7 @@ hasgot() { fi echo ' return 0;' echo '}') > hasgot.c - ${CC:-cc} -I$1 -o hasgot.exe hasgot.c $3 $4 + $CC -I$1 -o hasgot.exe hasgot.c $3 $4 2>/dev/null res=$? rm -f hasgot.c hasgot.exe return $res @@ -46,7 +50,7 @@ dbm_include="not found" dbm_link="not found" dbm_defines="" -for dir in /usr/include /usr/include/db1 /usr/include/gdbm /usr/local/include; do +for dir in `$CC -xc -E -v /dev/null 2>&1 | sed -e '1,/#include <...>/d' -e '/End of search list./,$d'` /usr/include /usr/include/db1 /usr/include/gdbm /usr/local/include ; do if test -f $dir/ndbm.h; then dbm_include=$dir dbm_defines="-DDBM_COMPAT"