ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have, may be, a 'strange' request.
Anyone here is familiar with any tool to navigate makefiles?(makefile, Makefile, .mk etc) .I have a huge build system for me to study and make some modifications . I am really finding it difficult to go through the makefiles. Any help is appreciated.
Note: what I need is something line ctags for .c files.
I usually use vim. Here's a couple of navigation tips.
Here are some good shortcuts. HINT: ^W means CTRL+W keyboard shortcut.
vim Terminology
buffer - a file loaded into memory (not always displayed in the current window)
key sequence - mode invoked - description
gf - normal "command" - when cursor is over a file name it will follow and open the file. It subsequently adds that file to your list of buffers to be accessed.
:ls - normal "command" - show a list of buffers
:b N - normal "command" - where N is an integer. Replaces the current window with the contents of the buffer. List buffers using :ls.
^W n - normal "command" - open a blank window. You can load other buffers into the blank window.
^W [hjkl] - normal "command" - navigates to other windows when screen is split. Use only one letter of the list [hjkl].
^W f - split window and edit file name under the cursor
To learn more about vim and it's many uses run the following command to learn it.
Code:
vimtutor
To learn more about the commands I listed above see the following help documentation within vim. For the help documentation when you see ^W you literally type ^W.
:help ^W
:help sp
:help :ls
:help gf
:help :b
:help :sb
:help gt
:help gT
It's pretty useful for navigating any document which links other files due to its ability to follow linked files relative to the path of the working directory. In C programs, it correctly follows headers to their source files.
Lastly, find and grep are great utilities for figuring out where a function shows up in a source tree when paired with other files. Here's an example where I'm looking for which files contain the function tree() but don't necessarily care how many times the function is referenced (just which files it shows up in).
Note: what I need is something line ctags for .c files.
The version of ctags I have supports Makefiles:
Code:
1% ctags --version
ctags (GNU Emacs 23.4)
Copyright (C) 2012 Free Software Foundation, Inc.
This program is distributed under the terms in ETAGS.README
% ctags --help
...
-l LANG, --language=LANG
Force the following files to be considered as written in the
named language up to the next --language=LANG option.
...
These are the currently supported languages, along with the
default file names and dot suffixes:
...
makefile Makefile makefile GNUMakefile Makefile.in Makefile.am
...
I usually use vim. Here's a couple of navigation tips.
Here are some good shortcuts. HINT: ^W means CTRL+W keyboard shortcut.
vim Terminology
buffer - a file loaded into memory (not always displayed in the current window)
key sequence - mode invoked - description
gf - normal "command" - when cursor is over a file name it will follow and open the file. It subsequently adds that file to your list of buffers to be accessed.
:ls - normal "command" - show a list of buffers
:b N - normal "command" - where N is an integer. Replaces the current window with the contents of the buffer. List buffers using :ls.
^W n - normal "command" - open a blank window. You can load other buffers into the blank window.
^W [hjkl] - normal "command" - navigates to other windows when screen is split. Use only one letter of the list [hjkl].
^W f - split window and edit file name under the cursor
To learn more about vim and it's many uses run the following command to learn it.
Code:
vimtutor
To learn more about the commands I listed above see the following help documentation within vim. For the help documentation when you see ^W you literally type ^W.
:help ^W
:help sp
:help :ls
:help gf
:help :b
:help :sb
:help gt
:help gT
It's pretty useful for navigating any document which links other files due to its ability to follow linked files relative to the path of the working directory. In C programs, it correctly follows headers to their source files.
Lastly, find and grep are great utilities for figuring out where a function shows up in a source tree when paired with other files. Here's an example where I'm looking for which files contain the function tree() but don't necessarily care how many times the function is referenced (just which files it shows up in).
1% ctags --version
ctags (GNU Emacs 23.4)
Copyright (C) 2012 Free Software Foundation, Inc.
This program is distributed under the terms in ETAGS.README
% ctags --help
...
-l LANG, --language=LANG
Force the following files to be considered as written in the
named language up to the next --language=LANG option.
...
These are the currently supported languages, along with the
default file names and dot suffixes:
...
makefile Makefile makefile GNUMakefile Makefile.in Makefile.am
...
This means I can use this version of ctags and make the utility believe that .mk files are written in Makefile language. My understanding is correct?
This means I can use this version of ctags and make the utility believe that .mk files are written in Makefile language. My understanding is correct?
Yes. linux.die.net seems to list a different version of ctags (associated with vi, rather than emacs like mine appears to be); it has slightly different options for this:
Quote:
--langmap=map[,map[...]]
...To map makefiles (e.g. files named either "Makefile", "makefile", or having the extension ".mak") to a language called "make", specify "--langmap=make:([Mm]akefile).mak".
Both versions also have options to find declarations using an arbitrary regex, so they could support any language (well, assuming regexes are suffcient to extract declarations for that language).
Yes. linux.die.net seems to list a different version of ctags (associated with vi, rather than emacs like mine appears to be); it has slightly different options for this:
Both versions also have options to find declarations using an arbitrary regex, so they could support any language (well, assuming regexes are suffcient to extract declarations for that language).
I use Vim more.
Infact I found that ctags already supports .mk files. Here is what my ctags shows
Quote:
$>ctags --list-maps=Make
Make *.mak *.mk [Mm]akefile GNUmakefile
Lastly, find and grep are great utilities for figuring out where a function shows up in a source tree when paired with other files. Here's an example where I'm looking for which files contain the function tree() but don't necessarily care how many times the function is referenced (just which files it shows up in).
I usually use vim. Here's a couple of navigation tips.
gf - normal "command" - when cursor is over a file name it will follow and open the file. It subsequently adds that file to your list of buffers to be accessed.
:ls - normal "command" - show a list of buffers
:b N - normal "command" - where N is an integer. Replaces the current window with the contents of the buffer. List buffers using :ls.
^W n - normal "command" - open a blank window. You can load other buffers into the blank window.
^W [hjkl] - normal "command" - navigates to other windows when screen is split. Use only one letter of the list [hjkl].
^W f - split window and edit file name under the cursor
SAM
gf command does not expand the VARIABLES , isnt it?
suppose I have,
Quote:
include $(MY_ROOT)/jump.mk
when i try gf command, it tries to jump to /jump.mk and does not expand $(MY_ROOT) .. Is there anyway to include Variable expansion as well?
Well, you can't actually close the thread, but it looks like there is no easy answer for this. I guess you would have to parse the makefile in vimscript.
Well, you can't actually close the thread, but it looks like there is no easy answer for this. I guess you would have to parse the makefile in vimscript.
Okay.I mean Solved.
I know there was no need to reply at this point of time..But my last question is still relevant.Its just that I am too optimistic to expect a reply.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.