2 if $(not $(defined PREFIX))
7 if $(not $(defined ENABLE_DEBUG))
13 if $(not $(defined ENABLE_NATIVE))
16 value $(ENABLE_NATIVE)
18 # behavior as traditional cpp
19 CPPFLAGS=-traditional-cpp
21 if $(file-exists VERSION)
22 VERSION=$(shell head -1 VERSION)
30 rm -f *.cm[aiox] *.o *.omc *.opt *.run *~ $(argv) *.cmxa *.a *.spot *.spit *.annot *.runner
32 # ------------------------------
34 # ------------------------------
35 public.UseCamlp4(files) =
36 protected.CAMLP4CMO = $(addprefix $(ROOT)/camlp4/,$(addsuffix .cmo,$(files)))
37 OCAMLPPFLAGS+=-pp 'camlp4o $(CAMLP4CMO)'
38 OCAMLDEPFLAGS+=-pp 'camlp4o $(CAMLP4CMO)'
41 .SCANNER: scan-ocaml-%.ml: %.ml $(CAMLP4CMO)
43 # ------------------------------
45 # ------------------------------
46 public.MyOCamlPackage(name, files) =
47 # XXX: JYH: these variables should be marked private in 0.9.9
48 protected.OFILES = $(addsuffix $(EXT_OBJ), $(files))
49 protected.CMOFILES = $(addsuffix .cmo, $(files))
50 protected.CMXFILES = $(addsuffix .cmx, $(files))
52 protected.OBJ = $(file $(name)$(EXT_OBJ))
53 protected.CMO = $(file $(name).cmo)
54 protected.CMX = $(file $(name).cmx)
55 protected.CMI = $(file $(name).cmi)
56 protected.MLI = $(file $(name).mli)
58 protected.BYTE_TARGETS = $(CMO)
59 protected.NATIVE_TARGETS = $(CMX) $(OBJ)
61 protected.TARGETS = $(CMI)
63 TARGETS += $(NATIVE_TARGETS)
67 TARGETS += $(BYTE_TARGETS)
73 protected.BYTE_DEPS = $(CMOFILES)
74 if $(and $(not $(NATIVE_ENABLED)), $(target-exists $(MLI)))
78 BYTE_TARGETS += $(CMI)
81 protected.NATIVE_DEPS = $(CMXFILES) $(OFILES)
82 if $(target-exists $(MLI))
86 NATIVE_TARGETS += $(CMI)
89 if $(target-exists $(MLI))
90 $(CMI): $(MLI) :scanner: scan-ocaml-$(name).mli
92 elseif $(NATIVE_ENABLED)
93 $(NATIVE_TARGETS) $(CMI): $(NATIVE_DEPS)
94 $(OCAMLFIND) $(OCAMLOPTLINK) $(LAZY_OCAMLFINDFLAGS) $(PREFIXED_OCAMLPACKS) $(OCAMLFLAGS) \
95 $(OCAMLOPTFLAGS) $(OCAML_LIB_FLAGS) -pack -o $(CMX) $(OCamlLinkSort $(CMXFILES))
97 $(BYTE_TARGETS) $(CMI): $(BYTE_DEPS)
98 $(OCAMLFIND) $(OCAMLC) $(LAZY_OCAMLFINDFLAGS) $(PREFIXED_OCAMLPACKS) $(OCAMLFLAGS) \
99 $(OCAMLCFLAGS) $(OCAML_LIB_FLAGS) -pack -o $(CMO) $(OCamlLinkSort $(CMOFILES))
104 # ------------------------------
106 # ------------------------------
107 OUNIT_SRC_DIR=../src/
111 ounit-postproc(argv) =
112 (grep "FAIL\|ERROR\|Error\|Fail" && exit 1) || exit 0
114 public.OUnitTest(name,files) =
115 protected.test_file = $(addsuffix Test,$(name))
116 protected.target = $(addsuffix -runner,$(test_file))
117 protected.src_files = $(addprefix $(OUNIT_SRC_DIR),$(files))
119 .PHONY: check check-$(name) clean
120 OCamlProgram($(target), $(test_file) $(src_files) $(OUNIT_LIBS))
122 check-$(name): $(target)
123 $(addprefix ./,$(target)) | ounit-postproc
129 # ------------------------------
131 # ------------------------------t
134 @echo "(* CAUTION: this is a generated file. If you edit it, all changes will be lost! *)" > $@
135 $(CPP) $(CPPFLAGS) $*.mlip >> $@
138 .SCANNER: %.mli : %.mlip
139 $(CPP) $(CPPFLAGS) -M $< ; true
143 @echo "(* CAUTION: this is a generated file. If you edit it, all changes will be lost! *)" > $@
144 $(CPP) $(CPPFLAGS) $*.mlp >> $@
147 .SCANNER: %.ml : %.mlp
148 $(CPP) $(CPPFLAGS) -M $< ; true
153 if $(not $(OCAMLFIND_EXISTS))
154 eprintln('This project requires ocamlfind, but is was not found.')
155 eprintln('You need to install ocamlfind and run "omake --configure".')
158 .PHONY: all install config clean distclean
160 # ------------------------------
162 # ------------------------------
163 config: OMakefile.config config.ml
165 .INCLUDE: OMakefile.config
166 if $(mem config,$(TARGETS))
168 if $(and $(defined RELATIVE),$(RELATIVE))
169 echo LIB_DIR=$(PREFIX) >> $@
170 echo SHARE_DIR=$(PREFIX) >> $@
171 echo BIN_DIR=$(PREFIX) >> $@
173 if $(not $(defined LIB_DIR))
174 echo LIB_DIR=$(PREFIX)/lib/habc >> $@
176 echo LIB_DIR=$(LIB_DIR) >> $@
177 if $(not $(defined SHARE_DIR))
178 echo SHARE_DIR=$(PREFIX)/share/habc >> $@
180 echo SHARE_DIR=$(SHARE_DIR) >> $@
181 if $(not $(defined BIN_DIR))
182 echo BIN_DIR=$(PREFIX)/bin >> $@
184 echo BIN_DIR=$(BIN_DIR) >> $@
186 if $(shell-success-null ocamlc$(if $(OCAMLC_OPT_EXISTS), .opt) -annot)
187 @echo "static.OCAMLFLAGS +=-annot" >> $@
189 @echo "static.OCAMLFLAGS +=-dtypes" >> $@
191 @echo "static.OCAMLFLAGS +=-g" >> $@
193 @echo "static.NATIVE_ENABLED = true" >> $@
194 @echo "static.BYTE_ENABLED = false" >> $@
196 @echo "static.NATIVE_ENABLED = false" >> $@
197 @echo "static.BYTE_ENABLED = true" >> $@
200 if $(not $(file-exists OMakefile.config))
201 @echo "Please refer to the installation instructions in file README.mkdn."
202 @echo "If you've just unpacked the distribution, something like"
203 @echo " omake config"
205 @echo " omake install"
206 @echo "should work. But see the file README.mkdn for more details."
209 if $(mem config,$(TARGETS))
211 echo 'let version = "$(VERSION)"' >> $@
212 if $(and $(defined RELATIVE),$(RELATIVE))
213 @echo 'let bin_dir = Str.global_replace (Str.regexp "\\\\") "/" (Filename.dirname Sys.executable_name)' >> $@
214 @echo 'let share_dir = bin_dir' >> $@
215 @echo 'let lib_dir = bin_dir' >> $@
217 @echo 'let bin_dir = "$(ocaml-escaped $(BIN_DIR))"' >> $@
218 @echo 'let share_dir = "$(ocaml-escaped $(SHARE_DIR))"' >> $@
219 @echo 'let lib_dir = "$(ocaml-escaped $(LIB_DIR))"' >> $@
220 @echo 'let default_includes = [lib_dir;"."]' >> $@
221 @echo 'let default_template = share_dir ^ "/template.xml"' >> $@
222 @echo 'let path_sep="$(PATHSEP)"' >> $@
223 @echo 'let exe="$(EXE)"' >> $@
226 ################################################
228 if $(not $(OCAMLFIND_EXISTS))
229 eprintln('This project requires ocamlfind, but is was not found.')
230 eprintln('You need to install ocamlfind and run "omake --configure".')
233 OCAMLINCLUDES += $(ROOT)
234 .SUBDIRS: scm xml driver base lib camlp4
236 # ------------------------------
238 # ------------------------------
239 habc-scm$(EXE): scm/src/habc-scm$(EXE)
242 habc-xml$(EXE): xml/src/habc-xml$(EXE)
245 habc$(EXE) : driver/src/habc$(EXE)
248 PROGRAM = habc$(EXE) habc-xml$(EXE) habc-scm$(EXE)
250 all: config $(PROGRAM)
254 # ------------------------------
256 # ------------------------------
260 mkdir -p $(SHARE_DIR)
261 mkdir -p $(SHARE_DIR)/example
262 $(INSTALL) $(PROGRAM) $(BIN_DIR)
263 $(INSTALL) share/habc/* $(SHARE_DIR)
264 $(INSTALL) example/* $(SHARE_DIR)/example/
265 $(INSTALL) lib/habc/* $(LIB_DIR)
266 if $(or $(equal Win32,$(OSTYPE)),$(equal Cygwin,$(OSTYPE)))
267 $(INSTALL) win32/swfmill/* $(BIN_DIR)/
268 $(INSTALL) README.mkdn $(BIN_DIR)/
270 # ------------------------------
272 # ------------------------------
274 ocaml-clean *.abc $(PROGRAM)
277 ocaml-clean *.abc $(PROGRAM) OMakefile.config base/config.ml
279 # ------------------------------
281 # ------------------------------
282 %.swf: example/%.scm all
283 ./habc -o $(removesuffix $@) $<