Help cleaning up my makefile
Posted: Wed Jun 13, 2007 7:56 am
Below is the contents of my current makefile. It needs to change in a BAD way... its becoming very combersome to maintain, and on top of that, my source code folder is being overloaded with files.
What I would like to do, is start moving code around so in my source folder, I would have sub folders:
mm/ -- This would contain the code for the allocator, pager, and kmalloc
tasks/ -- This would contain the code for tasks, and schedulers
drivers/ -- This would contain the code for the drivers, keyboard etc...
lowlevel/ -- This would contain all low-level init stuff, like gdt,idt,isr, and the assembler files...
I am not looking for someone to re-write my make file, but reading the faqs on the net isn't helping me much.
What I would like to do is:
go to the source folder, and run make all... gcc (nasm) creates objects for all the files in all the folders and moves all of the objects to a build/ folder. Then the linker links it all together, and copies to resulting file onto my floppy image... (thats currently what make install does) and currently make all, does include the make install...
Thanks in advance,
Rich
What I would like to do, is start moving code around so in my source folder, I would have sub folders:
mm/ -- This would contain the code for the allocator, pager, and kmalloc
tasks/ -- This would contain the code for tasks, and schedulers
drivers/ -- This would contain the code for the drivers, keyboard etc...
lowlevel/ -- This would contain all low-level init stuff, like gdt,idt,isr, and the assembler files...
I am not looking for someone to re-write my make file, but reading the faqs on the net isn't helping me much.
What I would like to do is:
go to the source folder, and run make all... gcc (nasm) creates objects for all the files in all the folders and moves all of the objects to a build/ folder. Then the linker links it all together, and copies to resulting file onto my floppy image... (thats currently what make install does) and currently make all, does include the make install...
Thanks in advance,
Rich
Code: Select all
CC=gcc
CFLAGS=-Wall -O -fstrength-reduce -fomit-frame-pointer -fleading-underscore -fno-stack-protector -finline-functions -nostdinc -fno-builtin -I./include -c -o
LD=ld
LDFLAGS=-Tlink.ld -o
ASM=nasm
ASMFLAGS=-f elf -o
SOURCES=start.asm pmutil.asm isr_handlers.asm irq_handlers.asm main.c gdt.c string.c iotech.c conio.c idt.c isrs.c irq.c xprinf.c kbdrv.c timer.c allocator.c pageman.c kmalloc.c reboot.c tasks.c
OBJS=start.o pmutil.o isr_handlers.o irq_handlers.o main.o gdt.o string.o iotech.o conio.o idt.o isrs.o irq.o xprintf.o kbdrv.o timer.o allocator.o pageman.o kmalloc.o reboot.o tasks.o
EXECUTABLE=cnex.sys
all: $(EXECUTABLE) install clean
$(EXECUTABLE) : $(OBJS)
$(LD) $(LDFLAGS) $(EXECUTABLE) $(OBJS)
start.o : start.asm
$(ASM) $(ASMFLAGS) start.o start.asm
pmutil.o : pmutil.asm
$(ASM) $(ASMFLAGS) pmutil.o pmutil.asm
isr_handlers.o : isr_handlers.asm
$(ASM) $(ASMFLAGS) isr_handlers.o isr_handlers.asm
irq_handlers.o : irq_handlers.asm
$(ASM) $(ASMFLAGS) irq_handlers.o irq_handlers.asm
main.o : main.c
$(CC) $(CFLAGS) main.o main.c
string.o : string.c
$(CC) $(CFLAGS) string.o string.c
iotech.o : iotech.c
$(CC) $(CFLAGS) iotech.o iotech.c
conio.o : conio.c
$(CC) $(CFLAGS) conio.o conio.c
idt.o : idt.c
$(CC) $(CFLAGS) idt.o idt.c
gdt.o : gdt.c
$(CC) $(CFLAGS) gdt.o gdt.c
irq.o : irq.c
$(CC) $(CFLAGS) irq.o irq.c
isrs.o : isrs.c
$(CC) $(CFLAGS) isrs.o isrs.c
xprintf.o : xprintf.c
$(CC) $(CFLAGS) xprintf.o xprintf.c
kbdrv.o : kbdrv.c
$(CC) $(CFLAGS) kbdrv.o kbdrv.c
timer.o : timer.c
$(CC) $(CFLAGS) timer.o timer.c
allocator.o : allocator.c
$(CC) $(CFLAGS) allocator.o allocator.c
pageman.o : pageman.c
$(CC) $(CFLAGS) pageman.o pageman.c
kmalloc.o : kmalloc.c
$(CC) $(CFLAGS) kmalloc.o kmalloc.c
reboot.o : reboot.c
$(CC) $(CFLAGS) reboot.o reboot.c
tasks.o : tasks.c
$(CC) $(CFLAGS) tasks.o tasks.c
clean :
rm -rf *.o
install :
mdel a:cnex.sys
mcopy cnex.sys a: