shithub: mc

Download patch

ref: 1100eb4309cef7fbc7f488a7d066d1f16d80409f
parent: 9d1c4f8aebdc89303323e33cecad42cf6aa36d7a
author: Ori Bernstein <ori@eigenstate.org>
date: Thu Sep 25 15:16:43 EDT 2014

Add support for installing manpages.

--- a/bldfile
+++ b/bldfile
@@ -1,5 +1,4 @@
 # comment
-sub = foo;
 bin mbld =
 	build.myr
 	clean.myr
@@ -13,4 +12,6 @@
         types.myr
 	util.myr
 ;
+
+man = mbld.1;
 
--- a/install.myr
+++ b/install.myr
@@ -38,7 +38,7 @@
 		| `Man mans:
 			/* FIXME: figure out man section by number */
 			for m in mans
-				movefile(delete, m, opt_instroot, opt_destdir, "share/man1")
+				moveman(delete, m)
 			;;
 		;;
 	;;
@@ -66,4 +66,23 @@
 		;;
 	;;
 	std.slfree(path)
+}
+
+const moveman = {delete, man
+	var sect, manrel
+
+	std.put("man = %s\n", man)
+	match std.strrfind(man, ".")
+	| `std.None:
+		std.fatal(1, "manpage %s has no section\n", man)
+	| `std.Some s:
+		sect = s + 1
+		if s + 1 == man.len
+			std.fatal(1, "manpage %s missing suffix\n", man)
+		;;
+	;;
+
+	manrel = std.fmt("share/man%s", man[sect:])
+	movefile(delete, man, opt_instroot, opt_destdir, manrel)
+	std.slfree(manrel)
 }