#! /bin/sh -e
## 10_Makefile.dpatch by Mike Furr <mfurr@debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Handling non-native archs and proper handling of .so generation
[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
patch_opts="${patch_opts:--f --no-backup-if-mismatch ${2:+-d $2}}"
if [ $# -lt 1 ]; then
echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
exit 1
fi
case "$1" in
-patch) patch $patch_opts -p1 < $0;;
-unpatch) patch $patch_opts -p1 -R < $0;;
*)
echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
exit 1;;
esac
exit 0
@DPATCH@
diff -urNad --exclude=CVS --exclude=.svn ./Makefile /tmp/dpep-work.HWFzlv/mlgmp-20021123/Makefile
--- ./Makefile 2005-09-03 15:15:47.339340437 -0400
+++ /tmp/dpep-work.HWFzlv/mlgmp-20021123/Makefile 2005-09-03 15:15:56.140184593 -0400
@@ -2,12 +2,14 @@
RANLIB= ranlib
OCAML_LIBDIR:= $(shell ocamlc -where)
-GMP_INCLUDES= -I/opt/gmp/include -I/users/absint2/local/include -I$(HOME)/packages/gmp/include
+GMP_INCLUDES=
-GMP_LIBDIR=/opt/gmp/lib
-DESTDIR= $(OCAML_LIBDIR)/gmp
+GMP_LIBDIR=
+PREFIX= $(OCAML_LIBDIR)
+PKGDIR= $(PREFIX)/gmp/
+STUBDIR= $(PREFIX)/stublibs/
-RLIBFLAGS= -cclib "-Wl,-rpath $(GMP_LIBDIR)" # Linux, FreeBSD
+#RLIBFLAGS= -cclib "-Wl,-rpath $(GMP_LIBDIR)" # Linux, FreeBSD
#RLIBFLAGS= -cclib "-Wl,-R $(GMP_LIBDIR)" # Solaris
# RLIBFLAGS= # MacOS X
@@ -15,33 +17,53 @@
-cclib -lmpfr -cclib -lgmp -cclib -L$(DESTDIR)
CC= gcc
-CFLAGS_MISC= -Wall -Wno-unused -g -O3
+CFLAGS_MISC= -Wall -Wno-unused -g -O2 -fPIC
#CFLAGS_MISC=
CFLAGS_INCLUDE= -I $(OCAML_LIBDIR) $(GMP_INCLUDES)
CFLAGS= $(CFLAGS_MISC) $(CFLAGS_INCLUDE)
OCAMLC= ocamlc -g
OCAMLOPT= ocamlopt
+OCAMLMKLIB= ocamlmklib
OCAMLFLAGS=
CMODULES= mlgmp_z.c mlgmp_q.c mlgmp_f.c mlgmp_fr.c mlgmp_random.c mlgmp_misc.c
CMODULES_O= $(CMODULES:%.c=%.o)
-LIBS= libmlgmp.a gmp.a gmp.cma gmp.cmxa gmp.cmi
PROGRAMS= test_creal test_creal.opt essai essai.opt toplevel\
test_suite test_suite.opt
-TESTS= test_suite test_suite.opt
+
+C_STATIC = libgmpstub.a
+C_SHARED = dllgmpstub.so
+
+HAS_OPT=
+BYTE_LIBS= gmp.cma gmp.cmi
+BYTE_TESTS= test_suite
+
+ifdef HAS_OPT
+ OPT_LIBS= gmp.cmxa
+ OPT_CMX= gmp.cmx
+ OPT_TESTS= test_suite.opt
+else
+ OPT_LIBS=
+ OPT_CMX=
+ OPT_TESTS=
+endif
+
+LIBS = $(C_SHARED) $(BYTE_LIBS) $(OPT_LIBS)
all: $(LIBS) tests
install: all
- -mkdir $(DESTDIR)
- cp $(LIBS) gmp.mli $(DESTDIR)
+ install -d $(DESTDIR)$(PKGDIR)
+ install -m 0644 -c $(BYTE_LIBS) $(OPT_LIBS) *.a gmp.mli $(DESTDIR)$(PKGDIR)
+ install -d $(STUBDIR)
+ install -m 0644 -c $(C_SHARED) $(STUBDIR)
-tests: $(LIBS) $(TESTS)
+tests: $(LIBS) $(BYTE_TESTS) $(OPT_TESTS)
./test_suite
- ./test_suite.opt
+ if [ -e ./test_suite.opt ]; then ./test_suite.opt; fi
%.i: %.c
$(CC) $(CFLAGS) -E $*.c > $*.i
@@ -63,15 +85,9 @@
$(CMODULES_O): conversions.c config.h
-libmlgmp.a: $(CMODULES_O)
- $(AR) -rc $@ $+
- $(RANLIB) $@
-
-gmp.cma: gmp.cmo libmlgmp.a
- $(OCAMLC) $(OCAMLFLAGS) -a gmp.cmo -cclib -lmlgmp $(LIBFLAGS) -o $@
-
-gmp.a gmp.cmxa: gmp.cmx libmlgmp.a
- $(OCAMLOPT) $(OCAMLFLAGS) -a gmp.cmx -cclib -lmlgmp $(LIBFLAGS) -o $@
+dllgmpstub.so libgmpstub.a gmp.cma gmp.cmxa: gmp.cmo $(OPT_CMX) $(CMODULES_O)
+ $(OCAMLMKLIB) $(OCAMLFLAGS) -o gmp -oc gmpstub gmp.cmo \
+ $(OPT_CMX) $(CMODULES_O) -lgmp
pretty_gmp.cmo: pretty_gmp.cmi gmp.cmo
@@ -81,27 +97,27 @@
essai: gmp.cma essai.cmo
$(OCAMLC) -custom $+ -o $@
-essai.opt: gmp.cmxa essai.cmx
+essai.opt: gmp.cmxa essai.cmx
$(OCAMLOPT) $+ -o $@
-test_creal: gmp.cma creal.cmo test_creal.cmo
- $(OCAMLC) -custom $+ -o $@
+test_creal: gmp.cma creal.cmo test_creal.cmo
+ $(OCAMLC) $+ -o $@
test_creal.opt: gmp.cmxa creal.cmx test_creal.cmx
$(OCAMLOPT) $+ -o $@
-test_suite: gmp.cma test_suite.cmo
- $(OCAMLC) -custom $+ -o $@
+test_suite: gmp.cma test_suite.cmo
+ $(OCAMLC) -custom $+ -o $@ -cclib -L.
test_suite.opt: gmp.cmxa test_suite.cmx
- $(OCAMLOPT) $+ -o $@
+ $(OCAMLOPT) $+ -o $@ -cclib -L.
clean:
- rm -f *.o *.cm* $(PROGRAMS) *.a
+ -rm -f *.o *.cm* $(PROGRAMS) *.a *.so
depend:
ocamldep *.ml *.mli > depend
.PHONY: clean
-include depend
+-include depend