Skip to content

Commit

Permalink
Improve installation/deinstallation of the package with ocamlfind
Browse files Browse the repository at this point in the history
  • Loading branch information
T Ar Creator authored and g2p committed Feb 17, 2010
1 parent c203f5a commit 672607c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
3 changes: 3 additions & 0 deletions META
@@ -0,0 +1,3 @@
version="0.5"
archive(byte)="inotify.cma"
archive(native)="inotify.cmxa"
32 changes: 25 additions & 7 deletions Makefile
@@ -1,27 +1,38 @@
CC = gcc
CFLAGS = -Wall -O2
CFLAGS = -Wall -fPIC -O2
OCAMLC = ocamlc
OCAMLOPT = ocamlopt

OCAMLOPTFLAGS =

OCAMLABI := $(shell ocamlc -version)
OCAMLLIBDIR := $(shell ocamlc -where)
OCAMLDESTDIR ?= $(OCAMLLIBDIR)

OCAML_TEST_INC = -I `ocamlfind query oUnit`
OCAML_TEST_LIB = `ocamlfind query oUnit`/oUnit.cmxa

LIBS = inotify.cmi inotify.cmxa inotify.cma
PROGRAMS = test.inotify

all: $(LIBS) $(PROGRAMS)
all: $(LIBS)

bins: $(PROGRAMS)

libs: $(LIBS)

inotify.cma: inotify_stubs.o inotify.cmo
$(OCAMLC) -a -o $@ -custom $+
inotify.cmxa: libinotify_stubs.a inotify_stubs.a inotify.cmx
$(OCAMLOPT) $(OCAMLOPTFLAGS) -a -cclib -linotify_stubs -o $@ inotify.cmx

inotify.cma: libinotify_stubs.a inotify.cmi inotify.cmo
$(OCAMLC) -a -dllib dllinotify_stubs.so -cclib -linotify_stubs -o $@ inotify.cmo

inotify_stubs.a: inotify_stubs.o
ocamlmklib -o inotify_stubs $+

inotify.cmxa: inotify_stubs.o inotify.cmx
$(OCAMLOPT) $(OCAMLOPTFLAGS) -a -o $@ $+
libinotify_stubs.a: inotify_stubs.o
ar rcs $@ $+
ocamlmklib -o inotify_stubs $+

%.cmo: %.ml
$(OCAMLC) -c -o $@ $<
Expand All @@ -35,8 +46,15 @@ inotify.cmxa: inotify_stubs.o inotify.cmx
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<

.PHONY: install
install: $(LIBS)
ocamlfind install -destdir $(OCAMLDESTDIR) -ldconf ignore inotify META inotify.cmi inotify.mli inotify.cma inotify.cmxa *.a *.so *.cmx

uninstall:
ocamlfind remove -destdir $(OCAMLDESTDIR) sqlite3

test.inotify: inotify.cmxa test.inotify.ml
$(OCAMLOPT) -o $@ unix.cmxa $+

clean:
rm -f *.o *.a *.cmo *.cmi *.cma *.cmx *.cmxa $(LIBS) $(PROGRAMS)
-rm -f *.o *.so *.a *.cmo *.cmi *.cma *.cmx *.cmxa $(LIBS) $(PROGRAMS)
2 changes: 1 addition & 1 deletion inotify_stubs.c
Expand Up @@ -3,7 +3,7 @@
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; version 2 only.
* by the Free Software Foundation; version 2.1 only.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
Expand Down

0 comments on commit 672607c

Please sign in to comment.