$OpenBSD: patch-c-lib_Makefile,v 1.2 2017/09/16 09:03:15 jasper Exp $
- OpenBSD doesn't need libdl
- use pkg-config to find glib libs
- make sure libcamlrun.a is writable after copying it from system libs
- don't attempt to overwrite an optimized library with a non-existant one
- fix .pc datarootdir
Index: c-lib/Makefile
--- c-lib/Makefile.orig
+++ c-lib/Makefile
@@ -13,7 +13,7 @@ PROG_CFLAGS = -Wall
 OCAML_LIBDIR := $(shell ocamlc -where)
 INCLUDES = -I . -I $(OCAML_LIBDIR) $(shell pkg-config --cflags glib-2.0)
 CUDF_LDFLAGS = -L$(OCAML_LIBDIR) -L$(CURDIR)
-CUDF_CLIBS = -lcudf -lm -ldl -lunix -lncurses -lglib-2.0
+CUDF_CLIBS = -lcudf -lm -lunix -lncurses $(shell pkg-config --libs glib-2.0)
 OCAMLC = ocamlfind ocamlc -package unix,extlib
 OCAMLOPT = ocamlfind ocamlopt -package unix,extlib
 
@@ -21,9 +21,11 @@ INSTALL_STUFF = libcudf.a cudf.h cudf.pc
 
 libcudf.a: cudf-caml.o cudf.o
 	cp $(OCAML_LIBDIR)/libcamlrun.a $@
+	chmod 644 $@
 	ar r $@ $^
 libcudf-opt.a: cudf-caml-opt.o cudf.o
 	cp $(OCAML_LIBDIR)/libasmrun.a $@
+	chmod 644 $@
 	ar r $@ $^
 
 ../_build/%:
@@ -53,6 +55,7 @@ cudf.pc: cudf.pc.in
 			-e "s,@VERSION@,$(VERSION),g" \
 			-e "s,@LIBDIR@,$(LIBDIR),g" \
 			-e "s,@INCDIR@,$(INCDIR),g" \
+			-e "s,@DATAROOTDIR@,$(PREFIX),g" \
 		> $@
 
 %.o: %.c
@@ -72,7 +75,6 @@ install: cudf.pc
 	else \
 		cp libcudf.a $(DESTDIR)$(LIBDIR)/libcudf.a ; \
 	fi
-	cp libcudf.a $(DESTDIR)$(LIBDIR)
 	cp cudf.h $(DESTDIR)$(INCDIR)
 	cp cudf.pc $(DESTDIR)$(PCDIR)
 
