Skip to content

Commit

Permalink
Build system: simplify installation rules
Browse files Browse the repository at this point in the history
Now that programs are built with their $(EXE) suffix, their installation
rules can be simplified a bit because most of the programs get installed
under the name they have been built with.
  • Loading branch information
shindere committed Jun 17, 2020
1 parent d4987b6 commit 5dc4aba
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 32 deletions.
19 changes: 8 additions & 11 deletions Makefile
Expand Up @@ -353,7 +353,7 @@ install:
VERSION \
"$(INSTALL_LIBDIR)"
$(MAKE) -C runtime install
$(INSTALL_PROG) ocaml$(EXE) "$(INSTALL_BINDIR)/ocaml$(EXE)"
$(INSTALL_PROG) ocaml$(EXE) "$(INSTALL_BINDIR)"
ifeq "$(INSTALL_BYTECODE_PROGRAMS)" "true"
$(INSTALL_PROG) ocamlc$(EXE) "$(INSTALL_BINDIR)/ocamlc.byte$(EXE)"
endif
Expand All @@ -362,7 +362,7 @@ ifeq "$(INSTALL_BYTECODE_PROGRAMS)" "true"
$(INSTALL_PROG) lex/ocamllex$(EXE) \
"$(INSTALL_BINDIR)/ocamllex.byte$(EXE)"
endif
$(INSTALL_PROG) yacc/ocamlyacc$(EXE) "$(INSTALL_BINDIR)/ocamlyacc$(EXE)"
$(INSTALL_PROG) yacc/ocamlyacc$(EXE) "$(INSTALL_BINDIR)"
$(INSTALL_DATA) \
utils/*.cmi \
parsing/*.cmi \
Expand Down Expand Up @@ -391,7 +391,7 @@ endif
$(INSTALL_DATA) \
$(BYTESTART) $(TOPLEVELSTART) \
"$(INSTALL_COMPLIBDIR)"
$(INSTALL_PROG) $(expunge) "$(INSTALL_LIBDIR)/$(expunge)"
$(INSTALL_PROG) $(expunge) "$(INSTALL_LIBDIR)"
$(INSTALL_DATA) \
toplevel/topdirs.cmi \
"$(INSTALL_LIBDIR)"
Expand Down Expand Up @@ -420,7 +420,7 @@ ifeq "$(UNIX_OR_WIN32)" "win32"
$(MAKE) install-flexdll; \
fi
endif
$(INSTALL_DATA) Makefile.config "$(INSTALL_LIBDIR)/Makefile.config"
$(INSTALL_DATA) Makefile.config "$(INSTALL_LIBDIR)"
ifeq "$(INSTALL_BYTECODE_PROGRAMS)" "true"
if test -f ocamlopt$(EXE); then $(MAKE) installopt; else \
cd "$(INSTALL_BINDIR)"; \
Expand Down Expand Up @@ -511,11 +511,9 @@ endif

.PHONY: installoptopt
installoptopt:
$(INSTALL_PROG) ocamlc.opt$(EXE) "$(INSTALL_BINDIR)/ocamlc.opt$(EXE)"
$(INSTALL_PROG) ocamlopt.opt$(EXE) \
"$(INSTALL_BINDIR)/ocamlopt.opt$(EXE)"
$(INSTALL_PROG) \
lex/ocamllex.opt$(EXE) "$(INSTALL_BINDIR)/ocamllex.opt$(EXE)"
$(INSTALL_PROG) ocamlc.opt$(EXE) "$(INSTALL_BINDIR)"
$(INSTALL_PROG) ocamlopt.opt$(EXE) "$(INSTALL_BINDIR)"
$(INSTALL_PROG) lex/ocamllex.opt$(EXE) "$(INSTALL_BINDIR)"
cd "$(INSTALL_BINDIR)"; \
$(LN) ocamlc.opt$(EXE) ocamlc$(EXE); \
$(LN) ocamlopt.opt$(EXE) ocamlopt$(EXE); \
Expand All @@ -538,8 +536,7 @@ installoptopt:
$(OPTSTART:.cmo=.cmx) $(OPTSTART:.cmo=.$(O)) \
"$(INSTALL_COMPLIBDIR)"
if test -f ocamlnat$(EXE) ; then \
$(INSTALL_PROG) \
ocamlnat$(EXE) "$(INSTALL_BINDIR)/ocamlnat$(EXE)"; \
$(INSTALL_PROG) ocamlnat$(EXE) "$(INSTALL_BINDIR)"; \
$(INSTALL_DATA) \
toplevel/opttopdirs.cmi \
"$(INSTALL_LIBDIR)"; \
Expand Down
2 changes: 1 addition & 1 deletion debugger/Makefile
Expand Up @@ -60,7 +60,7 @@ ocamldebug$(EXE): $(libraries) $(all_objects)
$(CAMLC) $(LINKFLAGS) -o $@ -linkall $^

install:
$(INSTALL_PROG) ocamldebug$(EXE) "$(INSTALL_BINDIR)/ocamldebug$(EXE)"
$(INSTALL_PROG) ocamldebug$(EXE) "$(INSTALL_BINDIR)"

clean::
rm -f ocamldebug ocamldebug.exe
Expand Down
5 changes: 2 additions & 3 deletions ocamldoc/Makefile
Expand Up @@ -294,7 +294,7 @@ install:
$(MKDIR) "$(INSTALL_BINDIR)"
$(MKDIR) "$(INSTALL_LIBDIR)/ocamldoc"
$(MKDIR) "$(INSTALL_MANODIR)"
$(INSTALL_PROG) $(OCAMLDOC) "$(INSTALL_BINDIR)/$(OCAMLDOC)"
$(INSTALL_PROG) $(OCAMLDOC) "$(INSTALL_BINDIR)"
$(INSTALL_DATA) \
ocamldoc.hva *.cmi $(OCAMLDOC_LIBCMA) \
"$(INSTALL_LIBDIR)/ocamldoc"
Expand All @@ -321,8 +321,7 @@ installopt:
installopt_really:
$(MKDIR) "$(INSTALL_BINDIR)"
$(MKDIR) "$(INSTALL_LIBDIR)/ocamldoc"
$(INSTALL_PROG) \
$(OCAMLDOC_OPT) "$(INSTALL_BINDIR)/$(OCAMLDOC_OPT)"
$(INSTALL_PROG) $(OCAMLDOC_OPT) "$(INSTALL_BINDIR)"
$(INSTALL_DATA) \
$(OCAMLDOC_LIBCMIS) \
"$(INSTALL_LIBDIR)/ocamldoc"
Expand Down
5 changes: 2 additions & 3 deletions otherlibs/Makefile.otherlibs.common
Expand Up @@ -86,8 +86,7 @@ lib$(CLIBNAME).$(A): $(COBJS)
install::
if test -f dll$(CLIBNAME)$(EXT_DLL); then \
$(INSTALL_PROG) \
dll$(CLIBNAME)$(EXT_DLL) \
"$(INSTALL_STUBLIBDIR)/"; \
dll$(CLIBNAME)$(EXT_DLL) "$(INSTALL_STUBLIBDIR)"; \
fi
ifneq "$(STUBSLIB)" ""
$(INSTALL_DATA) $(STUBSLIB) "$(INSTALL_LIBDIR)/"
Expand All @@ -113,7 +112,7 @@ installopt:
"$(INSTALL_LIBDIR)/"
cd "$(INSTALL_LIBDIR)"; $(RANLIB) $(LIBNAME).a
if test -f $(LIBNAME).cmxs; then \
$(INSTALL_PROG) $(LIBNAME).cmxs "$(INSTALL_LIBDIR)/"; \
$(INSTALL_PROG) $(LIBNAME).cmxs "$(INSTALL_LIBDIR)"; \
fi

partialclean:
Expand Down
3 changes: 1 addition & 2 deletions otherlibs/dynlink/Makefile
Expand Up @@ -241,8 +241,7 @@ ifeq "$(INSTALL_SOURCE_ARTIFACTS)" "true"
dynlink.cmti dynlink.mli \
"$(INSTALL_LIBDIR)"
endif
$(INSTALL_PROG) \
$(extract_crc) "$(INSTALL_LIBDIR)/$(extract_crc)"
$(INSTALL_PROG) $(extract_crc) "$(INSTALL_LIBDIR)"

installopt:
if $(NATDYNLINK); then \
Expand Down
3 changes: 1 addition & 2 deletions otherlibs/systhreads/Makefile
Expand Up @@ -109,8 +109,7 @@ INSTALL_THREADSLIBDIR=$(INSTALL_LIBDIR)/$(LIBNAME)

install:
if test -f dllthreads$(EXT_DLL); then \
$(INSTALL_PROG) \
dllthreads$(EXT_DLL) "$(INSTALL_STUBLIBDIR)/dllthreads$(EXT_DLL)"; \
$(INSTALL_PROG) dllthreads$(EXT_DLL) "$(INSTALL_STUBLIBDIR)"; \
fi
$(INSTALL_DATA) libthreads.$(A) "$(INSTALL_LIBDIR)"
cd "$(INSTALL_LIBDIR)"; $(RANLIB) libthreads.$(A)
Expand Down
17 changes: 7 additions & 10 deletions tools/Makefile
Expand Up @@ -188,19 +188,18 @@ ifeq "$(INSTALL_BYTECODE_PROGRAMS)" "true"
do \
$(INSTALL_PROG) "$$i$(EXE)" "$(INSTALL_BINDIR)/$$i.byte$(EXE)"; \
if test -f "$$i".opt$(EXE); then \
$(INSTALL_PROG) "$$i.opt$(EXE)" \
"$(INSTALL_BINDIR)/$$i.opt$(EXE)" && \
(cd "$(INSTALL_BINDIR)/" && $(LN) "$$i.opt$(EXE)" "$$i$(EXE)"); \
$(INSTALL_PROG) "$$i.opt$(EXE)" "$(INSTALL_BINDIR)" && \
(cd "$(INSTALL_BINDIR)" && $(LN) "$$i.opt$(EXE)" "$$i$(EXE)"); \
else \
(cd "$(INSTALL_BINDIR)/" && $(LN) "$$i.byte$(EXE)" "$$i$(EXE)"); \
(cd "$(INSTALL_BINDIR)" && $(LN) "$$i.byte$(EXE)" "$$i$(EXE)"); \
fi; \
done
else
for i in $(install_files); \
do \
if test -f "$$i".opt$(EXE); then \
$(INSTALL_PROG) "$$i.opt$(EXE)" "$(INSTALL_BINDIR)/$$i.opt$(EXE)"; \
(cd "$(INSTALL_BINDIR)/" && $(LN) "$$i.opt$(EXE)" "$$i$(EXE)"); \
$(INSTALL_PROG) "$$i.opt$(EXE)" "$(INSTALL_BINDIR)"; \
(cd "$(INSTALL_BINDIR)" && $(LN) "$$i.opt$(EXE)" "$$i$(EXE)"); \
fi; \
done
endif
Expand Down Expand Up @@ -244,10 +243,9 @@ install::
$(INSTALL_PROG)\
ocamlcmt.opt$(EXE) "$(INSTALL_BINDIR)/ocamlcmt$(EXE)"; \
else \
$(INSTALL_PROG) ocamlcmt$(EXE) "$(INSTALL_BINDIR)/ocamlcmt$(EXE)"; \
$(INSTALL_PROG) ocamlcmt$(EXE) "$(INSTALL_BINDIR)"; \
fi


# The bytecode disassembler

DUMPOBJ= \
Expand Down Expand Up @@ -301,8 +299,7 @@ OBJINFO=$(ROOTDIR)/compilerlibs/ocamlcommon.cma \
$(call byte_and_opt,ocamlobjinfo,$(OBJINFO),objinfo_helper$(EXE))

install::
$(INSTALL_PROG) \
objinfo_helper$(EXE) "$(INSTALL_LIBDIR)/objinfo_helper$(EXE)"
$(INSTALL_PROG) objinfo_helper$(EXE) "$(INSTALL_LIBDIR)"

primreq=$(ROOTDIR)/compilerlibs/ocamlcommon.cma \
$(ROOTDIR)/compilerlibs/ocamlbytecomp.cma \
Expand Down

0 comments on commit 5dc4aba

Please sign in to comment.