Added the mk/inc and upgraded installation.

This commit is contained in:
Andrey Parhomenko 2023-02-16 22:04:38 +05:00
parent f98ca5c70f
commit efa48101b0
15 changed files with 237 additions and 6 deletions

12
app/mk/inc/cabuild Normal file
View file

@ -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

8
app/mk/inc/cbuild Normal file
View file

@ -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

60
app/mk/inc/config Normal file
View file

@ -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

22
app/mk/inc/cybuild Normal file
View file

@ -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

14
app/mk/inc/dirs Normal file
View file

@ -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}
}

4
app/mk/inc/gobuild Normal file
View file

@ -0,0 +1,4 @@
# Compatible with pkg module for Golang.
<$MKINCDIR/std/gobuild
<$MKINCDIR/std/install

7
app/mk/inc/script Normal file
View file

@ -0,0 +1,7 @@
TARG = exe
exe:
mkdir -p $target
all:VQ:
echo -n
<$MKINCDIR/std/install

15
app/mk/inc/std/cbuild Normal file
View file

@ -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

39
app/mk/inc/std/gobuild Normal file
View file

@ -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

30
app/mk/inc/std/install Normal file
View file

@ -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
}

2
app/mk/inc/std/usegcc Normal file
View file

@ -0,0 +1,2 @@
CC = $GCC
LD = $CC

14
app/mk/inc/w3/run-dev Normal file
View file

@ -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

View file

@ -1,5 +0,0 @@
#!/bin/sh
cd m/cmd/goblin
exec go install

9
install.sh Executable file
View file

@ -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

View file

@ -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)