Advertisement
Guest User

Untitled

a guest
Jul 25th, 2013
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Make 1.60 KB | None | 0 0
  1. .PHONY: all build test prep pack install reinstall uninstall clean
  2.  
  3. NAME=sodium
  4. VERSION=0.0.1
  5. PKGS=ctypes.foreign,bigarray,threads
  6. OBJS=sodium
  7. TESTS=test_crypto_box
  8. TESTT=native
  9.  
  10. CMIS=$(addprefix lib/,$(addsuffix .cmi,${OBJS}))
  11. CMOS=$(addprefix lib/,$(addsuffix .cmo,${OBJS}))
  12. CMXS=$(addprefix lib/,$(addsuffix .cmx,${OBJS}))
  13. CMA=lib/${NAME}.cma
  14. CMXA=lib/${NAME}.cmxa
  15. A=lib/${NAME}.a
  16. B=_build/lib/
  17. INSTALL=META $(addprefix _build/,${CMA} ${CMXA} ${A} ${CMIS} dll${NAME}.so)
  18.  
  19. FLAGS=-use-ocamlfind -tag thread
  20.  
  21. build: prep ${CMA} ${CMXA} ${A}
  22.  
  23. all: build test install
  24.  
  25. test: build $(addprefix lib_test/,$(addsuffix .${TESTT},${TESTS}))
  26.  
  27. lib_test/test_%.${TESTT}: lib_test/test_%.ml
  28.     ocamlbuild ${FLAGS} -lflags -cclib,-lsodium -pkgs ${PKGS},oUnit \
  29.     -I lib $@
  30.     ${MAKE} -C lib_test
  31.     ./test_$*.${TESTT}
  32.  
  33. prep: _build/.stamp
  34.     @ :
  35.  
  36. _build/.stamp:
  37.     mkdir -p _build/lib
  38.     @touch $@
  39.  
  40. %.cmo: %.ml %.mli
  41.     ocamlbuild ${FLAGS} -pkgs ${PKGS} $@
  42.  
  43. %.cma: ${CMOS}
  44.     ocamlbuild ${FLAGS} -lflags -dllib,-lsodium -pkgs ${PKGS} $@
  45.  
  46. %.cmx: %.ml %.mli
  47.     ocamlbuild ${FLAGS} -pkgs ${PKGS} $@
  48.  
  49. %.cmxa: ${CMXS}
  50.     ocamlbuild ${FLAGS} -lflags -cclib,-lsodium -pkgs ${PKGS} $@
  51.  
  52. %.a: ${CMXS}
  53.     ocamlbuild ${FLAGS} -lflags -cclib,-lsodium -pkgs ${PKGS} $@
  54.  
  55. %.so:
  56.     $(CC) -shared -o $@ -lsodium
  57.  
  58. META: META.in
  59.     sed s/%%VERSION%%/${VERSION}/ < META.in \
  60.     | sed s/%%PACKAGES%%/${PKGS}/ > META
  61.  
  62. install: build ${INSTALL}
  63.     ocamlfind install ${NAME} ${INSTALL}
  64.  
  65. reinstall: uninstall install
  66.  
  67. uninstall:
  68.     ocamlfind remove ${NAME}
  69.  
  70. clean:
  71.     ${MAKE} -C lib_test clean
  72.     rm -rf _build META $(addsuffix .${TESTT},${TESTS})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement