Add "make help" option
[openssl.git] / Configurations / unix-Makefile.tmpl
index a72fdd558b3339817c5ebe05b7ab2767ba1bd5fb..9dc8e18d64fe2f8aabb08e3b5138b056c9432904 100644 (file)
@@ -20,8 +20,9 @@
      # to. You're welcome.
      sub dependmagic {
          my $target = shift;
+         my $help = shift;
 
-         return "$target: build_generated\n\t\$(MAKE) depend && \$(MAKE) _$target\n_$target";
+         return "$target: build_generated ## $help\n\t\$(MAKE) depend && \$(MAKE) _$target\n_$target";
      }
 
      our $COLUMNS = $ENV{COLUMNS};
@@ -311,6 +312,14 @@ MODULESDIR=$(libdir)/ossl-modules
 # libraries and applications
 LIBRPATH=$(libdir)
 
+BINDIR={- our $bindir = $config{bindir};
+          unless ($bindir) {
+              $bindir = "bin$target{multibin}";
+          }
+          file_name_is_absolute($bindir) ? "" : $bindir -}
+bindir={- file_name_is_absolute($bindir)
+          ? $bindir : '$(INSTALLTOP)/$(BINDIR)' -}
+
 MANDIR=$(INSTALLTOP)/share/man
 DOCDIR=$(INSTALLTOP)/share/doc/$(BASENAME)
 HTMLDIR=$(DOCDIR)/html
@@ -496,15 +505,20 @@ LANG=C
 
 # The main targets ###################################################
 
-{- dependmagic('build_sw'); -}: build_libs_nodep build_modules_nodep build_programs_nodep link-utils
-{- dependmagic('build_libs'); -}: build_libs_nodep
-{- dependmagic('build_modules'); -}: build_modules_nodep
-{- dependmagic('build_programs'); -}: build_programs_nodep
+##@ Software
+
+{- dependmagic('build_sw', 'Build all the software (default target)'); -}: build_libs_nodep build_modules_nodep build_programs_nodep link-utils
+{- dependmagic('build_libs', 'Build the libraries libssl and libcrypto'); -}: build_libs_nodep
+{- dependmagic('build_modules', 'Build the modules (i.e. providers and engines)'); -}: build_modules_nodep
+{- dependmagic('build_programs', 'Build the openssl executables and scripts'); -}: build_programs_nodep
+
+all: build_sw build_docs ## Build software and documentation
 
+##@ Documentation
 build_generated_pods: $(GENERATED_PODS)
-build_docs: build_man_docs build_html_docs
-build_man_docs: $(MANDOCS1) $(MANDOCS3) $(MANDOCS5) $(MANDOCS7)
-build_html_docs: $(HTMLDOCS1) $(HTMLDOCS3) $(HTMLDOCS5) $(HTMLDOCS7)
+build_docs: build_man_docs build_html_docs ## Create documentation
+build_man_docs: $(MANDOCS1) $(MANDOCS3) $(MANDOCS5) $(MANDOCS7) ## Create manpages
+build_html_docs: $(HTMLDOCS1) $(HTMLDOCS3) $(HTMLDOCS5) $(HTMLDOCS7) ## Create HTML documentation
 
 build_generated: $(GENERATED_MANDATORY)
 build_libs_nodep: libcrypto.pc libssl.pc openssl.pc
@@ -523,10 +537,14 @@ build_all_generated: $(GENERATED_MANDATORY) $(GENERATED) build_docs
        @echo "         then make will fail..."
        @ : {- output_on() if $disabled{makedepend}; "" -}
 
-all: build_sw build_docs
+##@ Help
+.PHONY: help
+help: ## Show this help screen
+       @$(PERL) $(SRCDIR)/util/help.pl $(BLDDIR)/Makefile
 
-test: tests
-{- dependmagic('tests'); -}: build_programs_nodep build_modules_nodep link-utils run_tests
+##@ Testing
+test: tests ## Run tests (alias of "tests")
+{- dependmagic('tests', 'Run tests'); -}: build_programs_nodep build_modules_nodep link-utils run_tests
 run_tests:
        @ : {- output_off() if $disabled{tests}; "" -}
        ( SRCTOP=$(SRCDIR) \
@@ -539,16 +557,14 @@ run_tests:
        @echo "Tests are not supported with your chosen Configure options"
        @ : {- output_on() if !$disabled{tests}; "" -}
 
-list-tests:
+list-tests: ## List available tests that can be invoked via "make test TESTS=<name>"
        @ : {- output_off() if $disabled{tests}; "" -}
        $(MAKE) run_tests TESTS=list
        @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
        @echo "Tests are not supported with your chosen Configure options"
        @ : {- output_on() if !$disabled{tests}; "" -}
 
-install: install_sw install_ssldirs install_docs {- $disabled{fips} ? "" : "install_fips" -}
-
-uninstall: uninstall_docs uninstall_sw {- $disabled{fips} ? "" : "uninstall_fips" -}
+##@ Workspace cleaning
 
 libclean:
        @set -e; for s in $(SHLIB_INFO); do \
@@ -573,7 +589,7 @@ libclean:
        $(RM) $(LIBS)
        $(RM) *{- platform->defext() -}
 
-clean: libclean
+clean: libclean ## Clean the workspace, keep the configuration
        $(RM) $(HTMLDOCS1)
        $(RM) $(HTMLDOCS3)
        $(RM) $(HTMLDOCS5)
@@ -593,7 +609,7 @@ clean: libclean
        $(RM) openssl.pc libcrypto.pc libssl.pc
        -find . -type l \! -name '.*' -exec $(RM) {} \;
 
-distclean: clean
+distclean: clean ## Clean and remove the configuration
        $(RM) include/openssl/configuration.h
        $(RM) configdata.pm
        $(RM) Makefile
@@ -606,14 +622,19 @@ depend: Makefile
        @: {- output_on() if $disabled{makedepend}; "" -}
 
 # Install helper targets #############################################
+##@ Installation
+
+install: install_sw install_ssldirs install_docs {- $disabled{fips} ? "" : "install_fips" -} ## Install software and documentation, create OpenSSL directories
+
+uninstall: uninstall_docs uninstall_sw {- $disabled{fips} ? "" : "uninstall_fips" -} ## Uninstall software and documentation
 
-install_sw: install_dev install_engines install_modules install_runtime
+install_sw: install_dev install_engines install_modules install_runtime ## Install just the software and libraries
 
-uninstall_sw: uninstall_runtime uninstall_modules uninstall_engines uninstall_dev
+uninstall_sw: uninstall_runtime uninstall_modules uninstall_engines uninstall_dev ## Uninstall the software and libraries
 
-install_docs: install_man_docs install_html_docs
+install_docs: install_man_docs install_html_docs ## Install manpages and HTML documentation
 
-uninstall_docs: uninstall_man_docs uninstall_html_docs
+uninstall_docs: uninstall_man_docs uninstall_html_docs ## Uninstall manpages and HTML documentation
        $(RM) -r $(DESTDIR)$(DOCDIR)
 
 {- output_off() if $disabled{fips}; "" -}
@@ -871,18 +892,18 @@ install_runtime_libs: build_libs
        @ : {- output_off() if windowsdll(); "" -}
        @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)
        @ : {- output_on() if windowsdll(); output_off() unless windowsdll(); "" -}
-       @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin
+       @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(bindir)/
        @ : {- output_on() unless windowsdll(); "" -}
        @$(ECHO) "*** Installing runtime libraries"
        @set -e; for s in dummy $(INSTALL_SHLIBS); do \
                if [ "$$s" = "dummy" ]; then continue; fi; \
                fn=`basename $$s`; \
                : {- output_off() unless windowsdll(); "" -}; \
-               $(ECHO) "install $$s -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
-               cp $$s $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
-               chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
-               mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
-                     $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
+               $(ECHO) "install $$s -> $(DESTDIR)$(bindir)/$$fn"; \
+               cp $$s $(DESTDIR)$(bindir)/$$fn.new; \
+               chmod 755 $(DESTDIR)$(bindir)/$$fn.new; \
+               mv -f $(DESTDIR)$(bindir)/$$fn.new \
+                     $(DESTDIR)$(bindir)/$$fn; \
                : {- output_on() unless windowsdll(); "" -}{- output_off() if windowsdll(); "" -}; \
                $(ECHO) "install $$s -> $(DESTDIR)$(libdir)/$$fn"; \
                cp $$s $(DESTDIR)$(libdir)/$$fn.new; \
@@ -894,25 +915,25 @@ install_runtime_libs: build_libs
 
 install_programs: install_runtime_libs build_programs
        @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
-       @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin
+       @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(bindir)
        @$(ECHO) "*** Installing runtime programs"
        @set -e; for x in dummy $(INSTALL_PROGRAMS); do \
                if [ "$$x" = "dummy" ]; then continue; fi; \
                fn=`basename $$x`; \
-               $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
-               cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
-               chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
-               mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
-                     $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
+               $(ECHO) "install $$x -> $(DESTDIR)$(bindir)/$$fn"; \
+               cp $$x $(DESTDIR)$(bindir)/$$fn.new; \
+               chmod 755 $(DESTDIR)$(bindir)/$$fn.new; \
+               mv -f $(DESTDIR)$(bindir)/$$fn.new \
+                     $(DESTDIR)$(bindir)/$$fn; \
        done
        @set -e; for x in dummy $(BIN_SCRIPTS); do \
                if [ "$$x" = "dummy" ]; then continue; fi; \
                fn=`basename $$x`; \
-               $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
-               cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
-               chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
-               mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
-                     $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
+               $(ECHO) "install $$x -> $(DESTDIR)$(bindir)/$$fn"; \
+               cp $$x $(DESTDIR)$(bindir)/$$fn.new; \
+               chmod 755 $(DESTDIR)$(bindir)/$$fn.new; \
+               mv -f $(DESTDIR)$(bindir)/$$fn.new \
+                     $(DESTDIR)$(bindir)/$$fn; \
        done
 
 uninstall_runtime: uninstall_programs uninstall_runtime_libs
@@ -923,17 +944,17 @@ uninstall_programs:
        do  \
                if [ "$$x" = "dummy" ]; then continue; fi; \
                fn=`basename $$x`; \
-               $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
-               $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
+               $(ECHO) "$(RM) $(DESTDIR)$(bindir)/$$fn"; \
+               $(RM) $(DESTDIR)$(bindir)/$$fn; \
        done;
        @set -e; for x in dummy $(BIN_SCRIPTS); \
        do  \
                if [ "$$x" = "dummy" ]; then continue; fi; \
                fn=`basename $$x`; \
-               $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
-               $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
+               $(ECHO) "$(RM) $(DESTDIR)$(bindir)/$$fn"; \
+               $(RM) $(DESTDIR)$(bindir)/$$fn; \
        done
-       -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/bin
+       -$(RMDIR) $(DESTDIR)$(bindir)
 
 uninstall_runtime_libs:
        @$(ECHO) "*** Uninstalling runtime libraries"
@@ -941,8 +962,8 @@ uninstall_runtime_libs:
        @set -e; for s in dummy $(INSTALL_SHLIBS); do \
                if [ "$$s" = "dummy" ]; then continue; fi; \
                fn=`basename $$s`; \
-               $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
-               $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
+               $(ECHO) "$(RM) $(DESTDIR)$(bindir)/$$fn"; \
+               $(RM) $(DESTDIR)$(bindir)/$$fn; \
        done
        @ : {- output_on() unless windowsdll(); "" -}
 
@@ -1100,10 +1121,11 @@ uninstall_image_docs:
        done
 
 # Developer targets (note: these are only available on Unix) #########
+##@ Code maintenence
 
 # It's important that generate_buildinfo comes after ordinals, as ordinals
 # is sensitive to build.info changes.
-update: generate errors ordinals generate_buildinfo
+update: generate errors ordinals generate_buildinfo ## Update errors, ordinals and build info
 
 .PHONY: generate generate_apps generate_crypto_bn generate_crypto_objects \
           generate_crypto_conf generate_crypto_asn1 generate_fuzz_oids
@@ -1114,7 +1136,7 @@ generate: generate_apps generate_crypto_bn generate_crypto_objects \
 generate_buildinfo: generate_doc_buildinfo
 
 .PHONY: doc-nits md-nits
-doc-nits: build_generated_pods
+doc-nits: build_generated_pods ## Evaluate OpenSSL documentation
        $(PERL) $(SRCDIR)/util/find-doc-nits -c -n -l -e
 
 # This uses "mdl", the markdownlint application, which is written in ruby.
@@ -1123,7 +1145,7 @@ doc-nits: build_generated_pods
 # Another option is at https://snapcraft.io/install/mdl/debian
 # Finally, there's a Node.js version, which we haven't tried, that
 # can be found at https://github.com/DavidAnson/markdownlint
-md-nits:
+md-nits: ## Evaluate markdown files via "mdl"
        mdl -s util/markdownlint.rb .
 
 # Test coverage is a good idea for the future
@@ -1131,13 +1153,13 @@ md-nits:
 #      ...
 
 .PHONY: lint
-lint:
+lint: ## Evaluate C code via "splint"
        @( cd $(SRCDIR); \
            echo splint -DLINT -posixlib -preproc -D__gnuc_va_list=void \
           -I. -Iinclude -Iapps/include $(CRYPTOHEADERS) $(SSLHEADERS) $(SRCS) )
 
 .PHONY: check-format
-check-format:
+check-format: ## Evaluate C code according to OpenSSL coding standards
        ( cd $(SRCDIR); $(PERL) util/check-format.pl \
                        $(SRCS) \$(CRYPTOHEADERS) $(SSLHEADERS) )