2013-03-19 18:28:32 -04:00
|
|
|
SOFTWARE_MEANT_FOR_SORTIX=1
|
2014-06-28 10:10:20 -04:00
|
|
|
include ../build-aux/platform.mak
|
|
|
|
include ../build-aux/compiler.mak
|
|
|
|
include ../build-aux/version.mak
|
|
|
|
include ../build-aux/dirs.mak
|
2011-11-28 09:25:00 -05:00
|
|
|
|
2013-03-19 18:28:32 -04:00
|
|
|
# Default values in case the user doesn't override these variables.
|
2015-05-10 10:56:22 -04:00
|
|
|
OPTLEVEL?=$(DEFAULT_OPTLEVEL)
|
2013-03-19 18:28:32 -04:00
|
|
|
CPPFLAGS?=
|
|
|
|
CXXFLAGS?=$(OPTLEVEL)
|
|
|
|
|
|
|
|
# Base compiler options and definitions.
|
|
|
|
|
2013-09-22 17:55:39 -04:00
|
|
|
CPPFLAGS:=$(CPPFLAGS) -I. -Iinclude -D__is_sortix_kernel
|
2013-03-19 18:28:32 -04:00
|
|
|
CXXFLAGS:=$(CXXFLAGS) -Wall -Wextra -ffreestanding -fbuiltin -std=gnu++11 \
|
|
|
|
-fno-exceptions -fno-rtti
|
|
|
|
|
|
|
|
ifeq ($(PANIC_SHORT),1)
|
|
|
|
CPPFLAGS:=$(CPPFLAGS) -DPANIC_SHORT
|
2011-08-05 08:25:00 -04:00
|
|
|
endif
|
2013-03-19 18:28:32 -04:00
|
|
|
ifdef VERSION
|
|
|
|
CPPFLAGS:=$(CPPFLAGS) -DVERSIONSTR=\"$(VERSION)\"
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Architecture-dependent options and definitions.
|
|
|
|
|
|
|
|
BOOTOBJS:=
|
2011-08-05 08:25:00 -04:00
|
|
|
|
|
|
|
ifeq ($(CPU),x86)
|
2013-03-19 18:28:32 -04:00
|
|
|
X86FAMILY:=1
|
2015-02-11 11:41:55 -05:00
|
|
|
CPUDIR:=$(CPU)
|
2015-03-15 19:14:21 -04:00
|
|
|
CPUOBJS:=$(CPUDIR)/boot.o
|
2011-08-05 08:25:00 -04:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(CPU),x64)
|
2013-03-19 18:28:32 -04:00
|
|
|
X86FAMILY:=1
|
2015-02-11 11:41:55 -05:00
|
|
|
CPUDIR:=$(CPU)
|
2014-05-28 11:40:30 -04:00
|
|
|
CXXFLAGS:=$(CXXFLAGS) -mno-red-zone -mno-mmx -mno-sse -mno-sse2
|
2015-03-15 19:14:21 -04:00
|
|
|
CPUOBJS:=$(CPUDIR)/boot.o
|
2015-02-11 11:41:55 -05:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifndef CPUDIR
|
|
|
|
CPUDIR=.
|
2011-08-05 08:25:00 -04:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifdef X86FAMILY
|
|
|
|
CPUOBJS:=$(CPUOBJS) \
|
2015-02-11 11:41:55 -05:00
|
|
|
$(CPUDIR)/memorymanagement.o \
|
2011-10-02 09:58:08 -04:00
|
|
|
x86-family/memorymanagement.o \
|
2015-02-11 11:41:55 -05:00
|
|
|
$(CPUDIR)/interrupt.o \
|
2014-01-31 07:19:27 -05:00
|
|
|
x86-family/interrupt.o \
|
2015-01-15 19:19:05 -05:00
|
|
|
x86-family/ioport.o \
|
2014-01-31 07:19:27 -05:00
|
|
|
x86-family/pic.o \
|
2012-02-29 18:15:28 -05:00
|
|
|
x86-family/gdt.o \
|
|
|
|
x86-family/idt.o \
|
2015-02-11 11:41:55 -05:00
|
|
|
$(CPUDIR)/syscall.o \
|
2013-05-15 16:04:18 -04:00
|
|
|
x86-family/cmos.o \
|
2013-10-13 17:56:58 -04:00
|
|
|
x86-family/time.o \
|
2013-09-14 11:10:14 -04:00
|
|
|
x86-family/pat.o \
|
2012-08-04 18:06:17 -04:00
|
|
|
x86-family/float.o \
|
2015-04-30 18:07:06 -04:00
|
|
|
x86-family/ps2.o \
|
2011-08-12 11:17:02 -04:00
|
|
|
x86-family/x86-family.o
|
2011-08-05 08:25:00 -04:00
|
|
|
endif
|
|
|
|
|
2013-03-19 18:28:32 -04:00
|
|
|
# Object files that constitute the kernel.
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2015-11-21 18:28:59 -05:00
|
|
|
CRTI_OBJ=$(CPUDIR)/crti.o
|
|
|
|
CRTBEGIN_OBJ=$(shell $(CXX) $(CXXFLAGS) -print-file-name=crtbegin.o)
|
|
|
|
CRTEND_OBJ=$(shell $(CXX) $(CXXFLAGS) -print-file-name=crtend.o)
|
|
|
|
CRTN_OBJ=$(CPUDIR)/crtn.o
|
2013-10-18 16:28:29 -04:00
|
|
|
|
2013-03-19 18:28:32 -04:00
|
|
|
LIBS=\
|
|
|
|
-nostdlib \
|
2014-02-13 14:26:38 -05:00
|
|
|
-lk \
|
2012-09-28 17:37:32 -04:00
|
|
|
-lgcc \
|
2012-02-13 07:16:43 -05:00
|
|
|
|
2013-03-19 18:28:32 -04:00
|
|
|
OBJS=\
|
|
|
|
$(CPUOBJS) \
|
2013-02-09 12:32:45 -05:00
|
|
|
addralloc.o \
|
2013-05-11 19:24:42 -04:00
|
|
|
alarm.o \
|
2013-10-13 17:56:58 -04:00
|
|
|
clock.o \
|
2012-12-05 13:29:20 -05:00
|
|
|
com.o \
|
2012-08-07 18:19:44 -04:00
|
|
|
copy.o \
|
2015-02-11 11:41:55 -05:00
|
|
|
$(CPUDIR)/kthread.o \
|
2012-08-07 18:19:44 -04:00
|
|
|
descriptor.o \
|
2013-05-27 17:55:49 -04:00
|
|
|
disk/ahci/ahci.o \
|
|
|
|
disk/ahci/hba.o \
|
|
|
|
disk/ahci/port.o \
|
2014-09-27 18:48:09 -04:00
|
|
|
disk/ata/ata.o \
|
|
|
|
disk/ata/hba.o \
|
|
|
|
disk/ata/port.o \
|
|
|
|
disk/node.o \
|
2012-08-07 18:19:44 -04:00
|
|
|
dtable.o \
|
2011-09-06 13:51:47 -04:00
|
|
|
elf.o \
|
2013-03-12 09:24:31 -04:00
|
|
|
fcache.o \
|
2013-11-02 17:46:55 -04:00
|
|
|
fs/full.o \
|
2014-03-19 18:34:09 -04:00
|
|
|
fsfunc.o \
|
2012-08-07 18:19:44 -04:00
|
|
|
fs/kram.o \
|
2013-10-28 20:03:57 -04:00
|
|
|
fs/null.o \
|
2015-05-10 17:09:59 -04:00
|
|
|
fs/random.o \
|
2013-01-30 14:33:13 -05:00
|
|
|
fs/user.o \
|
2012-12-05 13:29:20 -05:00
|
|
|
fs/util.o \
|
2013-11-02 17:37:17 -04:00
|
|
|
fs/zero.o \
|
2014-03-25 15:28:51 -04:00
|
|
|
gpu/bga/bga.o \
|
2014-10-05 09:02:50 -04:00
|
|
|
hostname.o \
|
2013-01-12 20:37:14 -05:00
|
|
|
identity.o \
|
2012-12-05 13:29:20 -05:00
|
|
|
initrd.o \
|
2012-08-07 18:19:44 -04:00
|
|
|
inode.o \
|
2012-12-05 13:29:20 -05:00
|
|
|
interlock.o \
|
|
|
|
interrupt.o \
|
2012-08-07 18:19:44 -04:00
|
|
|
ioctx.o \
|
2012-12-05 13:29:20 -05:00
|
|
|
io.o \
|
2014-04-22 08:02:04 -04:00
|
|
|
kb/kblayout.o \
|
2012-12-05 13:29:20 -05:00
|
|
|
kb/ps2.o \
|
|
|
|
kernelinfo.o \
|
|
|
|
kernel.o \
|
|
|
|
kthread.o \
|
|
|
|
lfbtextbuffer.o \
|
2016-02-28 06:11:02 -05:00
|
|
|
libk.o \
|
2012-12-05 13:29:20 -05:00
|
|
|
linebuffer.o \
|
|
|
|
log.o \
|
|
|
|
logterminal.o \
|
|
|
|
memorymanagement.o \
|
2015-04-30 19:21:35 -04:00
|
|
|
mouse/ps2.o \
|
2012-08-07 18:19:44 -04:00
|
|
|
mtable.o \
|
2013-04-23 17:53:16 -04:00
|
|
|
net/fs.o \
|
2013-03-18 09:22:17 -04:00
|
|
|
op-new.o \
|
2012-12-05 13:29:20 -05:00
|
|
|
panic.o \
|
2013-06-01 07:24:27 -04:00
|
|
|
partition.o \
|
2014-03-25 11:02:50 -04:00
|
|
|
pci-mmio.o \
|
2012-12-05 13:29:20 -05:00
|
|
|
pci.o \
|
|
|
|
pipe.o \
|
2012-12-29 17:09:09 -05:00
|
|
|
poll.o \
|
2012-12-05 13:29:20 -05:00
|
|
|
process.o \
|
2015-07-30 19:20:39 -04:00
|
|
|
psctl.o \
|
2014-03-19 18:34:09 -04:00
|
|
|
ptable.o \
|
2014-07-14 17:24:43 -04:00
|
|
|
random.o \
|
2012-12-05 13:29:20 -05:00
|
|
|
refcount.o \
|
2014-03-03 18:11:13 -05:00
|
|
|
registers.o \
|
2013-08-30 11:35:30 -04:00
|
|
|
resource.o \
|
2012-12-05 13:29:20 -05:00
|
|
|
scheduler.o \
|
2013-08-19 20:23:53 -04:00
|
|
|
segment.o \
|
2012-12-05 13:29:20 -05:00
|
|
|
signal.o \
|
2014-04-30 11:25:52 -04:00
|
|
|
sockopt.o \
|
2012-12-05 13:29:20 -05:00
|
|
|
string.o \
|
|
|
|
syscall.o \
|
|
|
|
textbuffer.o \
|
|
|
|
textterminal.o \
|
|
|
|
thread.o \
|
|
|
|
time.o \
|
2013-10-13 17:56:58 -04:00
|
|
|
timer.o \
|
2016-04-18 17:58:09 -04:00
|
|
|
tty.o \
|
2012-12-05 13:29:20 -05:00
|
|
|
uart.o \
|
2013-10-13 17:56:58 -04:00
|
|
|
user-timer.o \
|
2012-12-05 13:29:20 -05:00
|
|
|
vga.o \
|
|
|
|
vgatextbuffer.o \
|
|
|
|
video.o \
|
2012-08-07 18:19:44 -04:00
|
|
|
vnode.o \
|
2012-12-05 13:29:20 -05:00
|
|
|
worker.o \
|
2011-09-06 13:51:47 -04:00
|
|
|
|
2012-09-10 17:36:15 -04:00
|
|
|
ALLOBJS=\
|
2013-10-18 16:28:29 -04:00
|
|
|
$(CRTI_OBJ) \
|
2012-09-10 17:36:15 -04:00
|
|
|
$(OBJS) \
|
2013-10-18 16:28:29 -04:00
|
|
|
$(CRTN_OBJ) \
|
2012-09-10 17:36:15 -04:00
|
|
|
end.o
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2013-10-18 16:28:29 -04:00
|
|
|
LINK_OBJECTS=\
|
|
|
|
$(CRTI_OBJ) $(CRTBEGIN_OBJ) $(OBJS) $(LIBS) $(CRTN_OBJ) $(CRTEND_OBJ) end.o
|
|
|
|
|
2013-03-19 18:28:32 -04:00
|
|
|
# Rules and recipes for building the kernel.
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2013-03-19 18:28:32 -04:00
|
|
|
all: kernel
|
|
|
|
|
|
|
|
kernel: sortix.bin
|
|
|
|
|
|
|
|
.PHONY: all kernel headers clean install install-include-dirs install-headers \
|
|
|
|
install-kernel install-kernel-binary
|
2012-09-10 15:45:38 -04:00
|
|
|
|
|
|
|
headers:
|
|
|
|
|
2011-08-05 08:25:00 -04:00
|
|
|
# x64 compilation
|
2013-03-19 18:28:32 -04:00
|
|
|
ifeq ($(CPU),x64)
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2013-03-19 18:28:32 -04:00
|
|
|
sortix-x86_64.bin: $(ALLOBJS)
|
2015-05-10 10:56:22 -04:00
|
|
|
$(CXX) $(CXXFLAGS) -Wl,-Ttext -Wl,100000 -Wl,-z -Wl,max-page-size=0x1000 $(LINK_OBJECTS) -o $@
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2013-03-19 18:28:32 -04:00
|
|
|
sortix.bin: sortix-x86_64.bin
|
2015-05-10 10:56:22 -04:00
|
|
|
$(OBJCOPY) $< -O elf32-i386-sortix $@
|
2013-03-19 18:28:32 -04:00
|
|
|
|
|
|
|
endif
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2013-03-19 18:28:32 -04:00
|
|
|
# x86 compilation
|
|
|
|
ifeq ($(CPU),x86)
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2013-03-19 18:28:32 -04:00
|
|
|
sortix.bin: $(ALLOBJS)
|
2015-05-10 10:56:22 -04:00
|
|
|
$(CXX) $(CXXFLAGS) -Wl,-Ttext -Wl,100000 $(LINK_OBJECTS) -o $@
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2013-03-19 18:28:32 -04:00
|
|
|
endif
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2014-04-22 08:02:04 -04:00
|
|
|
%: %.kblayout
|
|
|
|
kblayout-compiler --format=sortix-kblayout-1 --compression=none $< -o $@
|
|
|
|
|
2016-08-12 12:34:19 -04:00
|
|
|
# TODO: After releasing Sortix 1.1, change --identifier to -i.
|
2014-04-22 08:02:04 -04:00
|
|
|
kb/default-kblayout.h: kb/default-kblayout
|
2016-08-12 12:34:19 -04:00
|
|
|
carray -cgHs -t uint8_t -G SORTIX_KB_DEFAULT_KBLAYOUT_H --identifier=default_kblayout $< -o $@
|
2014-04-22 08:02:04 -04:00
|
|
|
|
2015-03-19 19:08:08 -04:00
|
|
|
vgafont.h: vgafont.f16
|
2016-08-12 12:34:19 -04:00
|
|
|
carray -gHs -t uint8_t -G VGAFONT_H --identifier=vgafont $< -o $@
|
2015-03-19 19:08:08 -04:00
|
|
|
|
|
|
|
*.cpp */*.cpp */*/*.cpp: | kb/default-kblayout.h vgafont.h
|
2014-04-22 08:02:04 -04:00
|
|
|
|
2011-08-05 08:25:00 -04:00
|
|
|
%.o: %.cpp
|
2015-05-10 10:56:22 -04:00
|
|
|
$(CXX) -c $< -o $@ $(CPPFLAGS) $(CXXFLAGS)
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2013-12-28 15:00:15 -05:00
|
|
|
%.o: %.S
|
2015-05-10 10:56:22 -04:00
|
|
|
$(CXX) -c $< -o $@ $(CPPFLAGS) $(CXXFLAGS)
|
2011-08-05 08:25:00 -04:00
|
|
|
|
|
|
|
clean:
|
2013-03-19 18:28:32 -04:00
|
|
|
rm -f $(ALLOBJS) sortix.bin
|
2014-06-28 10:10:20 -04:00
|
|
|
rm -f *.bin *.out *.tmp
|
|
|
|
rm -f *.o */*.o */*/*.o
|
2014-04-22 08:02:04 -04:00
|
|
|
rm -f kb/default-kblayout kb/default-kblayout.h
|
2015-03-19 19:08:08 -04:00
|
|
|
rm -f vgafont.h
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2011-09-15 16:38:40 -04:00
|
|
|
# Installation into sysroot
|
2012-09-10 17:36:15 -04:00
|
|
|
install: install-headers install-kernel
|
2012-09-10 15:45:38 -04:00
|
|
|
|
|
|
|
install-include-dirs: headers
|
2013-03-19 18:28:32 -04:00
|
|
|
mkdir -p $(DESTDIR)$(INCLUDEDIR)
|
2012-09-10 15:45:38 -04:00
|
|
|
|
|
|
|
install-headers: install-include-dirs headers
|
2013-03-19 18:28:32 -04:00
|
|
|
cp -RTv include $(DESTDIR)$(INCLUDEDIR)
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2012-09-10 17:36:15 -04:00
|
|
|
install-kernel: install-kernel-binary
|
|
|
|
|
2013-03-19 18:28:32 -04:00
|
|
|
install-kernel-binary: sortix.bin
|
2015-01-22 18:07:40 -05:00
|
|
|
mkdir -p $(DESTDIR)$(BOOTDIR)
|
|
|
|
cp sortix.bin $(DESTDIR)$(BOOTDIR)/sortix.bin
|