-
Notifications
You must be signed in to change notification settings - Fork 629
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4024 from masatake/make--extract-D
Make: add CppDef extra for extracting FOO in -DFOO as a macro of CPreProcessor See bootlin/elixir#221
- Loading branch information
Showing
16 changed files
with
617 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--sort=no | ||
--fields=+{language}{signature} | ||
--extras-Make=+{CppDef} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
REALMODE_CFLAGS input.mak /^REALMODE_CFLAGS := -std=gnu11 -m16 -g -Os -DDISABLE_BRANCH_PROFILING -D__DISABLE_EXPORTS \\$/;" m language:Make | ||
DISABLE_BRANCH_PROFILING input.mak /^REALMODE_CFLAGS := -std=gnu11 -m16 -g -Os -DDISABLE_BRANCH_PROFILING -D__DISABLE_EXPORTS \\$/;" d language:CPreProcessor | ||
__DISABLE_EXPORTS input.mak /^REALMODE_CFLAGS := -std=gnu11 -m16 -g -Os -DDISABLE_BRANCH_PROFILING -D__DISABLE_EXPORTS \\$/;" d language:CPreProcessor | ||
MYDEF input.mak /^ -DMYDEF=1 \\$/;" d language:CPreProcessor | ||
MYDEF0 input.mak /^ -DMYDEF0 \\$/;" d language:CPreProcessor | ||
MYDEF1 input.mak /^ -DMYDEF1=1 \\$/;" d language:CPreProcessor | ||
MYDEF2 input.mak /^ -DMYDEF2(X)=X \\$/;" d language:CPreProcessor signature:(X) | ||
MYDEF3 input.mak /^ -D MYDEF3 \\$/;" d language:CPreProcessor | ||
MYDEF4 input.mak /^ -D MYDEF4=1 \\$/;" d language:CPreProcessor | ||
MYDEF5 input.mak /^ -D MYDEF5(X)=X \\$/;" d language:CPreProcessor signature:(X) | ||
MYDEF6 input.mak /^ -D'MYDEF6' \\$/;" d language:CPreProcessor | ||
MYDEF7 input.mak /^ -D'MYDEF7=1' \\$/;" d language:CPreProcessor | ||
MYDEF8 input.mak /^ -D'MYDEF8(X)=X' \\$/;" d language:CPreProcessor signature:(X) | ||
MYDEF9 input.mak /^ -D 'MYDEF9' \\$/;" d language:CPreProcessor | ||
MYDEFa input.mak /^ -D 'MYDEFa=1' \\$/;" d language:CPreProcessor | ||
MYDEFb input.mak /^ -D 'MYDEFb(X)=X' \\$/;" d language:CPreProcessor signature:(X) | ||
MYDEFc input.mak /^ -D"MYDEFc" \\$/;" d language:CPreProcessor | ||
MYDEFd input.mak /^ -D"MYDEFd=1" \\$/;" d language:CPreProcessor | ||
MYDEFe input.mak /^ -D"MYDEFe(X)=X" \\$/;" d language:CPreProcessor signature:(X) | ||
MYDEFf input.mak /^ -D "MYDEFf" \\$/;" d language:CPreProcessor | ||
MYDEFg input.mak /^ -D "MYDEFg=1" \\$/;" d language:CPreProcessor | ||
MYDEFh input.mak /^ -D "MYDEFh(X)=X" \\$/;" d language:CPreProcessor signature:(X) | ||
KBUILD_CPPFLAGS input.mak /^KBUILD_CPPFLAGS := -D__KERNEL__$/;" m language:Make | ||
__KERNEL__ input.mak /^KBUILD_CPPFLAGS := -D__KERNEL__$/;" d language:CPreProcessor | ||
KBUILD_RUSTFLAGS input.mak /^KBUILD_RUSTFLAGS := $(rust_common_flags) \\$/;" m language:Make | ||
clippy::float_arithmetic input.mak /^ -Dclippy::float_arithmetic$/;" d language:CPreProcessor | ||
KBUILD_AFLAGS_KERNEL input.mak /^KBUILD_AFLAGS_KERNEL :=$/;" m language:Make | ||
KBUILD_CFLAGS_KERNEL input.mak /^KBUILD_CFLAGS_KERNEL :=$/;" m language:Make | ||
KBUILD_RUSTFLAGS_KERNEL input.mak /^KBUILD_RUSTFLAGS_KERNEL :=$/;" m language:Make | ||
KBUILD_AFLAGS_MODULE input.mak /^KBUILD_AFLAGS_MODULE := -DMODULE$/;" m language:Make | ||
MODULE input.mak /^KBUILD_AFLAGS_MODULE := -DMODULE$/;" d language:CPreProcessor | ||
KBUILD_CFLAGS_MODULE input.mak /^KBUILD_CFLAGS_MODULE := -DMODULE$/;" m language:Make | ||
MODULE input.mak /^KBUILD_CFLAGS_MODULE := -DMODULE$/;" d language:CPreProcessor | ||
KBUILD_RUSTFLAGS_MODULE input.mak /^KBUILD_RUSTFLAGS_MODULE := --cfg MODULE$/;" m language:Make | ||
all input.mak /^all:$/;" t language:Make | ||
FOO input.mak /^ $(CC) -DFOO ...$/;" d language:CPreProcessor | ||
macdef input.mak /^define macdef$/;" m language:Make | ||
MACDEF_CPPFLAGS input.mak /^ MACDEF_CPPFLAGS = -DMACDEFMAC0(X0,Y0,Z0)$/;" m language:Make macro:macdef | ||
MACDEFMAC0 input.mak /^ MACDEF_CPPFLAGS = -DMACDEFMAC0(X0,Y0,Z0)$/;" d language:CPreProcessor signature:(X0,Y0,Z0) | ||
MACDEFMAC1 input.mak /^ MACDEF_CPPFLAGS += -DMACDEFMAC1(X1,Y1,Z1)=X1##Y1##Z1$/;" d language:CPreProcessor signature:(X1,Y1,Z1) | ||
MACDEF_CPPFLAGS_BROKEN0 input.mak /^ MACDEF_CPPFLAGS_BROKEN0 = -DMACDEFMAC_BROKEN0(A0,B0,C0$/;" m language:Make macro:macdef | ||
MACDEFMAC_BROKEN0 input.mak /^ MACDEF_CPPFLAGS_BROKEN0 = -DMACDEFMAC_BROKEN0(A0,B0,C0$/;" d language:CPreProcessor | ||
MACDEF_CPPFLAGS_BROKEN1 input.mak /^ MACDEF_CPPFLAGS_BROKEN1 = -D MACDEFMAC_BROKEN1(A1,B1,C1$/;" m language:Make macro:macdef | ||
MACDEFMAC_BROKEN1 input.mak /^ MACDEF_CPPFLAGS_BROKEN1 = -D MACDEFMAC_BROKEN1(A1,B1,C1$/;" d language:CPreProcessor | ||
MACDEFMAC2 input.mak /^ MACDEF_CPPFLAGS += -DMACDEFMAC2(X2,Y2,Z2)="f b"$/;" d language:CPreProcessor signature:(X2,Y2,Z2) | ||
install-man input-0.mak /^install-man: $(srctree)\/man\/pfrut.8$/;" t language:Make | ||
install input-0.mak /^install:$/;" t language:Make | ||
ACPI_DEBUGGER0 input-1.mak /^CFLAGS0 += -DACPI_DEBUGGER0\\$/;" d language:CPreProcessor | ||
CFLAGS1 input-1.mak /^CFLAGS1 ?= -DACPI_DEBUGGER1\\$/;" m language:Make | ||
ACPI_DEBUGGER1 input-1.mak /^CFLAGS1 ?= -DACPI_DEBUGGER1\\$/;" d language:CPreProcessor | ||
CFLAGS2 input-1.mak /^CFLAGS2 := -DACPI_DEBUGGER2\\$/;" m language:Make | ||
ACPI_DEBUGGER2 input-1.mak /^CFLAGS2 := -DACPI_DEBUGGER2\\$/;" d language:CPreProcessor | ||
CFLAGS3 input-1.mak /^CFLAGS3 = -DACPI_DEBUGGER3\\$/;" m language:Make | ||
ACPI_DEBUGGER3 input-1.mak /^CFLAGS3 = -DACPI_DEBUGGER3\\$/;" d language:CPreProcessor | ||
FOO_$(VAL) input-2.mak /^X += -DFOO_$(VAL)$/;" d language:CPreProcessor | ||
ARM_ARCH_SELECTOR input-2.mak /^ARM_ARCH_SELECTOR := $(filter -D__LINUX_ARM_ARCH__%, $(KBUILD_CFLAGS))$/;" m language:Make | ||
__LINUX_ARM_ARCH__% input-2.mak /^ARM_ARCH_SELECTOR := $(filter -D__LINUX_ARM_ARCH__%, $(KBUILD_CFLAGS))$/;" d language:CPreProcessor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Taken from linux/tools/power/acpi/tools/pfrut/Makefile | ||
# Don't capture object starting from $. | ||
install-man: $(srctree)/man/pfrut.8 | ||
$(ECHO) " INST " pfrut.8 | ||
$(QUIET) $(INSTALL_DATA) -D $< $(DESTDIR)$(mandir)/man8/pfrut.8 | ||
|
||
# Taken from linux/arch/loongarch/Makefile | ||
# Don't capture object starting from -.h | ||
install: | ||
$(Q)install -D -m 755 $(KBUILD_IMAGE) $(INSTALL_PATH)/$(image-name-y)-$(KERNELRELEASE) | ||
$(Q)install -D -m 644 .config $(INSTALL_PATH)/config-$(KERNELRELEASE) | ||
$(Q)install -D -m 644 System.map $(INSTALL_PATH)/System.map-$(KERNELRELEASE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
CFLAGS0 += -DACPI_DEBUGGER0\ | ||
-I. | ||
|
||
CFLAGS1 ?= -DACPI_DEBUGGER1\ | ||
-I. | ||
|
||
CFLAGS2 := -DACPI_DEBUGGER2\ | ||
-I. | ||
|
||
CFLAGS3 = -DACPI_DEBUGGER3\ | ||
-I. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
X += -DFOO_$(VAL) | ||
ARM_ARCH_SELECTOR := $(filter -D__LINUX_ARM_ARCH__%, $(KBUILD_CFLAGS)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Derrived from linux/Makefile | ||
|
||
REALMODE_CFLAGS := -std=gnu11 -m16 -g -Os -DDISABLE_BRANCH_PROFILING -D__DISABLE_EXPORTS \ | ||
-Wall -Wstrict-prototypes -march=i386 -mregparm=3 \ | ||
-fno-strict-aliasing -fomit-frame-pointer -fno-pic \ | ||
-DMYDEF=1 \ | ||
-DMYDEF0 \ | ||
-DMYDEF1=1 \ | ||
-DMYDEF2(X)=X \ | ||
-D MYDEF3 \ | ||
-D MYDEF4=1 \ | ||
-D MYDEF5(X)=X \ | ||
-D'MYDEF6' \ | ||
-D'MYDEF7=1' \ | ||
-D'MYDEF8(X)=X' \ | ||
-D 'MYDEF9' \ | ||
-D 'MYDEFa=1' \ | ||
-D 'MYDEFb(X)=X' \ | ||
-D"MYDEFc" \ | ||
-D"MYDEFd=1" \ | ||
-D"MYDEFe(X)=X" \ | ||
-D "MYDEFf" \ | ||
-D "MYDEFg=1" \ | ||
-D "MYDEFh(X)=X" \ | ||
-mno-mmx -mno-sse $(call cc-option,-fcf-protection=none) | ||
|
||
KBUILD_CPPFLAGS := -D__KERNEL__ | ||
KBUILD_RUSTFLAGS := $(rust_common_flags) \ | ||
-Cpanic=abort -Cembed-bitcode=n -Clto=n \ | ||
-Cforce-unwind-tables=n -Ccodegen-units=1 \ | ||
-Csymbol-mangling-version=v0 \ | ||
-Crelocation-model=static \ | ||
-Zfunction-sections=n \ | ||
-Dclippy::float_arithmetic | ||
|
||
KBUILD_AFLAGS_KERNEL := | ||
KBUILD_CFLAGS_KERNEL := | ||
KBUILD_RUSTFLAGS_KERNEL := | ||
KBUILD_AFLAGS_MODULE := -DMODULE | ||
KBUILD_CFLAGS_MODULE := -DMODULE | ||
KBUILD_RUSTFLAGS_MODULE := --cfg MODULE | ||
|
||
all: | ||
$(CC) -DFOO ... | ||
|
||
define macdef | ||
MACDEF_CPPFLAGS = -DMACDEFMAC0(X0,Y0,Z0) | ||
MACDEF_CPPFLAGS += -DMACDEFMAC1(X1,Y1,Z1)=X1##Y1##Z1 | ||
MACDEF_CPPFLAGS_BROKEN0 = -DMACDEFMAC_BROKEN0(A0,B0,C0 | ||
MACDEF_CPPFLAGS_BROKEN1 = -D MACDEFMAC_BROKEN1(A1,B1,C1 | ||
MACDEF_CPPFLAGS += -DMACDEFMAC2(X2,Y2,Z2)="f b" | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
.. _ctags-lang-make(7): | ||
|
||
============================================================== | ||
ctags-lang-make | ||
============================================================== | ||
|
||
Random notes about tagging Make source code with Universal Ctags | ||
|
||
:Version: 6.1.0 | ||
:Manual group: Universal Ctags | ||
:Manual section: 7 | ||
|
||
SYNOPSIS | ||
-------- | ||
| **ctags** ... --languages=+Make ... | ||
| **ctags** ... --language-force=Make ... | ||
| **ctags** ... --map-Make=+([Mm]akefile) --map-Make=+(GNUmakefile) ... | ||
| **ctags** ... --map-Make=+.mak --map-Make=+.mk ... | ||
DESCRIPTION | ||
----------- | ||
This parser extracts macro and target definitions. It also extracts included files as references. | ||
|
||
Examples | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
"input.mak" | ||
|
||
.. code-block:: Makefile | ||
-include base.mak | ||
SRC = hello.c | ||
all: hello | ||
hello: hello.o | ||
hello.o: hello.c | ||
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< | ||
"output.tags" | ||
with "--options=NONE --extras=+r --fields=+KlrE -o - input.mak" | ||
|
||
.. code-block:: tags | ||
SRC input.mak /^SRC = hello.c$/;" macro language:Make roles:def | ||
all input.mak /^all: hello$/;" target language:Make roles:def | ||
base.mak input.mak /^-include base.mak$/;" makefile language:Make roles:optional extras:reference | ||
hello input.mak /^hello: hello.o$/;" target language:Make roles:def | ||
hello.o input.mak /^hello.o: hello.c$/;" target language:Make roles:def | ||
EXTRACTING CPP MACRO DEFINTIONS DEFINED WITH -DFOO | ||
--------------------------------------------------- | ||
With ``-D`` option in a C compiler like gcc, a programmer can define a | ||
macro outside C source files. The options appears on a Makefile | ||
frequently. For an example: | ||
|
||
.. code-block:: Makefile | ||
CPPFLAGS = -DDEBUG | ||
The Make parser has heuristics [DINMAKE]_ for extracting the macros defined with | ||
the option. With enabling ``CppDef`` extra, you can turn on the heuristics. | ||
|
||
Examples | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
"input.mak" | ||
|
||
.. code-block:: Makefile | ||
-include base.mak | ||
CFLAGS = -g -O2 | ||
CPPFLAGS = -DOUTPUT=stdout | ||
SRC = hello.c | ||
all: hello | ||
hello: hello.o | ||
hello.o: hello.c | ||
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< | ||
"output.tags" | ||
with "--options=NONE --extras-Make=+{CppDef} --fields=+KlE -o - input.mak" | ||
|
||
.. code-block:: tags | ||
CFLAGS input.mak /^CFLAGS = -g -O2$/;" macro language:Make | ||
CPPFLAGS input.mak /^CPPFLAGS = -DOUTPUT=stdout$/;" macro language:Make | ||
OUTPUT input.mak /^CPPFLAGS = -DOUTPUT=stdout$/;" macro language:CPreProcessor extras:CppDef | ||
SRC input.mak /^SRC = hello.c$/;" macro language:Make | ||
all input.mak /^all: hello$/;" target language:Make | ||
hello input.mak /^hello: hello.o$/;" target language:Make | ||
hello.o input.mak /^hello.o: hello.c$/;" target language:Make | ||
VERSIONS | ||
-------- | ||
|
||
Change since "0.0" | ||
~~~~~~~~~~~~~~~~~~ | ||
|
||
* New extra ``CppDef`` [DINMAKE]_ | ||
|
||
SEE ALSO | ||
-------- | ||
:ref:`ctags(1) <ctags(1)>` | ||
|
||
.. [DINMAKE] `CONFIG_X86_X32_ABI is not visible (defined in Makefile, not C or Kconfig) <https://github.com/bootlin/elixir/issues/221>`_ (https://github.com/bootlin/elixir/issues/221) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.