#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    india
    Posts
    28
    Rep Power
    0

    make file creation


    can i get an idea how a make is creating

    steps
    and codes used in this context
    i am toatally null about this concept
    i want to what is make file

    what is the use
    how will i create one
    steps
    key words
  2. #2
  3. *bounce*
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2002
    Location
    Delft, The Netherlands
    Posts
    514
    Rep Power
    42
    "A poor programmer is he who blames his tools."
    http://analyser.oli.tudelft.nl/
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    india
    Posts
    28
    Rep Power
    0

    make file creation


    can i get the meaning of this commands


    CFLAGS = -o
    OBJ = mnpmadisc.o
    LIBS = -lnetsnmp -lcrypto -lm -lmcrypt -L/usr/lib -lz -lm libhttp_fetcher.a /usr/lib/libxml2.a
    INCLUDE = -I/usr/include/libxml2

    all: mnpmadisc

    mnpmadisc: $(OBJ)
    $(CC) -o mnpmadisc $(OBJ) -lnetsnmp -lcrypto -lm -lmcrypt -L/usr/lib -lz -lm libhttp_fetcher.a /usr/lib/libxml2.a

    mnpmadisc.o: mnpmadisc.c
    $(CC) -c mnpmadisc.c $(INCLUDE)
    ~
    ~
    ~
    ~
    ~
    ~
    ~
    ~
    ~
  6. #4
  7. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,162
    Rep Power
    2222
    The whole idea behind make files is to write down all the instructions needed for creating a project. The whole idea behind how they work are the ideas of targets, dependencies, and rules: you are creating a final and intermediate targets, these targets depend on certain files and intermediate targets and there are rules for creating these targets. If a file changes, then all targets dependent on that file must be created again, whereupon the applicable rule is applied.

    Originally posted by suji
    CFLAGS = -o
    OBJ = mnpmadisc.o
    LIBS = -lnetsnmp -lcrypto -lm -lmcrypt -L/usr/lib -lz -lm libhttp_fetcher.a /usr/lib/libxml2.a
    INCLUDE = -I/usr/include/libxml2
    Such assignment statements are macro definitions, very much like creating shell variables. All we are doing here is to assign everything on the right side of the equals sign to the macro name on the left side. Then when we reference that macro later (eg with $(OBJ) ), the assigned string will be substituted in its place.
    Originally posted by suji
    all: mnpmadisc
    mnpmadisc is the final target.

    I should probably add that a makefile can have several different targets, any of which can be selected from the command line invocation of make. You can have a "clean" target in which you list the commands for deleting some intermediate files. You can have an "install" target which will create the target files, if necessary, and copy them to the appropriate directories. If no target is specified, then it defaults to the "all" target. The command line invocations would look like (assuming make file named Makefile):
    To run the default "all" target --
    make
    To run the "clean" target --
    make clean
    To run the "install" target --
    make install
    Originally posted by suji

    mnpmadisc: $(OBJ)
    $(CC) -o mnpmadisc $(OBJ) -lnetsnmp -lcrypto -lm -lmcrypt -L/usr/lib -lz -lm libhttp_fetcher.a /usr/lib/libxml2.a
    mnpdadisc depends on the objects named in the macro definition of OBJ, which in this case is mnpmadisc.o. If mnpmadisc.o has changed since mnpmadisc was created, then mnpdadisc must be created again.
    The next line is the rule for creating mnpdadisc. Please note that the line must begin with a tab character; leading spaces will not work. Note also that the macro CC must have been defined either within the makefile or as a shell variable. For Linux, it should have been defined as:
    CC= gcc

    Also, the rule is unnecessarily verbose. All those libraries have already been included in the macro definition for LIBS, so instead the rule should read:
    $(CC) -o mnpmadisc $(OBJ) $(LIBS)

    Originally posted by suji
    mnpmadisc.o: mnpmadisc.c
    $(CC) -c mnpmadisc.c $(INCLUDE)
    Here we state that mnpmadisc.o is dependent on mnpmadisc.c and the next line contains the rule for making mnpdadisc.o. Please note that, as before, the rule must begin with a tab character.

    Also note that if all the targets are up-to-date, then nothing needs to be done and make will report that there was nothing to be done for this makefile. That may appear to be an error message, but it is not.
    Last edited by dwise1_aol; July 9th, 2003 at 10:14 AM.
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    india
    Posts
    28
    Rep Power
    0

    i didn't the real answer yet


    i didn't the real answer yet
    about libraries
    how they store
    ehat is meaning of below
    where is the actual store

    mnpmadisc: $(OBJ)
    $(CC) -o mnpmadisc $(OBJ) -lnetsnmp -lcrypto -lm -lmcrypt -L/usr/lib -lz -lm libhttp_fetcher.a /usr/lib/libxml2.a
  10. #6
  11. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,162
    Rep Power
    2222

    Re: i didn't the real answer yet


    Originally posted by suji
    i didn't the real answer yet
    about libraries
    how they store
    ehat is meaning of below
    where is the actual store

    mnpmadisc: $(OBJ)
    $(CC) -o mnpmadisc $(OBJ) -lnetsnmp -lcrypto -lm -lmcrypt -L/usr/lib -lz -lm libhttp_fetcher.a /usr/lib/libxml2.a
    Read the man page for gcc.

    In your compiler's configuration files, there are default library and include file pathes that it will search. If you want to include additional directories, then you will use the -L option to specify additional library directories and the -I option to specify additional header file directories.

    (guessing at some file names based on my experience)
    -lnetsnmp refers to the library file libnetsnmp.a
    -lm refers to the math library file libm.a
    -lz refers to the library file libz.a
    -lmcrypt refers to the library file libmcrypt.a
    -L/usr/lib tells $(CC) to also search the directory /usr/lib for library files.
    -lz -lm libhttp_fetcher.a after the -L/usr/lib refers to those library files in that directory (I believe, assuming that order matters)
    /usr/lib/libxml2.a refers explicitly to that xml library file in that specific directory.

IMN logo majestic logo threadwatch logo seochat tools logo