Skip to content

Commit d108082

Browse files
tmshortpaulidale
authored andcommitted
Add "make help" option
Based on kubernetes controller Makefile help. Reviewed-by: Richard Levitte <[email protected]> Reviewed-by: Paul Dale <[email protected]> (Merged from openssl#20407)
1 parent 08a11ba commit d108082

File tree

3 files changed

+67
-26
lines changed

3 files changed

+67
-26
lines changed

.github/workflows/ci.yml

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ jobs:
5151
run: make -s build_generated
5252
- name: make doc-nits
5353
run: make doc-nits
54+
- name: make help
55+
run: make help
5456
- name: make md-nits
5557
run: |
5658
sudo gem install mdl

Configurations/unix-Makefile.tmpl

+40-26
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@
2020
# to. You're welcome.
2121
sub dependmagic {
2222
my $target = shift;
23+
my $help = shift;
2324

24-
return "$target: build_generated\n\t\$(MAKE) depend && \$(MAKE) _$target\n_$target";
25+
return "$target: build_generated ## $help\n\t\$(MAKE) depend && \$(MAKE) _$target\n_$target";
2526
}
2627

2728
our $COLUMNS = $ENV{COLUMNS};
@@ -504,15 +505,20 @@ LANG=C
504505

505506
# The main targets ###################################################
506507

507-
{- dependmagic('build_sw'); -}: build_libs_nodep build_modules_nodep build_programs_nodep link-utils
508-
{- dependmagic('build_libs'); -}: build_libs_nodep
509-
{- dependmagic('build_modules'); -}: build_modules_nodep
510-
{- dependmagic('build_programs'); -}: build_programs_nodep
508+
##@ Software
511509

510+
{- dependmagic('build_sw', 'Build all the software (default target)'); -}: build_libs_nodep build_modules_nodep build_programs_nodep link-utils
511+
{- dependmagic('build_libs', 'Build the libraries libssl and libcrypto'); -}: build_libs_nodep
512+
{- dependmagic('build_modules', 'Build the modules (i.e. providers and engines)'); -}: build_modules_nodep
513+
{- dependmagic('build_programs', 'Build the openssl executables and scripts'); -}: build_programs_nodep
514+
515+
all: build_sw build_docs ## Build software and documentation
516+
517+
##@ Documentation
512518
build_generated_pods: $(GENERATED_PODS)
513-
build_docs: build_man_docs build_html_docs
514-
build_man_docs: $(MANDOCS1) $(MANDOCS3) $(MANDOCS5) $(MANDOCS7)
515-
build_html_docs: $(HTMLDOCS1) $(HTMLDOCS3) $(HTMLDOCS5) $(HTMLDOCS7)
519+
build_docs: build_man_docs build_html_docs ## Create documentation
520+
build_man_docs: $(MANDOCS1) $(MANDOCS3) $(MANDOCS5) $(MANDOCS7) ## Create manpages
521+
build_html_docs: $(HTMLDOCS1) $(HTMLDOCS3) $(HTMLDOCS5) $(HTMLDOCS7) ## Create HTML documentation
516522

517523
build_generated: $(GENERATED_MANDATORY)
518524
build_libs_nodep: libcrypto.pc libssl.pc openssl.pc
@@ -531,10 +537,14 @@ build_all_generated: $(GENERATED_MANDATORY) $(GENERATED) build_docs
531537
@echo " then make will fail..."
532538
@ : {- output_on() if $disabled{makedepend}; "" -}
533539

534-
all: build_sw build_docs
540+
##@ Help
541+
.PHONY: help
542+
help: ## Show this help screen
543+
@$(PERL) $(SRCDIR)/util/help.pl $(BLDDIR)/Makefile
535544

536-
test: tests
537-
{- dependmagic('tests'); -}: build_programs_nodep build_modules_nodep link-utils run_tests
545+
##@ Testing
546+
test: tests ## Run tests (alias of "tests")
547+
{- dependmagic('tests', 'Run tests'); -}: build_programs_nodep build_modules_nodep link-utils run_tests
538548
run_tests:
539549
@ : {- output_off() if $disabled{tests}; "" -}
540550
( SRCTOP=$(SRCDIR) \
@@ -547,16 +557,14 @@ run_tests:
547557
@echo "Tests are not supported with your chosen Configure options"
548558
@ : {- output_on() if !$disabled{tests}; "" -}
549559

550-
list-tests:
560+
list-tests: ## List available tests that can be invoked via "make test TESTS=<name>"
551561
@ : {- output_off() if $disabled{tests}; "" -}
552562
$(MAKE) run_tests TESTS=list
553563
@ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
554564
@echo "Tests are not supported with your chosen Configure options"
555565
@ : {- output_on() if !$disabled{tests}; "" -}
556566

557-
install: install_sw install_ssldirs install_docs {- $disabled{fips} ? "" : "install_fips" -}
558-
559-
uninstall: uninstall_docs uninstall_sw {- $disabled{fips} ? "" : "uninstall_fips" -}
567+
##@ Workspace cleaning
560568

561569
libclean:
562570
@set -e; for s in $(SHLIB_INFO); do \
@@ -581,7 +589,7 @@ libclean:
581589
$(RM) $(LIBS)
582590
$(RM) *{- platform->defext() -}
583591

584-
clean: libclean
592+
clean: libclean ## Clean the workspace, keep the configuration
585593
$(RM) $(HTMLDOCS1)
586594
$(RM) $(HTMLDOCS3)
587595
$(RM) $(HTMLDOCS5)
@@ -601,7 +609,7 @@ clean: libclean
601609
$(RM) openssl.pc libcrypto.pc libssl.pc
602610
-find . -type l \! -name '.*' -exec $(RM) {} \;
603611

604-
distclean: clean
612+
distclean: clean ## Clean and remove the configuration
605613
$(RM) include/openssl/configuration.h
606614
$(RM) configdata.pm
607615
$(RM) Makefile
@@ -614,14 +622,19 @@ depend: Makefile
614622
@: {- output_on() if $disabled{makedepend}; "" -}
615623

616624
# Install helper targets #############################################
625+
##@ Installation
626+
627+
install: install_sw install_ssldirs install_docs {- $disabled{fips} ? "" : "install_fips" -} ## Install software and documentation, create OpenSSL directories
628+
629+
uninstall: uninstall_docs uninstall_sw {- $disabled{fips} ? "" : "uninstall_fips" -} ## Uninstall software and documentation
617630

618-
install_sw: install_dev install_engines install_modules install_runtime
631+
install_sw: install_dev install_engines install_modules install_runtime ## Install just the software and libraries
619632

620-
uninstall_sw: uninstall_runtime uninstall_modules uninstall_engines uninstall_dev
633+
uninstall_sw: uninstall_runtime uninstall_modules uninstall_engines uninstall_dev ## Uninstall the software and libraries
621634

622-
install_docs: install_man_docs install_html_docs
635+
install_docs: install_man_docs install_html_docs ## Install manpages and HTML documentation
623636

624-
uninstall_docs: uninstall_man_docs uninstall_html_docs
637+
uninstall_docs: uninstall_man_docs uninstall_html_docs ## Uninstall manpages and HTML documentation
625638
$(RM) -r $(DESTDIR)$(DOCDIR)
626639

627640
{- output_off() if $disabled{fips}; "" -}
@@ -1108,10 +1121,11 @@ uninstall_image_docs:
11081121
done
11091122

11101123
# Developer targets (note: these are only available on Unix) #########
1124+
##@ Code maintenence
11111125

11121126
# It's important that generate_buildinfo comes after ordinals, as ordinals
11131127
# is sensitive to build.info changes.
1114-
update: generate errors ordinals generate_buildinfo
1128+
update: generate errors ordinals generate_buildinfo ## Update errors, ordinals and build info
11151129

11161130
.PHONY: generate generate_apps generate_crypto_bn generate_crypto_objects \
11171131
generate_crypto_conf generate_crypto_asn1 generate_fuzz_oids
@@ -1122,7 +1136,7 @@ generate: generate_apps generate_crypto_bn generate_crypto_objects \
11221136
generate_buildinfo: generate_doc_buildinfo
11231137

11241138
.PHONY: doc-nits md-nits
1125-
doc-nits: build_generated_pods
1139+
doc-nits: build_generated_pods ## Evaluate OpenSSL documentation
11261140
$(PERL) $(SRCDIR)/util/find-doc-nits -c -n -l -e
11271141

11281142
# This uses "mdl", the markdownlint application, which is written in ruby.
@@ -1131,21 +1145,21 @@ doc-nits: build_generated_pods
11311145
# Another option is at https://snapcraft.io/install/mdl/debian
11321146
# Finally, there's a Node.js version, which we haven't tried, that
11331147
# can be found at https://github.com/DavidAnson/markdownlint
1134-
md-nits:
1148+
md-nits: ## Evaluate markdown files via "mdl"
11351149
mdl -s util/markdownlint.rb .
11361150

11371151
# Test coverage is a good idea for the future
11381152
#coverage: $(PROGRAMS) $(TESTPROGRAMS)
11391153
# ...
11401154

11411155
.PHONY: lint
1142-
lint:
1156+
lint: ## Evaluate C code via "splint"
11431157
@( cd $(SRCDIR); \
11441158
echo splint -DLINT -posixlib -preproc -D__gnuc_va_list=void \
11451159
-I. -Iinclude -Iapps/include $(CRYPTOHEADERS) $(SSLHEADERS) $(SRCS) )
11461160

11471161
.PHONY: check-format
1148-
check-format:
1162+
check-format: ## Evaluate C code according to OpenSSL coding standards
11491163
( cd $(SRCDIR); $(PERL) util/check-format.pl \
11501164
$(SRCS) \$(CRYPTOHEADERS) $(SSLHEADERS) )
11511165

util/help.pl

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#! /usr/bin/env perl
2+
# Copyright 2023 The OpenSSL Project Authors. All Rights Reserved.
3+
#
4+
# Licensed under the Apache License 2.0 (the "License"). You may not use
5+
# this file except in compliance with the License. You can obtain a copy
6+
# in the file LICENSE in the source distribution or at
7+
# https://www.openssl.org/source/license.html
8+
9+
die "No input files" if scalar @ARGV == 0;
10+
$FS = ':.*##';
11+
printf "\nUsage:\n make <OPTIONS> \033[36m<target>\033[0m\n";
12+
13+
while (<>) {
14+
chomp; # strip record separator
15+
@Fld = split($FS, $_, -1);
16+
if (/^[a-zA-Z0-9_\-]+:.*?##/) {
17+
printf " \033[36m%-15s\033[0m %s\n", $Fld[0], $Fld[1]
18+
}
19+
if (/^##@/) {
20+
printf "\n\033[1m%s\033[0m\n", substr($Fld[$_], (5)-1);
21+
}
22+
}
23+
24+
printf "\nNote: This list is not all-inclusive\n";
25+

0 commit comments

Comments
 (0)