Alan Falloon avatar Alan Falloon committed 55871db

Made the makefile build the three different targets

Comments (0)

Files changed (2)

-export PATH:=.:$(shell pwd)/extern/bin:$(PATH)
+FEATURES:=$(sort $(filter target-specific order-only second-expansion,$(.FEATURES)))
+ifneq (order-only second-expansion target-specific,$(FEATURES))
+$(error Your version of make does not support the required features.)
+.PHONY: all
+all: $(addprefix bin/,part1 part2 part3)
+export PATH:=$(abspath extern/bin):$(PATH)
-SRC_FILES := part3/
-ML_FILES  := $(filter,$(patsubst %.mll,,$(
-MLI_FILES := $(filter %.mli,$(SRC_FILES:%.mly=%.mli))
-CMX_FILES := $( 
-CMO_FILES := $(
-CMI_FILES := $(MLI_FILES:%.mli=%.cmi) $(
-GARBAGE := $(filter-out $(SRC_FILES),$(ML_FILES) $(MLI_FILES) $(CMX_FILES) $(CMX_FILES:%.cmx=%.o) $(CMO_FILES) $(CMI_FILES) interpreter .depend)
+LLVMMODULES:=llvm_bitwriter llvm_executionengine llvm llvm_scalar_opts
+LLVML:=$(addprefix -cclib ,$(LLVMMODULES:%=-l%))
+# A little function to get all the ml files that can be created from the sources
+get-ml-files= $(filter,$(patsubst %.mly,,$(patsubst %.mll,,$(1))))
+get-mli-files=$(filter %.mli,$(patsubst %.mly,%.mli,$(1)))
+part1_SRC_FILES := part1/
+part2_SRC_FILES := part2/
+part3_SRC_FILES := part3/
+GARBAGE := .depend $(filter-out $(SRC_FILES),$(GARBAGE))
+$(addprefix bin/,part1 part2 part3): %:
 .SUFFIXES: %.mll
 	$(OCAMLLEX) $<
-all : part1
-LLVMMODULES:=llvm_bitwriter llvm_executionengine llvm llvm_scalar_opts
-LLVML:=$(addprefix -cclib ,$(LLVMMODULES:%=-l%))
-part1 : $(CMX_FILES)
 clean ::
 	rm -f $(GARBAGE)
-extern/ extern/tar/ extern/build/ : %/ :
+extern/ extern/tar/ extern/build/ bin/ : %/ :
 	mkdir -p $@
-extern/tar/ extern/build/ : extern/
+extern/tar/ extern/build/ : | extern/
 PREFIX:=$(shell pwd)/extern
 EXTERNALS:=$(addprefix extern/bin/,ocamlc ocamlfind llvm-as) $(patsubst %,extern/lib/ocaml/site-lib/%/META,monad extlib)
 .depend: $(MLI_FILES) $(ML_FILES) | $(EXTERNALS) 
 	$(OCAMLFIND) $(OCAMLDEP) $(INCLUDES) $^ > .depend
-include .depend
+-include .depend
+$(part)_ML_FILES  := $(call get-ml-files, $($(part)_SRC_FILES))
+$(part)_MLI_FILES := $(call get-mli-files,$($(part)_SRC_FILES))
+$(part)_CMX_FILES := $($(part) 
+$(part)_CMO_FILES := $($(part)
+$(part)_CMI_FILES := $($(part)_MLI_FILES:%.mli=%.cmi) $($(part)
+SRC_FILES      	  := $(SRC_FILES) $($(part)_SRC_FILES)
+GARBAGE        	  := $(GARBAGE)					\
+		     $($(part)_ML_FILES)			\
+		     $($(part)_MLI_FILES)			\
+		     $($(part)_CMX_FILES)			\
+		     $($(part)_CMO_FILES)			\
+		     $($(part)_CMI_FILES)			\
+		     $($(part)_CMX_FILES:%.cmx=%.o)	
+ML_FILES  := $(ML_FILES)  $($(part)_ML_FILES)
+bin/$(part): $($(part)_CMX_FILES) | bin/
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.