Thread: make only does the first line

  1. #1
    Registered User
    Join Date
    Jul 2002
    Posts
    913

    make only does the first line

    im working on a couple of makefiles. i have one for a couple of source file in a dir. its supports to turn them into libraries, but it only does the first line, why?

    i did it like this
    [edit]
    str_remove.o : str_remove.c
    gcc -c str_remove.c

    ar -r str_remove.a
    ranlib str_remove.a
    str_replace.o : str_replace.c
    gcc -c str_replace.c

    ar -r str_replace.a
    ranlib str_replace.a
    [/edit]

    whats wrong?
    Last edited by mart_man00; 06-20-2003 at 04:43 PM.

  2. #2
    Registered User
    Join Date
    Jul 2002
    Posts
    913
    i removed the blank lines and the spaces, it still doesnt work. im doing this in windows with gnu make.

    i miss gentoo..........

  3. #3
    Registered User
    Join Date
    Jul 2002
    Posts
    913
    sure. i added the .txt extention so i could upload it here.

    thanks for looking at it.

  4. #4
    Registered User
    Join Date
    Jul 2002
    Posts
    913
    Your ar commands do not list any object files
    so it should end with a .o? it worked before(gave me a .o and a .A)

    Your last dependency doesn't make any sense - you list one object, yet compile 2 unrelated source files.
    i forgot to add in move.c the other files is what it needs.

  5. #5
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    For me, your file made the first archive file when I simply run make against it:

    $ make
    gcc -c str_remove.c
    ar -r str_remove.a
    ranlib str_remove.a

    To make all your str_* files in one go, add another rule like this:

    all: str_remove.o \
    str_replace.o

    (obviously add the rest to the list)
    Then you can go "make all"

    There are other ways to do this too. Try finding a make tutorial.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  6. #6
    Registered User
    Join Date
    Jul 2002
    Posts
    913
    my last rule has extra dependacies, could i use my other rules as functions and call them in all?

    but why does it stop after the first line?

  7. #7
    Registered User
    Join Date
    Jul 2002
    Posts
    913
    i changed it to this

    Code:
    str_remove.o : str_remove.c
    	gcc -c str_remove.c
    	ar -r str_remove.a str_remove.o
    	ranlib str_remove.a
    str_replace.o : str_replace.c
    	gcc -c str_replace.c
    	ar -r str_replace.a str_replace.o
    	ranlib str_replace.a
    str_copy.o : str_copy.c
    	gcc -c str_copy.c
    	ar -r str_copy.a str_copy.o
    	ranlib str_copy.a
    str_count.o : str_count.c
    	gcc -c str_count.c
    	ar -r str_count.a str_count.o
    	ranlib str_count.a
    str_insert.o : str_insert.c
    	gcc -c str_insert.c
    	ar -r str_insert.a str_insert.a
    	ranlib str_insert.a
    str_move.o : str_move.c str_remove.c str_insert.c
    	gcc -c str_move.c str_remove.c str_insert.c
    	ar -r str_move.a str_move.o
    	ranlib str_move.a
    i get back from make "make: `str_remove.o' is up to date." i only have .c's and .h's in my dir. im sure its right in front of me but i still dont see it, sorry.
    Last edited by mart_man00; 06-20-2003 at 04:43 PM.

  8. #8
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You should probably pick up something like the Linux Programming Bible which covers Make files, shell scripts, and a bunch of other nifty stuff. Doubtless there are other books out there, but it's one I have, and it does in fact cover make files.

    Quzah.
    Hope is the first step on the road to disappointment.

  9. #9
    Registered User
    Join Date
    Jul 2002
    Posts
    913
    i have the gnu make manual downloaded, i still dont see the problem. how do it look different from ones you written(or is that the problem, no one writes them any more).

    i have that book in a pdf, i think i will buy it. is there a book section in the faq coming?

  10. #10
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >>is there a book section in the faq?
    No, but there blooming should be You wanna complain to one in charge of it ...

    mart, use code tags when posting source (include make file contents). It'll keep the indentation correct for us to see.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  11. #11
    Registered User
    Join Date
    Jul 2002
    Posts
    913
    mart, use code tags when posting source (include make file contents). It'll keep the indentation correct for us to see.
    sorry i forgot about what quote cant do.

    so no ideas? this is new....

  12. #12
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    I copy/paste your make file, I have only a str_remove.c in my directory, I run:
    >>make str_remove.o
    and it says:
    Code:
    $ make str_remove.o
    gcc -c str_remove.c
    ar -r str_remove.a str_remove.o
    ranlib str_remove.a
    Are you sure you're not doing "make str_remove" by mistake?
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  13. #13
    Registered User
    Join Date
    Jul 2002
    Posts
    913
    no, im typing in "make" with nothing else. the file's name is "Makefile".

    why would it stop? there are no .A's or .o's, they would have to be created. i do have all the programs. im getting no error, im see exactly what you posted. those are tabs not spaces too.

  14. #14
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >>im see exactly what you posted
    Are you meaning that it runs the compile and archive for the first .o file, then stops? With output like shown in my previous post?

    If so, then you need to understand that simply running "make" with no parameters doesn't make all the targets in the file. Try running it as I suggested:
    >>make str_replace.o

    If this is your problem, you need to create another rule, normal named "all" (as I mentioned earlier).
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  15. #15
    Registered User
    Join Date
    Jul 2002
    Posts
    913
    so a file that is not in a dir is not seen as being updated? im using a old book then.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help again with scrolling without wrapping
    By Dukefrukem in forum C Programming
    Replies: 8
    Last Post: 09-21-2007, 12:48 PM
  2. makefile
    By twans in forum C++ Programming
    Replies: 3
    Last Post: 04-08-2005, 12:16 AM
  3. print line by line from a file
    By SoFarAway in forum C Programming
    Replies: 3
    Last Post: 02-18-2005, 01:36 PM
  4. SSCANF help
    By mattz in forum C Programming
    Replies: 7
    Last Post: 12-10-2001, 04:53 PM
  5. Validating the contents of a char buffer
    By mattz in forum C Programming
    Replies: 3
    Last Post: 12-09-2001, 06:21 PM