Error with osdev.org Makefile
Posted: Thu Oct 18, 2012 12:55 pm
Hi,
First off I would like to thank the author of the Makefile article in the wiki http://wiki.osdev.org/Makefile. I am using this as a reference for my own makefile for a little project I have just started (not OS development). Here is the makefile,
However I noticed that if I execute make the second time (without a clean and just some minor file source code modifications) I get the following error (I need to do a clean and make again to get a proper compile),
I think this is most probably because of an error in my Makefile (constructed with my limited understanding of the wiki article), and would really appreciate any help from the folks here in figuring out what I am missing here.
TIA
First off I would like to thank the author of the Makefile article in the wiki http://wiki.osdev.org/Makefile. I am using this as a reference for my own makefile for a little project I have just started (not OS development). Here is the makefile,
Code: Select all
CC := gcc
RM := rm
CFLAGS := -Iinclude/ -g -std=c99 -Wall
RMFLAGS := -rf
EXT_LIBS := -lc -lssl
PROJDIRS := dir1 dir2
SRCFILES := $(shell find $(PROJDIRS) -type f -name "*.c")
HDRFILES := $(shell find $(PROJDIRS) -type f -name "*.h")
OBJFILES := $(patsubst %.c,%.o,$(SRCFILES))
DEPFILES := $(patsubst %.c,%.d,$(SRCFILES))
EXECUTABLE := my_exec
.PHONY: all clean
all: $(EXECUTABLE)
$(EXECUTABLE): $(OBJFILES)
@$(CC) -o $(EXECUTABLE) $? $(EXT_LIBS)
%.o: %.c Makefile
@$(CC) $(CFLAGS) -MD -MP -c $< -o $@
-include $(DEPFILES)
clean:
-@$(RM) $(RMFLAGS) $(OBJFILES) $(DEPFILES) $(EXECUTABLE)
Code: Select all
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: ld returned 1 exit status
make: *** [my_exec] Error 1
TIA