Using GCC to generate makefile dependencies.

  • Thread starter TylerH
  • Start date
  • #1
724
0
How do I use GCC to generate dependencies for makefiles? I tried using the -M option, like below, but I don't know how to insert the name of the .cpp into the shell command that calls GCC with the -M option.

Code:
%.cpp : $(shell gcc -M $<)
Instead of the desired effect, $< is replaced by nothing, causing GCC to generate an error and my attempt to generate dependencies to fail.
 

Answers and Replies

  • #2
s09
25
0
I had the same problem that you do now. For that I did some googling around and found a set of tools called Autotools. Here is a pretty good explanation of what you might want to do:

http://www.freesoftwaremagazine.com/books/autotools_a_guide_to_autoconf_automake_libtool

This requires some effort to setup correctly (depends on the complexity of your compilation environment), so if you have only a small number of libraries, hard-coding would be a better option.

What operating system are you using? What libraries are you trying to use?
 

Related Threads on Using GCC to generate makefile dependencies.

  • Last Post
2
Replies
34
Views
2K
  • Last Post
Replies
4
Views
781
  • Last Post
Replies
1
Views
2K
Replies
4
Views
7K
  • Last Post
Replies
3
Views
5K
  • Last Post
Replies
13
Views
6K
Replies
12
Views
634
  • Last Post
Replies
3
Views
13K
Replies
2
Views
6K
  • Last Post
Replies
5
Views
3K
Top