ref: df4476ab77a8e48cc15f8316a914e734f6ce4434
dir: /make-plan9.rc/
#!/bin/rc rfork ne 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 } } fn pragma_pack { sed 's/#pragma[ ]+pack[ (]*(push|1)[ )]*/#pragma pack on/g s/#pragma[ ]+pack[ (]*(pop|0)[ )]*/#pragma pack off/g s/#ifdef[ ]+_MSC_VER/#if defined(_MSC_VER) || defined(__plan9__)/g' $1 } for(f in src/*.[ch] src/*/*.[ch]){ grep -s '^#pragma[ ]+pack' $f && ! grep -s '^#pragma pack off' $f && { pragma_pack $f >$f.p mv $f.p $f } } { test -d npe -o -d /sys/include/npe || { hget https://git.sr.ht/~ft/npe/archive/master.tar.gz | tar xz && cd npe-master && mk install && cd .. && mv npe-master npe } } && mk -f mkfile.plan9 $*