You are not logged in.
Pages: 1
I am trying to understand how a make file works.
I have installed remake which helps how the makefile flows.
I am stuck with some variables which are not defined in the makefile. Niether i find then as environmental variables.
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-recursive
In this I dont find MAKE and AM_MAKEFLAGS anywhere.
Offline
If you are looking at a Makefile.am file, that gets processed with the automake tool to make a real Makefile. If you're looking at a raw Makefile (or Makefile.in) then don't expect to follow the logic for the whole thing.
Offline
Thank you,
As per you Makefile is made from Makefile.am
What is raw makefile you mentioned - Makefile.in
what is the difference between Makefile.in and Makefile.am
I am tryiing to understand a source code
So i have in the src directory all these three files.
I did automake Makefile.am
I got the following
automake: no Automake input file found for `Makefile.am'
automake: no input file found among supplied arguments
I the Makefile.am it has the following code
ACLOCAL_AMFLAGS=-I m4
EXTRA_DIST= gen-ver.sh VERSION
SUBDIRS= src doc
.PHONY: ChangeLog VERSION
VERSION:
@if test -d "$(top_srcdir)/.git" -o -f "$(top_srcdir)/.git"; then \
"$(top_srcdir)/gen-ver.sh" "$(top_srcdir)" > $@; \
fi
ChangeLog:
@if test -d "$(top_srcdir)/.git" -o -f "$(top_srcdir)/.git"; then \
git log --stat --name-only --date=short --abbrev-commit \
--after="Thu Aug 12 15:54:58 2010" > $@; \
fi
dist-hook: ChangeLog VERSIONIn this code i dont understand the variable "top_srcdir" because its not mentioned in the variables.
FYI the source code i am looking is cclive-0.7.6
Last edited by sant527 (2011-11-06 13:20:13)
Offline
Makefile.in and Makefile.am are used by GNU Autotools to build a normal Makefile.
Offline
If you want to understand automake, read this: http://www.gnu.org/software/automake/ma … omake.html
But you likely don't need to understand the whole thing, just know that $(top_srcdir) is the top directory of the project (that is, the directory that contains ./configure).
Anyway, if you want to understand how Makefiles work, read this: http://www.opussoftware.com/tutorial/TutMakefile.htm. Makefiles made by automake are giant and complicated and unreadable.
Offline
If you're playing with makefile.am and friends, I quite liked this autotools tutorial:
Autotools: A Guide To Autoconf, Automake and Libtool
OTOH, if you really want to understand Makefiles, you should find a makefile tutorial and write your own Makefiles from scratch. Like tavianator said, the Makefiles generated by automake are not fit for human consumption.
Offline
Thank you.
After digging into Makefile. I felt its not possible to understand it. Anyhow my purpose for understanding is only to understand the source code.
If you see there are so many .c files in the directory. I just want to know how they are compiled. So that I can understand the code easily by debugger like ddd.
Generally in the makefle tutorials its clear that how the things are getting compiled, because they are written and not autogenerated So if I get such information, i can also compile on my own and debug the code.
So what is the key so that i can understand the c programs in a source code. How the programs from each folder are compiled and how the final executable is arrived at. Because from makefile we should be able to see the compiler command and the dependicies. But from the autogenerated it is not possible to understand.
I am only interested in the final files which are being installed. So how are they arrived at from the files in the source directory.
Please also suggest a source code example for a newbie to begin. Because cclive may be quite complicated.
Offline
To understand source code wrapped up with autotools, I find it useful to first generate a dependency graph. Doxygen is good for this.
Offline
Is this something similar to lxr and cscope
But with these when i want to compile i will not get what compile command to be used.
Offline
I haven't used lxr or cscope. In terms of the compile command to use, I assume you mean you just want to know what include flags to use and so forth? In that case, you can extract the information from the Doxygen dependency graph.
Or unless I'm overlooking something, you could even just use the like of a good old
grep -h '#include <' *What source package do you specifically have in mind?
Offline
After digging into Makefile. I felt its not possible to understand it.
Me too. Last year I tried to study and understand autotools and makefile.am and makefile.in. I gave up. It's too complicated for me.
So what is the key so that i can understand the c programs in a source code. How the programs from each folder are compiled and how the final executable is arrived at.
No problem! When you type "make" and the program compiles, it shows you everything it does. For example, if you look at the output of the "make" command, you will see "gcc ...". If you copy and paste that gcc commands then you can "compile it yourself". ![]()
Offline
Pages: 1