############################################################################
-CF = -c -I include -fno-builtin
-CC = $(_CC) $(CF) -o
+CC = gcc
+CFLAGS = -c -fno-builtin
SYSTEMMAP = System.map
KERNELBIN = KERNEL.BIN
LINKSCRIPT = scripts/link.ld
-OBJS = boot/multiboot.S.o boot/boot.o boot/reboot.S.o boot/cmdline.o\
- setup/*.o mm/*.o kernel/*.o fs/*.o pci/*.o lib/*.o \
- drivers/*.o
-#BINS#######################################################################
-$(KERNELBIN):
- cd boot && make
- cd setup && make
- cd mm && make
- cd kernel && make
- cd fs && make
- cd pci && make
- cd lib && make
- cd drivers && make
- ld -M -T$(LINKSCRIPT) -o $@ $(OBJS) > $(SYSTEMMAP)
- ld -T$(LINKSCRIPT) -o $@ $(OBJS)
- cd bin && make
- md5sum $(KERNELBIN)
- #./scripts/grub2-debug.sh
- #mv $@ KRNL.ELF
-.PHONY:real
-real:
-
-.PHONY:c
+############################################################################
+
+SRC_DIRS = boot setup mm lib fs kernel drivers pci
+INC_DIRS = include drivers
+
+CSOURCE_FILES := $(foreach dir, $(SRC_DIRS), $(wildcard $(dir)/*.c))
+SSOURCE_FILES := $(foreach dir, $(SRC_DIRS), $(wildcard $(dir)/*.S))
+
+OBJS := $(patsubst %.c,%.c.o,$(CSOURCE_FILES))
+OBJS += $(patsubst %.S,%.S.o,$(SSOURCE_FILES))
+
+CFLAGS += ${INC_DIRS:%=-I%}
+
+${KERNELBIN}: ${OBJS} $
+ ld -M -T$(LINKSCRIPT) $(OBJS) -o $@ > $(SYSTEMMAP)
+
+%.S.o: %.S
+ ${CC} ${CFLAGS} $< -o $@
+
+%.c.o: %.c
+ ${CC} ${CFLAGS} $< -o $@
+
c:
rm -f $(KERNELBIN)
-.PHONY:clean
clean:
- cd boot && make clean
- cd setup && make clean
- cd mm && make clean
- cd kernel && make clean
- cd fs && make clean
- cd pci && make clean
- cd lib && make clean
- cd drivers && make clean
- cd bin && make clean
- rm -f $(KERNELBIN) System.map snapshot.txt log.txt
- rm -f KRNL.ELF
-
-.PHONY:install
+ rm -f $(OBJS)
+ rm -f $(KERNELBIN) $(SYSTEMMAP)
+
install:
cp KERNEL.BIN /boot/
-.PHONY:copy
+
copy:
./scripts/copy.sh
CC = gcc
CFLAGS = -c -I../include -fno-builtin
-LDOBJS = ../lib/errno.o ../lib/fork.o ../lib/lib.o ../lib/open.o \
- ../lib/stat.o ../lib/string.o ../lib/write.o ../lib/exec.o \
- ../lib/vsprintf.o ../lib/read.o \
- ../lib/keyboard.o ../lib/exit.o
+LDOBJS = ../lib/errno.c.o ../lib/fork.c.o ../lib/lib.c.o ../lib/open.c.o \
+ ../lib/stat.c.o ../lib/string.c.o ../lib/write.c.o ../lib/exec.c.o \
+ ../lib/vsprintf.c.o ../lib/read.c.o \
+ ../lib/keyboard.c.o ../lib/exit.c.o
all:
- gcc -c shell.S -o shell.S.o
- gcc $(CFLAGS) shell.c -o shell.o
- ld $(LDOBJS) shell.S.o shell.o -o sh
- gcc -c helloworld.S -o helloworld.S.o
- gcc $(CFLAGS) helloworld.c -o helloworld.o
- ld $(LDOBJS) helloworld.S.o helloworld.o -o hw
+ gcc -c shell.S -o shell.S.c.o
+ gcc $(CFLAGS) shell.c -o shell.c.o
+ ld $(LDOBJS) shell.S.c.o shell.c.o -o sh
+ gcc -c helloworld.S -o helloworld.S.c.o
+ gcc $(CFLAGS) helloworld.c -o helloworld.c.o
+ ld $(LDOBJS) helloworld.S.c.o helloworld.c.o -o hw
.PHONY:clean
clean:
- rm sh hw helloworld.o -f
+ rm sh hw helloworld.c.o -f
.PHONY:c
c:
make clean
+++ /dev/null
-include ../kernel.mk
-CC = gcc
-CFLAGS = $(CF)
-
-CSOUCE_FILES = $(wildcard *.c)
-SSOUCE_FILES = $(wildcard *.S)
-OBJS = $(patsubst %.c,%.o,$(CSOUCE_FILES))
-OBJS += $(patsubst %.S,%.S.o,$(SSOUCE_FILES))
-
-%.o : %.c *.h ../include/*.h
- $(CC) $(CFLAGS) $< -o $@
-%.S.o : %.S ../include/*.h
- $(CC) $(CFLAGS) $< -o $@
-
-
-all:$(OBJS)
-
-.PHONY:clean
-clean:
- $(RM) $(OBJS)
-.PHONY:c
-c:
- make clean
+++ /dev/null
-include ../kernel.mk
-CC = gcc
-CFLAGS = $(CF)
-
-CSOUCE_FILES = $(wildcard *.c)
-SSOUCE_FILES = $(wildcard *.S)
-OBJS = $(patsubst %.c,%.o,$(CSOUCE_FILES))
-OBJS += $(patsubst %.S,%.S.o,$(SSOUCE_FILES))
-
-%.o : %.c ../include/*.h ./*.h
- $(CC) $(CFLAGS) $< -o $@
-%.S.o : %.S ../include/*.h ./*.h
- $(CC) $(CFLAGS) $< -o $@
-
-
-all:$(OBJS)
-
-.PHONY:clean
-clean:
- $(RM) $(OBJS)
-.PHONY:c
-c:
- make clean
+++ /dev/null
-include ../kernel.mk
-CC = gcc
-CFLAGS = $(CF)
-
-CSOUCE_FILES = $(wildcard *.c)
-SSOUCE_FILES = $(wildcard *.S)
-OBJS = $(patsubst %.c,%.o,$(CSOUCE_FILES))
-OBJS += $(patsubst %.S,%.S.o,$(SSOUCE_FILES))
-
-%.o : %.c ../include/*.h ./*.h
- $(CC) $(CFLAGS) $< -o $@
-%.S.o : %.S ../include/*.h ./*.h
- $(CC) $(CFLAGS) $< -o $@
-
-
-all:$(OBJS)
-
-.PHONY:clean
-clean:
- $(RM) $(OBJS)
-.PHONY:c
-c:
- make clean
+++ /dev/null
-CF = -g -c -I. -Iinclude -I../include -fno-builtin
+++ /dev/null
-include ../kernel.mk
-CC = gcc
-CFLAGS = $(CF)
-
-CSOUCE_FILES = $(wildcard *.c)
-SSOUCE_FILES = $(wildcard *.S)
-OBJS = $(patsubst %.c,%.o,$(CSOUCE_FILES))
-OBJS += $(patsubst %.S,%.S.o,$(SSOUCE_FILES))
-
-%.o : %.c ../include/*.h
- $(CC) $(CFLAGS) $< -o $@
-%.S.o : %.S ../include/*.h
- $(CC) $(CFLAGS) $< -o $@
-
-
-all:$(OBJS)
-
-.PHONY:clean
-clean:
- $(RM) $(OBJS)
-.PHONY:c
-c:
- make clean
+++ /dev/null
-include ../kernel.mk
-CC = gcc
-CFLAGS = $(CF)
-
-CSOUCE_FILES = $(wildcard *.c)
-SSOUCE_FILES = $(wildcard *.S)
-OBJS = $(patsubst %.c,%.o,$(CSOUCE_FILES))
-OBJS += $(patsubst %.S,%.S.o,$(SSOUCE_FILES))
-
-%.o : %.c ../include/*.h
- $(CC) $(CFLAGS) $< -o $@
-%.S.o : %.S ../include/*.h
- $(CC) $(CFLAGS) $< -o $@
-
-
-all:$(OBJS)
-
-.PHONY:clean
-clean:
- $(RM) $(OBJS)
-.PHONY:c
-c:
- make clean
+++ /dev/null
-include ../kernel.mk
-CC = gcc
-CFLAGS = $(CF)
-
-CSOUCE_FILES = $(wildcard *.c)
-SSOUCE_FILES = $(wildcard *.S)
-OBJS = $(patsubst %.c,%.o,$(CSOUCE_FILES))
-OBJS += $(patsubst %.S,%.S.o,$(SSOUCE_FILES))
-
-%.o : %.c ../include/*.h
- $(CC) $(CFLAGS) $< -o $@
-%.S.o : %.S ../include/*.h
- $(CC) $(CFLAGS) $< -o $@
-
-
-all:$(OBJS)
-
-.PHONY:clean
-clean:
- $(RM) $(OBJS)
-.PHONY:c
-c:
- make clean
+++ /dev/null
-include ../kernel.mk
-CC = gcc
-CFLAGS = $(CF)
-
-CSOUCE_FILES = $(wildcard *.c)
-SSOUCE_FILES = $(wildcard *.S)
-OBJS = $(patsubst %.c,%.o,$(CSOUCE_FILES))
-OBJS += $(patsubst %.S,%.S.o,$(SSOUCE_FILES))
-
-%.o : %.c ../include/*.h
- $(CC) $(CFLAGS) $< -o $@
-%.S.o : %.S ../include/*.h
- $(CC) $(CFLAGS) $< -o $@
-
-
-all:$(OBJS)
-
-.PHONY:clean
-clean:
- $(RM) $(OBJS)
-.PHONY:c
-c:
- make clean
+++ /dev/null
-include ../kernel.mk
-CC = gcc
-CFLAGS = $(CF)
-
-CSOUCE_FILES = $(wildcard *.c)
-SSOUCE_FILES = $(wildcard *.S)
-OBJS = $(patsubst %.c,%.o,$(CSOUCE_FILES))
-OBJS += $(patsubst %.S,%.S.o,$(SSOUCE_FILES))
-
-%.o : %.c ../include/*.h
- $(CC) $(CFLAGS) $< -o $@
-%.S.o : %.S ../include/*.h
- $(CC) $(CFLAGS) $< -o $@
-
-
-all:$(OBJS)
-
-.PHONY:clean
-clean:
- $(RM) $(OBJS)
-.PHONY:c
-c:
- make clean