2013-03-19 18:15:12 -04:00
|
|
|
include ../platform.mak
|
|
|
|
|
|
|
|
# Protect the user from accidentally replacing his build operating system with a broken Sortix.
|
|
|
|
ifeq ($(HOST_IS_SORTIX),0)
|
|
|
|
$(error You are about to build Sortix as $(HOST) and possibly overwrite your root filesystem. Use the HOST=cpu-sortix environmental variable if you wish to cross-compile)
|
|
|
|
endif
|
|
|
|
|
|
|
|
SRCDIR:=..
|
|
|
|
BOOTDIR:=$(ROOT)/boot/$(cputype)
|
|
|
|
KERNEL:=$(BOOTDIR)/sortix.bin
|
|
|
|
INITRD_COMPRESSION:=.gz
|
|
|
|
INITRD:=$(BOOTDIR)/sortix.initrd
|
|
|
|
INITRD_FILTER:=$(BOOTDIR)/sortix.initrd.filter
|
|
|
|
|
|
|
|
all: $(KERNEL) $(INITRD)$(INITRD_COMPRESSION)
|
|
|
|
|
|
|
|
# Delete various temporary build files.
|
|
|
|
clean:
|
|
|
|
$(MAKE) -B -C $(SRCDIR)/doc clean
|
|
|
|
$(MAKE) -B -C $(SRCDIR)/libc clean
|
|
|
|
$(MAKE) -B -C $(SRCDIR)/libm clean
|
2013-08-31 07:15:53 -04:00
|
|
|
$(MAKE) -B -C $(SRCDIR)/libpthread clean
|
2013-03-19 18:15:12 -04:00
|
|
|
$(MAKE) -B -C $(SRCDIR)/dispd clean
|
|
|
|
$(MAKE) -B -C $(SRCDIR)/bench clean
|
|
|
|
$(MAKE) -B -C $(SRCDIR)/games clean
|
|
|
|
$(MAKE) -B -C $(SRCDIR)/mkinitrd clean
|
|
|
|
$(MAKE) -B -C $(SRCDIR)/utils clean
|
|
|
|
$(MAKE) -B -C $(SRCDIR)/ext clean
|
|
|
|
$(MAKE) -B -C $(SRCDIR)/mbr clean
|
2014-02-20 09:48:20 -05:00
|
|
|
$(MAKE) -B -C $(SRCDIR)/systest clean
|
2013-12-19 19:24:47 -05:00
|
|
|
$(MAKE) -B -C $(SRCDIR)/kernel clean
|
2013-03-19 18:15:12 -04:00
|
|
|
|
|
|
|
# Set up the base filesystem.
|
|
|
|
fsh:
|
|
|
|
mkdir -p $(ROOT)/
|
|
|
|
mkdir -p $(ROOT)/boot
|
|
|
|
mkdir -p $(ROOT)/boot/$(cputype)
|
|
|
|
mkdir -p $(ROOT)/dev
|
|
|
|
mkdir -p $(ROOT)/etc
|
|
|
|
mkdir -p $(ROOT)/etc/$(cputype)
|
|
|
|
mkdir -p $(ROOT)/etc/skel
|
|
|
|
mkdir -p $(ROOT)/home
|
|
|
|
mkdir -p $(ROOT)/include
|
|
|
|
mkdir -p $(ROOT)/include/$(cputype)
|
|
|
|
mkdir -p $(ROOT)/mnt
|
|
|
|
mkdir -p $(ROOT)/root
|
|
|
|
mkdir -p $(ROOT)/share
|
|
|
|
mkdir -p $(ROOT)/src
|
|
|
|
mkdir -p $(ROOT)/tmp
|
|
|
|
mkdir -p $(ROOT)/$(cputype)/bin
|
|
|
|
mkdir -p $(ROOT)/$(cputype)/lib
|
2014-07-11 16:50:45 -04:00
|
|
|
mkdir -p $(ROOT)/$(cputype)/libexec
|
2013-03-19 18:15:12 -04:00
|
|
|
|
|
|
|
# Install the system headers.
|
|
|
|
system-headers:
|
|
|
|
$(MAKE) fsh ROOT=$(ROOT)
|
|
|
|
$(MAKE) system-headers_internal ROOT=$(ROOT)
|
|
|
|
|
|
|
|
system-headers_internal:
|
2013-12-19 19:24:47 -05:00
|
|
|
$(MAKE) -B -C $(SRCDIR)/kernel install-headers DESTDIR=$(ROOT)
|
2013-03-19 18:15:12 -04:00
|
|
|
$(MAKE) -B -C $(SRCDIR)/libc install-headers DESTDIR=$(ROOT)
|
|
|
|
$(MAKE) -B -C $(SRCDIR)/libm install-headers DESTDIR=$(ROOT)
|
2013-08-31 07:15:53 -04:00
|
|
|
$(MAKE) -B -C $(SRCDIR)/libpthread install-headers DESTDIR=$(ROOT)
|
2013-03-19 18:15:12 -04:00
|
|
|
|
|
|
|
# Rebuild and install the entire system.
|
|
|
|
system:
|
|
|
|
$(MAKE) fsh ROOT=$(ROOT)
|
|
|
|
$(MAKE) system-headers_internal ROOT=$(ROOT)
|
|
|
|
$(MAKE) -B -C $(SRCDIR)/doc install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib
|
|
|
|
$(MAKE) -B -C $(SRCDIR)/libc install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib
|
|
|
|
$(MAKE) -B -C $(SRCDIR)/libm install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib
|
2013-08-31 07:15:53 -04:00
|
|
|
$(MAKE) -B -C $(SRCDIR)/libpthread install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib
|
2013-03-19 18:15:12 -04:00
|
|
|
$(MAKE) -B -C $(SRCDIR)/dispd install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib
|
|
|
|
$(MAKE) -B -C $(SRCDIR)/games install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib
|
|
|
|
$(MAKE) -B -C $(SRCDIR)/mkinitrd install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib
|
|
|
|
$(MAKE) -B -C $(SRCDIR)/utils install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib
|
|
|
|
$(MAKE) -B -C $(SRCDIR)/bench install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib
|
|
|
|
$(MAKE) -B -C $(SRCDIR)/ext install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib
|
|
|
|
$(MAKE) -B -C $(SRCDIR)/mbr install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib
|
2014-02-20 09:48:20 -05:00
|
|
|
$(MAKE) -B -C $(SRCDIR)/systest install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib
|
2013-12-19 19:24:47 -05:00
|
|
|
$(MAKE) -B -C $(SRCDIR)/kernel install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/libs
|
2013-03-19 18:15:12 -04:00
|
|
|
|
|
|
|
# Rebuild and install the kernel
|
|
|
|
kernel:
|
2013-12-19 19:24:47 -05:00
|
|
|
$(MAKE) -B -C $(SRCDIR)/kernel install-headers DESTDIR=$(ROOT)
|
|
|
|
$(MAKE) -B -C $(SRCDIR)/kernel install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/libs
|
2013-03-19 18:15:12 -04:00
|
|
|
|
|
|
|
# Rebuild the initrd and the kernel.
|
|
|
|
boot-files: initrd kernel
|
|
|
|
|
|
|
|
# Regenerate the initrd from $ROOT.
|
|
|
|
initrd:
|
|
|
|
mkdir -p $(BOOTDIR)
|
|
|
|
rm -f $(INITRD_FILTER)
|
|
|
|
echo exclude /boot >> $(INITRD_FILTER)
|
|
|
|
echo exclude /dev >> $(INITRD_FILTER)
|
|
|
|
echo exclude /next >> $(INITRD_FILTER)
|
|
|
|
echo exclude /tmp >> $(INITRD_FILTER)
|
|
|
|
echo exclude /$(OTHER_PLATFORM_1) >> $(INITRD_FILTER)
|
|
|
|
echo exclude /etc/$(OTHER_PLATFORM_1) >> $(INITRD_FILTER)
|
|
|
|
echo exclude /include/$(OTHER_PLATFORM_1) >> $(INITRD_FILTER)
|
2013-10-30 07:09:57 -04:00
|
|
|
echo exclude /tix/$(OTHER_PLATFORM_1) >> $(INITRD_FILTER)
|
2013-03-19 18:15:12 -04:00
|
|
|
mkinitrd $(ROOT)/ -o $(INITRD) -f $(INITRD_FILTER)
|
|
|
|
rm -f $(INITRD_FILTER)
|
|
|
|
gzip -v $(INITRD)
|
|
|
|
|
|
|
|
# Format a device with a tar filesystem.
|
|
|
|
device-format-tar:
|
|
|
|
tar cvf DEVICE=$(DEVICE)
|
|
|
|
|
|
|
|
# Update the kernel on a device.
|
|
|
|
update-tar-device-kernel: $(KERNEL)
|
|
|
|
cd $(BOOTDIR) ; head sortix.bin > /dev/null
|
|
|
|
cd $(BOOTDIR) ; tar --delete --verbose --checkpoint=1 --blocking-factor=2048 --file=$(DEVICE) sortix.bin
|
|
|
|
cd $(BOOTDIR) ; tar --append --verbose --checkpoint=1 --blocking-factor=2048 --file=$(DEVICE) sortix.bin
|
|
|
|
|
|
|
|
# Update the initrd on a device.
|
|
|
|
update-tar-device-initrd: $(INITRD)$(INITRD_COMPRESSION)
|
|
|
|
cd $(BOOTDIR) ; head sortix.initrd$(INITRD_COMPRESSION) > /dev/null
|
|
|
|
cd $(BOOTDIR) ; tar --delete --verbose --checkpoint=1 --blocking-factor=2048 --file=$(DEVICE) sortix.initrd$(INITRD_COMPRESSION)
|
|
|
|
cd $(BOOTDIR) ; tar --append --verbose --checkpoint=1 --blocking-factor=2048 --file=$(DEVICE) sortix.initrd$(INITRD_COMPRESSION)
|
|
|
|
|
|
|
|
# Update the kernel and initrd on a device.
|
|
|
|
update-tar-device-image: $(KERNEL) $(INITRD)$(INITRD_COMPRESSION)
|
|
|
|
cd $(BOOTDIR) ; head sortix.bin sortix.initrd$(INITRD_COMPRESSION) > /dev/null
|
|
|
|
cd $(BOOTDIR) ; tar --create --verbose --checkpoint=1 --blocking-factor=2048 --file=$(DEVICE) sortix.bin sortix.initrd$(INITRD_COMPRESSION)
|
|
|
|
|
|
|
|
# Build an entire new Sortix system and install onto this device.
|
|
|
|
install-onto-device:
|
|
|
|
$(MAKE) system ROOT=/next
|
|
|
|
$(MAKE) initrd ROOT=/next
|
|
|
|
$(MAKE) update-tar-device-image ROOT=/next DEVICE=$(DEVICE)
|
|
|
|
|
|
|
|
# Misc. stuff down here.
|
|
|
|
fetch-device-stuff: fetch-device-kernel fetch-device-initrd
|
|
|
|
|
|
|
|
fetch-device-kernel:
|
|
|
|
cd $(BOOTDIR) ; tar xvf $(DEVICE) sortix.bin
|
|
|
|
|
|
|
|
fetch-device-initrd:
|
|
|
|
cd $(BOOTDIR) ; tar xvf $(DEVICE)
|
|
|
|
#
|