summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexis211 <alexis211@gmail.com>2010-08-10 17:14:38 +0200
committerAlexis211 <alexis211@gmail.com>2010-08-10 17:14:38 +0200
commit0ec0ca40a4fedfe97c49903a329b2a9ad2e22d03 (patch)
treeb9033e69392dd1a7ffe0173ef8db561ecce9b21b
parentad27a90fa788a81253b5f2ad621d82ae574ae65d (diff)
downloadTCE-0ec0ca40a4fedfe97c49903a329b2a9ad2e22d03.tar.gz
TCE-0ec0ca40a4fedfe97c49903a329b2a9ad2e22d03.zip
Using a cross-compiler. Better makefile system.
-rw-r--r--Grapes.fl.imgbin1474560 -> 1474560 bytes
-rw-r--r--Makefile15
-rw-r--r--README3
-rwxr-xr-xcopy_fdd.sh4
-rw-r--r--src/common.make39
-rw-r--r--src/kernel/Makefile46
-rw-r--r--src/kernel/core/sys.c2
-rw-r--r--src/library/Makefile42
-rw-r--r--src/library/gm/call.c2
-rw-r--r--src/library/gm/call/manager.c2
-rw-r--r--src/modules/manager/Makefile34
-rw-r--r--src/modules/test/Makefile35
12 files changed, 87 insertions, 137 deletions
diff --git a/Grapes.fl.img b/Grapes.fl.img
index b0e4c18..8ebf30b 100644
--- a/Grapes.fl.img
+++ b/Grapes.fl.img
Binary files differ
diff --git a/Makefile b/Makefile
index 9425023..6a014ec 100644
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,8 @@ Projects = kernel library modules/manager modules/test
Floppy = Grapes.fl.img
all:
- for p in $(Projects); do \
+ @for p in $(Projects); do \
+ echo ""; echo "----------------------"; \
echo "=> Building $$p"; \
make -C src/$$p -s; \
done
@@ -13,21 +14,23 @@ all:
rebuild: mrproper all
clean:
- for p in $(Projects); do \
- echo "=> Building $$p"; \
+ @for p in $(Projects); do \
+ echo ""; echo "----------------------"; \
+ echo "=> Cleaning $$p"; \
make -C src/$$p clean -s; \
done
mrproper:
- for p in $(Projects); do \
- echo "=> Building $$p"; \
+ @for p in $(Projects); do \
+ echo ""; echo "----------------------"; \
+ echo "=> Cleaning $$p"; \
make -C src/$$p mrproper -s; \
done
commit: mrproper
git add .
git commit -a; exit 0
- git push github
+ git push origin
floppy:
mkdir mnt; exit 0
diff --git a/README b/README
index e69de29..f9f10b8 100644
--- a/README
+++ b/README
@@ -0,0 +1,3 @@
+To compile Grapes, you will need a i586-elf gcc cross-compiler.
+You can find some scripts to build cross-compilers here :
+ http://github.com/Alexis211/cross-scripts
diff --git a/copy_fdd.sh b/copy_fdd.sh
index 087939d..4a6b239 100755
--- a/copy_fdd.sh
+++ b/copy_fdd.sh
@@ -1,13 +1,15 @@
#!/bin/sh
# We assume mnt/ is the directory where the image is mounted, and src/ is the directory with all the compiled files
+rm mnt/*
# Update GRUB's menu.cfg
cp menu_fdd.cfg mnt/boot/menu.cfg
# copy kernel
cp src/kernel/kernel.elf mnt
-cp src/modules/test/test.elf src/modules/manager/manager.elf mnt
+cp src/modules/test/test.elf mnt
+cp src/modules/manager/manager.elf mnt
#echo "*** Launching a BASH shell, if you want to do any maintenance ***"
#bash || exit 0
diff --git a/src/common.make b/src/common.make
new file mode 100644
index 0000000..6aa6e4b
--- /dev/null
+++ b/src/common.make
@@ -0,0 +1,39 @@
+# ============== ENVIRONMENT VARIABLES
+
+CC = i586-elf-gcc
+CFLAGS = -nostdlib -nostartfiles -nodefaultlibs -fno-builtin -fno-stack-protector -Wall -Wextra
+
+LD = i586-elf-ld
+.PHONY: clean, mrproper
+
+LDFLAGS =
+
+ASM = nasm
+AFLAGS = -f elf
+
+# ============== GENERAL BUILD PROCEDURES
+
+all: $(Out)
+
+$(Out): $(Obj)
+ echo ""; echo "- Linking $@..."
+ $(LD) $(LDFLAGS) $^ -o $@
+
+# ============== GENERAL CLEAINING PROCEDURES
+
+clean:
+ rm $(Obj) || exit 0
+ rm *.o */*.o || exit 0
+
+mrproper: clean
+ rm $(Out) || exit 0
+
+# ============== SOURCE FILE BUILD PROCEDURES
+
+%.o: %.asm
+ echo ""; echo "- $<"
+ $(ASM) $(AFLAGS) -o $@ $<
+
+%.o: %.c
+ echo ""; echo "- $<"
+ $(CC) -c $< -o $@ $(CFLAGS)
diff --git a/src/kernel/Makefile b/src/kernel/Makefile
index d7a6a57..eb69cfc 100644
--- a/src/kernel/Makefile
+++ b/src/kernel/Makefile
@@ -1,39 +1,15 @@
-.PHONY: clean, mrproper
+Out = kernel.elf
+Obj = core/loader_.o core/kmain.o core/sys.o \
+ core/monitor.o task/timer.o \
+ task/idt.o task/idt_.o task/task.o task/task_.o task/syscall.o \
+ lib/stdlib.o lib/bitset.o lib/mutex.o \
+ mem/mem.o mem/paging.o mem/gdt.o mem/heap.o mem/seg.o \
+ ipc/shm.o ipc/object.o ipc/request.o \
+ linker/elf.o
-CC = gcc
-CFLAGS = -nostdlib -nostartfiles -nodefaultlibs -fno-builtin -fno-stack-protector -Wall -Wextra -I . -I ./lib -g
+include ../common.make
-LD = ld
-LDFLAGS = -T link.ld
+CFLAGS += -I . -I ./lib -g
-ASM = nasm
-AFLAGS = -f elf
+LDFLAGS += -T link.ld -Map kernel.map
-OBJECTS = core/loader_.o core/kmain.o core/sys.o \
- core/monitor.o task/timer.o \
- task/idt.o task/idt_.o task/task.o task/task_.o task/syscall.o \
- lib/stdlib.o lib/bitset.o lib/mutex.o \
- mem/mem.o mem/paging.o mem/gdt.o mem/heap.o mem/seg.o \
- ipc/shm.o ipc/object.o ipc/request.o \
- linker/elf.o
-OUT = kernel.elf
-
-all: $(OBJECTS)
- echo "* Linking $(OUT)..."
- $(LD) $(LDFLAGS) $(OBJECTS) -o $(OUT) -Map kernel.map
-
-clean:
- rm $(OBJECTS) || exit 0
- rm *.o */*.o || exit 0
- rm *.map || exit 0
-
-mrproper: clean
- rm $(OUT) || exit 0
-
-%.o: %.asm
- echo "* Compiling $<..."
- $(ASM) $(AFLAGS) -o $@ $<
-
-%.o: %.c
- echo "* Compiling $<..."
- $(CC) -c $< -o $@ $(CFLAGS)
diff --git a/src/kernel/core/sys.c b/src/kernel/core/sys.c
index 1045cff..1e07f7c 100644
--- a/src/kernel/core/sys.c
+++ b/src/kernel/core/sys.c
@@ -25,7 +25,7 @@ void panic(char* message, char* file, int line) {
monitor_write("\n>> PANIC: >>");
monitor_write(message); monitor_write("<< at "); monitor_write(file);
monitor_write(":"); monitor_writeDec(line);
- monitor_write("\nSystem halted T_T");
+ monitor_write("\nSystem halted -_-'");
asm volatile("cli; hlt");
}
diff --git a/src/library/Makefile b/src/library/Makefile
index 3d55354..ac585f5 100644
--- a/src/library/Makefile
+++ b/src/library/Makefile
@@ -1,37 +1,13 @@
-.PHONY: clean, mrproper
+Out = grapes.o
+Obj = gc/syscall.o gc/server.o \
+ gm/call.o gm/call/manager.o \
+ gc/mem.o gc/shm.o \
+ std/mutex.o std/string.o std/stdio.o \
+ start.o
-CC = gcc
-CFLAGS = -nostdlib -nostartfiles -nodefaultlibs -fno-builtin -fno-stack-protector -Wall -Wextra -I../include
+include ../common.make
-LD = ld
-LDFLAGS = -r
+CFLAGS = -I../include
-Library = grapes.o
-Objects = gc/syscall.o gc/server.o \
- gm/call.o gm/call/manager.o \
- gc/mem.o gc/shm.o \
- std/mutex.o std/string.o std/stdio.o \
- start.o
+LDFLAGS += -r
-all: $(Library)
- echo "* Done with library $(Library)"
-
-rebuild: mrproper all
-
-$(Library): $(Objects)
- echo "* Linking library $(Library)..."
- $(LD) $(LDFLAGS) $^ -o $@
-
-%.uo: %.c
- echo "* Compiling $<..."
- $(CC) $(CFLAGS) -c $< -o $@
-
-clean:
- echo "* Removing object files..."
- rm *.o || exit 0
- rm -rf $(Objects) || exit 0
-
-mrproper: clean
- echo "* Removing library..."
- rm *.o || exit 0
- rm -rf $(Library) || exit 0
diff --git a/src/library/gm/call.c b/src/library/gm/call.c
index 553fbaf..c897415 100644
--- a/src/library/gm/call.c
+++ b/src/library/gm/call.c
@@ -1,4 +1,4 @@
-#include <syscall.h>
+#include <gc/syscall.h>
#include <gm/call.h>
#include <gm/method.h>
#include <gc/shm.h>
diff --git a/src/library/gm/call/manager.c b/src/library/gm/call/manager.c
index 4b296f7..f4cef90 100644
--- a/src/library/gm/call/manager.c
+++ b/src/library/gm/call/manager.c
@@ -1,4 +1,4 @@
-#include <syscall.h>
+#include <gc/syscall.h>
#include <gm/call/manager.h>
#include <gm/method.h>
#include <gc/shm.h>
diff --git a/src/modules/manager/Makefile b/src/modules/manager/Makefile
index 87a9590..abce5cb 100644
--- a/src/modules/manager/Makefile
+++ b/src/modules/manager/Makefile
@@ -1,33 +1,9 @@
-.PHONY: clean, mrproper
+Obj = main.o
+Out = manager.elf
-CC = gcc
-CFLAGS = -nostdlib -nostartfiles -nodefaultlibs -fno-builtin -fno-stack-protector -Wall -Wextra -I ../../include
+include ../../common.make
-LD = ld
-LDFLAGS = -T ../../library/link.ld -L ../../library -Map manager.map
+CFLAGS += -I ../../include
-Objects = main.o
-Outfile = manager.elf
-
-all: $(Outfile)
- echo "* Done with $(Outfile)"
-
-rebuild: mrproper all
-
-$(Outfile): $(Objects)
- echo "* Linking $@..."
- $(LD) $(LDFLAGS) -o $@ $^
-
-%.o: %.c
- $(CC) $(CFLAGS) -c $< -o $@
-
-clean:
- echo "* Removing objects..."
- rm *.o || exit 0
- rm *.map || exit 0
- rm $(Objects) || exit 0
-
-mrproper: clean
- rm *.elf || exit 0
- rm $(Outfile) || exit 0
+LDFLAGS += -T ../../library/link.ld -L ../../library -Map manager.map
diff --git a/src/modules/test/Makefile b/src/modules/test/Makefile
index 6dd9f80..3b9ac14 100644
--- a/src/modules/test/Makefile
+++ b/src/modules/test/Makefile
@@ -1,33 +1,8 @@
-.PHONY: clean, mrproper
+Obj = main.o
+Out = test.elf
-CC = gcc
-CFLAGS = -nostdlib -nostartfiles -nodefaultlibs -fno-builtin -fno-stack-protector -Wall -Wextra -I ../../include
+include ../../common.make
-LD = ld
-LDFLAGS = -T ../../library/link.ld -L ../../library -Map test.map
-
-Objects = main.o
-Outfile = test.elf
-
-all: $(Outfile)
- echo "* Done with $(Outfile)"
-
-rebuild: mrproper all
-
-$(Outfile): $(Objects)
- echo "* Linking $@..."
- $(LD) $(LDFLAGS) -o $@ $^
-
-%.o: %.c
- $(CC) $(CFLAGS) -c $< -o $@
-
-clean:
- echo "* Removing objects..."
- rm *.o || exit 0
- rm *.map || exit 0
- rm $(Objects) || exit 0
-
-mrproper: clean
- rm *.elf || exit 0
- rm $(Outfile) || exit 0
+CFLAGS += -I ../../include
+LDFLAGS += -T ../../library/link.ld -L ../../library -Map test.map