[osinfo-db-tools PATCH 6/8] Support `make syntax-check` without Makefile

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



A few dirty hacks have been done in GNUmakefile, cfg.mk, and maint.mk in
order to support running `make syntax-check` without having to have a
Makefile around.

GNUmakefile: set srcdir & top_srcdir and remove the parts that would
cause an error due to no presence of a Makefile.

cfg.mk: replace $(SED) by sed as $(SED) is set in the Makefile after
running ./configure.

maint.mk: add sc_prohibit_always-defined_macros to the list of local
checks to skip as it looks for Makefile, which is generated after
running ./configure.

Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx>
---
 GNUmakefile | 28 ++--------------------------
 cfg.mk      |  3 ++-
 maint.mk    | 32 ++++++++++++++++----------------
 3 files changed, 20 insertions(+), 43 deletions(-)

diff --git a/GNUmakefile b/GNUmakefile
index ca88b6b..a62b880 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -30,10 +30,8 @@ else
 SHELL = sh
 endif
 
-# If the user runs GNU make but has not yet run ./configure,
-# give them a diagnostic.
-_have-Makefile := $(shell test -f Makefile && echo yes)
-ifeq ($(_have-Makefile),yes)
+srcdir = .
+top_srcdir = .
 
 # Make tar archive easier to reproduce.
 export TAR_OPTIONS = --owner=0 --group=0 --numeric-owner
@@ -41,8 +39,6 @@ export TAR_OPTIONS = --owner=0 --group=0 --numeric-owner
 # Allow the user to add to this in the Makefile.
 ALL_RECURSIVE_TARGETS =
 
-include Makefile
-
 # Some projects override e.g., _autoreconf here.
 -include $(srcdir)/cfg.mk
 
@@ -94,26 +90,6 @@ _version:
 	cd $(srcdir) && rm -rf autom4te.cache .version && $(_autoreconf)
 	$(MAKE) $(AM_MAKEFLAGS) Makefile
 
-else
-
-.DEFAULT_GOAL := abort-due-to-no-makefile
-srcdir = .
-
-# The package can override .DEFAULT_GOAL to run actions like autoreconf.
--include ./cfg.mk
-include ./maint.mk
-
-ifeq ($(.DEFAULT_GOAL),abort-due-to-no-makefile)
-$(MAKECMDGOALS): abort-due-to-no-makefile
-endif
-
-abort-due-to-no-makefile:
-	@echo There seems to be no Makefile in this directory.   1>&2
-	@echo "You must run ./configure before running \`make'." 1>&2
-	@exit 1
-
-endif
-
 # Tell version 3.79 and up of GNU make to not build goals in this
 # directory in parallel, in case someone tries to build multiple
 # targets, and one of them can cause a recursive target to be invoked.
diff --git a/cfg.mk b/cfg.mk
index caa62ac..2ff9b03 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -35,7 +35,8 @@ local-checks-to-skip =			\
   sc_program_name			\
   sc_makefile_check			\
   sc_require_config_h			\
-  sc_require_config_h_first
+  sc_require_config_h_first		\
+  sc_prohibit_always-defined_macros
 
 # Files that should never cause syntax check failures.
 VC_LIST_ALWAYS_EXCLUDE_REGEX = \
diff --git a/maint.mk b/maint.mk
index 04a839a..035d2ac 100644
--- a/maint.mk
+++ b/maint.mk
@@ -69,7 +69,7 @@ _dot_escaped_srcdir = $(subst .,\.,$(srcdir))
 ifeq ($(srcdir),.)
   _prepend_srcdir_prefix =
 else
-  _prepend_srcdir_prefix = | $(SED) 's|^|$(srcdir)/|'
+  _prepend_srcdir_prefix = | sed 's|^|$(srcdir)/|'
 endif
 
 # In order to be able to consistently filter "."-relative names,
@@ -78,7 +78,7 @@ endif
 _sc_excl = \
   $(or $(exclude_file_name_regexp--$@),^$$)
 VC_LIST_EXCEPT = \
-  $(VC_LIST) | $(SED) 's|^$(_dot_escaped_srcdir)/||' \
+  $(VC_LIST) | sed 's|^$(_dot_escaped_srcdir)/||' \
 	| if test -f $(srcdir)/.x-$@; then grep -vEf $(srcdir)/.x-$@; \
 	  else grep -Ev -e "$${VC_LIST_EXCEPT_DEFAULT-ChangeLog}"; fi \
 	| grep -Ev -e '($(VC_LIST_ALWAYS_EXCLUDE_REGEX)|$(_sc_excl))' \
@@ -151,7 +151,7 @@ export LC_ALL = C
 _cfg_mk := $(wildcard $(srcdir)/cfg.mk)
 
 # Collect the names of rules starting with 'sc_'.
-syntax-check-rules := $(sort $(shell $(SED) -n \
+syntax-check-rules := $(sort $(shell sed -n \
    's/^\(sc_[a-zA-Z0-9_-]*\):.*/\1/p' $(srcdir)/$(ME) $(_cfg_mk)))
 .PHONY: $(syntax-check-rules)
 
@@ -441,7 +441,7 @@ sc_require_config_h_first:
 	@if $(VC_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then		\
 	  fail=0;							\
 	  for i in $$($(VC_LIST_EXCEPT) | grep '\.c$$'); do		\
-	    grep '^# *include\>' $$i | $(SED) 1q			\
+	    grep '^# *include\>' $$i | sed 1q			\
 		| grep -E '^# *include $(config_h_header)' > /dev/null	\
 	      || { echo $$i; fail=1; };					\
 	  done;								\
@@ -461,7 +461,7 @@ sc_prohibit_HAVE_MBRTOWC:
 # re: a regular expression that matches IFF something provided by $h is used.
 define _sc_header_without_use
   dummy=; : so we do not need a semicolon before each use;		\
-  h_esc=`echo '[<"]'"$$h"'[">]'|$(SED) 's/\./\\\\./g'`;			\
+  h_esc=`echo '[<"]'"$$h"'[">]'|sed 's/\./\\\\./g'`;			\
   if $(VC_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then			\
     files=$$(grep -l '^# *include '"$$h_esc"				\
 	     $$($(VC_LIST_EXCEPT) | grep '\.c$$')) &&			\
@@ -782,7 +782,7 @@ sc_useless_cpp_parens:
 # #if HAVE_HEADER_H that you remove, be sure that your project explicitly
 # requires the gnulib module that guarantees the usability of that header.
 gl_assured_headers_ = \
-  cd $(gnulib_dir)/lib && echo *.in.h|$(SED) 's/\.in\.h//g'
+  cd $(gnulib_dir)/lib && echo *.in.h|sed 's/\.in\.h//g'
 
 # Convert the list of names to upper case, and replace each space with "|".
 az_ = abcdefghijklmnopqrstuvwxyz
@@ -833,7 +833,7 @@ define def_sym_regex
 	      && perl -lne '$(gl_extract_significant_defines_)' $$f;	\
 	  done;								\
 	) | sort -u							\
-	  | $(SED) 's/^/^ *# *(define|undef)  */;s/$$/\\>/'
+	  | sed 's/^/^ *# *(define|undef)  */;s/$$/\\>/'
 endef
 
 # Don't define macros that we already get from gnulib header files.
@@ -1047,12 +1047,12 @@ sc_const_long_option:
 	  $(_sc_search_regexp)
 
 NEWS_hash =								\
-  $$($(SED) -n '/^\*.* $(PREV_VERSION_REGEXP) ([0-9-]*)/,$$p'		\
+  $$(sed -n '/^\*.* $(PREV_VERSION_REGEXP) ([0-9-]*)/,$$p'		\
        $(srcdir)/NEWS							\
      | perl -0777 -pe							\
 	's/^Copyright.+?Free\sSoftware\sFoundation,\sInc\.\n//ms'	\
      | md5sum -								\
-     | $(SED) 's/ .*//')
+     | sed 's/ .*//')
 
 # Ensure that we don't accidentally insert an entry into an old NEWS block.
 sc_immutable_NEWS:
@@ -1090,7 +1090,7 @@ sc_makefile_at_at_check:
 	  && { echo '$(ME): use $$(...), not @...@' 1>&2; exit 1; } || :
 
 news-check: NEWS
-	$(AM_V_GEN)if $(SED) -n $(news-check-lines-spec)p $<		\
+	$(AM_V_GEN)if sed -n $(news-check-lines-spec)p $<		\
 	    | grep -E $(news-check-regexp) >/dev/null; then		\
 	  :;								\
 	else								\
@@ -1139,7 +1139,7 @@ sc_po_check:
 	    files="$$files $$file";					\
 	  done;								\
 	  grep -E -l '$(_gl_translatable_string_re)' $$files		\
-	    | $(SED) 's|^$(_dot_escaped_srcdir)/||' | sort -u > $@-2;	\
+	    | sed 's|^$(_dot_escaped_srcdir)/||' | sort -u > $@-2;	\
 	  diff -u -L $(po_file) -L $(po_file) $@-1 $@-2			\
 	    || { printf '$(ME): '$(fix_po_file_diag) 1>&2; exit 1; };	\
 	  rm -f $@-1 $@-2;						\
@@ -1504,7 +1504,7 @@ refresh-gnulib-patches:
 	  test -n "$$t" && gl=$$t;					\
 	fi;								\
 	for diff in $$(cd $$gl; git ls-files | grep '\.diff$$'); do	\
-	  b=$$(printf %s "$$diff"|$(SED) 's/\.diff$$//');		\
+	  b=$$(printf %s "$$diff"|sed 's/\.diff$$//');		\
 	  VERSION_CONTROL=none						\
 	    patch "$(gnulib_dir)/$$b" "$$gl/$$diff" || exit 1;		\
 	  ( cd $(gnulib_dir) || exit 1;					\
@@ -1523,7 +1523,7 @@ refresh-po:
 	wget --no-verbose --directory-prefix $(PODIR) --no-directories --recursive --level 1 --accept .po --accept .po.1 $(POURL) && \
 	echo 'en@boldquot' > $(PODIR)/LINGUAS && \
 	echo 'en@quot' >> $(PODIR)/LINGUAS && \
-	ls $(PODIR)/*.po | $(SED) 's/\.po//;s,$(PODIR)/,,' | \
+	ls $(PODIR)/*.po | sed 's/\.po//;s,$(PODIR)/,,' | \
 	  sort >> $(PODIR)/LINGUAS
 
  # Running indent once is not idempotent, but running it twice is.
@@ -1634,18 +1634,18 @@ _gl_tight_scope: $(bin_PROGRAMS)
 	       test -f $$f && d= || d=$(srcdir)/; echo $$d$$f; done`;	\
 	( printf '^%s$$\n' '__.*' $(_gl_TS_unmarked_extern_functions);	\
 	  grep -h -A1 '^extern .*[^;]$$' $$src				\
-	    | grep -vE '^(extern |--)' | $(SED) 's/ .*//';		\
+	    | grep -vE '^(extern |--)' | sed 's/ .*//';		\
 	  perl -lne							\
 	     '$(_gl_TS_function_match) and print "^$$1\$$"' $$hdr;	\
 	) | sort -u > $$t;						\
-	nm -e $(_gl_TS_obj_files)|$(SED) -n 's/.* T //p'|grep -Ev -f $$t \
+	nm -e $(_gl_TS_obj_files)|sed -n 's/.* T //p'|grep -Ev -f $$t \
 	  && { echo the above functions should have static scope >&2;	\
 	       exit 1; } || : ;						\
 	( printf '^%s$$\n' '__.*' $(_gl_TS_unmarked_extern_vars);	\
 	  perl -lne '$(_gl_TS_var_match) and print "^$$1\$$"'		\
 		$$hdr $(_gl_TS_other_headers)				\
 	) | sort -u > $$t;						\
-	nm -e $(_gl_TS_obj_files) | $(SED) -n 's/.* [BCDGRS] //p'	\
+	nm -e $(_gl_TS_obj_files) | sed -n 's/.* [BCDGRS] //p'	\
             | sort -u | grep -Ev -f $$t					\
 	  && { echo the above variables should have static scope >&2;	\
 	       exit 1; } || :
-- 
2.21.0

_______________________________________________
Libosinfo mailing list
Libosinfo@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libosinfo




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Fedora Users]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux