Skip to content

Commit

Permalink
Install to lib/stublibs in legacy mode as well (#40)
Browse files Browse the repository at this point in the history
* Install to `lib`/`stublibs` in legacy mode too

* Generate the same META file for modern and legacy

* Unify `META.modern` & `META.legacy` into `META.num`

* Only install dllnums.so once

The switch will be configured to load dllnums.so from the switch
stublibs directory anyway and the compatibility is necessary for the cma
and cmxa to be in the stdlib directory, not for the stubs library.

---------

Co-authored-by: David Allsopp <[email protected]>
  • Loading branch information
Leonidas-from-XIV and dra27 authored Jun 26, 2024
1 parent a2b9a58 commit f6e31b1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
*.cmti
*.annot
src/META.top
src/META.modern
src/META.legacy
src/META.num
src/META
src/num_top*.ml*
test/test.byt
Expand Down
25 changes: 8 additions & 17 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ SOURCES_NUM_TOP=\
$(addsuffix .mli,$(MODULES_NUM_TOP)) $(addsuffix .ml,$(MODULES_NUM_TOP))
CMOS_NUM_TOP=$(addsuffix .cmo,$(MODULES_NUM_TOP))

all:: libnums.$(A) nums.cma num_top.cma META.legacy META.modern META.top \
all:: libnums.$(A) nums.cma num_top.cma META.num META.top \
num-legacy.install num-modern.install

ifeq "$(NATIVE_COMPILER)" "true"
Expand All @@ -42,16 +42,12 @@ META.top: META.num-top.in
echo 'version = "$(VERSION)"' > $@
cat $^ >> $@

META.%:
META.num:
@echo 'requires = "num.core"' > $@
@echo 'requires(toploop) = "num.core,num-top"' >> $@
@echo 'version = "$(VERSION)"' >> $@
@echo 'description = "Arbitrary-precision rational arithmetic"' >> $@
@echo 'package "core" (' >> $@
# META.legacy installs num to the OCaml standard library directory so requires
# the extra directory line. META.modern installs num as a standard findlib
# package.
@echo ' directory = "^"' >> $(if $(*:legacy=),/dev/null,$@)
@echo ' version = "$(VERSION)"' >> $@
@echo ' browse_interfaces = ""' >> $@
@echo ' archive(byte) = "nums.cma"' >> $@
Expand Down Expand Up @@ -118,14 +114,13 @@ TOINSTALL_NUM_TOP=num_top.cma $(addsuffix .cmi,$(MODULES_NUM_TOP))
# - num artefacts to ocaml/ (legacy only)
# libexec_root section
# - nums.cmxs (legacy only)
# - dllnums.so to ocaml/stublibs/ (legacy only)
# lib section:
# - num META file
# - num artefacts (modern only)
# - num artefacts
# libexec section:
# - nums.cmxs (modern only)
# stublibs section:
# - dllnums.so (modern only)
# - dllnums.so
define GENERATE_INSTALL_FILE
num-$1.install:
@echo 'lib_root: [' > $$@
Expand All @@ -139,13 +134,10 @@ $(foreach file,$(TOINSTALL),
@echo 'libexec_root: [' >> $$@
$(foreach file,$(TOINSTALL_CMXS),
@echo ' "src/$(file)" {"ocaml/$(file)"}' >> $$@)
$(foreach file,$(TOINSTALL_STUBS),
@echo ' "src/$(file)" {"ocaml/stublibs/$(file)"}' >> $$@)
endif
@echo ']' >> $$@
@echo 'lib: [' >> $$@
@echo ' "src/META.$(1)" {"META"}' >> $$@
ifeq "$(1)" "modern"
@echo ' "src/META.num" {"META"}' >> $$@
$(foreach file,$(TOINSTALL),
@echo ' "src/$(file)"' >> $$@)
@echo ']' >> $$@
Expand All @@ -156,7 +148,6 @@ $(foreach file,$(TOINSTALL_CMXS),
@echo 'stublibs: [' >> $$@
$(foreach file,$(TOINSTALL_STUBS),
@echo ' "src/$(file)"' >> $$@)
endif
@echo ']' >> $$@
endef

Expand All @@ -165,7 +156,7 @@ $(eval $(call GENERATE_INSTALL_FILE,modern))

install: num-top-install
$(INSTALL_DIR) $(DESTDIR)$(STDLIBDIR)
cp META.legacy META
cp META.num META
$(OCAMLFIND) install num META
rm -f META
$(INSTALL_DATA) $(TOINSTALL) $(DESTDIR)$(STDLIBDIR)
Expand All @@ -183,7 +174,7 @@ num-top-install:
rm -f META

findlib-install: num-top-install
cp META.modern META
cp META.num META
$(OCAMLFIND) install num META $(TOINSTALL) $(TOINSTALL_CMXS) $(TOINSTALL_STUBS)
rm -f META

Expand All @@ -201,7 +192,7 @@ endif

clean:
rm -f *.cm[ioxta] *.cmx[as] *.cmti *.$(O) *.$(A) *$(EXT_DLL) \
META.top META.legacy META.modern $(SOURCES_NUM_TOP) \
META.top META.num $(SOURCES_NUM_TOP) \
num-legacy.install num-modern.install

$(SOURCES_NUM_TOP:num_=%): $(addprefix ../toplevel/,$(SOURCES_NUM_TOP))
Expand Down

0 comments on commit f6e31b1

Please sign in to comment.