From 968a81caeb2ab8402e54caa16c3cb3b423993d32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonin=20D=C3=A9cimo?= Date: Wed, 4 Feb 2026 18:51:50 +0100 Subject: [PATCH 1/2] Idiomatic use of LN_S in configure and Makefiles LN_S is the variable produced by Autoconf's AC_PROG_LN_S. It is less surprising, and more idiomatic to find this spelling than LN. https://www.gnu.org/software/autoconf/manual/autoconf-2.71/html_node/Particular-Programs.html#index-AC_005fPROG_005fLN_005fS-1 --- Makefile | 28 ++++++++++++++-------------- Makefile.build_config.in | 2 +- Makefile.common | 8 ++++---- Makefile.cross | 12 ++++++------ aclocal.m4 | 4 ++-- configure | 9 ++++----- configure.ac | 4 ++-- testsuite/in_prefix/Makefile.test | 4 ++-- tools/opam/generate.ml | 2 +- 9 files changed, 36 insertions(+), 37 deletions(-) diff --git a/Makefile b/Makefile index e79162992138..f0a0593424d8 100644 --- a/Makefile +++ b/Makefile @@ -718,7 +718,7 @@ coldstart: boot/ocamlrun$(EXE) runtime/libcamlrun.$(A) $(MAKE) -C stdlib OCAMLRUN='$$(ROOTDIR)/$<' USE_BOOT_OCAMLC=true all rm -f $(addprefix boot/, libcamlrun.$(A) $(LIBFILES)) cp $(addprefix stdlib/, $(LIBFILES)) boot - cd boot; $(LN) ../runtime/libcamlrun.$(A) . + cd boot && $(LN_S) ../runtime/libcamlrun.$(A) . # Recompile the core system using the bootstrap compiler .PHONY: coreall @@ -911,7 +911,7 @@ flexlink.opt$(EXE): \ flexlink.exe cp $(FLEXDLL_SOURCE_DIR)/flexlink.exe $@ rm -f $(OPT_BINDIR)/flexlink$(EXE) - cd $(OPT_BINDIR); $(LN) $(call ROOT_FROM, $(OPT_BINDIR))/$@ flexlink$(EXE) + cd $(OPT_BINDIR) && $(LN_S) $(call ROOT_FROM, $(OPT_BINDIR))/$@ flexlink$(EXE) else @@ -1102,7 +1102,7 @@ endif # to add otherlibs/dynlink/native to the search path as well otherlibs/dynlink/dynlink.cmx : otherlibs/dynlink/native/dynlink.cmx - cd otherlibs/dynlink; $(LN) native/dynlink.cmx . + cd otherlibs/dynlink && $(LN_S) native/dynlink.cmx . DYNLINK_DEPEND_DUMMY_FILES = \ otherlibs/dynlink/dynlink.ml \ @@ -1147,28 +1147,28 @@ beforedepend:: lambda/runtimedef.ml # Choose the right machine-dependent files asmcomp/arch.mli: asmcomp/$(ARCH)/arch.mli - @cd asmcomp; $(LN) $(ARCH)/arch.mli . + @cd asmcomp && $(LN_S) $(ARCH)/arch.mli . asmcomp/arch.ml: asmcomp/$(ARCH)/arch.ml - @cd asmcomp; $(LN) $(ARCH)/arch.ml . + @cd asmcomp && $(LN_S) $(ARCH)/arch.ml . asmcomp/proc.ml: asmcomp/$(ARCH)/proc.ml - @cd asmcomp; $(LN) $(ARCH)/proc.ml . + @cd asmcomp && $(LN_S) $(ARCH)/proc.ml . asmcomp/selection.ml: asmcomp/$(ARCH)/selection.ml - @cd asmcomp; $(LN) $(ARCH)/selection.ml . + @cd asmcomp && $(LN_S) $(ARCH)/selection.ml . asmcomp/CSE.ml: asmcomp/$(ARCH)/CSE.ml - @cd asmcomp; $(LN) $(ARCH)/CSE.ml . + @cd asmcomp && $(LN_S) $(ARCH)/CSE.ml . asmcomp/reload.ml: asmcomp/$(ARCH)/reload.ml - @cd asmcomp; $(LN) $(ARCH)/reload.ml . + @cd asmcomp && $(LN_S) $(ARCH)/reload.ml . asmcomp/scheduling.ml: asmcomp/$(ARCH)/scheduling.ml - @cd asmcomp; $(LN) $(ARCH)/scheduling.ml . + @cd asmcomp && $(LN_S) $(ARCH)/scheduling.ml . asmcomp/stackframe.ml: asmcomp/$(ARCH)/stackframe.ml - @cd asmcomp; $(LN) $(ARCH)/stackframe.ml . + @cd asmcomp && $(LN_S) $(ARCH)/stackframe.ml . # Preprocess the code emitters cvt_emit = tools/cvt_emit$(EXE) @@ -1693,7 +1693,7 @@ runtime: stdlib/libcamlrun.$(A) .PHONY: makeruntime makeruntime: runtime-all stdlib/libcamlrun.$(A): runtime-all - cd stdlib; $(LN) ../runtime/libcamlrun.$(A) . + cd stdlib && $(LN_S) ../runtime/libcamlrun.$(A) . clean:: rm -f $(addprefix runtime/, *.o *.obj *.a *.lib *.so *.dll) rm -f $(addprefix runtime/, ocamlrun ocamlrund ocamlruni ocamlruns sak) @@ -1711,9 +1711,9 @@ runtimeopt: stdlib/libasmrun.$(A) .PHONY: makeruntimeopt makeruntimeopt: runtime-allopt stdlib/libasmrun.$(A): runtime-allopt - cd stdlib; $(LN) ../runtime/libasmrun.$(A) . + cd stdlib && $(LN_S) ../runtime/libasmrun.$(A) . stdlib/libcomprmarsh.$(A): runtime/libcomprmarsh.$(A) - cd stdlib; $(LN) ../runtime/libcomprmarsh.$(A) . + cd stdlib && $(LN_S) ../runtime/libcomprmarsh.$(A) . clean:: rm -f stdlib/libasmrun.a stdlib/libasmrun.lib diff --git a/Makefile.build_config.in b/Makefile.build_config.in index e2fb0309e076..2e1d6f0a1e21 100644 --- a/Makefile.build_config.in +++ b/Makefile.build_config.in @@ -211,7 +211,7 @@ ZINC_RUNTIME_ID_HI = @zinc_runtime_id_hi@ ZINC_RUNTIME_ID = @zinc_runtime_id_lo@$(ZINC_RUNTIME_ID_HI) # Platform-dependent command to create symbolic links -LN = @ln@ +LN_S = @LN_S@ # Tool to generate manifests for managed assemblies and unmanaged side-by-side # assemblies, for the Windows targets. diff --git a/Makefile.common b/Makefile.common index a66fbcbda22e..cc7014ef8792 100644 --- a/Makefile.common +++ b/Makefile.common @@ -220,7 +220,7 @@ INSTALL_DESPATCH_install_MKDIR = \ MK_LINK = \ (cd "$(INSTALL_SECTION_$(2))$(addprefix /,$(3))" && \ - $(LN) $(call QUOTE_SINGLE,$(1)) $(call QUOTE_SINGLE,$(4))) + $(LN_S) $(call QUOTE_SINGLE,$(1)) $(call QUOTE_SINGLE,$(4))) INSTALL_DESPATCH_install_ITEM = \ $(INSTALL_CMD_$(2)) $(1) \ @@ -243,7 +243,7 @@ INSTALL_DESPATCH_display_MKDIR = \ -> MKDIR $(INSTALL_SECTION_$(1))$(addprefix /,$(2))) $(SH_AND) MKLINK_display = \ - echo $(call QUOTE_SINGLE,-> LN \ + echo $(call QUOTE_SINGLE,-> LN_S \ $(abspath $(INSTALL_SECTION_$(2))$(addprefix /,$(3))/$(1)) -> \ $(if $(4),$(4),$(notdir $(1)))) @@ -311,7 +311,7 @@ ADD_LINE = $(call INVOKE, echo, $(2)) >> $(1) # These can then be munged to a cd + ln combination in the fixup script. # If symlinks are not supported, $1 is instead used to create an additional copy # of the file, using the .install file. -ifeq "$(firstword $(LN))" "ln" +ifeq "$(firstword $(LN_S))" "ln" RECORD_SYMLINK_TO_INSTALL = \ $(call ADD_LINE, $(ROOTDIR)/create-symlinks, \ $(patsubst lib%,lib,$(2))$(addprefix /,$(3)) $(4) $(5)) @@ -402,7 +402,7 @@ INSTALL_DESPATCH_opam_BEGIN = \ # then munge clone-* and create-symlinks into the fixup script. INSTALL_DESPATCH_opam_END = \ $(OCAMLRUN) ./ocaml$(EXE) $(STDLIBFLAGS) \ - tools/opam/generate.ml $(INSTALL_MODE) $(OPAM_PACKAGE_NAME) '$(LN)' + tools/opam/generate.ml $(INSTALL_MODE) $(OPAM_PACKAGE_NAME) '$(LN_S)' # Generate $(OPAM_PACKAGE_NAME)-clone.sh (INSTALL_MODE=clone) diff --git a/Makefile.cross b/Makefile.cross index 71a15b0bd2ef..ba06974032dd 100644 --- a/Makefile.cross +++ b/Makefile.cross @@ -99,13 +99,13 @@ cross-flexdll: | $(BYTE_BINDIR) $(OPT_BINDIR) rm -f $(FLEXDLL_SOURCE_DIR)/flexlink.exe $(MAKE) -C $(FLEXDLL_SOURCE_DIR) $(FLEXLINK_BUILD_ENV) \ NATDYNLINK=false LINKFLAGS= flexlink.exe support - $(LN) $(FLEXDLL_SOURCE_DIR)/flexlink.exe flexlink.opt.exe - $(LN) flexlink.opt.exe flexlink.byte.exe + $(LN_S) $(FLEXDLL_SOURCE_DIR)/flexlink.exe flexlink.opt.exe + $(LN_S) flexlink.opt.exe flexlink.byte.exe cp flexlink.byte.exe $(BYTE_BINDIR)/flexlink - cd $(BYTE_BINDIR) && $(LN) flexlink flexlink.exe + cd $(BYTE_BINDIR) && $(LN_S) flexlink flexlink.exe cp $(addprefix $(FLEXDLL_SOURCE_DIR)/, $(FLEXDLL_OBJECTS)) $(ROOTDIR) cp flexlink.opt.exe $(OPT_BINDIR)/flexlink - cd $(OPT_BINDIR) && $(LN) flexlink flexlink.exe + cd $(OPT_BINDIR) && $(LN_S) flexlink flexlink.exe INSTALL_OVERRIDES=build_ocamldoc=false WITH_DEBUGGER= OCAMLRUN=ocamlrun @@ -116,7 +116,7 @@ installcross: $(addprefix toplevel/, \ $(foreach ext,cmi cmt cmti cmx, native/nat__dummy__.$(ext)) \ all__dummy__.cmx topstart.o native/tophooks.cmi) - $(LN) `command -v ocamllex` lex/ocamllex.opt$(EXE) - $(LN) `command -v ocamlyacc` yacc/ocamlyacc.opt$(EXE) + cd lex && $(LN_S) `command -v ocamllex` ocamllex.opt$(EXE) + cd yacc && $(LN_S) `command -v ocamlyacc` ocamlyacc.opt$(EXE) # Real installation $(MAKE) install $(INSTALL_OVERRIDES) diff --git a/aclocal.m4 b/aclocal.m4 index a1db7c2cc42d..c268dae9f70e 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -633,8 +633,8 @@ AC_DEFUN([OCAML_CHECK_LN_ON_WINDOWS], [ AS_IF([m4_normalize(MSYS=winsymlinks:nativestrict CYGWIN=winsymlinks:nativestrict ln -sf configure conftestLink 2>/dev/null)], - [ln='ln -sf'], - [ln='cp -pf'] + [LN_S='ln -sf'], + [LN_S='cp -pRf'] ) AC_MSG_RESULT([$ln]) ]) diff --git a/configure b/configure index 60be943b5ae1..c609beb0183b 100755 --- a/configure +++ b/configure @@ -756,7 +756,6 @@ ac_ct_AR DLLTOOL OBJDUMP FILECMD -LN_S NM ac_ct_DUMPBIN DUMPBIN @@ -925,7 +924,7 @@ syslib outputobj outputexe ocamlyacc_wstr_module -ln +LN_S unix_or_win32 ocamlsrcdir systhread_support @@ -15295,9 +15294,9 @@ case $cygwin_build_env,$host in #( printf %s "checking for a workable solution for ln -sf... " >&6; } if MSYS=winsymlinks:nativestrict CYGWIN=winsymlinks:nativestrict ln -sf configure conftestLink 2>/dev/null then : - ln='ln -sf' + LN_S='ln -sf' else $as_nop - ln='cp -pf' + LN_S='cp -pRf' fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ln" >&5 @@ -15305,7 +15304,7 @@ printf "%s\n" "$ln" >&6; } ocamlsrcdir="$(LC_ALL=C.UTF-8 cygpath -w -- "$srcdir_abs")" ;; #( *) : - ln='ln -sf' + LN_S='ln -sf' ocamlsrcdir="$srcdir_abs" ;; esac diff --git a/configure.ac b/configure.ac index 57f4d79b1d80..22436497b83d 100644 --- a/configure.ac +++ b/configure.ac @@ -164,7 +164,7 @@ AC_SUBST([oc_native_cppflags]) AC_SUBST([systhread_support]) AC_SUBST([ocamlsrcdir]) AC_SUBST([unix_or_win32]) -AC_SUBST([ln]) +AC_SUBST([LN_S]) AC_SUBST([ocamlyacc_wstr_module]) AC_SUBST([outputexe]) AC_SUBST([outputobj]) @@ -945,7 +945,7 @@ AS_CASE([$cygwin_build_env,$host], [true,*-w64-mingw32*|true,*-pc-windows], [OCAML_CHECK_LN_ON_WINDOWS ocamlsrcdir="$(LC_ALL=C.UTF-8 cygpath -w -- "$srcdir_abs")"], - [ln='ln -sf' + [LN_S='ln -sf' ocamlsrcdir="$srcdir_abs"]) # Whether ar supports @FILE arguments diff --git a/testsuite/in_prefix/Makefile.test b/testsuite/in_prefix/Makefile.test index 16ffe3a30dd6..a458ce4fb265 100644 --- a/testsuite/in_prefix/Makefile.test +++ b/testsuite/in_prefix/Makefile.test @@ -55,10 +55,10 @@ endif test-in-prefix: $(DRIVER) ../tools/main_in_c.$(O) ../tools/poisonedruntime$(EXE) @rm -f ocamlrun* - @$(LN) $(ROOTDIR)/runtime/ocamlrun$(EXE) test-$(RUNTIME_NAME) + @$(LN_S) $(ROOTDIR)/runtime/ocamlrun$(EXE) test-$(RUNTIME_NAME) @$(MKDIR) poisoned-runtime @cd poisoned-runtime \ - && $(LN) ../../tools/poisonedruntime$(EXE) $(RUNTIME_NAME) + && $(LN_S) ../../tools/poisonedruntime$(EXE) $(RUNTIME_NAME) @$< $(DRIVER_ARGS) @rm -rf poisoned-runtime @rm -f test-ocamlrun* diff --git a/tools/opam/generate.ml b/tools/opam/generate.ml index d0084d9b2ee8..d259b2eda237 100644 --- a/tools/opam/generate.ml +++ b/tools/opam/generate.ml @@ -18,7 +18,7 @@ Parameters are the following Makefile variables: $1 = $(INSTALL_MODE) (opam or clone) $2 = $(OPAM_PACKAGE_NAME) - $3 = $(LN) *) + $3 = $(LN_S) *) let exit_because fmt = Printf.ksprintf (fun s -> prerr_endline s; exit 1) fmt From 4c084008918b62093c3254169d67a4ee937ec542 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonin=20D=C3=A9cimo?= Date: Wed, 4 Feb 2026 18:52:29 +0100 Subject: [PATCH 2/2] Makefile.config: define AR rather than ARCMD, define ARFLAGS Both AR and ARFLAGS are GNU Make variables used by implicit rules and are commonly used to select a build toolchain, as in: ./configure AR=llvm-ar ARFLAGS=rcvs Deprecate ARCMD, which is not "standard". Export AR and ARFLAGS into Makefile.config. - https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html#index-AR - https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html#index-ARFLAGS --- Makefile.config.in | 7 ++++++- configure | 13 +++++++++++-- configure.ac | 8 ++++++-- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/Makefile.config.in b/Makefile.config.in index 9771c9a6fbd7..092fce6f6302 100644 --- a/Makefile.config.in +++ b/Makefile.config.in @@ -75,7 +75,8 @@ LDFLAGS?=@LDFLAGS@ CPP=@CPP@ ### How to invoke ar -ARCMD=@AR@ +AR=@AR@ +ARFLAGS=@ARFLAGS@ ### Extension of object files O=@OBJEXT@ @@ -226,6 +227,10 @@ NATIVE_RUNTIME_ID=@native_runtime_id@ # Deprecated variables +## Variables deprecated since OCaml 5.5 + +ARCMD=@AR@ + ## Variables deprecated since OCaml 5.3 OCAMLC_CFLAGS=@bytecode_cflags@ diff --git a/configure b/configure index c609beb0183b..9ed7fe1a0182 100755 --- a/configure +++ b/configure @@ -893,6 +893,7 @@ natdynlinkopts natdynlink supports_shared_libraries mklib +ARFLAGS AR launch_method_target launch_method @@ -1084,6 +1085,8 @@ enable_libtool_lock ac_precious_vars='build_alias host_alias target_alias +AR +ARFLAGS AS ASPP PARTIALLD @@ -1815,6 +1818,8 @@ Optional Packages: --with-odoc Some influential environment variables: + AR Archive-maintaining program + ARFLAGS Flags to give the archive-maintaining program AS which assembler to use ASPP which assembler (with preprocessor) to use PARTIALLD how to build partial (relocatable) object files @@ -3571,6 +3576,7 @@ LINEAR_MAGIC_NUMBER=Caml1999L038 + # TODO: rename this variable @@ -4064,6 +4070,8 @@ esac + + # Command-line arguments to configure # Check whether --enable-debug-runtime was given. @@ -15183,7 +15191,7 @@ case $target in #( # In config/Makefile.mingw*, we had: # TARGET=i686-w64-mingw32 and x86_64-w64-mingw32 # TOOLPREF=$(TARGET)- - # ARCMD=$(TOOLPREF)ar + # AR=$(TOOLPREF)ar # However autoconf and libtool seem to use ar # So we let them do, at the moment *-pc-windows) : @@ -15201,7 +15209,8 @@ fi ;; #( *) : - mklib="rm -f \$(1) && ${AR} rc \$(1) \$(2)" + : ${ARFLAGS:=rc} + mklib="rm -f \$(1) && ${AR} ${ARFLAGS} \$(1) \$(2)" ;; esac diff --git a/configure.ac b/configure.ac index 22436497b83d..1546b2670e30 100644 --- a/configure.ac +++ b/configure.ac @@ -198,6 +198,7 @@ AC_SUBST([shebangscripts]) AC_SUBST([launch_method]) AC_SUBST([launch_method_target]) AC_SUBST([AR]) +AC_SUBST([ARFLAGS]) AC_SUBST([mklib]) AC_SUBST([supports_shared_libraries]) AC_SUBST([natdynlink]) @@ -461,6 +462,8 @@ AS_CASE([$target], # Environment variables that are taken into account +AC_ARG_VAR([AR], [Archive-maintaining program]) +AC_ARG_VAR([ARFLAGS], [Flags to give the archive-maintaining program]) AC_ARG_VAR([AS], [which assembler to use]) AC_ARG_VAR([ASPP], [which assembler (with preprocessor) to use]) AC_ARG_VAR([PARTIALLD], [how to build partial (relocatable) object files]) @@ -881,7 +884,7 @@ AS_CASE([$target], # In config/Makefile.mingw*, we had: # TARGET=i686-w64-mingw32 and x86_64-w64-mingw32 # TOOLPREF=$(TARGET)- - # ARCMD=$(TOOLPREF)ar + # AR=$(TOOLPREF)ar # However autoconf and libtool seem to use ar # So we let them do, at the moment [*-pc-windows], @@ -895,7 +898,8 @@ AS_CASE([$target], mklib="link -lib -nologo $machine /out:\$(1) \$(2)" ], [ - mklib="rm -f \$(1) && ${AR} rc \$(1) \$(2)" + : ${ARFLAGS:=rc} + mklib="rm -f \$(1) && ${AR} ${ARFLAGS} \$(1) \$(2)" ]) ## In cross-compilation mode, can we run executables produced?