Makefiles chain, dependancies and libsndfile configure checked.
[Faustine.git] / interpretor / Makefile
index e287f8b..715aadc 100644 (file)
@@ -1,22 +1,25 @@
+# Faustine interpreter Makefile.
+
 ########################## User's variables #####################
 #
 # The Caml sources (including camlyacc and camllex source files)
 
-SOURCES = types.ml parser.mly lexer.mll basic.ml symbol.ml aux.ml value.ml signal.ml beam.ml process.ml faustio.ml preprocess.ml main.ml preprocess_stubs.cpp
+SOURCES = types.ml parser.mly lexer.mll aux.ml basic.ml symbol.ml value.ml signal.ml beam.ml process.ml faustio.ml preprocess.ml main.ml preprocess_stubs.cpp
 
 # The executable file to generate
-
 EXEC = faustine
 
 # Path to ocaml include header files
-export OCAML_INCLUDE_PATH
+OCAML_INCLUDE_PATH := $(subst bin,lib,$(shell which ocaml))
 
 # Path to sndfile library
-#SNDFILE_PATH = /home/wang/Desktop/libsndfile-ocaml
-export SNDFILE_PATH
+SNDFILE_PATH := lib
+
+# Path to sndfile-ocaml library
+SNDFILE_OCAML_PATH := $(SNDFILE_PATH)/src/libsndfile-ocaml
 
-# Path to Faust.mr2
-FAUST_PATH = faust-0.9.47mr3
+# Path to Faust.mr3
+FAUST_PATH = preprocessor/faust-0.9.47mr3
 
 # Path to preprocessor library
 PREPROCESSOR_PATH = $(FAUST_PATH)/compiler
@@ -53,7 +56,8 @@ LIBS = $(WITHSNDFILE) $(WITHUNIX) $(WITHSTR)
 
 # INCLUDE=-INCLUDE
 
-INCLUDE = -I $(SNDFILE_PATH)
+INCLUDE = -I $(SNDFILE_OCAML_PATH)
+SNDFILE_STUB := $(SNDFILE_OCAML_PATH)/sndfile_stub.o
 
 # Default setting of the WITH* variables. Should be changed if your
 # local libraries are not found by the compiler.
@@ -84,6 +88,7 @@ CAMLC_OPTIONS = $(GPP_CALL) $(INCLUDE) $(LIBS)
 CAMLOPT_OPTIONS = -p $(GPP_CALL) $(INCLUDE) $(LIBS:.cma=.cmxa) 
 
 CAMLDOC_OPTIONS = -d $(OCAML_DOC_PATH) -html $(INCLUDE)
+
 CC_OPTIONS = -c -I$(PREPROCESSOR_INCLUDE_PATH) -I$(OCAML_INCLUDE_PATH)
 
 ################ End of user's variables #####################
@@ -94,9 +99,9 @@ CC_OPTIONS = -c -I$(PREPROCESSOR_INCLUDE_PATH) -I$(OCAML_INCLUDE_PATH)
 ################ Nothing to set up or fix here
 ##############################################################
 
-all:: .depend.input .depend preprocessor $(EXEC)
+all:: .depend.input .depend preprocessor libsndfile-ocaml $(EXEC)
 
-opt : .depend.input .depend preprocessor $(EXEC).opt
+opt : .depend.input .depend preprocessor libsndfile-ocaml $(EXEC).opt
 
 doc : document
 
@@ -111,6 +116,8 @@ SMLIY = $(SOURCES:.mly=.ml)
 SMLIYL = $(SMLIY:.mll=.ml)
 SMLYL = $(filter %.ml, $(SMLIYL))
 OBJS = $(SMLYL:.ml=.cmo)
+MLYS = $(filter %.mly, $(SOURCES))
+MLIS = $(MLYS:.mly=.mli)
 OPTOBJS = $(OBJS:.cmo=.cmx)
 
 CSOURCES = $(filter %.cpp, $(SOURCES))
@@ -121,16 +128,27 @@ PARSER_MLY = $(filter %.mly, $(SOURCES))
 LEXER_MLL = $(filter %.mll, $(SOURCES))
 MIDDLE_ML = $(PARSER_MLY:.mly=.ml) $(LEXER_MLL:.mll=.ml)
 
-preprocessor:
-       @(cd $(FAUST_PATH) && $(MAKE))
+preprocessor::
+       @echo "Compiling preprocessor..."
+       $(MAKE) -C $(FAUST_PATH) preprocessor
+
+libsndfile-ocaml::
+       @echo "Compiling libsndfile-ocaml..."
+       $(MAKE) -C $(SNDFILE_PATH)
+
 
-$(EXEC): $(OBJS) $(COBJS)
+$(EXEC): $(OBJS) $(COBJS) $(CLIBS)
+       @echo "Compiling $(EXEC)..."
+       cp $(SNDFILE_STUB) .
        $(CAMLC) $(CAMLC_OPTIONS) -o $(EXEC) $(OBJS) $(COBJS) $(CLIBS)
 
-$(EXEC).opt: $(OPTOBJS) $(COBJS)
+$(EXEC).opt: $(OPTOBJS) $(COBJS) $(CLIBS)
+       @echo "Compiling optimized $(EXEC)..."
+       cp $(SNDFILE_STUB) .
        $(CAMLOPT) $(CAMLOPT_OPTIONS) -o $(EXEC) $(OPTOBJS) $(COBJS) $(CLIBS)
 
 document: $(SMLYL) $(OBJS)
+       @echo "Compiling documentation..."
        $(CAMLDOC) $(CAMLDOC_OPTIONS) $(SMLYL)
 
 main.cmo: main.ml
@@ -194,11 +212,13 @@ faustio.cmx: faustio.ml
        $(CAMLYACC) $<
 
 clean::
-       rm -f *.cm[iox] *~ .*~ #*#
-       rm -f $(MIDDLE_ML) *.o *.mli .depend*
+       rm -f *.cm[iox] *~ .*~
+       rm -f $(MIDDLE_ML) *.o $(MLIS) # .depend*
+       @$(MAKE) -C $(SNDFILE_PATH) clean
 
 mrproper: clean
-       rm -f $(EXEC)*
+       @$(MAKE) -C $(SNDFILE_PATH) mrproper
+       rm -f $(EXEC)* .depend*
 
 .depend.input: Makefile
        @echo -n '--Checking Ocaml input files: '