-
makefile blues....
Hi, based off some errors I got compiling last week, it was recommended I create a makefile to include some links for necessary libs.
I began researching make and creating makefiles and found some good examples to work from but the make file I created is blowing up on me.
Have I created a bad makefile or is it finding issues with my source code? I know thats a vague question I'm trying to get someone to read the code, just not sure if I am grasping the makefile concept or not and wanted to know if anyone see's an obvious mistake. Thanks-
the error while running make is:
Code:
make: Fatal error in reader: Makefile, line 17: Unexpected end of line seen
the actual make file is:
Code:
INCL = utilserv.h
SRC = simpletest.c
OBJ = $(SRC:.c=.o)
LIBS = -lsocket -lcomctl32
EXE = a.exe
# compiler stuff
CC = gcc
CFLAGS = -O3
LDFLAGS = -o $(EXE) $(LIBS)
CFDEBUG = -g -DDEBUG $(LDFLAGS)
RM = rm -f
# create object files
%.o: %.c
$(CC) -c $(CFLAGS) $*.c -o $*.o
# linker objects
$(EXE): $(OBJ)
$(CC) $(OBJ) menu.o $(LDFLAGS) -mwindows
# object-dependent libraries
$(OBJ): $(INCL)
# make debug
debug:
$(CC) $(CFDEBUG) $(SRC)
# make clean
clean:
$(RM) $(OBJ) $(EXE)
-
Code:
# create object files
%.o: %.c
$(CC) -c $(CFLAGS) $*.c -o $*.o
I don't think there is supposed to be a space between the : and %.
-
Thanks for the reply, I tried removing the space between the : and %, but still got the same error. I'm not familiar with the syntax for unix with make, I'm new to programing in the unix environment.
I tried compiling against a known good .c file and it still failed with the same error, so I'm pretty sure its an error with how my makefile is setup, I just don't enough about to find the problem.... Thanks again for any help :)
-
Maybe there's something in one of these; or man make.
-
Thanks Dave.
Google is always a good place to look. I have not been able to find my issue, I'm sure its just some simple syntax issue on my part so I will start writing from scratch and see if I catch it.
Thanks for the replies-
-
Assuming you are indenting your rules with tab characters make sure you don't have any extra/stray spaces there, too.
-
As it turns out Ken you are correct. Thats what I get for being lazy! and doing a paste and copy of an example and trying to fill in the blanks. Thanks again to all. Sometimes shortcuts are not as short as they seem. But I am learning! :D