Created
October 16, 2015 22:06
-
-
Save joshmarlow/5fad1a782bc2b8271186 to your computer and use it in GitHub Desktop.
Example Makefile for a small OCaml module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Note: I've used a consistent naming schem for the files in this project | |
# (ie, bindigo.mli bindigo.ml bindigo_tests.ml). | |
# This allows easy construction of various make targets working working with the files. | |
DELIM = ---------------------------- | |
LIB_NAME = bindigo | |
# Install this package so that is accessible in other projects on this sytem | |
install: clean uninstall $(LIB_NAME).byte $(LIB_NAME).native | |
@echo $(DELIM) Installing... | |
@ocamlfind install $(LIB_NAME) META *.mli _build/*.cmi _build/*.cmo _build/*.cmx _build/*.o | |
@echo $(DELIM) installed... | |
# Uninstall this package so that ocamlfind cannot access it | |
uninstall: | |
@echo $(DELIM) Uninstalling... | |
@ocamlfind remove $(LIB_NAME) | |
# Build an optimized native version of this library | |
$(LIB_NAME).native: | |
@echo $(DELIM) Building $(LIB_NAME) native library... | |
@ocamlbuild -use-ocamlfind $(LIB_NAME).native | |
# Build a bytecode version of this library | |
$(LIB_NAME).byte: | |
@echo $(DELIM) Building $(LIB_NAME) byte library... | |
@ocamlbuild -use-ocamlfind $(LIB_NAME).byte | |
# Run the tests for this library | |
tests: | |
@echo $(DELIM) Testing... | |
@ocamlbuild -cflags "-w A" -use-ocamlfind $(LIB_NAME)_tests.native | |
@./$(LIB_NAME)_tests.native | |
# Remove all build files associated for this library | |
clean: | |
@echo $(DELIM) Cleaning up... $(DELIM) | |
@ocamlbuild -clean | |
@rm -f *.native *.byte |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment