prefix?=/usr/local cc_files=wait_for_files samizdat-pinentry cpp_files=dynmenu compiled_programs=${cc_files} ${cpp_files} CC=gcc -std=gnu99 CFLAGS=-Os SUBMODULES = fsmgr kiki openssh all: samizdat-paths.sh ${compiled_programs} ${SUBMODULES} .PHONY: stack install-stack install-stack: curl -sSL https://get.haskellstack.org/ | sh stack: @which stack >/dev/null || make install-stack build-deps: build-dep-stamp build-dep-stamp: build-deps.txt sudo apt-get install --no-upgrade $$(cat build-deps.txt) touch $@ dynmenu: src/dynmenu.cpp | build-deps $(CXX) $(CFLAGS) $< -o $@ -lcurses samizdat-pinentry: src/samizdat-pinentry.c | build-deps $(CC) $(CFLAGS) $< -o $@ -lcurses wait_for_files: src/wait_for_files.c | build-deps $(CC) $(CFLAGS) $< -o $@ dyndns_realprog = dyndns.ssh-rsa.cryptonomic.net dyndns_links = dyndns.ssh-dss.cryptonomic.net \ dyndns.ecdsa-sha2-nistp256.cryptonomic.net dyndns.ssh-ed25519.cryptonomic.net dyndns_progs = $(dyndns_realprog) $(dyndns_links) $(addprefix src/, $(dyndns_links)): ln -s $(dyndns_realprog) $@ src_bin_programs = xorriso-usb.sh btrfs-functions.sh btrfs-receive-root.sh \ btrfs-send-root.sh var.sh grub-efi.sh keygen.sh initrd.sh qemu.sh \ dnsmasq-dhcp-script.sh samizdat-password-agent samizdat-gpg-agent publish-ip.sh \ selfstrap samizdat-daily-snapshot-root samizdat-diff-root kiki-export-stdout \ kiki-import-stdin $(dyndns_progs) bin_programs=$(addprefix src/, $(src_bin_programs)) samizdat-paths.sh ${cc_files} ${btrfs_utils} btrfs_utils=$(addprefix src/btrfs-utils/, btarfs btrfs-shrink with-btrfs-seed) initrd_files:=$(wildcard src/initrd/*) dynmenu samizdat-pinentry wait_for_files initramfs_conf_files:=$(wildcard initramfs-tools/*) isolinux_files:=$(wildcard isolinux/*) clean: rm -f samizdat-paths.sh ${compiled_programs} .PHONY: all clean samizdat-paths.sh: src/samizdat-paths.in @sed -e "s?PREFIX?$(prefix)?g" $< > $@ include samizdat-paths.sh install-nested-kvm: conf/kvm.conf install -m0644 conf/kvm.conf ${instdir}/etc/modprobe.d/ modprobe -r kvm-intel kvm-amd kvm; modprobe kvm; modprobe kvm-intel; modprobe kvm-amd; true network_filter := $(shell ./src/generate-network-filter.sh) conf_files_out = conf/br0 conf/dnsmasq.conf conf/network_if-up.d_samizdat conf_files_in = $(addsuffix .in, $(conf_files_out)) $(conf_files_out): $(conf_files_in) ./src/generate-network-filter.sh sed -e '$(network_filter)' < $@.in > $@ static_conf_files = conf/torrc conf/nbd-server conf/postfix_main.cf .PHONY: install-configuration install-bootserver start-bootserver install-bootserver: sudo initrd.sh sudo -E $(MAKE) instdir=/ real-install-bootserver start-bootserver start-bootserver: ifup --force br0 service dnsmasq restart service nbd-server restart real-install-bootserver: $(conf_files_out) $(static_conf_files) ifndef instdir $(error "You must specify instdir, for safety.") else install -p -m0644 -DT conf/dnsmasq.conf ${instdir}/etc/dnsmasq.conf install -p -m0644 -DT conf/eth0 ${instdir}/etc/network/interfaces.d/eth0 install -p -m0644 -DT conf/br0 ${instdir}/etc/network/interfaces.d/br0 install -p -m0644 -DT conf/network_if-up.d_samizdat ${instdir}/etc/network/if-up.d/samizdat install -p -m0644 -DT conf/nbd-server ${instdir}/etc/nbd-server/conf.d/samizdat.conf endif install-configuration: real-install-bootserver $(conf_files_out) $(static_conf_files) ifndef instdir $(error "You must specify instdir, for safety.") else install -p -m0644 -DT conf/postfix_main.cf ${instdir}/etc/postfix/main.cf install -p -m0644 -DT conf/torrc ${instdir}/etc/tor/torrc ln -sf /var/cache/kiki/config/tor/hostname ${instdir}/etc/mailname ln -sf /var/cache/kiki/config/tor/hostname ${instdir}/etc/hostname endif include user.mk .PHONY: submodule $(SUBMODULES) $(SUBMODULES): stack [ -e $@/Makefile ] || git submodule update --init $(MAKE) -C $@ $(cmd) install-submodules: cmd=install install-submodules: $(SUBMODULES) rootfs = samizdat export rootfs .PHONY: rootfs rootfs: [ -e install-submodules-stamp ] || make install-submodules-stamp [ -e install-stamp ] || sudo make install-stamp $(MAKE) -C rootfs sudo mkdir -p /srv/nbd sudo ln -sf "$$PWD"/rootfs/$(rootfs).btrfs /srv/nbd/samizdat.btrfs boot: rootfs sudo SLOW_BOOT=y qemu.sh fastboot: rootfs sudo qemu.sh reuse_child := $(shell 2>/dev/null read child < reused-child && echo --reuse_child=$$child; true) samizdat.iso: sudo initrd.sh xorriso-usb.sh $(reuse_child) --bootloader --out samizdat.iso isotest: install sudo initrd.sh xorriso-usb.sh $(reuse_child) --bootloader --out samizdat.iso USE_ISO=y SLOW_BOOT=y qemu.sh isotest-nonet: install sudo initrd.sh xorriso-usb.sh $(reuse_child) --out samizdat-nonet.iso USE_ISO=y SLOW_BOOT=y NO_NET=y qemu.sh samizdat-nonet.iso .PHONY: install install: [ -e install-submodules-stamp ] || make install-submodules-stamp sudo make install-stamp install-submodules-stamp: install-submodules touch $@ install-bin-programs: ${bin_programs} install -p ${bin_programs} ${instdir}${samizdat_bindir} CP=cp --preserve=timestamps -r install-stamp: install-bin-programs samizdat-paths.sh ${compiled_programs} mkdir -p ${instdir}${samizdat_initrd_files_dir} mkdir -p ${instdir}${samizdat_child_dir} mkdir -p ${instdir}${samizdat_grub_efi_dir} mkdir -p ${instdir}${samizdat_initramfs_conf_dir} mkdir -p ${instdir}${samizdat_isolinux_dir} mkdir -p ${instdir}${samizdat_linux_dir} $(CP) ${initrd_files} ${instdir}${samizdat_initrd_files_dir} $(CP) ${initramfs_conf_files} ${instdir}${samizdat_initramfs_conf_dir} $(CP) ${isolinux_files} ${instdir}${samizdat_isolinux_dir} touch $@