make all rule

This is a discussion on make all rule within the C Programming forums, part of the General Programming Boards category; I need to add a "all" rule to my make file, but ive never seen what that is before, and ...

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    31

    make all rule

    I need to add a "all" rule to my make file, but ive never seen what that is before, and ive done a search but cant find anything. the all rule is meant to make it so that make all produces an executable.

    Can anyone please show me. heres the makefile that i have already made:

    Code:
    CC=gcc
    OBJS=num.o
    EXTRA-FLAGS=
    
    num: $(OBJS)
    	$(CC) $(EXTRA_FLAGS) -c num.c
    clean:
    	rm -f num ${OBJS}
    debug:
    	make EXTRA_FLAGS=-g
    tar:
    	tar cf num.tar makefile num.c

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Something like:

    Code:
    EXEC=myprog.exe
    all: ${EXEC}
    
    ${EXEC}: ${OBJS}
        $(CC) $(CFLAGS) ${LARGS} -o $(EXEC) $(OBJS)
    Some additional help
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Registered User
    Join Date
    Sep 2002
    Posts
    31
    Im getting a warning that newline is not the last character in the makefile, but there is a blank line there, so whats the problem.? Does it have to be a \n
    ?

  4. #4
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    A blank line isn't necessarily a newline (\n). Make sure the last character is a newline.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  5. #5
    Registered User
    Join Date
    Sep 2002
    Posts
    31
    Now I get this:

    make: Fatal error in reader: makefile, line 20: Unexpected end of line seen

    What am i doing wrong??!!!

    Code:
    CC=gcc
    OBJS=num.o
    EXEC=num.exe
    EXTRA-FLAGS=
    
    all: ${EXEC}
    
    ${EXEC}: ${OBJS}
    	$(CC) $(CFLAGS) $(LARGS) -o ${EXEC} ${OBJS}
    
    num: $(OBJS)
    	$(CC) $(EXTRA_FLAGS) -c num.c
    clean:
    	rm -f num ${OBJS}
    debug:
    	make EXTRA_FLAGS=-g
    tar:
    	tar cf num.tar makefile num.c
    \n

  6. #6
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    You don't put \n in your file, just hit the [enter] button to create an empty last line.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  7. #7
    Registered User
    Join Date
    Sep 2002
    Posts
    31
    Hmm well it must be the tester then, coz i tried that aswell :-)

    Thanks for your help tho.

  8. #8
    Registered User
    Join Date
    Sep 2002
    Posts
    31
    How do i get my program to end when the enter button is hit, with no input on the line?


    Example:

    $12345 (enter)
    $24234 (enter)
    $ (enter)
    (program ends here.)

    ??

  9. #9
    Registered User
    Join Date
    Sep 2002
    Posts
    31
    anyone? its urgent

  10. #10
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    if you're using fgets(), do it like so:

    Code:
    fgets(buf, sizeof buf, stdin);
    if (buf[0] == '\n')
    {
       Terminate
    }
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Establishing 'make clean' with GNU make
    By Jesdisciple in forum C Programming
    Replies: 9
    Last Post: 04-11-2009, 09:10 AM
  2. How to make a Packet sniffer/filter?
    By shown in forum C++ Programming
    Replies: 2
    Last Post: 02-22-2009, 08:51 PM
  3. Replies: 1
    Last Post: 12-03-2008, 02:10 AM
  4. HELP!wanting to make full screen game windowed
    By rented in forum Game Programming
    Replies: 3
    Last Post: 06-11-2004, 04:19 AM
  5. Replies: 6
    Last Post: 04-20-2002, 06:35 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21