Index: boot/Makefile
===================================================================
--- boot/Makefile	(revision b2695b939449fec6cfdf61b4b470205152d1316d)
+++ boot/Makefile	(revision 123cd6dd292baa578b9531311775cb6b785d69c4)
@@ -38,19 +38,5 @@
 
 build_dist: clean_dist
-	cp -r -L -T -u "$(USPACE_PATH)/dist" "$(DIST_PATH)"
-	mkdir -p "$(DIST_PATH)/app/"
-	mkdir -p "$(DIST_PATH)/cfg/"
-	mkdir -p "$(DIST_PATH)/data/"
-	mkdir -p "$(DIST_PATH)/lib/"
-	mkdir -p "$(DIST_PATH)/loc/"
-	mkdir -p "$(DIST_PATH)/log/"
-	mkdir -p "$(DIST_PATH)/test/"
-	mkdir -p "$(DIST_PATH)/tmp/"
-	mkdir -p "$(DIST_PATH)/vol/"
-	mkdir -p "$(DIST_PATH)/w/"
 
-ifeq ($(CONFIG_DEVEL_FILES), y)
-	cp -L "$(LIBGCC_PATH)" "$(DIST_PATH)/lib/"
-endif
 
 	if ls $(DIST_OVERLAY_PATH)/* >/dev/null 2>/dev/null; then \
Index: install.sh.in
===================================================================
--- install.sh.in	(revision b2695b939449fec6cfdf61b4b470205152d1316d)
+++ install.sh.in	(revision 123cd6dd292baa578b9531311775cb6b785d69c4)
@@ -2,8 +2,20 @@
 
 if [ "$#" -ge 1 ]; then
-	DESTDIR="$1"
+	touch "$1"
+fi
+
+if [ "$#" -ge 2 ]; then
+	DESTDIR="$2"
 else
 	DESTDIR="${MESON_INSTALL_DESTDIR_PREFIX}"
 fi
 
+mkdir -p "${DESTDIR}cfg/"
+mkdir -p "${DESTDIR}data/"
+mkdir -p "${DESTDIR}loc/"
+mkdir -p "${DESTDIR}log/"
+mkdir -p "${DESTDIR}tmp/"
+mkdir -p "${DESTDIR}vol/"
+mkdir -p "${DESTDIR}w/"
+
 @text@
Index: meson.build
===================================================================
--- meson.build	(revision b2695b939449fec6cfdf61b4b470205152d1316d)
+++ meson.build	(revision 123cd6dd292baa578b9531311775cb6b785d69c4)
@@ -385,5 +385,5 @@
 )
 
-custom_target('config.sh',
+config_sh = custom_target('config.sh',
 	input: config_mk,
 	output: 'config.sh',
@@ -393,14 +393,33 @@
 
 install_files += [[ 'config', meson.current_build_dir() / 'config.mk', 'config.mk' ]]
+install_deps += [ config_mk ]
 install_files += [[ 'config', meson.current_build_dir() / 'config.sh', 'config.sh' ]]
+install_deps += [ config_sh ]
 
 # TODO: remove
 install_files += [[ 'config', meson.current_source_dir() / 'Makefile.common', 'Makefile.common' ]]
+install_deps += files('Makefile.common')
 install_files += [[ 'config', meson.current_source_dir() / 'Makefile.config', 'Makefile.config' ]]
-
-
-# Emit and register the install script.
+install_deps += files('Makefile.config')
+
+if CONFIG_DEVEL_FILES
+	# Also install libgcc
+	libgcc = run_command(
+		cc.cmd_array(), arch_uspace_c_args, '-print-libgcc-file-name',
+		check: true,
+	).stdout().strip()
+
+	install_files += [[ 'lib', libgcc, 'libgcc.a' ]]
+	install_deps += [ files(libgcc) ]
+endif
+
+
+# Emit the install script.
 
 install_script_text = []
+
+# Copy uspace/dist.
+_uspace = meson.current_source_dir() / 'uspace'
+install_script_text += 'cp -r -L -T -u "@0@/dist" "${DESTDIR}"'.format(_uspace)
 
 foreach f : install_files
@@ -411,6 +430,4 @@
 install_script_text += uspace_lib_install_script_text
 
-install_script_name = meson.current_build_dir() / 'install.sh'
-
 install_script = configure_file(
 	configuration: { 'text' : '\n'.join(install_script_text) },
@@ -419,12 +436,16 @@
 )
 
-meson.add_install_script(install_script_name)
-
-custom_target('DIST',
-	output: 'dist.log',
+# Build up dist
+
+dist = custom_target('DIST',
+	output: 'dist.tag',
 	input: [ install_script, install_deps ],
-	command: [ sh, '@INPUT0@', meson.current_build_dir()/'dist/' ],
-	capture: true,
+	command: [ sh, '-x', '-u', '-e', '@INPUT0@', '@OUTPUT@', meson.current_build_dir()/'dist/' ],
 	build_by_default: true,
 )
 
+#initrd_img = custom_target('initrd.img',
+#	output: 'initrd.img',
+#	input: dist,
+
+
Index: uspace/lib/c/meson.build
===================================================================
--- uspace/lib/c/meson.build	(revision b2695b939449fec6cfdf61b4b470205152d1316d)
+++ uspace/lib/c/meson.build	(revision 123cd6dd292baa578b9531311775cb6b785d69c4)
@@ -220,3 +220,4 @@
 if CONFIG_DEVEL_FILES
 	install_files += [[ 'lib', libstartfiles.full_path(), 'libstartfiles.a' ]]
+	install_deps += [ libstartfiles ]
 endif
Index: uspace/lib/meson.build
===================================================================
--- uspace/lib/meson.build	(revision b2695b939449fec6cfdf61b4b470205152d1316d)
+++ uspace/lib/meson.build	(revision 123cd6dd292baa578b9531311775cb6b785d69c4)
@@ -131,5 +131,5 @@
 				_sdir = meson.current_source_dir() / l
 				uspace_lib_install_script_text += 'mkdir -p "${DESTDIR}include/lib@0@"'.format(l)
-				uspace_lib_install_script_text += 'cp -L -t "${DESTDIR}include/lib@0@" "@1@"/*.h'.format(l, _sdir)
+				uspace_lib_install_script_text += 'cp -L -t "${DESTDIR}include/lib@0@" "@1@"/*.h || true'.format(l, _sdir)
 			endif
 		endif
Index: uspace/meson.build
===================================================================
--- uspace/meson.build	(revision b2695b939449fec6cfdf61b4b470205152d1316d)
+++ uspace/meson.build	(revision 123cd6dd292baa578b9531311775cb6b785d69c4)
@@ -44,4 +44,5 @@
 		_dstdir = 'drv' / _basename
 		install_files += [[ _dstdir, _src, _basename + '.ma' ]]
+		install_deps += files(_src)
 	endif
 endforeach
@@ -72,4 +73,5 @@
 			_src = meson.current_source_dir() / dir / _f.get('name')
 			install_files += [[ _dstdir, _src, _f.get('name') ]]
+			install_deps += files(_src)
 		endforeach
 	endif
