From efa48101b0dd68aff41d8a74addce1395ac61e47 Mon Sep 17 00:00:00 2001 From: surdeus Date: Thu, 16 Feb 2023 22:04:38 +0500 Subject: [PATCH] Added the mk/inc and upgraded installation. --- app/mk/inc/cabuild | 12 +++++++++ app/mk/inc/cbuild | 8 ++++++ app/mk/inc/config | 60 ++++++++++++++++++++++++++++++++++++++++++ app/mk/inc/cybuild | 22 ++++++++++++++++ app/mk/inc/dirs | 14 ++++++++++ app/mk/inc/gobuild | 4 +++ app/mk/inc/script | 7 +++++ app/mk/inc/std/cbuild | 15 +++++++++++ app/mk/inc/std/gobuild | 39 +++++++++++++++++++++++++++ app/mk/inc/std/install | 30 +++++++++++++++++++++ app/mk/inc/std/usegcc | 2 ++ app/mk/inc/w3/run-dev | 14 ++++++++++ install | 5 ---- install.sh | 9 +++++++ src/tool/mk/main.go | 2 +- 15 files changed, 237 insertions(+), 6 deletions(-) create mode 100644 app/mk/inc/cabuild create mode 100644 app/mk/inc/cbuild create mode 100644 app/mk/inc/config create mode 100644 app/mk/inc/cybuild create mode 100644 app/mk/inc/dirs create mode 100644 app/mk/inc/gobuild create mode 100644 app/mk/inc/script create mode 100644 app/mk/inc/std/cbuild create mode 100644 app/mk/inc/std/gobuild create mode 100644 app/mk/inc/std/install create mode 100644 app/mk/inc/std/usegcc create mode 100644 app/mk/inc/w3/run-dev delete mode 100755 install create mode 100755 install.sh diff --git a/app/mk/inc/cabuild b/app/mk/inc/cabuild new file mode 100644 index 0000000..b479206 --- /dev/null +++ b/app/mk/inc/cabuild @@ -0,0 +1,12 @@ +TARG = shr/obj/$OBJNAME.a +CFLAGS = $DEFS $INCS $CPPFLAGS +OFILES = ${CFILES:%.c=%.o} +all:V: $TARG +$TARG : $OFILES + mkdir -p shr/obj + $AR $ARFLAGS $TARG $OFILES +%.o : %.c + $CC -c -o $target $CFLAGS $stem.c +clean:V: + rm -f $TARG $OFILES +<$MKINCDIR/std/install diff --git a/app/mk/inc/cbuild b/app/mk/inc/cbuild new file mode 100644 index 0000000..16f80fd --- /dev/null +++ b/app/mk/inc/cbuild @@ -0,0 +1,8 @@ +# Universal powerful simple C build file. +<$(MKINCDIR)/std/cbuild +<$(MKINCDIR)/std/install + +clean:V: + rm -f $TARG $TARG.strip $OFILES +uninstall:V: + rm -f $EXEDIR/$TARG diff --git a/app/mk/inc/config b/app/mk/inc/config new file mode 100644 index 0000000..f22b329 --- /dev/null +++ b/app/mk/inc/config @@ -0,0 +1,60 @@ +# Main configuration file. + +MKINCDIR = $(MKINCDIR) + +EXEDIR = $(HOME)/exe +APPDIR = $(HOME)/app +SHRDIR = $(HOME)/shr +INCDIR = $SHRDIR/inc +MKINCDIR = $APPDIR/mk/inc +OBJDIR = $SHRDIR/obj +MANDIR = $SHRDIR/man +INSTALLDIRS = $OBJDIR $MANDIR $EXEDIR $INCDIR $APPDIR + +USRDIR = /usr +USRINC = -I$USRDIR/include +USRLIB = -L$USRDIR/lib +X11 = $USRDIR/X11R6 +X11INC = -I$X11/include +X11LIB = -L$X11/lib -lX11 +XFTLIB = -lXft +FTINC = $USRINC/freetype2 +FTLIB = -lfreetype +FCINC = +FCLIB = -lfontconfig +MLIB = -lm +CLIB = -lc +UTILLIB = -lutil +XINLIB = -lXinerama +XINCPP = -DXINERAMA +XTLIB = -lXt +XILIB = -lXi +XEXTLIB = -lXext +DOTINC = -I. +SECINC = -Isec +PATH9 = lib/9 +SECINC9 = -I$PATH9/sec +CRYPTLIB = -lcrypt +XRLIB = -lXrandr +CURLIB = -lcurses +PNGLIB = -lpng +JPGLIB = -ljpeg +OBJ9 = $OBJDIR/9.a +INC9 = -I$INCDIR/9 +FRAMEOBJ = $OBJDIR/frame.a +FRAMEINC = -I$INCDIR/frame +XGOBJ = $OBJDIR/Xg.a +XGINC = -I$INCDIR/Xg +SLINC = -I$INCDIR/sl +XMULIB = -lXmu +GCC = cc +CC = tcc +LD = $CC +STRIP = strip +AR = ar +YACC = 9yacc +LEX = lex +PKG_CONFIG_CFLAGS = pkg-config --cflags +PkG_CONFIG_LIBS = pkg-config --libs + +<$(HOME)/env/mk/config diff --git a/app/mk/inc/cybuild b/app/mk/inc/cybuild new file mode 100644 index 0000000..12f7ae0 --- /dev/null +++ b/app/mk/inc/cybuild @@ -0,0 +1,22 @@ +# File to build programs with Yacc files. +INSTALLDIRS = $APPDIR $EXEDIR $SHRDIR +OFILES = ${CFILES:%.c=%.o} +YOFILES = ${YCFILES:%.c=%.o} +TARG = exe/$PROGNAME +CFLAGS = $CPPFLAGS $DEFS $INCS $CFLAGS +all :V: $TARG +strip :V: $TARG + $STRIP $TARG +$TARG : $OFILES $YOFILES + mkdir -p exe + $LD -o $target $LDFLAGS $OFILES $YOFILES $AFILES $LIBS +%.o : %.c + $CC -c -o $target $CFLAGS $stem.c +$CFILES $YCFILES :N: $HFILES $YHFILES +$HFILES :N: +$YHFILES $YCFILES : $YFILES + $YACC -d $YFILES +$YFILES :N: +clean: + rm -f $TARG $OFILES $YOFILES $YHFILES $YCFILES +<$MKINCDIR/std/install diff --git a/app/mk/inc/dirs b/app/mk/inc/dirs new file mode 100644 index 0000000..79c1786 --- /dev/null +++ b/app/mk/inc/dirs @@ -0,0 +1,14 @@ +% :V: %-$MKSHELL +%-sh :QV: + pwd=`pwd` + export pwd + for d in $DIRS ; do + echo "[ cd $d ; mk $stem]" + cd "$d" ; mk $MKFLAGS $stem ; cd "$pwd" + done +%-rc :QV: + pwd = `{pwd} + for(d in $DIRS){ + echo [ cd $d ';' mk $stem] + { builtin cd $d ; mk $MKFLAGS $stem ; builtin cd $pwd} + } diff --git a/app/mk/inc/gobuild b/app/mk/inc/gobuild new file mode 100644 index 0000000..bcb3919 --- /dev/null +++ b/app/mk/inc/gobuild @@ -0,0 +1,4 @@ +# Compatible with pkg module for Golang. +<$MKINCDIR/std/gobuild +<$MKINCDIR/std/install + diff --git a/app/mk/inc/script b/app/mk/inc/script new file mode 100644 index 0000000..84ef683 --- /dev/null +++ b/app/mk/inc/script @@ -0,0 +1,7 @@ +TARG = exe +exe: + mkdir -p $target +all:VQ: + echo -n +<$MKINCDIR/std/install + diff --git a/app/mk/inc/std/cbuild b/app/mk/inc/std/cbuild new file mode 100644 index 0000000..d9c6d50 --- /dev/null +++ b/app/mk/inc/std/cbuild @@ -0,0 +1,15 @@ +OFILES = ${CFILES:%.c=%.o} +TARG = exe/$PROGNAME +CFLAGS = $CPPFLAGS $DEFS $INCS $CFLAGS +all :V: $TARG +strip :V: $TARG.strip +$TARG.strip : $TARG + cp -f $TARG $target + $STRIP $target +$TARG : $OFILES + mkdir -p exe + $LD -o $target $LDFLAGS $OFILES $AFILES $LIBS +%.o : %.c $HFILES + $CC -c -o $target $CFLAGS $stem.c +run :V: $TARG + exec ./$TARG $MKFLAGS diff --git a/app/mk/inc/std/gobuild b/app/mk/inc/std/gobuild new file mode 100644 index 0000000..51a2413 --- /dev/null +++ b/app/mk/inc/std/gobuild @@ -0,0 +1,39 @@ +all :V: build +strip :V: $STRIPTARG +%.strip : % + cp -f $prereq $target + $STRIP $target + +build :VQ: build-$MKSHELL +build-sh :VQ: + mkdir -p exe + pwd=`pwd` + for name in `command cd src/cmd && goblin ls && command cd $pwd`; do + cd src/cmd/$name + echo Buliding "$name"... + if go build -o $pwd/exe/$name ; then + echo Done building "$name" + else + echo "Error(s) while building $name" + fi + if echo "$name" | goblin in $BUILD_WASM ; then + echo Bulding WASM for "'$name'"... + if GOARCH=wasm GOOS=js go build -o "$pwd/$STATIC/$name.wasm" ; then + echo Done building WASM for "$name" + else + echo "Error(s) while building WASM for '$name'" + fi + fi + command cd $pwd + done +clean:V: + pwd=`pwd` + names=`command cd src/cmd && goblin ls && command cd $pwd` + for name in $names ; do + echo Removing "'$name'..." + rm -f "$pwd/exe/$name" + if echo "$name" | goblin in $BUILD_WASM ; then + rm -f "$pwd/$STATIC/$name.wasm" + fi + done + diff --git a/app/mk/inc/std/install b/app/mk/inc/std/install new file mode 100644 index 0000000..82e32cc --- /dev/null +++ b/app/mk/inc/std/install @@ -0,0 +1,30 @@ +install:V: install-$MKSHELL +install-sh:VQ: build + if test -d shr ; then + echo Installing shared files... + cp -rf shr $HOME/shr/.. + echo Done installing shared files + fi + if test -d app ; then + echo Installing application files... + mkdir -p $APPDIR/$PROGNAME && cp -rf app/* $APPDIR/$PROGNAME/ + echo Done installing application files + fi + if test -d exe ; then + echo Installing executables... + cp -rf exe $EXEDIR/.. + files=`goblin basename $(ls exe)` + for i in $files ; do + chmod 0755 $EXEDIR/$i + done + echo Done installing executables + fi +install-rc:V: build + if(test -d shr) cp -rf shr $SHRDIR/.. + if(test -d app){ mkdir -p $APPDIR/$PROGNAME && cp -rf app/* $APPDIR/$PROGNAME/ } + if(test -d exe) { + cp -rf exe $EXEDIR/.. + files = `{goblin basename `{ls exe} } + chmod 0755 $EXEDIR/^$files + } + diff --git a/app/mk/inc/std/usegcc b/app/mk/inc/std/usegcc new file mode 100644 index 0000000..da1d646 --- /dev/null +++ b/app/mk/inc/std/usegcc @@ -0,0 +1,2 @@ +CC = $GCC +LD = $CC diff --git a/app/mk/inc/w3/run-dev b/app/mk/inc/w3/run-dev new file mode 100644 index 0000000..6cb415c --- /dev/null +++ b/app/mk/inc/w3/run-dev @@ -0,0 +1,14 @@ +run-dev:V: + while true ; do + goblin echo -n '> ' + input=`goblin read` + case $input in + exit) + exit + ;; + esac + goblin ls -r 100 $WATCH_FILES \ + | entr -d -r sh -c \ + 'mk && ./exe/w3site' \ + || pkill w3site && ./exe/w3site + done diff --git a/install b/install deleted file mode 100755 index f1c09ae..0000000 --- a/install +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -cd m/cmd/goblin -exec go install - diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..4887a72 --- /dev/null +++ b/install.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +wd=`pwd` + +cd src/cmd/goblin && go install && cd $wd + +mkdir -p $HOME/app/goblin +cp -rf app/* $HOME/app/goblin + diff --git a/src/tool/mk/main.go b/src/tool/mk/main.go index 91d6254..6f4f47b 100644 --- a/src/tool/mk/main.go +++ b/src/tool/mk/main.go @@ -328,7 +328,7 @@ func Run(args []string) { if mkincdir := os.Getenv("MKINCDIR") ; mkincdir == "" { homeDir, _ := os.UserHomeDir() - os.Setenv("MKINCDIR", homeDir + "/app/mk/inc" ) + os.Setenv("MKINCDIR", homeDir + "/app/goblin/mk/inc" ) } flags := flag.NewFlagSet(arg0, flag.ExitOnError)