2011-12-04 14:13:29 -05:00
|
|
|
BITS:=$(shell getconf LONG_BIT)
|
2011-08-05 08:25:00 -04:00
|
|
|
ifndef CPU
|
2011-12-04 14:13:29 -05:00
|
|
|
ifeq ($(BITS),64)
|
|
|
|
CPU:=x64
|
|
|
|
else
|
|
|
|
CPU:=x86
|
|
|
|
endif
|
|
|
|
MFLAGS:=$(MFLAGS) CPU=$(CPU)
|
2011-09-15 16:38:40 -04:00
|
|
|
endif
|
|
|
|
|
2011-11-28 09:25:00 -05:00
|
|
|
ifndef O
|
|
|
|
O=-O2
|
2011-12-04 14:13:29 -05:00
|
|
|
MFLAGS:=$(MFLAGS) 0=$(O)
|
2011-11-28 09:25:00 -05:00
|
|
|
endif
|
|
|
|
|
2011-12-02 16:48:30 -05:00
|
|
|
ifeq ($(BENCH),1)
|
2011-12-04 14:13:29 -05:00
|
|
|
EXTRAMODULES:=$(EXTRAMODULES) bench
|
2011-12-02 16:48:30 -05:00
|
|
|
endif
|
|
|
|
|
2011-09-15 16:38:40 -04:00
|
|
|
ifndef SYSROOT
|
|
|
|
SYSROOT:=$(shell pwd)/sysroot
|
2011-12-04 14:13:29 -05:00
|
|
|
MFLAGS:=$(MFLAGS) SYSROOT=$(SYSROOT)
|
2011-08-05 08:25:00 -04:00
|
|
|
endif
|
|
|
|
|
|
|
|
REMOTE=192.168.2.6
|
|
|
|
REMOTEUSER=sortie
|
|
|
|
REMOTECOPYDIR:=/home/$(REMOTEUSER)/Desktop/MaxsiOS
|
2011-12-02 16:48:30 -05:00
|
|
|
MODULES=libmaxsi games mkinitrd utils $(EXTRAMODULES) sortix
|
2011-12-04 09:06:30 -05:00
|
|
|
ALLMODULES=libmaxsi games mkinitrd utils bench sortix
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2011-12-05 19:28:23 -05:00
|
|
|
VERSION=0.6dev
|
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
|
2011-08-27 14:07:08 -04:00
|
|
|
INITRDDIR:=initrd
|
2011-09-07 06:19:17 -04:00
|
|
|
INITRD=sortix/sortix.initrd
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2012-03-07 12:04:59 -05:00
|
|
|
MFLAGS:=$(MFLAGS) VERSION=$(VERSION)
|
|
|
|
|
2011-09-08 05:10:41 -04:00
|
|
|
all: $(INITRD)
|
|
|
|
|
2011-09-07 06:19:17 -04:00
|
|
|
suball:
|
2011-09-15 16:38:40 -04:00
|
|
|
(for D in $(MODULES); do ($(MAKE) all $(MFLAGS) --directory $$D && $(MAKE) install $(MFLAGS) --directory $$D) || exit $?; done)
|
2011-09-07 06:19:17 -04:00
|
|
|
|
|
|
|
clean:
|
2011-09-15 16:38:40 -04:00
|
|
|
rm -rf $(SYSROOT)
|
2011-09-07 06:19:17 -04:00
|
|
|
rm -f $(INITRD)
|
2011-11-17 16:33:17 -05:00
|
|
|
rm -f initrd/*
|
2011-12-04 09:06:30 -05:00
|
|
|
(for D in $(ALLMODULES); do $(MAKE) clean $(MFLAGS) --directory $$D || exit $?; done)
|
2011-08-05 08:25:00 -04:00
|
|
|
|
|
|
|
distclean: clean cleanbuilds
|
|
|
|
|
|
|
|
cleanbuilds:
|
|
|
|
rm -rf builds/
|
|
|
|
rm -f sortix.iso
|
|
|
|
|
2011-09-07 06:19:17 -04:00
|
|
|
everything: all deb iso
|
|
|
|
|
2011-12-02 16:56:50 -05:00
|
|
|
everything-all-archs:
|
|
|
|
$(MAKE) clean $(MFLAGS)
|
2011-12-04 14:13:29 -05:00
|
|
|
$(MAKE) everything $(MFLAGS) CPU=x86
|
2011-12-02 16:56:50 -05:00
|
|
|
$(MAKE) clean $(MFLAGS)
|
2011-12-04 14:13:29 -05:00
|
|
|
$(MAKE) everything $(MFLAGS) CPU=x64
|
2011-12-02 16:56:50 -05:00
|
|
|
|
2011-09-07 06:19:17 -04:00
|
|
|
# Initializing RamDisk
|
|
|
|
$(INITRD): suball
|
|
|
|
(cd $(INITRDDIR) && ../mkinitrd/mkinitrd * -o ../$(INITRD))
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2011-08-06 21:02:37 -04:00
|
|
|
# Statistics
|
|
|
|
linecount:
|
2011-10-06 04:17:36 -04:00
|
|
|
wc -l `find | grep -E '\.h$$|\.c$$|\.cpp$$|\.s$$|\.asm$$|Makefile$$' | grep -v sysroot` | sort -n
|
2011-08-06 21:02:37 -04:00
|
|
|
|
2011-08-05 08:25:00 -04:00
|
|
|
# Local machine
|
|
|
|
|
|
|
|
install: all
|
|
|
|
cp sortix/sortix.bin /boot
|
2011-09-07 06:19:17 -04:00
|
|
|
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
|
|
|
|
update-grub
|
|
|
|
|
|
|
|
# Remote machine
|
|
|
|
|
|
|
|
install-remote: all
|
|
|
|
scp -r ./ $(REMOTE):$(REMOTECOPYDIR)
|
|
|
|
scp sortix/sortix.bin root@$(REMOTE):/boot
|
2011-09-07 06:19:17 -04:00
|
|
|
scp $(INITRD) root@$(REMOTE):/boot
|
2011-08-05 08:25:00 -04:00
|
|
|
ssh root@$(REMOTE) "init 6"
|
|
|
|
|
|
|
|
uninstall-remote:
|
|
|
|
ssh root@$(REMOTE) "rm /boot/sortix.bin"
|
|
|
|
|
|
|
|
# Packaging
|
|
|
|
|
|
|
|
deb: debfile debsource
|
|
|
|
|
|
|
|
debfile: all
|
|
|
|
rm -rf $(DEBDIR)
|
|
|
|
mkdir -p $(DEBDIR)
|
2011-10-16 11:58:19 -04:00
|
|
|
mkdir -p $(DEBDIR)/boot
|
2011-08-05 08:25:00 -04:00
|
|
|
cp sortix/sortix.bin $(DEBDIR)/boot
|
2011-09-07 06:19:17 -04:00
|
|
|
cp sortix/sortix.initrd $(DEBDIR)/boot
|
2011-10-16 11:58:19 -04:00
|
|
|
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" | \
|
2011-10-16 11:58:19 -04:00
|
|
|
sed "s/SORTIX_SIZE/$$SIZE/g" | \
|
2011-08-05 08:25:00 -04:00
|
|
|
cat > $(DEBDIR)/DEBIAN/control
|
2011-10-16 11:58:19 -04:00
|
|
|
rm $(DEBDIR)/boot/deb.size
|
2011-08-05 08:25:00 -04:00
|
|
|
dpkg --build $(DEBDIR) $(DEBFILE)
|
|
|
|
rm -rf $(DEBDIR)/DEBIAN
|
2012-02-11 13:06:00 -05:00
|
|
|
(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)
|
2011-10-13 13:27:05 -04:00
|
|
|
for D in `ls | grep -v builds | grep -v sysroot`; do cp -r $$D $(DEBSRCDIR); done
|
2011-08-05 08:25:00 -04:00
|
|
|
(cd $(DEBSRCDIR) && make distclean)
|
2011-11-02 14:14:01 -04:00
|
|
|
rm -rf $(DEBSRCDIR)/sysroot
|
2012-02-11 13:06:00 -05:00
|
|
|
(cd builds && tar cfz $(DEBSRCNAME)-src.tar.gz $(DEBSRCNAME)-src)
|
2011-08-05 08:25:00 -04:00
|
|
|
rm -rf $(DEBSRCDIR)
|
|
|
|
|
|
|
|
# Bootable images
|
|
|
|
|
|
|
|
iso: all debsource
|
|
|
|
rm -rf $(ISODIR)
|
|
|
|
mkdir -p builds
|
|
|
|
mkdir -p $(ISODIR)
|
|
|
|
cp -r isosrc/. $(ISODIR)
|
|
|
|
cp sortix/sortix.bin $(ISODIR)/boot
|
2011-09-07 06:19:17 -04:00
|
|
|
cp $(INITRD) $(ISODIR)/boot/sortix.initrd
|
2011-08-05 08:25:00 -04:00
|
|
|
cp builds/$(DEBSRCNAME)-src.tar.gz $(ISODIR)
|
|
|
|
grub-mkrescue -o $(ISOFILE) $(ISODIR)
|
|
|
|
rm -rf $(ISODIR)
|
|
|
|
|
|
|
|
sortix.iso: iso
|
|
|
|
cp $(ISOFILE) sortix.iso
|
|
|
|
|
|
|
|
# Virtualization
|
|
|
|
run-virtualbox: sortix.iso
|
|
|
|
virtualbox --startvm sortix
|
|
|
|
|
|
|
|
run-virtualbox-debug: sortix.iso
|
|
|
|
virtualbox --debug --start-running --startvm sortix
|
|
|
|
|
|
|
|
|