1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00
sortix--sortix/Makefile

191 lines
4.7 KiB
Makefile
Raw Normal View History

2012-09-10 17:36:15 -04:00
include compiler.mak
include version.mak
ifneq ($(BUILD_LIBC),0)
2012-09-28 18:53:50 -04:00
MODULES:=$(MODULES) libc
2012-09-10 17:36:15 -04:00
endif
2012-09-28 18:53:50 -04:00
ALLMODULES:=$(ALLMODULES) libc
2012-09-10 17:36:15 -04:00
ifneq ($(BUILD_GAMES),0)
MODULES:=$(MODULES) games
endif
2012-09-10 17:36:15 -04:00
ALLMODULES:=$(ALLMODULES) games
2012-09-10 17:36:15 -04:00
ifneq ($(BUILD_MKINITRD),0)
MODULES:=$(MODULES) mkinitrd
endif
2012-09-10 17:36:15 -04:00
ALLMODULES:=$(ALLMODULES) mkinitrd
ifneq ($(BUILD_UTILS),0)
MODULES:=$(MODULES) utils
endif
ALLMODULES:=$(ALLMODULES) utils
ifneq ($(BUILD_BENCH),0)
MODULES:=$(MODULES) bench
2012-09-09 07:20:48 -04:00
endif
2012-09-10 17:36:15 -04:00
ALLMODULES:=$(ALLMODULES) bench
ifneq ($(BUILD_KERNEL),0)
MODULES:=$(MODULES) sortix
endif
2012-09-10 17:36:15 -04:00
ALLMODULES:=$(ALLMODULES) sortix
ifndef SYSROOT
2012-09-10 17:36:15 -04:00
SYSROOT:=$(shell pwd)/sysroot
MFLAGS:=$(MFLAGS) SYSROOT=$(SYSROOT)
endif
ifndef PREFIXNAME
PREFIXNAME:=/
MFLAGS:=$(MFLAGS) PREFIXNAME=$(PREFIXNAME)
2011-08-05 08:25:00 -04:00
endif
2012-09-10 17:36:15 -04:00
include dirs.mak
2011-08-05 08:25:00 -04:00
DEBNAME:=sortix_$(VERSION)_$(CPU)
DEBSRCNAME:=sortix_$(VERSION)
DEBDIR:=builds/$(DEBNAME)
DEBSRCDIR:=builds/$(DEBSRCNAME)-src
DEBFILE:=builds/$(DEBNAME).deb
PACKAGENAME:=sortix
ISODIR:=builds/$(DEBNAME)-iso
ISOFILE:=builds/$(DEBNAME).iso
2012-09-10 17:36:15 -04:00
INITRD=$(INSTALLBOOTDIR)/$(HOST)/sortix.initrd
2011-08-05 08:25:00 -04:00
MFLAGS:=$(MFLAGS) VERSION=$(VERSION)
all: $(INITRD)
2012-09-10 17:36:15 -04:00
.PHONY: all suball sysroot-base-headers sysroot-fsh clean distclean \
everything everything-all-archs all-archs linecount install uninstall \
deb debfile debsource iso run-virtualbox run-virtualbox-debug \
clean-builds clean-sysroot
2012-09-10 17:36:15 -04:00
suball: sysroot-base-headers
(for D in $(MODULES); do ($(MAKE) all $(MFLAGS) --directory $$D && $(MAKE) install $(MFLAGS) --directory $$D) || exit $$?; done)
2012-09-10 17:36:15 -04:00
sysroot-base-headers: sysroot-fsh
2012-09-28 18:53:50 -04:00
(for D in libc sortix; do ($(MAKE) install-headers $(MFLAGS) --directory $$D) || exit $$?; done)
2012-09-10 17:36:15 -04:00
sysroot-fsh:
mkdir -p "$(SYSROOT)"
for DIRNAME in bin boot lib include; do (\
mkdir -p "$(SYSROOT)/$$DIRNAME" &&\
mkdir -p "$(SYSROOT)/$$DIRNAME/$(HOST)" \
) || exit $$?; done;
if [ ! -e "$(SYSROOT)/usr" ]; then ln -s . "$(SYSROOT)/usr"; fi
2011-08-05 08:25:00 -04:00
2012-09-10 17:36:15 -04:00
clean:
rm -f "$(INITRD)"
rm -f sortix/sortix.initrd # Backwards compatibility, not needed for newer builds.
rm -f initrd/* # Backwards compatibility, not needed for newer builds.
(for D in $(ALLMODULES); do $(MAKE) clean $(MFLAGS) --directory $$D || exit $$?; done)
2011-08-05 08:25:00 -04:00
2012-09-10 17:36:15 -04:00
clean-builds:
2011-08-05 08:25:00 -04:00
rm -rf builds/
rm -f sortix.iso
2012-09-10 17:36:15 -04:00
clean-sysroot:
rm -rf "$(SYSROOT)"
distclean: clean clean-builds clean-sysroot
everything: all deb iso
everything-all-archs:
$(MAKE) clean $(MFLAGS)
2012-09-10 17:36:15 -04:00
$(MAKE) everything $(MFLAGS) HOST=i486-sortix
$(MAKE) clean $(MFLAGS)
$(MAKE) everything $(MFLAGS) HOST=x86_64-sortix
all-archs:
$(MAKE) clean $(MFLAGS)
$(MAKE) all $(MFLAGS) HOST=i486-sortix
$(MAKE) clean $(MFLAGS)
2012-09-10 17:36:15 -04:00
$(MAKE) all $(MFLAGS) HOST=x86_64-sortix
# Initializing RamDisk
$(INITRD): suball
2012-09-10 17:36:15 -04:00
mkinitrd/mkinitrd $(SYSROOT)/bin/$(HOST) -o $(INITRD)
2011-08-05 08:25:00 -04:00
# Statistics
linecount:
wc -l `find | grep -E '\.h$$|\.c$$|\.cpp$$|\.s$$|\.asm$$|Makefile$$' | grep -v sysroot` | sort -n
2011-08-05 08:25:00 -04:00
# Local machine
install: all
cp sortix/sortix.bin /boot
cp $(INITRD) /boot
2011-08-05 08:25:00 -04:00
cp debsrc/etc/grub.d/42_sortix /etc/grub.d/42_sortix
chmod +x /etc/grub.d/42_sortix
update-grub
uninstall:
rm -f /boot/sortix.bin
rm -f /etc/grub.d/42_sortix
# Packaging
deb: debfile debsource
debfile: all
rm -rf $(DEBDIR)
mkdir -p $(DEBDIR)
mkdir -p $(DEBDIR)/boot
2011-08-05 08:25:00 -04:00
cp sortix/sortix.bin $(DEBDIR)/boot
2012-09-10 17:36:15 -04:00
cp $(INITRD) $(DEBDIR)/boot
expr \( `stat --printf="%s" $(DEBDIR)/boot/sortix.bin` \
+ `stat --printf="%s" $(DEBDIR)/boot/sortix.initrd` \
+ 1023 \) / 1024 > $(DEBDIR)/boot/deb.size
cp -r debsrc/. $(DEBDIR)
mkdir -p $(DEBDIR)/boot
SIZE=`cat $(DEBDIR)/boot/deb.size`; \
2011-08-05 08:25:00 -04:00
cat debsrc/DEBIAN/control | \
sed "s/SORTIX_PACKAGE_NAME/$(PACKAGENAME)/g" | \
sed "s/SORTIX_VERSION/$(VERSION)/g" | \
sed "s/SORTIX_ARCH/all/g" | \
sed "s/SORTIX_SIZE/$$SIZE/g" | \
2011-08-05 08:25:00 -04:00
cat > $(DEBDIR)/DEBIAN/control
rm $(DEBDIR)/boot/deb.size
2011-08-05 08:25:00 -04:00
dpkg --build $(DEBDIR) $(DEBFILE)
rm -rf $(DEBDIR)/DEBIAN
(cd builds/$(DEBNAME) && tar cfz ../$(DEBNAME).tar.gz `ls`)
2011-08-05 08:25:00 -04:00
rm -rf $(DEBDIR)
debsource: all
rm -rf $(DEBSRCDIR)
mkdir -p $(DEBSRCDIR)
for D in `ls | grep -v builds | grep -v sysroot`; do cp -r $$D $(DEBSRCDIR); done
2012-09-10 17:36:15 -04:00
(cd $(DEBSRCDIR) && make distclean SYSROOT=$(shell pwd)/$(DEBSRCDIR)/sysroot)
rm -rf $(DEBSRCDIR)/sysroot
(cd builds && tar cfz $(DEBSRCNAME)-src.tar.gz $(DEBSRCNAME)-src)
2011-08-05 08:25:00 -04:00
rm -rf $(DEBSRCDIR)
# Bootable images
2012-09-10 17:36:15 -04:00
$(ISOFILE): all debsource
2011-08-05 08:25:00 -04:00
rm -rf $(ISODIR)
mkdir -p builds
mkdir -p $(ISODIR)
cp -r isosrc/. $(ISODIR)
cp sortix/sortix.bin $(ISODIR)/boot
cp $(INITRD) $(ISODIR)/boot/sortix.initrd
cp builds/$(DEBSRCNAME)-src.tar.gz $(ISODIR)
2011-08-05 08:25:00 -04:00
grub-mkrescue -o $(ISOFILE) $(ISODIR)
rm -rf $(ISODIR)
2012-09-10 17:36:15 -04:00
iso: $(ISOFILE)
2011-08-05 08:25:00 -04:00
sortix.iso: iso
2012-09-10 17:36:15 -04:00
cp $(ISOFILE) $@
2011-08-05 08:25:00 -04:00
# Virtualization
run-virtualbox: sortix.iso
virtualbox --startvm sortix
run-virtualbox-debug: sortix.iso
virtualbox --debug --start-running --startvm sortix