Find the answer to your Linux question:
Results 1 to 8 of 8
You must also hand in a makefile that contains at least two rules. The required rules are "all" and "clean". Your program should be compiled with the -Wall and -ansi ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jan 2005
    Posts
    3

    Programming: How to create a makefile.


    You must also hand in a makefile that contains at least two rules. The required rules are "all" and "clean". Your program should be compiled with the -Wall and -ansi flags with "make all" producing an executable named a1. The clean rule must remove all .o files and optionally the executable a1.


    Is there anyone here who can explain, in plain english, exactly how to go about doing this?

    If you require any more information I can provide it.

    Thanks in advance for any help.

  2. #2
    Linux Guru lakerdonald's Avatar
    Join Date
    Jun 2004
    Location
    St. Petersburg, FL
    Posts
    5,035
    We are not supposed to do your homework for you.
    http://www.linuxforums.org/rules.php

  3. #3
    Just Joined!
    Join Date
    Jan 2005
    Posts
    3
    I apologize, I wasn't asking you to do my homework.

    I was merely asking for, in plain english (not the code), how exactly I'm supposed to create a makefile. If that's still too much then I guess this forum isn't much use.

    I'll watch my wording next time.

  4. #4
    Linux Guru lakerdonald's Avatar
    Join Date
    Jun 2004
    Location
    St. Petersburg, FL
    Posts
    5,035
    oh okay.
    well a makefile is a file full of automated commands which run and do a certain task (a little like a shell script) and is one of the most powerful utilities out there. is this more what you were looking for?

  5. #5
    Just Joined!
    Join Date
    Jan 2005
    Posts
    3
    Better.

    So how do I operate the make utility? Do I use it from the terminal, or is it a seperate sort of program?

    ie. do I type "make" followed by some arguments, or is there not even any specific mention of "make" in its operation? I can't seem to find a decent explanation of this anywhere, and I'm beginning to feel as though I'm the only person in the world who just can't grasp this utility.

    Except nobody else in my building can do it either.

  6. #6
    Linux Guru lakerdonald's Avatar
    Join Date
    Jun 2004
    Location
    St. Petersburg, FL
    Posts
    5,035
    you execute the make command followed by options and "targets" which execute various commands. i suggest:

    Managing Projects With GNU Make -- 3rd Edition from O'REILLY Media Inc.

  7. #7
    Linux Enthusiast
    Join Date
    Dec 2004
    Location
    Rockin' in the USA!!!
    Posts
    603
    basically you make a bash script to compile your program. You use normal gcc and ld commands to compile and link the program just as you would from the terminal, the advantage is to automat the process. As for the targets, a target is section of commands in the makefile following a tag such as "install: " whatever is between "install: " and the next target will be executed with the command
    Code:
    make install
    as is with whatever the target name is.

  8. #8
    Linux Guru lakerdonald's Avatar
    Join Date
    Jun 2004
    Location
    St. Petersburg, FL
    Posts
    5,035
    that is partially correct.
    makefiles have a very strange syntax.
    i suggest the aforementioned book or
    Code:
    man make

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •