| 1 |
# Attempt to ask git for a version (tag or hash) but fall back on LEMRELEASE. |
| 2 |
# Note that opam builds from a tar ball so LEMRELEASE will be used in that case. |
| 3 |
LEMRELEASE:=2026-05-01 |
| 4 |
LEMVERSION:=$(shell git describe --dirty --always 2>/dev/null || echo $(LEMRELEASE)) |
| 5 |
|
| 6 |
DDIR=lem-$(LEMVERSION) |
| 7 |
|
| 8 |
# by default assume local install |
| •9 |
#INSTALL_DIR := $(realpath .) |
| 10 |
INSTALL_DIR := $(DESTDIR) |
| 11 |
|
| •12 |
OCAMLBUILD_BEST ?= native |
| 13 |
|
| 14 |
#all: il.pdf build-main ilTheory.uo |
| 15 |
all: bin/lem libs_phase_1 |
| 16 |
|
| 17 |
# we might want run the tests for all backends that are present |
| 18 |
|
| 19 |
install: |
| •20 |
mkdir -p $(INSTALL_DIR)/bin |
| 21 |
rm -f $(INSTALL_DIR)/bin/lem |
| 22 |
cp src/main.$(OCAMLBUILD_BEST) $(INSTALL_DIR)/bin/lem |
| 23 |
rm -rf $(INSTALL_DIR)/share/lem |
| 24 |
mkdir -p $(INSTALL_DIR)/share/lem/library |
| 25 |
cp library/*.lem $(INSTALL_DIR)/share/lem/library |
| 26 |
cp library/*_constants $(INSTALL_DIR)/share/lem/library |
| 27 |
$(MAKE) -C ocaml-lib install |
| 28 |
cp -R coq-lib "$(INSTALL_DIR)/share/lem" |
| 29 |
cp -R hol-lib "$(INSTALL_DIR)/share/lem" |
| 30 |
# cp -R html-lib "$(INSTALL_DIR)/share/lem" |
| 31 |
cp -R isabelle-lib "$(INSTALL_DIR)/share/lem" |
| 32 |
# cp -R tex-lib "$(INSTALL_DIR)/share/lem" |
| 33 |
|
| 34 |
uninstall: |
| 35 |
rm -f "$(INSTALL_DIR)/bin/lem" |
| 36 |
rm -rf "$(INSTALL_DIR)/share/lem" |
| 37 |
$(MAKE) -C ocaml-lib uninstall |
| 38 |
|
| 39 |
build-doc: |
| 40 |
$(MAKE) -C doc |
| 41 |
|
| 42 |
do-tests: |
| 43 |
$(MAKE) -C tests |
| 44 |
|
| 45 |
lem_dep.tex: lem_dep.ott |
| 46 |
ott -o lem_dep.tex -picky_multiple_parses true lem_dep.ott |
| 47 |
|
| 48 |
lem_dep.pdf: lem_dep.tex |
| 49 |
pdflatex lem_dep.tex |
| 50 |
|
| 51 |
# this runs Lem on the Lem library (library/*.lem), leaving the |
| 52 |
# generated OCaml, Coq, HOL4, and Isabelle files to ocaml-libs, |
| 53 |
# hol-libs, etc. |
| 54 |
libs_phase_1: |
| 55 |
$(MAKE) -C library |
| 56 |
$(MAKE) ocaml-libs |
| 57 |
|
| 58 |
|
| 59 |
# this processes the Lem-generated library files for that target, |
| 60 |
# together with any other hand-written files needed (eg the ocaml |
| 61 |
# pset.ml), through the target. |
| 62 |
libs_phase_2: |
| 63 |
# $(MAKE) ocaml-libs |
| 64 |
$(MAKE) tex-libs |
| 65 |
$(MAKE) hol-libs |
| 66 |
$(MAKE) coq-libs |
| 67 |
$(MAKE) isa-libs |
| 68 |
|
| 69 |
hol-libs: |
| 70 |
# $(MAKE) -C library hol-libs |
| 71 |
cd hol-lib; Holmake --qof -k |
| 72 |
$(MAKE) -C library hol-lib-tests |
| 73 |
|
| 74 |
ocaml-libs: |
| 75 |
# $(MAKE) -C library ocaml-libs |
| 76 |
$(MAKE) -C ocaml-lib all |
| 77 |
$(MAKE) -C library ocaml-lib-tests |
| 78 |
|
| 79 |
isa-libs: |
| 80 |
# $(MAKE) -C library isa-libs |
| 81 |
isabelle build -d isabelle-lib -b LEM |
| 82 |
|
| 83 |
coq-libs: |
| 84 |
# $(MAKE) -C library coq-libs |
| 85 |
cd coq-lib; coqc -R . Lem coqharness.v |
| 86 |
cd coq-lib; coq_makefile -f coq_makefile.in > Makefile |
| 87 |
$(MAKE) -C coq-lib |
| 88 |
|
| 89 |
tex-libs: |
| 90 |
# $(MAKE) -C library tex-libs |
| 91 |
cd tex-lib; pdflatex lem-libs.tex |
| 92 |
cd tex-lib; pdflatex lem-libs.tex |
| 93 |
|
| 94 |
# test-other: test-ppcmem test-cpp test-cppppc |
| 95 |
# |
| 96 |
# test-ppc: |
| 97 |
# # ppc model |
| 98 |
# $(MAKE) -C ../../sem/WeakMemory/ppc-abstract-machine |
| 99 |
# # pull ppc model into ppcmem directory |
| 100 |
# # DON'T COMMIT |
| 101 |
# $(MAKE) -C ../ppcmem/system model |
| 102 |
# |
| 103 |
# test-axppc: |
| 104 |
# # Sela model |
| 105 |
# $(MAKE) -C ../axppc |
| 106 |
# # pull Sela model into ppcmem directory |
| 107 |
# # DON'T COMMIT |
| 108 |
# $(MAKE) -C ../ppcmem/system axmodel |
| 109 |
# |
| 110 |
# test-arm: |
| 111 |
# # ARM flowing model |
| 112 |
# $(MAKE) -C ../arm/flowing-things |
| 113 |
# # pull ARM model into ppcmem directory |
| 114 |
# # DON'T COMMIT |
| 115 |
# $(MAKE) -C ../ppcmem/system flowingmodel |
| 116 |
# |
| 117 |
# test-ppcmem: test-ppc test-axppc test-arm |
| 118 |
# # next 3 compile PPCMEM |
| 119 |
# # Check makefile in ppcmem/system is set to "text" |
| 120 |
# # DON'T commit |
| 121 |
# $(MAKE) -C ../ppcmem/system clean |
| 122 |
# $(MAKE) -C ../ppcmem/system depend_text |
| 123 |
# $(MAKE) -C ../ppcmem/system text |
| 124 |
# |
| 125 |
# test-cpp: |
| 126 |
# # C++. Chat with Mark to fix |
| 127 |
# $(MAKE) -C ../cpp/axiomatic/ntc deadlock |
| 128 |
# # C++. Chat with Mark to fix HOL building and Mark/Susmit/Mike ML |
| 129 |
# # building |
| 130 |
# #$(MAKE) -C ../cpp/opsem |
| 131 |
# #$(MAKE) -C ../cpp/axiomatic/ntc/proofs all |
| 132 |
# |
| 133 |
# test-cppppc: |
| 134 |
# $(MAKE) -C ../cppppc proof |
| 135 |
# $(MAKE) -C ../cppppc/proof2 lem |
| 136 |
# |
| 137 |
# |
| 138 |
# MACHINEFILES=\ |
| 139 |
# MachineDefUtils.lem \ |
| 140 |
# MachineDefFreshIds.lem \ |
| 141 |
# MachineDefValue.lem \ |
| 142 |
# MachineDefTypes.lem \ |
| 143 |
# MachineDefInstructionSemantics.lem \ |
| 144 |
# MachineDefStorageSubsystem.lem \ |
| 145 |
# MachineDefThreadSubsystem.lem \ |
| 146 |
# MachineDefSystem.lem |
| 147 |
# |
| 148 |
# test-tex: lem |
| 149 |
# rm -rf tests/test-tex/* |
| 150 |
# cp ../WeakMemory/ppc-abstract-machine/*.lem tests/test-tex |
| 151 |
# cp tests/test-tex-inc-wrapper.tex tests/test-tex |
| 152 |
# chmod ugo-w tests/test-tex/*.lem |
| 153 |
# cd tests/test-tex; ../../lem -hol -tex -ocaml -lib ../../library $(MACHINEFILES) |
| 154 |
# cd tests/test-tex; TEXINPUTS=../../tex-lib:$(TEXINPUTS) latex alldoc.tex; dvips alldoc |
| 155 |
# cd tests/test-tex; TEXINPUTS=../../tex-lib:$(TEXINPUTS) latex test-tex-inc-wrapper.tex; dvips test-tex-inc-wrapper |
| 156 |
# #cd tests/test-tex; TEXINPUTS=../../tex-lib:$(TEXINPUTS) latex MachineDefUtils.tex; dvips MachineDefUtils |
| 157 |
# #cd tests/test-tex; TEXINPUTS=../../tex-lib:$(TEXINPUTS) latex MachineDefFreshIds.tex; dvips MachineDefFreshIds |
| 158 |
# #cd tests/test-tex; TEXINPUTS=../../tex-lib:$(TEXINPUTS) latex MachineDefValue.tex; dvips MachineDefValue |
| 159 |
# #cd tests/test-tex; TEXINPUTS=../../tex-lib:$(TEXINPUTS) latex MachineDefTypes.tex; dvips MachineDefTypes |
| 160 |
# #cd tests/test-tex; TEXINPUTS=../../tex-lib:$(TEXINPUTS) latex MachineDefInstructionSemantics.tex; dvips MachineDefInstructionSemantics |
| 161 |
# #cd tests/test-tex; TEXINPUTS=../../tex-lib:$(TEXINPUTS) latex MachineDefStorageSubsystem.tex; dvips MachineDefStorageSubsystem |
| 162 |
# #cd tests/test-tex; TEXINPUTS=../../tex-lib:$(TEXINPUTS) latex MachineDefThreadSubsystem.tex; dvips MachineDefThreadSubsystem |
| 163 |
# #cd tests/test-tex; TEXINPUTS=../../tex-lib:$(TEXINPUTS) latex MachineDefSystem.tex; dvips MachineDefSystem |
| 164 |
# |
| 165 |
# test-texg: |
| 166 |
# g tests/test-tex/alldoc |
| 167 |
# #g tests/test-tex/MachineDefStorageSubsystem |
| 168 |
# |
| 169 |
# test-texw: |
| 170 |
# cd tests/test-tex; TEXINPUTS=../../tex-lib:$(TEXINPUTS) latex test-tex-inc-wrapper.tex; dvips test-tex-inc-wrapper |
| 171 |
# |
| 172 |
# |
| 173 |
# test-texgw: |
| 174 |
# g tests/test-tex/test-tex-inc-wrapper |
| 175 |
|
| 176 |
debug: version share_directory |
| 177 |
rm -f library/lib_cache |
| 178 |
$(MAKE) -C src debug |
| 179 |
ln -sf src/main.d.byte lem |
| 180 |
|
| 181 |
|
| 182 |
build-lem: version share_directory |
| 183 |
$(MAKE) -C src all |
| •184 |
ln -sf src/main.$(OCAMLBUILD_BEST) lem |
| 185 |
|
| 186 |
build-lem-profile: version share_directory |
| 187 |
$(MAKE) -C src profile |
| 188 |
ln -sf src/main.p.native lem-profile |
| 189 |
|
| 190 |
|
| 191 |
lem: build-lem |
| 192 |
true |
| 193 |
|
| 194 |
bin/lem: lem |
| 195 |
mkdir -p bin |
| •196 |
cd bin && ln -sf ../src/main.$(OCAMLBUILD_BEST) lem |
| 197 |
|
| 198 |
OCAML-LIB-NON_LGPL = \ |
| 199 |
ocaml-lib/Makefile \ |
| 200 |
ocaml-lib/big_int_impl.ml \ |
| 201 |
ocaml-lib/big_int_impl.mli \ |
| 202 |
ocaml-lib/nat_big_num.ml \ |
| 203 |
ocaml-lib/nat_big_num.mli \ |
| 204 |
ocaml-lib/nat_num.ml \ |
| 205 |
ocaml-lib/nat_num.mli \ |
| 206 |
ocaml-lib/vector.ml \ |
| 207 |
ocaml-lib/vector.mli |
| 208 |
# not |
| 209 |
# pmap.ml |
| 210 |
# pmap.mli |
| 211 |
# pset.ml |
| 212 |
# pset.mli |
| 213 |
|
| 214 |
apply_header: |
| 215 |
headache -h etc/header `ls src/*.ml` |
| 216 |
headache -h etc/header `ls src/*.mli` |
| 217 |
headache -h etc/header `ls src/*.mly` |
| 218 |
headache -h etc/header `ls src/*.mll` |
| 219 |
headache -c etc/head_config -h etc/header `ls language/*.lem` |
| 220 |
headache -c etc/head_config -h etc/header `ls tex-lib/*.sty` |
| 221 |
headache -c etc/head_config -h etc/header `ls coq-lib/*.v` |
| 222 |
headache -c etc/head_config -h etc/header `ls isabelle-lib/*.thy` |
| 223 |
headache -c etc/head_config -h etc/header `ls tex-lib/*.sty` |
| 224 |
headache -c etc/head_config -h etc/header $(OCAML-LIB-NONLGPL) |
| 225 |
headache -c etc/head_config -h etc/header `ls library/coq/*.lem` |
| 226 |
headache -c etc/head_config -h etc/header `ls library/hol/*.lem` |
| 227 |
headache -c etc/head_config -h etc/header `ls library/isabelle/*.lem` |
| 228 |
headache -c etc/head_config -h etc/header `ls library/ocaml/*.lem` |
| 229 |
|
| 230 |
|
| 231 |
#lem_unwrapped.tex: lem.ott |
| 232 |
# ott -tex_wrap false -o lem_unwrapped.tex lem.ott |
| 233 |
# |
| 234 |
#install_lem_unwrapped: lem_unwrapped.tex |
| 235 |
# cp lem_unwrapped.tex ../../ott/examples/ich/generated/lem_unwrapped.tex |
| 236 |
|
| 237 |
#src/version.ml: |
| 238 |
version: |
| 239 |
echo "(* Generated file -- do not edit. *)" > src/version.ml |
| 240 |
echo 'let v="$(LEMVERSION)"' >> src/version.ml |
| 241 |
|
| 242 |
share_directory: |
| 243 |
echo "(* Generated file -- do not edit. *)" > src/share_directory.ml |
| 244 |
echo let d=\"$(INSTALL_DIR)/share/lem\" >> src/share_directory.ml |
| 245 |
|
| 246 |
|
| 247 |
distrib: src/ast.ml version |
| 248 |
rm -rf $(DDIR) |
| 249 |
rm -rf $(DDIR).tar.gz |
| 250 |
mkdir $(DDIR) |
| 251 |
mkdir $(DDIR)/src |
| 252 |
mkdir $(DDIR)/src/ulib |
| 253 |
cp src/*.ml $(DDIR)/src/ |
| 254 |
chmod a+w $(DDIR)/src/ast.ml |
| 255 |
chmod a+w $(DDIR)/src/version.ml |
| 256 |
cp src/*.mli $(DDIR)/src/ |
| 257 |
cp src/*.mll $(DDIR)/src/ |
| 258 |
cp src/*.mly $(DDIR)/src/ |
| 259 |
cp src/_tags $(DDIR)/src/ |
| 260 |
cp src/ulib/*.ml $(DDIR)/src/ulib/ |
| 261 |
cp src/ulib/*.mli $(DDIR)/src/ulib/ |
| 262 |
mkdir $(DDIR)/library |
| 263 |
mkdir $(DDIR)/library/hol |
| 264 |
mkdir $(DDIR)/library/isabelle |
| 265 |
mkdir $(DDIR)/library/ocaml |
| 266 |
cp library/*.lem $(DDIR)/library/ |
| 267 |
cp library/isabelle/constants $(DDIR)/library/isabelle/ |
| 268 |
cp library/isabelle/*.lem $(DDIR)/library/isabelle/ |
| 269 |
cp library/hol/constants $(DDIR)/library/hol/ |
| 270 |
cp library/hol/*.lem $(DDIR)/library/hol/ |
| 271 |
cp library/ocaml/*.lem $(DDIR)/library/ocaml/ |
| 272 |
mkdir $(DDIR)/ocaml-lib |
| 273 |
cp ocaml-lib/*.ml $(DDIR)/ocaml-lib |
| 274 |
cp ocaml-lib/*.mli $(DDIR)/ocaml-lib |
| 275 |
cp ocaml-lib/*.mllib $(DDIR)/ocaml-lib |
| 276 |
cp ocaml-lib/Makefile $(DDIR)/ocaml-lib |
| 277 |
mkdir $(DDIR)/tex-lib |
| 278 |
cp tex-lib/lem.sty $(DDIR)/tex-lib |
| 279 |
cp Makefile-distrib $(DDIR)/Makefile |
| 280 |
cp src/Makefile-distrib $(DDIR)/src/Makefile |
| 281 |
cp README $(DDIR) |
| 282 |
cp LICENSE $(DDIR) |
| 283 |
headache -h header `ls $(DDIR)/src/*.ml` |
| 284 |
headache -h header `ls $(DDIR)/src/*.mli` |
| 285 |
headache -h header `ls $(DDIR)/src/*.mly` |
| 286 |
headache -h header `ls $(DDIR)/src/*.mll` |
| 287 |
headache -c head_config -h header `ls $(DDIR)/tex-lib/*.sty` |
| 288 |
headache -c head_config -h header `ls $(DDIR)/library/*.lem` |
| 289 |
headache -c head_config -h header `ls $(DDIR)/library/hol/*.lem` |
| 290 |
headache -c head_config -h header `ls $(DDIR)/library/isabelle/*.lem` |
| 291 |
headache -c head_config -h header `ls $(DDIR)/library/ocaml/*.lem` |
| 292 |
tar cf $(DDIR).tar $(DDIR) |
| 293 |
gzip $(DDIR).tar |
| 294 |
rm -rf $(DDIR) |
| 295 |
|
| 296 |
clean: |
| 297 |
-$(MAKE) -C language clean |
| 298 |
-$(MAKE) -C src clean |
| 299 |
-$(MAKE) -C coq-lib clean |
| 300 |
-$(MAKE) -C ocaml-lib clean |
| 301 |
-$(MAKE) -C tex-lib clean |
| 302 |
-rm -f coq-lib/Makefile |
| 303 |
-rm -f coq-lib/coqharness.vo |
| 304 |
-rm -f coq-lib/coqharness.glob |
| 305 |
-rm -rf src/version.ml lem library/lib_cache src/share_directory.ml |
| 306 |
#-rm -rf lem_dep.tex lem_dep.pdf lem_dep.aux lem_dep.log |
| 307 |
|
| 308 |
cleanall: clean |
| 309 |
-$(MAKE) -C doc clean |
| 310 |
-$(MAKE) -C slides clean |
| 311 |
-$(MAKE) -C manual cleanall |
| 312 |
-$(MAKE) -C ocaml-lib clean |
| 313 |
-$(MAKE) -C tests clean |
| 314 |
-rm -rf lem-$(LEMVERSION) lem-$(LEMVERSION).tar.gz |