2 if $(not $(defined PREFIX))
7 if $(not $(defined ENABLE_DEBUG))
12 # behavior as traditional cpp
13 CPPFLAGS=-traditional-cpp
15 if $(file-exists VERSION)
16 VERSION=$(shell head -1 VERSION)
24 rm -f *.cm[aiox] *.o *.omc *.opt *.run *~ $(argv) *.cmxa *.a *.spot *.spit *.annot *.runner
26 # ------------------------------
28 # ------------------------------
29 public.UseCamlp4(files) =
30 protected.CAMLP4CMO = $(addprefix $(ROOT)/camlp4/,$(addsuffix .cmo,$(files)))
31 OCAMLPPFLAGS+=-pp 'camlp4o $(CAMLP4CMO)'
32 OCAMLDEPFLAGS+=-pp 'camlp4o $(CAMLP4CMO)'
35 .SCANNER: scan-ocaml-%.ml: %.ml $(CAMLP4CMO)
37 # ------------------------------
39 # ------------------------------
44 ounit-postproc(argv) =
45 (grep "FAIL\|ERROR\|Error\|Fail" && exit 1) || exit 0
47 public.OUnitTest(name,files) =
48 protected.test_file = $(addsuffix Test,$(name))
49 protected.target = $(addsuffix .runner.run,$(test_file))
50 protected.src_files = $(addprefix $(OUNIT_SRC_DIR),$(files))
52 .PHONY: check check-$(name) clean
53 OCamlProgram($(target), $(test_file) $(src_files) $(OUNIT_LIBS))
55 check-$(name): $(target)
56 $(addprefix ./,$(target)) | ounit-postproc
62 # ------------------------------
64 # ------------------------------t
67 @echo "(* CAUTION: this is a generated file. If you edit it, all changes will be lost! *)" > $@
68 $(CPP) $(CPPFLAGS) $*.mlip >> $@
71 .SCANNER: %.mli : %.mlip
72 $(CPP) $(CPPFLAGS) -M $< ; true
76 @echo "(* CAUTION: this is a generated file. If you edit it, all changes will be lost! *)" > $@
77 $(CPP) $(CPPFLAGS) $*.mlp >> $@
80 .SCANNER: %.ml : %.mlp
81 $(CPP) $(CPPFLAGS) -M $< ; true
86 if $(not $(OCAMLFIND_EXISTS))
87 eprintln('This project requires ocamlfind, but is was not found.')
88 eprintln('You need to install ocamlfind and run "omake --configure".')
91 NATIVE_ENABLED = false
95 .PHONY: all install config clean distclean example
97 # ------------------------------
99 # ------------------------------
100 config: OMakefile.config base/config.ml
102 .INCLUDE: OMakefile.config
103 if $(mem config,$(TARGETS))
105 if $(and $(defined RELATIVE),$(RELATIVE))
106 echo LIB_DIR=$(PREFIX) >> $@
107 echo SHARE_DIR=$(PREFIX) >> $@
108 echo BIN_DIR=$(PREFIX) >> $@
110 if $(not $(defined LIB_DIR))
111 echo LIB_DIR=$(PREFIX)/lib/habc >> $@
113 echo LIB_DIR=$(LIB_DIR) >> $@
114 if $(not $(defined SHARE_DIR))
115 echo SHARE_DIR=$(PREFIX)/share/habc >> $@
117 echo SHARE_DIR=$(SHARE_DIR) >> $@
118 if $(not $(defined BIN_DIR))
119 echo BIN_DIR=$(PREFIX)/bin >> $@
121 echo BIN_DIR=$(BIN_DIR) >> $@
123 if $(shell-success-null ocamlc$(if $(OCAMLC_OPT_EXISTS), .opt) -annot)
124 @echo "static.OCAMLFLAGS +=-annot" >> $@
126 @echo "static.OCAMLFLAGS +=-dtypes" >> $@
128 @echo "static.OCAMLFLAGS +=-g" >> $@
129 if $(not $(file-exists OMakefile.config))
130 @echo "Please refer to the installation instructions in file README.mkdn."
131 @echo "If you've just unpacked the distribution, something like"
132 @echo " omake config"
134 @echo " omake install"
135 @echo "should work. But see the file README.mkdn for more details."
138 if $(mem config,$(TARGETS))
140 echo 'let version = "$(VERSION)"' >> $@
141 if $(and $(defined RELATIVE),$(RELATIVE))
142 @echo 'let bin_dir = Str.global_replace (Str.regexp "\\\\") "/" (Filename.dirname Sys.executable_name)' >> $@
143 @echo 'let share_dir = bin_dir' >> $@
144 @echo 'let lib_dir = bin_dir' >> $@
146 @echo 'let bin_dir = "$(ocaml-escaped $(BIN_DIR))"' >> $@
147 @echo 'let share_dir = "$(ocaml-escaped $(SHARE_DIR))"' >> $@
148 @echo 'let lib_dir = "$(ocaml-escaped $(LIB_DIR))"' >> $@
149 @echo 'let default_includes = [lib_dir;"."]' >> $@
150 @echo 'let default_template = share_dir ^ "/template.xml"' >> $@
151 @echo 'let path_sep="$(PATHSEP)"' >> $@
152 @echo 'let exe="$(EXE)"' >> $@
154 .SUBDIRS: scm xml driver base lib camlp4 docs
156 # ------------------------------
158 # ------------------------------
159 habc-scm$(EXE): scm/src/habc-scm$(EXE)
162 habc-xml$(EXE): xml/src/habc-xml$(EXE)
165 habc$(EXE) : driver/habc$(EXE)
168 PROGRAM = habc$(EXE) habc-xml$(EXE) habc-scm$(EXE)
170 all: config $(PROGRAM)
174 # ------------------------------
176 # ------------------------------
180 mkdir -p $(SHARE_DIR)
181 mkdir -p $(SHARE_DIR)/example
182 $(INSTALL) $(PROGRAM) $(BIN_DIR)
183 $(INSTALL) share/habc/* $(SHARE_DIR)
184 $(INSTALL) example/* $(SHARE_DIR)/example/
185 $(INSTALL) lib/habc/* $(LIB_DIR)
186 if $(or $(equal Win32,$(OSTYPE)),$(equal Cygwin,$(OSTYPE)))
187 $(INSTALL) win32/swfmill/* $(BIN_DIR)/
188 $(INSTALL) README.mkdn $(BIN_DIR)/
190 # ------------------------------
192 # ------------------------------
194 ocaml-clean *.abc $(PROGRAM)
197 ocaml-clean *.abc $(PROGRAM) OMakefile.config base/config.ml
199 # ------------------------------
201 # ------------------------------
202 %.swf: example/%.scm all
203 ./habc -o $(removesuffix $@) $<