From 7fab365ffe9761c68d7c4c4ddefec860c5703c35 Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Thu, 25 Mar 2021 21:17:53 -0600 Subject: lift builtin macros from GNU make, not POSIX make --- yapymake/makefile/__init__.py | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/yapymake/makefile/__init__.py b/yapymake/makefile/__init__.py index 3407b3c..1f4687c 100644 --- a/yapymake/makefile/__init__.py +++ b/yapymake/makefile/__init__.py @@ -33,7 +33,11 @@ class Makefile: if args.builtin_rules: self._inference_rules += BUILTIN_INFERENCE_RULES for k, v in BUILTIN_MACROS.items(): - self._macros[k] = (MacroSource.Builtin, TokenString.text(v)) + if isinstance(v, TokenString): + v_tokens = v + else: + v_tokens = TokenString.text(v) + self._macros[k] = (MacroSource.Builtin, v_tokens) for target in BUILTIN_TARGETS: self._targets[target.name] = target @@ -480,19 +484,42 @@ BUILTIN_INFERENCE_RULES = [ CommandLine(tokenize('rm -f $*.o')), ]), ] -BUILTIN_MACROS = { +BUILTIN_MACROS: Dict[str, Union[str, TokenString]] = { 'MAKE': 'make', 'AR': 'ar', - 'ARFLAGS': '-rv', + #'ARFLAGS': '-rv', 'YACC': 'yacc', 'YFLAGS': '', 'LEX': 'lex', 'LFLAGS': '', 'LDFLAGS': '', - 'CC': 'c99', + #'CC': 'c99', 'CFLAGS': '-O 1', - 'FC': 'fort77', + #'FC': 'fort77', 'FFLAGS': '-O 1', + + # TODO bitch about the non-POSIXness of these GNUisms + # from https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html#Implicit-Variables + 'AS': 'as', + 'CC': 'cc', + 'CXX': 'g++', + 'CPP': tokenize('$(CC) -E'), + 'FC': 'f77', + 'M2C': 'm2c', + 'PC': 'pc', + 'CO': 'co', + 'GET': 'get', + 'LINT': 'lint', + 'MAKEINFO': 'makeinfo', + 'TEX': 'tex', + 'TEXI2DVI': 'texi2dvi', + 'WEAVE': 'weave', + 'CWEAVE': 'cweave', + 'TANGLE': 'tangle', + 'CTANGLE': 'ctangle', + 'RM': 'rm -f', + + 'ARFLAGS': 'rv', } BUILTIN_TARGETS = [ Target('.SUFFIXES', ['.o', '.c', '.y', '.l', '.a', '.sh', '.f'], []), -- cgit v1.2.3