Commit 5fe9a467 authored by Bruno Guillaume's avatar Bruno Guillaume

add DATADIR handling

parent e1b124e8
PREFIX?=/usr/local
BINDIR=$(PREFIX)/bin
DATADIR=$(PREFIX)/share/libgrew/
OCB_FLAGS = -use-ocamlfind -use-menhir -I src
OCB = ocamlbuild $(OCB_FLAGS)
......@@ -6,24 +10,33 @@ INSTALL_FILES = $(LIB_FILES:%=_build/src/%)
VERSION = `cat VERSION`
build:
build: datadir
$(OCB) $(LIB_FILES)
datadir:
echo $(DATADIR) > DATADIR
install: build uninstall
cp META_STD META
ocamlfind install -patch-version $(VERSION) libgrew META $(INSTALL_FILES)
rm -f META
mkdir -p $(DATADIR)
cp -rf grs/* $(DATADIR)
install_dev: build uninstall_dev
cp META_DEV META
ocamlfind install -patch-version $(VERSION) libgrew_dev META $(INSTALL_FILES)
rm -f META
mkdir -p $(DATADIR)
cp -rf grs/* $(DATADIR)
uninstall:
ocamlfind remove libgrew
rm -rf $(DATADIR)
uninstall_dev:
ocamlfind remove libgrew_dev
rm -rf $(DATADIR)
doc:
$(OCB) libgrew.docdir/index.html
......
open Ocamlbuild_plugin
let get_version () =
let in_ch = open_in "VERSION" in
let v = input_line in_ch in
close_in in_ch;
v
let read file =
let in_ch = open_in file in
try
let v = input_line in_ch in
close_in in_ch;
v
with End_of_file -> failwith ("Error loading file: "^file)
let () =
dispatch begin function
| After_rules ->
let version = "\""^(get_version ())^"\"" in
let pp_src = S[A"-pp"; A("cppo -D 'VERSION "^version^"'")] in
let version = "\""^(read "VERSION")^"\"" in
let datadir = "\""^(read "DATADIR")^"\"" in
let pp_src = S[A"-pp"; A("cppo -D 'VERSION "^version^"' -D 'DATADIR "^datadir^"'")] in
flag ["ocaml"; "ocamldep"] & pp_src;
flag ["ocaml"; "compile"] & pp_src;
flag ["ocaml"; "compile"] & pp_src;
| _ -> ()
end
......@@ -2,13 +2,13 @@ opam-version: "2.0"
maintainer: "Bruno.Guillaume@loria.fr"
homepage: "http://grew.fr"
build: [
["make"]
["make" "PREFIX=%{prefix}%"]
]
install: [
["make" "install"]
["make" "install" "PREFIX=%{prefix}%"]
]
remove: [
["make" "uninstall"]
["make" "uninstall" "PREFIX=%{prefix}%"]
]
depends: [
"cppo"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment