Sigrid Solveig Haflínudóttirhelpmeport: reduce header clutterb5485075 years agoHistory
110 lines · 2.5 KB · Text
RawDownload
#!/bin/rc# usage: rm -rf mkfile dir/plan9; helpmeport dir | rcrfork ne dir=$1shift if(! test -d $"dir){	echo directory should be specified	exit no} echo '# HEADERS'echo mkdir -p $dir/plan9g -h '#[ 	]*include[ 	]*<[^>/]+/' | sed 's☭.*<(.*)/[^/]*>.*☭mkdir -p '$dir'/plan9/\1☭g' $* | sort -ug -h '#[ 	]*include[ 	]*<[^>/]+' | sed 's☭.*<(.*)>.*☭echo ''#include "plan9.h"'' > '$dir'/plan9/\1☭g' $* | sort -uecho 'cat >'$dir'/plan9/plan9.h <<EOF#ifndef __plan9_h__#define __plan9_h__ #include <u.h>#include <libc.h>#include </sys/include/ctype.h>#include </sys/include/stdio.h> typedef enum { false, true } bool; typedef s8int int8_t;typedef u8int uint8_t;typedef s16int int16_t;typedef u16int uint16_t;typedef s32int int32_t;typedef u32int uint32_t;typedef s64int int64_t;typedef u64int uint64_t;typedef long ssize_t;typedef ulong size_t;typedef intptr ptrdiff_t;typedef intptr intptr_t;typedef uintptr uintptr_t; #define INT16_MAX 0x7fff#define INT16_MIN ((int16_t)0x8000)#define INT64_MIN ((int64_t)0x8000000000000000ULL)#define INT32_MAX 0x7fffffff#define INT_MAX INT32_MAX#define INT32_MIN (-INT32_MAX-1)#define INT_MIN INT32_MIN#define SHRT_MAX 0x7fff#define SHRT_MIN (-SHRT_MAX-1)#define SIZE_MAX 0xffffffffU#define UINT32_MAX 0xffffffffU#define UINT_MAX UINT32_MAX#define UINT64_MAX 0xffffffffffffffffULL #define PRId64 "lld"#define PRIu64 "llud"#define PRIx64 "llx" #define PATH_MAX 256 #define __attribute__(a) #define exit(x) exits(x == 0 ? nil : "error")#define setenv(k,v,x) putenv(k,v)#define unsetenv(k) putenv(k,"")#define strcasecmp cistrcmp#define strncasecmp cistrncmp#define getcwd getwd#define sinf sin#define cosf cos#define usleep(x) sleep(x/1000) #endifEOF' fn c2o {	echo 'HEADERS=\'	walk -f $* | grep '\.h$' | sed 's☭.*☭	&\\☭g'	echo	echo 'OFILES=\'	walk -f $* | grep '\.c$' | sed 's☭(.*)\.c☭	\1.$O\\☭g'	echo#	walk -f $* | grep '\.c$' | sed 's☭(.*/)*([^/]+)\.c$☭	\2.$O\\☭g'#	echo#	walk -f $* | grep '/.*\.c$' | sed 's☭/[^/]+$☭☭g' | sort -u | sed 's☭.*☭%.$O: &/$stem.c\n	$CC $CFLAGS &/$stem.c\n☭g'} echoecho '# MKFILE'echo 'cat >mkfile <<''EOF'''echo '</$objtype/mkfile'echoecho '#LIB=libFIXME.a$O'echo '#BIN=/$objtype/bin'echo '#TARG=FIXME'echo 'CFLAGS=$CFLAGS -p -I'$dir' -I'$dir'/plan9 -DNDEBUG -D__plan9__ -D__${objtype}__'echoc2o $direcho 'default:V: all'echoecho 'CLEANFILES=$OFILES'echoecho '#FIXME'echo '#</sys/src/cmd/mklib'echo '#</sys/src/cmd/mkone'echoecho '%.$O: %.c'echo '	$CC $CFLAGS -o $target $stem.c'echo EOF

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t