1 # ------------------------------
3 # ------------------------------
5 if $(not $(defined PREFIX))
10 if $(not $(defined ENABLE_DEBUG))
16 if $(not $(defined ENABLE_NATIVE))
19 value $(ENABLE_NATIVE)
21 if $(file-exists VERSION)
22 VERSION=$(shell head -1 VERSION)
31 if $(not $(OCAMLFIND_EXISTS))
32 eprintln('This project requires ocamlfind, but is was not found.')
33 eprintln('You need to install ocamlfind and run "omake --configure".')
36 # behavior as traditional cpp
37 CPPFLAGS=-traditional-cpp
39 OCAML_WARN_FLAGS=-w A -warn-error A
40 OCAMLFLAGS=$`(OCAML_WARN_FLAGS)
42 .PHONY: all install config clean package
43 # ------------------------------
45 # ------------------------------
48 rm -f *.cm[aiox] *.o *.omc *.opt *.run *~ $(argv) *.cmxa *.a *.spot *.spit *.annot *-runner
50 # ------------------------------
52 # ------------------------------
53 public.UseCamlp4(files) =
54 protected.CAMLP4CMO = $(addprefix $(ROOT)/camlp4/,$(addsuffix .cmo,$(files)))
55 OCAMLPPFLAGS+=-pp 'camlp4o $(CAMLP4CMO)'
56 OCAMLDEPFLAGS+=-pp 'camlp4o $(CAMLP4CMO)'
59 .SCANNER: scan-ocaml-%.ml: %.ml $(CAMLP4CMO)
61 # ------------------------------
63 # ------------------------------
64 public.MyOCamlPackage(name, files) =
65 # XXX: JYH: these variables should be marked private in 0.9.9
66 protected.OFILES = $(addsuffix $(EXT_OBJ), $(files))
67 protected.CMOFILES = $(addsuffix .cmo, $(files))
68 protected.CMXFILES = $(addsuffix .cmx, $(files))
70 protected.OBJ = $(file $(name)$(EXT_OBJ))
71 protected.CMO = $(file $(name).cmo)
72 protected.CMX = $(file $(name).cmx)
73 protected.CMI = $(file $(name).cmi)
74 protected.MLI = $(file $(name).mli)
76 protected.BYTE_TARGETS = $(CMO)
77 protected.NATIVE_TARGETS = $(CMX) $(OBJ)
79 protected.TARGETS = $(CMI)
81 TARGETS += $(NATIVE_TARGETS)
85 TARGETS += $(BYTE_TARGETS)
91 protected.BYTE_DEPS = $(CMOFILES)
92 if $(and $(not $(NATIVE_ENABLED)), $(target-exists $(MLI)))
96 BYTE_TARGETS += $(CMI)
99 protected.NATIVE_DEPS = $(CMXFILES) $(OFILES)
100 if $(target-exists $(MLI))
101 NATIVE_DEPS += $(CMI)
104 NATIVE_TARGETS += $(CMI)
107 if $(target-exists $(MLI))
108 $(CMI): $(MLI) :scanner: scan-ocaml-$(name).mli
110 elseif $(NATIVE_ENABLED)
111 $(NATIVE_TARGETS) $(CMI): $(NATIVE_DEPS)
112 $(OCAMLFIND) $(OCAMLOPTLINK) $(LAZY_OCAMLFINDFLAGS) $(PREFIXED_OCAMLPACKS) $(OCAMLFLAGS) \
113 $(OCAMLOPTFLAGS) $(OCAML_LIB_FLAGS) -pack -o $(CMX) $(OCamlLinkSort $(CMXFILES))
115 $(BYTE_TARGETS) $(CMI): $(BYTE_DEPS)
116 $(OCAMLFIND) $(OCAMLC) $(LAZY_OCAMLFINDFLAGS) $(PREFIXED_OCAMLPACKS) $(OCAMLFLAGS) \
117 $(OCAMLCFLAGS) $(OCAML_LIB_FLAGS) -pack -o $(CMO) $(OCamlLinkSort $(CMOFILES))
121 # ------------------------------
123 # ------------------------------
127 public.OUnitTest(name,files) =
128 protected.test_file = $(addsuffix Test,$(name))
129 protected.target = $(addsuffix -runner,$(test_file))
130 protected.src_files = $(addprefix $(OUNIT_SRC_DIR),$(files))
132 .PHONY: check check-$(name) clean check-detail-$(name) check-detail
133 OCamlProgram($(target), $(test_file) $(src_files) $(OUNIT_LIBS))
135 check-$(name): $(target)
136 $(addprefix ./,$(target))
138 check-$(name): $(target)
139 $(addprefix ./,$(target))
140 check-detail-$(name): $(target)
141 ($(addprefix ./,$(target)) -verbose ; true) | tee -a $(ROOT)/unittest.log
144 check-detail: check-detail-$(name)
148 # ------------------------------
150 # ------------------------------
153 @echo "(* CAUTION: this is a generated file. If you edit it, all changes will be lost! *)" > $@
154 $(CPP) $(CPPFLAGS) $*.mlip >> $@
157 .SCANNER: %.mli : %.mlip
158 $(CPP) $(CPPFLAGS) -M $< ; true
162 @echo "(* CAUTION: this is a generated file. If you edit it, all changes will be lost! *)" > $@
163 $(CPP) $(CPPFLAGS) $*.mlp >> $@
166 .SCANNER: %.ml : %.mlp
167 $(CPP) $(CPPFLAGS) -M $< /dev/null ; true
169 # ------------------------------
171 # ------------------------------
172 config: OMakefile.config config.ml
174 .INCLUDE: OMakefile.config
175 if $(mem config,$(TARGETS))
177 if $(and $(defined RELATIVE),$(RELATIVE))
178 echo LIB_DIR=$(PREFIX) >> $@
179 echo SHARE_DIR=$(PREFIX) >> $@
180 echo BIN_DIR=$(PREFIX) >> $@
182 if $(not $(defined LIB_DIR))
183 echo LIB_DIR=$(PREFIX)/lib/habc >> $@
185 echo LIB_DIR=$(LIB_DIR) >> $@
186 if $(not $(defined SHARE_DIR))
187 echo SHARE_DIR=$(PREFIX)/share/habc >> $@
189 echo SHARE_DIR=$(SHARE_DIR) >> $@
190 if $(not $(defined BIN_DIR))
191 echo BIN_DIR=$(PREFIX)/bin >> $@
193 echo BIN_DIR=$(BIN_DIR) >> $@
195 if $(shell-success-null ocamlc$(if $(OCAMLC_OPT_EXISTS), .opt) -annot)
196 @echo "static.OCAMLFLAGS +=-annot" >> $@
198 @echo "static.OCAMLFLAGS +=-dtypes" >> $@
200 @echo "static.OCAMLFLAGS +=-g" >> $@
202 @echo "static.NATIVE_ENABLED = true" >> $@
203 @echo "static.BYTE_ENABLED = false" >> $@
205 @echo "static.NATIVE_ENABLED = false" >> $@
206 @echo "static.BYTE_ENABLED = true" >> $@
209 if $(not $(file-exists OMakefile.config))
210 @echo "Please refer to the installation instructions in file README.mkdn."
211 @echo "If you've just unpacked the distribution, something like"
212 @echo " omake config"
214 @echo " omake install"
215 @echo "should work. But see the file README.mkdn for more details."
218 if $(mem config,$(TARGETS))
220 echo 'let version = "$(VERSION)"' >> $@
221 if $(and $(defined RELATIVE),$(RELATIVE))
222 @echo 'let bin_dir = Str.global_replace (Str.regexp "\\\\") "/" (Filename.dirname Sys.executable_name)' >> $@
223 @echo 'let share_dir = bin_dir' >> $@
224 @echo 'let lib_dir = bin_dir' >> $@
226 @echo 'let bin_dir = "$(ocaml-escaped $(BIN_DIR))"' >> $@
227 @echo 'let share_dir = "$(ocaml-escaped $(SHARE_DIR))"' >> $@
228 @echo 'let lib_dir = "$(ocaml-escaped $(LIB_DIR))"' >> $@
229 @echo 'let default_includes = [lib_dir;"."]' >> $@
230 @echo 'let default_template = share_dir ^ "/template.xml"' >> $@
231 @echo 'let path_sep="$(PATHSEP)"' >> $@
232 @echo 'let exe="$(EXE)"' >> $@
235 ################################################
236 OCAMLINCLUDES += $(ROOT)
237 .SUBDIRS: scm xml driver base lib camlp4
239 # ------------------------------
241 # ------------------------------
242 habc-scm$(EXE): scm/habc-scm$(EXE)
245 habc-xml$(EXE): xml/habc-xml$(EXE)
248 habc$(EXE) : driver/habc$(EXE)
251 PROGRAM = habc$(EXE) habc-xml$(EXE) habc-scm$(EXE)
253 all: config $(PROGRAM) lib
257 # ------------------------------
259 # ------------------------------
263 mkdir -p $(SHARE_DIR)
264 mkdir -p $(SHARE_DIR)/example
265 $(INSTALL) $(PROGRAM) $(BIN_DIR)
266 $(INSTALL) share/habc/* $(SHARE_DIR)
267 $(INSTALL) example/* $(SHARE_DIR)/example/
268 $(INSTALL) lib/habc/* $(LIB_DIR)
269 if $(or $(equal Win32,$(OSTYPE)),$(equal Cygwin,$(OSTYPE)))
270 $(INSTALL) win32/swfmill/* $(BIN_DIR)/
271 $(INSTALL) README.mkdn $(BIN_DIR)/
273 # ------------------------------
275 # ------------------------------
277 ocaml-clean *.abc $(PROGRAM)
280 git archive --format=tar --prefix=habc-$(shell cat VERSION)-src/ HEAD | gzip > habc-$(shell cat VERSION)-src.tar.gz