shithub: docs.9front.org

Download patch

ref: 198f12cf65a7f4730baf477972bdb94e5e7401fe
parent: f6ff8302f18a936f5b4d41a2a371346a24daf48c
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Wed Mar 17 06:44:02 EDT 2021

porting: update

--- a/howto.md
+++ b/howto.md
@@ -20,3 +20,4 @@
 [VMX](vmx.html)
 
 [Porting alien software *without* APE](porting.html)
+
--- a/porting.md
+++ b/porting.md
@@ -12,10 +12,12 @@
 
 ## Process
 
-To get started on an easy port of a POSIX library (or a program), one
-can use
+*It's might be the easiest to install and use*
+[npe](https://git.sr.ht/~ft/npe).
+
+But, for a _complete_ DIY, in case you *REALLY* want it, there is
 [helpmeport](https://git.sr.ht/~ft/snippets/blob/master/helpmeport)
-script.  It tries to generate the appopriate headers and a `mkfile`.
+script.  It tries to generate the appopriate headers and a `mkfile`:
 
 	cd coollib
 	# sometimes, the source files are located in `src` subdir
@@ -36,7 +38,7 @@
 The script will provide `__plan9__` and eg `__amd64__` definitions to
 be used throughout, in case needed.
 
-Feel free to show your script patches and ideas to Sigrid.
+Note that `helpmeport` is unsupported.
 
 ## Common issues
 
@@ -54,6 +56,23 @@
 	#define _header_name_h_
 	....
 	#endif
+
+For a more or less automated processing you could use a script:
+
+```
+fn pragma_once {
+	h=_^`"{echo $1 | sed 's,.*/,,g;s/\..*//g' | tr -d '
+'}^_h_
+	sed 's/#pragma once/#ifndef '^$h^'\n#define '^$h^'/g' $1 && echo && echo '#endif'
+}
+
+for(f in src/*.h src/*/*.h){
+	grep -s '^#pragma[ 	]+once' $f && {
+		pragma_once $f >$f.p
+		mv $f.p $f
+	}
+}
+```
 
 ### function not declared: ...