-
Makefile Help
Hello again guys. I would just like to ask for some help regarding the makefile I used for the inttohex program. It would not work and it would just say Missing separator. Stop..
Hope somebody could help. Here's the makefile:
Code:
# makefile for exercise on linked lists, files, searching and sorting
CC=gcc
CFLAGS=-g -W -Wall -I.
OBJECTS=inttohex.o
HEADERS=
PROGNAME=inttohex
$(PROGNAME): $(OBJECTS)
$(CC) $(CFLAGS) $(OBJECTS) -o $(PROGNAME)
inttohex.o: inttohex.c $(HEADERS)
$(CC) -c $(CFLAGS) -o inttohex.o
.PHONY: clean ctags
tags: ctags
ctags:
ctags -R
clean:
rm -rf $(OBJECTS) $(PROGNAME)
-
That's because you're using spaces instead of tabs in lines where command has to be executed. For example
Code:
$(CC) $(CFLAGS) $(OBJECTS) -o $(PROGNAME)
must be indented with tab not with 8 spaces.
Beside this, in the line
Code:
$(CC) -c $(CFLAGS) -o inttohex.o
you are not giving the source file to the compiler, so it cannot compile. Add inttohex.c after -c flag:
Code:
$(CC) -c inttohex.c $(CFLAGS) -o inttohex.o
Maybe there are more errors, that's what I saw immediately.
-
You shouldn't need to pass -r to rm, because I don't think it's going to be passed any directories.
Also, there is an implicit rule to compile .c files into .o files, so you can just use this:
Code:
inttohex.o: inttohex.c $(HEADERS)
leaving out the "$(CC) -c $(CFLAGS) -o inttohex.o".
-
Moved to Tech Board since it does not directly concern C programming.