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)
23 ounit-postproc(argv) =
24 (grep "FAIL\|ERROR\|Error\|Fail" && exit 1) || exit 0
26 rm -f *.cm[aiox] *.o *.omc *.opt *.run *~ $(argv) *.cmxa *.a *.spot *.spit *.annot
28 # ------------------------------
30 # ------------------------------
31 public.UseCamlp4(files) =
32 protected.CAMLP4CMO = $(addprefix $(ROOT)/camlp4/,$(addsuffix .cmo,$(files)))
33 OCAMLPPFLAGS+=-pp 'camlp4o $(CAMLP4CMO)'
34 OCAMLDEPFLAGS+=-pp 'camlp4o $(CAMLP4CMO)'
37 .SCANNER: scan-ocaml-%.ml: %.ml $(CAMLP4CMO)
41 @echo "(* CAUTION: this is a generated file. If you edit it, all changes will be lost! *)" > $@
42 $(CPP) $(CPPFLAGS) $*.mlip >> $@
45 .SCANNER: %.mli : %.mlip
46 $(CPP) $(CPPFLAGS) -M $< >& /dev/null; true
50 @echo "(* CAUTION: this is a generated file. If you edit it, all changes will be lost! *)" > $@
51 $(CPP) $(CPPFLAGS) $*.mlp >> $@
54 .SCANNER: %.ml : %.mlp
55 $(CPP) $(CPPFLAGS) -M $< >& /dev/null; true
60 if $(not $(OCAMLFIND_EXISTS))
61 eprintln('This project requires ocamlfind, but is was not found.')
62 eprintln('You need to install ocamlfind and run "omake --configure".')
65 NATIVE_ENABLED = $(OCAMLOPT_EXISTS)
69 .PHONY: all install config clean distclean example
71 # ------------------------------
73 # ------------------------------
74 config: OMakefile.config base/config.ml
76 .INCLUDE: OMakefile.config
77 if $(mem config,$(TARGETS))
79 if $(and $(defined RELATIVE),$(RELATIVE))
80 echo LIB_DIR=$(PREFIX) >> $@
81 echo SHARE_DIR=$(PREFIX) >> $@
82 echo BIN_DIR=$(PREFIX) >> $@
84 if $(not $(defined LIB_DIR))
85 echo LIB_DIR=$(PREFIX)/lib/habc >> $@
87 echo LIB_DIR=$(LIB_DIR) >> $@
88 if $(not $(defined SHARE_DIR))
89 echo SHARE_DIR=$(PREFIX)/share/habc >> $@
91 echo SHARE_DIR=$(SHARE_DIR) >> $@
92 if $(not $(defined BIN_DIR))
93 echo BIN_DIR=$(PREFIX)/bin >> $@
95 echo BIN_DIR=$(BIN_DIR) >> $@
97 if $(shell-success-null ocamlc$(if $(OCAMLC_OPT_EXISTS), .opt) -annot)
98 @echo "static.OCAMLFLAGS +=-annot" >> $@
100 @echo "static.OCAMLFLAGS +=-dtypes" >> $@
102 @echo "static.OCAMLFLAGS +=-g" >> $@
103 if $(not $(file-exists OMakefile.config))
104 @echo "Please refer to the installation instructions in file README.mkdn."
105 @echo "If you've just unpacked the distribution, something like"
106 @echo " omake config"
108 @echo " omake install"
109 @echo "should work. But see the file README.mkdn for more details."
112 if $(mem config,$(TARGETS))
114 echo 'let version = "$(VERSION)"' >> $@
115 if $(and $(defined RELATIVE),$(RELATIVE))
116 @echo 'let bin_dir = Str.global_replace (Str.regexp "\\\\") "/" (Filename.dirname Sys.executable_name)' >> $@
117 @echo 'let share_dir = bin_dir' >> $@
118 @echo 'let lib_dir = bin_dir' >> $@
120 @echo 'let bin_dir = "$(ocaml-escaped $(BIN_DIR))"' >> $@
121 @echo 'let share_dir = "$(ocaml-escaped $(SHARE_DIR))"' >> $@
122 @echo 'let lib_dir = "$(ocaml-escaped $(LIB_DIR))"' >> $@
123 @echo 'let default_includes = [lib_dir;"."]' >> $@
124 @echo 'let default_template = share_dir ^ "/template.xml"' >> $@
125 @echo 'let path_sep="$(PATHSEP)"' >> $@
126 @echo 'let exe="$(EXE)"' >> $@
128 .SUBDIRS: scm xml driver base lib camlp4 docs
130 # ------------------------------
132 # ------------------------------
133 habc-scm$(EXE): scm/src/habc-scm$(EXE)
136 habc-xml$(EXE): xml/src/habc-xml$(EXE)
139 habc$(EXE) : driver/habc$(EXE)
142 PROGRAM = habc$(EXE) habc-xml$(EXE) habc-scm$(EXE)
144 all: config $(PROGRAM)
148 # ------------------------------
150 # ------------------------------
154 mkdir -p $(SHARE_DIR)
155 mkdir -p $(SHARE_DIR)/example
156 $(INSTALL) $(PROGRAM) $(BIN_DIR)
157 $(INSTALL) share/habc/* $(SHARE_DIR)
158 $(INSTALL) example/* $(SHARE_DIR)/example/
159 $(INSTALL) lib/habc/* $(LIB_DIR)
160 if $(or $(equal Win32,$(OSTYPE)),$(equal Cygwin,$(OSTYPE)))
161 $(INSTALL) win32/swfmill/* $(BIN_DIR)/
162 $(INSTALL) README.mkdn $(BIN_DIR)/
164 # ------------------------------
166 # ------------------------------
168 ocaml-clean *.abc $(PROGRAM)
171 ocaml-clean *.abc $(PROGRAM) OMakefile.config base/config.ml
173 # ------------------------------
175 # ------------------------------
176 %.swf: example/%.scm all
177 ./habc -o $(removesuffix $@) $<