-
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
-
Something like:
Code:
EXEC=myprog.exe
all: ${EXEC}
${EXEC}: ${OBJS}
$(CC) $(CFLAGS) ${LARGS} -o $(EXEC) $(OBJS)
Some additional help
-
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
?
-
A blank line isn't necessarily a newline (\n). Make sure the last character is a newline.
-
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
-
You don't put \n in your file, just hit the [enter] button to create an empty last line.
-
Hmm well it must be the tester then, coz i tried that aswell :-)
Thanks for your help tho.
-
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.)
??
-
-
if you're using fgets(), do it like so:
Code:
fgets(buf, sizeof buf, stdin);
if (buf[0] == '\n')
{
Terminate
}