Makefile problem
Posted: Sun Feb 17, 2008 2:46 am
I recently started on a OS project, and as I build it with Cygwin (instead of VC++ which i sue for me other projects) I decided to create a makefile to simplify building.
However, somehow it only compiles one of the two .S files in my kernel, and the other is just given to the linker, which, obviously, doesn't like that.
this is the Makefile I use, based on the tutorial/example in the wiki:
What is wrong and how can I solve it???
However, somehow it only compiles one of the two .S files in my kernel, and the other is just given to the linker, which, obviously, doesn't like that.
this is the Makefile I use, based on the tutorial/example in the wiki:
Code: Select all
AUXFILES := Makefile
PROJDIRS := General Boot IDTManager Exceptions
SRCFILES := $(shell find $(PROJDIRS) -mindepth 1 -maxdepth 3 -name "*.c")
HDRFILES := $(shell find $(PROJDIRS) -mindepth 1 -maxdepth 3 -name "*.h")
ASMFILES := $(shell find $(PROJDIRS) -mindepth 1 -maxdepth 3 -name "*.S");
OBJFILES := $(patsubst %.c,%.o,$(SRCFILES)) $(patsubst %.S,%.o,$(ASMFILES))
DEPFILES := $(patsubst %.c,%.d,$(SRCFILES))
ALLFILES := $(SRCFILES) $(HDRFILES) $(AUXFILES) $(ASMFILES)
.PHONY: clean
CC := gcc
CFLAGS := -Wall -Wextra -pedantic -Wshadow -Wpointer-arith -Wcast-align \
-Wwrite-strings -Wmissing-prototypes -Wmissing-declarations \
-Wredundant-decls -Wnested-externs -Winline -Wno-long-long \
-Wconversion -Wstrict-prototypes
AS := nasm
all: kernel
kernel: $(OBJFILES)
@ld -o kernel -Map kernelmap $? boot/linker.ld
clean:
-@for file in $(OBJFILES) $(DEPFILES) kernel; do if [ -f $$file ]; then rm $$file; fi;
-include $(DEPFILES)
todolist:
-@for file in $(ALLFILES); do grep -H TODO $$file; done; true
%.o: %.c Makefile
@$(CC) $(CFLAGS) -DNDEBUG -MD -MP -std=c99 -c $< -o $@
%.o: %.S Makefile
@$(AS) -f elf -o $@ $<