Thread: difference makefile makefile.am makefile.in

  1. #1
    Registered User
    Join Date
    Jan 2007
    Posts
    113

    difference makefile makefile.am makefile.in

    Hi,
    Can anybody tell me the difference between makefile,makefile.am and makefile.in.
    What is the hierarchy of these file..ie which file is created first and after that which one..??

    Thanks

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Yes, there is a hierarchy. Makefile.am is a "automake" makefile. Makefile.in is a "template" makefile, and Makefile is a file created from the former two, usually usign "./configure".

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Jan 2007
    Posts
    113

    Angry Can u explain a this problem

    Hi matsp,

    Thanks for your reply.........

    I am working on a linux project and I want a little explanation regarding makefile concept.

    As you write that makefile is created from makefile.am and makefile.in by running ./configure....

    I have a question regarding this..........

    In my project I have several directories for same project so individual folder has there own makefile.am and so on........
    When I tried to include A .h file from one folder say A to another B.h file say in B folder I got the complier error that A.h does not exist.......so for this I include the folder path of directory A to the makefile.am file of folder B.....then again it give me the same error.........
    Then I apply a trick......what I do is that ...I don't include the header file A.h in B.h but include the directory path in makefile.am of directory B....then I run "make install" command............
    It make changes in makefile.in and makefile...........
    After this I include the A.h header file to B.h and at this time It doesn't give any error...........
    Why this happen ???
    As you have said that makefile.in and makefile is created from ./configure command then why these file created from "make install " command ???
    I should run ./configure to create makefile and then run "make install" ??

    Actually I am new to linux programming and need help to understand project functionality........
    It will be great if anybody explain with flow...........waiting for reply

    Thanks

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    So are you modifying the actual project, or just trying to build it?

    Normally, you do something like
    Code:
    $ ./configure
    $ make install
    and all works just fine.

    However, different projects may work differently, and there's certainly nothing to say that a particular project will not have bugs that are exposed when you try to build on a certain machine. Some projects also deal badly with missing required files - e.g. to build X, you need to install Y first. If Y isn't installed, it doesn't recognise this, but rather tries to compile and finds lots of header files and/or libraries missing during the build process.

    Note that "Automake" files are non-trivial to deal with in my experience. I can fix simple automake bugs, but I've also run into problems where I can't understand the makefile.am well enough to make it work [I usually manage quite well with regular makefiles, but even these CAN be hard to follow].

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Registered User
    Join Date
    Jan 2007
    Posts
    113

    Reply

    Thanks for reply ............

    Actually I am adding some functionality to the existing project..............

    I am explaining u what I have understood yet...........plz let me know if I am correct.........

    makefile.am was created earlier.When I run command autoreconf -i (not ./configure) then it create the makefile.in and makefile .............
    When I run command "make install" it call makefile and create it's exe...

    I want to know that if I want to make changes then should I make changes in makefile.am or in makefile ??????

    Thanks

  6. #6
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Yes, as far as I know, that would be the way to do it.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  7. #7
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    I want to know that if I want to make changes then should I make changes in makefile.am or in makefile ??????
    If you're the only one who's going to be using the modified program, then it really doesn't matter -- although the Makefile might be pretty long and difficult to follow.

    If you're going to give the modified version to other people, then don't modify the Makefile, because as soon as someone runs ./configure again, the Makefile will be overwritten.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  8. #8
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    You shouldn't modify auto-generated files out of basic principle. Always modify the source.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Building a project using a Makefile
    By starcatcher in forum Windows Programming
    Replies: 2
    Last Post: 11-23-2008, 11:50 PM
  2. unix makefile won't work but works in Dev C++
    By jk1998 in forum C++ Programming
    Replies: 1
    Last Post: 06-09-2007, 03:54 PM
  3. What's the difference between var++ and ++var
    By ulillillia in forum C Programming
    Replies: 6
    Last Post: 05-31-2007, 02:27 AM
  4. makefile blues....
    By WaterNut in forum C Programming
    Replies: 6
    Last Post: 05-30-2005, 08:22 PM
  5. Need help with Makefile
    By xshapirox in forum C++ Programming
    Replies: 14
    Last Post: 09-28-2004, 03:32 PM