author | Olivier Brunel
<jjk@jjacky.com> 2023-01-09 12:31:34 UTC |
committer | Olivier Brunel
<jjk@jjacky.com> 2023-01-16 20:02:29 UTC |
AUTHORS | +1 | -0 |
COPYING | +1 | -0 |
HISTORY | +1 | -0 |
Makefile | +23 | -0 |
common.mk | +146 | -0 |
configure | +525 | -0 |
getdeps | +95 | -0 |
init | +57 | -0 |
libcomain | +226 | -0 |
meta/AUTHORS | +2 | -0 |
meta/AUTHORS.tpl | +2 | -0 |
meta/COPYING | +339 | -0 |
meta/LICENSE | +15 | -0 |
meta/README.git | +50 | -0 |
meta/code | +1 | -0 |
meta/deps.tpl/limb/configure | +0 | -0 |
meta/deps.tpl/limb/files | +0 | -0 |
meta/deps.tpl/limb/git | +1 | -0 |
meta/deps.tpl/limb/static | +0 | -0 |
meta/deps.tpl/limb/version | +1 | -0 |
meta/deps.tpl/md4c/cpnt | +0 | -0 |
meta/deps.tpl/md4c/files | +3 | -0 |
meta/deps.tpl/md4c/git | +1 | -0 |
meta/deps.tpl/md4c/version | +1 | -0 |
meta/deps.tpl/skalibs/get_version | +2 | -0 |
meta/deps.tpl/skalibs/git | +1 | -0 |
meta/deps.tpl/skalibs/incdir | +1 | -0 |
meta/deps.tpl/skalibs/include | +0 | -0 |
meta/deps.tpl/skalibs/libdir | +1 | -0 |
meta/deps.tpl/skalibs/library | +1 | -0 |
meta/deps.tpl/skalibs/version | +1 | -0 |
meta/desc | +3 | -0 |
meta/git | +1 | -0 |
meta/name | +1 | -0 |
meta/options/debug/cflags | +1 | -0 |
meta/options/debug/desc | +1 | -0 |
meta/options/debug/disabled | +0 | -0 |
meta/site | +1 | -0 |
meta/version | +1 | -0 |
mkreadme | +159 | -0 |
mkrelease | +74 | -0 |
mktarball | +66 | -0 |
project.mk.tpl | +7 | -0 |
diff --git a/AUTHORS b/AUTHORS new file mode 120000 index 0000000..d66fa36 --- /dev/null +++ b/AUTHORS @@ -0,0 +1 @@ +meta/AUTHORS \ No newline at end of file diff --git a/COPYING b/COPYING new file mode 120000 index 0000000..897d319 --- /dev/null +++ b/COPYING @@ -0,0 +1 @@ +meta/COPYING \ No newline at end of file diff --git a/HISTORY b/HISTORY new file mode 120000 index 0000000..f0c764f --- /dev/null +++ b/HISTORY @@ -0,0 +1 @@ +meta/HISTORY \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2fe6a11 --- /dev/null +++ b/Makefile @@ -0,0 +1,23 @@ +# Do *not* edit this file +# Project-specific changes/customization should go into project.mk + +all: init + +init: comain configure common.mk config.mk + +configure common.mk: + $(_LN) ln -sf comain/$@ $@ + +comain: + git clone git://lila.oss/comain.git + +config.mk: | configure common.mk + $(error Please run ./configure to set things up.) + +say = @echo " "$1" " +_LN = $(if $(V),,$(call say," LN ")$@;) +_INIT = $(if $(V),,$(call say," INIT ")$@;) + +include common.mk + +.PHONY: all init diff --git a/common.mk b/common.mk new file mode 100644 index 0000000..208fd23 --- /dev/null +++ b/common.mk @@ -0,0 +1,146 @@ +# Do *not* edit this file +# Project-specific changes/customization should go into project.mk + +# init some variables +DEBUG = +CFLAGS = +LDFLAGS = + +# basic warnings, create .d dependency files +COMMON_CPPFLAGS = -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 +COMMON_CPPFLAGS += -iquote include +COMMON_CFLAGS = -pipe -Wall -O3 +COMMON_CFLAGS += -MMD -MP +COMMON_LDFLAGS = -Wl,--sort-section=alignment -Wl,--sort-common +CFLAGS_SHARED = -fPIC +LDFLAGS_SHARED = -shared -Wl,--hash-style=gnu + +SRCS = $(wildcard src/*.c) +OBJS = $(SRCS:.c=.o) +OBJS += $(SRCS:.c=.lo) +DEPS = $(SRCS:.c=.d) +BINS = +LIBS = +SHARED_LIBS = $(patsubst %,lib%.so,$(LIBS)) +STATIC_LIBS = $(patsubst %,lib%.a,$(LIBS)) +SRCS_DOCS = $(wildcard doc/*.md) +DOCS = README COPYING $(SRCS_DOCS:doc/%=%) +DATA = + +# to be removed upon `make clean` +CLEAN = $(BINS) $(STATIC_LIBS) $(SHARED_LIBS) $(OBJS) $(DEPS) + +%.o: %.c Makefile common.mk config.mk project.mk + $(_CC) $(COMMON_CPPFLAGS) $(CPPFLAGS) $(COMMON_CFLAGS) $(CFLAGS) -o $@ -c $< + +%.lo: %.c Makefile common.mk config.mk project.mk + $(_CC) $(COMMON_CPPFLAGS) $(CPPFLAGS) $(COMMON_CFLAGS) $(CFLAGS) $(CFLAGS_SHARED) -o $@ -c $< + +lib%.a: + $(_AR) $(AR) rc $@ $^ + $(_RANLIB) $(RANLIB) $@ + +lib%.so: + $(_CC) -o $@ $(COMMON_CFLAGS) $(CFLAGS) $(CFLAGS_SHARED) $(LDFLAGS_SHARED) \ + -Wl,-soname,$@.0 $^ + +# dependencies to try and make automatically +BUILD_DEPS = + +# to be generated by ./configure +include config.mk + +# te be manually edited +include project.mk + +# created upon compiling +-include $(DEPS) + +# install binaries +$(DESTDIR)$(BINDIR)/%: % + $(_INST) install -D -m 755 $< $@ + +# install shared libs +$(DESTDIR)$(LIBDIR)/%.so: %.so + $(_INST) install -D -m 755 $< $@ + +# install static libs +$(DESTDIR)$(LIBDIR)/%.a: %.a + $(_INST) install -D -m 644 $< $@ + +# install "orivate" binaries +$(DESTDIR)$(LIBDIR)/$(PROJECT_NAME)/%: % + $(_INST) install -D -m 755 $< $@ + +# install README +$(DESTDIR)$(SHAREDIR)/doc/$(PROJECT_NAME)/README: + $(_INST) install -D -m 644 /dev/null $@ ; comain/mkreadme > $@ + +# install documentation +$(DESTDIR)$(SHAREDIR)/doc/$(PROJECT_NAME)/%: % + $(_INST) install -D -m 644 $< $@ + +# install *.md documentation +$(DESTDIR)$(SHAREDIR)/doc/$(PROJECT_NAME)/%.md: doc/%.md | dummy% + $(_INST) install -D -m 644 $< $@ + +# dummy rule, so "install doc" takes precedence over "install *.md doc" whenver +# there is an *.md file in the root. E.g. whenit has been /generated from/ the +# doc/*.md source file +dummy%: + @: + +# install data +$(DESTDIR)$(SHAREDIR)/$(PROJECT_NAME)/%: % + $(_INST) install -D -m 644 $< $@ + + +install-bins: $(BINS:%=$(DESTDIR)$(BINDIR)/%) + +install-libs: $(SHARED_LIBS:%=$(DESTDIR)$(LIBDIR)/%) \ + $(STATIC_LIBS:%=$(DESTDIR)$(LIBDIR)/$(PROJECT_NAME)/%) + +install-docs: $(DOCS:%=$(DESTDIR)$(SHAREDIR)/doc/$(PROJECT_NAME)/%) + +install-data: $(DATA:%=$(DESTDIR)$(SHAREDIR)/$(PROJECT_NAME)/%) + +install: install-bins install-libs install-docs install-data + +clean: + $(_CLEAN) rm -f $(CLEAN) + +cleandeps: + $(_CLEAN) rm -f $(BUILD_DEPS) + $(foreach file,$(BUILD_DEPS),@make -C $(subst .built,,$(file)) clean) + +distclean: clean cleandeps + $(_CLEAN) rm -f config.mk include/config.h + +repoclean: distclean + $(_CLEAN) rm -f configure common.mk + +_CC = $(if $(V),$(CC),$(call say," CC ")$@;$(CC)) +_AR = $(if $(V),,$(call say," AR ")$@;) +_RANLIB = $(if $(V),,$(call say,"RANLIB")$@;) +_CLEAN = $(if $(V),,$(call say,"CLEAN ");) +_MAKE = $(if $(V),,$(call say," MAKE ")$@;) +_INST = $(if $(V),,$(call say," INST ")$@;) + + +$(BUILD_DEPS): Makefile common.mk + $(_MAKE) cd $(subst .built,,$@) && ln -sf ../comain \ + && test -e configure || ( make || true ) \ + && ./configure --bindir=$(BINDIR) --libdir=$(LIBDIR) \ + --incdir=$(INCDIR) --sharedir=$(SHAREDIR) \ + && make + @touch $@ + +$(BINS) $(SHARED_LIBS) $(STATIC_LIBS) $(OBJS): | $(BUILD_DEPS) + +all: $(BINS) $(SHARED_LIBS) $(STATIC_LIBS) $(BUILD_DEPS) + +$(BINS): + $(_CC) -o $@ $(COMMON_CFLAGS) $(CFLAGS) $(COMMON_LDFLAGS) $(LDFLAGS) $^ + +.PHONY: install-bins install-libs install-docs install-data install \ + clean cleandeps distclean repoclean diff --git a/configure b/configure new file mode 100755 index 0000000..ff8af79 --- /dev/null +++ b/configure @@ -0,0 +1,525 @@ +#!/bin/sh + +. "$(dirname $0)"/comain/libcomain + +usageoptions() +{ + local name=$1 + local desc + local disabled + eval desc=\$optdesc$name + eval disabled=\$optdisabled$name + # FIXME space alignment isn't right here, unless $name resolves to 5 chars + echon " --with-$name Enable $desc" + if test $disabled -eq 0; then + echo " [default]" + else + echo "" + fi + echon " --without-$name Disable $desc" + if test $disabled -eq 1; then + echo " [default]" + else + echo "" + fi +} + +usage() +{ + local r="$1" + cat <<EOF +usage: $0 [OPTION..] + + --target=TARGET Set target to run as TARGET [detected] + + --prefix=PREFIX Set main installation prefix to PREFIX [/] + --bindir=DIR Set binary directory to DIR [PREFIX/bin] + --libdir=DIR Set library directory to DIR [PREFIX/lib] + --incdir=DIR Set include directory to DIR [PREFIX/include] + --sharedir=DIR Set share directory to DIR [PREFIX/share] + + --sysdeps=DIR Use skalibs' sysdeps from DIR [LIBDIR/skalibs/sysdeps] + --prefer-shared Prefer to link shared libraires [default] + --prefer-static Prefer to link static libraires + --set-shared=DEP Use shared linking for dependency DEP + --set-static=DEP Use static linking for dependency DEP +EOF + foreach optname $nb_options usageoptions + cat <<EOF + + -h, --help Show this help screen and exit +EOF + exit $r +} + + +## + +target= + +prefix=/ +bindir= +libdir= +incdir= +sharedir= + +sysdeps= +prefer=shared + +CVARS= +CPPFLAGS= +CFLAGS= +LDFLAGS= +COMMON_CPPFLAGS= +COMMON_CFLAGS= +COMMON_LDFLAGS= +VPATHS="# this will handle prefer or set shared/static" +BUILD_DEPS= + +loadoptions + +for arg ; do + case "$arg" in + --target=*) target=${arg#*=} ;; + + --prefix=*) prefix=${arg#*=} ;; + --bindir=*) bindir=${arg#*=} ;; + --libdir=*) libdir=${arg#*=} ;; + --incdir=*) incdir=${arg#*=} ;; + --sharedir=*) sharedir=${arg#*=} ;; + + --sysdeps=*) sysdeps=${arg#*=} ;; + --prefer-shared) ;; + --prefer-static) prefer=static ;; + --set-shared=*) eval "link${arg#*=}=1" ;; + --set-static=*) eval "link${arg#*=}=2" ;; + --with-*) eval optdisabled${arg:7}=0 ;; + --without-*) eval optdisabled${arg:10}=1 ;; + --enable-*) eval optdisabled${arg:9}=0 ;; + --disable-*) eval optdisabled${arg:10}=1 ;; + + -h|--help) usage 0 ;; + -*) error 1 "invalid option '$arg'" ;; + *) target=$arg ;; + esac +done + +if test -z "$bindir"; then bindir="$prefix/bin"; fi +if test -z "$libdir"; then libdir="$prefix/lib"; fi +if test -z "$incdir"; then incdir="$prefix/include"; fi +if test -z "$sharedir"; then sharedir="$prefix/share"; fi +if test -z "$sysdeps"; then sysdeps="$libdir/skalibs/sysdeps"; fi + +bindir="$(echo $bindir | sed 's/\/\+/\//g')" +libdir="$(echo $libdir | sed 's/\/\+/\//g')" +incdir="$(echo $incdir | sed 's/\/\+/\//g')" +sharedir="$(echo $sharedir | sed 's/\/\+/\//g')" +sysdeps="$(echo $sysdeps | sed 's/\/\+/\//g')" + + + +procneeddep() +{ + local depname=$1 + local needed + eval needed=\"\$need$depname\" + if test -z "$needed"; then return 0; fi + return 1 +} + +procdep() +{ + local dep="$1" + local depname="${dep##*/}" + local cpnt="$2" + local link=0 + local needver="$(cat $dep/version 2>/dev/null)" + local include="$depname" + if test -e "$dep/include"; then include="$(cat $dep/include)"; fi + local path="$incdir/$include" + local depver= + local library="$depname" + if test -e "$dep/library"; then library="$(cat $dep/library)"; fi + local internal=0 + local found=0 + + if test "$cpnt" -ne 1; then + type="Dependency" + else + type="Component" + internal=1 + fi + + if procneeddep "$depname"; then + echo " -> $type $depname not needed; SKipping" + nbdeps=$(($nbdeps+1)) + eval dep$nbdeps=$depname + eval lib$depname= + return + fi + + if test -d "./$depname"; then + found=1 + internal=1 + if test -e "$dep/static"; then link=2; fi + path="include" + if test -e "$dep/incdir"; then path="$(cat $dep/incdir)"; fi + path="$depname/$path" + fi + + echon " -> $type $depname " + + local l="$(eval "echo \$link$depname")" + if test -n "$l" && test "$l" -ge 0; then link="$l"; fi + + local vpathso=$depname + local vpatha=$depname + if test $cpnt -ne 1 && test $found -eq 0; then + local ln="lib$library" + local d="$(cat $dep/dynlibdir 2>/dev/null)" + vpathso="$libdir/$d" + d="$(cat $dep/libdir 2>/dev/null)" + vpatha="$libdir/$d" + if test -e "$vpathso/$ln.so" || test -e "$vpatha/$ln.a"; then + found=1 + fi + fi + + if test $found -ne 1; then + echo "MISSING" + test -z "$fail" && fail="$type $depname could not be found" + return + fi + echon "found" + + if test -e "./$depname/meta/version"; then + depver="$(cat ./$depname/meta/version)" + fi + if test -z "$depver"; then + depver="$($dep/get_version "$path" 2>/dev/null)" + fi + if test -z "$depver"; then + echo + test -z "$fail" && fail="Unable to get version for $depname" + return + fi + verok=$(vercmp "$depver" "$needver") + + if test $cpnt -ne 1; then + if test $internal -ne 1; then + echon " (system)" + else + echon " (internal)" + fi + fi + echon ", " + if test $verok -lt 0; then + echon "version $depver too old (need $needver)" + test -z "$fail" && fail="Dependency $depname must be at least v$needver" + elif test $verok -eq 0; then + echon "verion $depver" + else + echon "version $depver ($needver needed)" + fi + if test $cpnt -ne 1 && test $link -gt 0; then + if test $link -eq 1; then + echo " (shared linking)" + else + echo " (static linking)" + fi + else + echo + fi + + if test $cpnt -ne 1; then + nbdeps=$(($nbdeps+1)) + eval dep$nbdeps=$depname + + case $link in + 0) + if test $prefer = "shared"; then + VPATHS="$VPATHS +vpath lib$library.so $vpathso +vpath lib$library.a $vpatha" + elif test $prefer = "static"; then + VPATHS="$VPATHS +vpath lib$library.a $vpatha +vpath lib$library.so $vpathso" + fi + ;; + 1) VPATHS="$VPATHS +vpath lib$library.so $vpathso" + ;; + 2) VPATHS="$VPATHS +vpath lib$library.a $vpatha" + ;; + esac + eval lib$depname=-l$library + + if test $internal -ne 1; then + path="$incdir/$include" + else + path="include" + if test -e "$dep/incdir"; then path="$(cat $dep/incdir)"; fi + path="$depname/$path" + + if test -e "$dep/configure"; then + BUILD_DEPS="$BUILD_DEPS $depname.built" + fi + fi + COMMON_CPPFLAGS="$COMMON_CPPFLAGS -isystem $path" + fi +} + +fail= +cat <<EOF +Configuring $name $version : + => Prefer $prefer linking for dependencies + => Checking requirements... +EOF + +setoptionsflags() +{ + local name=$1 + local cvar + local disabled + eval cvar=\$optcvar$name + eval disabled=\$optdisabled$name + if test $disabled -eq 1; then + CVARS="$CVARS +#undef $cvar" + return + fi + local cppflags + local cflags + local ldflags + eval cppflags=\"\$optcppflags$name\" + eval cflags=\"\$optcflags$name\" + eval ldflags=\"\$optldflags$name\" + CVARS="$CVARS +#define $cvar 1" + if test -n "$cppflags"; then COMMON_CPPFLAGS="$COMMON_CPPFLAGS $cppflags"; fi + if test -n "$cflags"; then COMMON_CFLAGS="$COMMON_CFLAGS $cflags"; fi + if test -n "$ldflags"; then COMMON_LDFLAGS="$COMMON_LDFLAGS $ldflags"; fi +} + +loaddeps +foreach optname $nb_options setoptionsflags + +nbdeps=0 +foreach "cpnt" $nb_cpnt procdep 1 +foreach "deps" $nb_deps procdep 0 + +if test -n "$fail"; then + error 2 "Cannot continue: $fail" +fi + + +cmdexists() +{ + type "$1" > /dev/null 2>&1 +} + +trycmd() +{ + local name="$1" + shift + test -z "$(eval echo \$$name)" && cmdexists "$1" && eval "$name=\"$*\"" +} + +tryflag() +{ + echon " -> Checking whether compiler accepts $2.." + echo "typedef int x;" > "tmp.c" + if $CC $CPPFLAGS $CFLAGS "$2" -c -o "tmp.o" "tmp.c" > /dev/null 2>&1; then + echo ".. yes" + eval "$1=\"\${$1} \$2\"" + eval "$1=\${$1# }" + return 0 + else + echo ".. no" + return 1 + fi +} + +trap 'rm -f tmp.c tmp.o config.mk.tmp config.h.tmp' EXIT ABRT INT QUIT TERM HUP + +echo " => Checking compiler..." + +echon " -> Looking for a C compiler.." +trycmd CC "$CC" +trycmd CC "gcc" +trycmd CC "clang" +trycmd CC "cc" +if test -z "$CC"; then + echo ".. not found" + error 2 "Unable to find a C compiler" +else + echo ".. $CC" +fi +trycmd AR "$AR" +trycmd AR "ar" +trycmd RANLIB "$RANLIB" +trycmd RANLIB "ranlib" + +echon " -> Checking target.." +if test -z "$target" ; then + target=$($CC -dumpmachine 2>/dev/null) || target=unknown +fi +echo ".. $target" +if test ! -d $sysdeps || test ! -f $sysdeps/target; then + error 2 "$sysdeps is not a valid sysdeps directory" +fi +if test "x$target" != "x$(cat $sysdeps/target)"; then + error 2 "target $target does not match the contents of $sysdeps/target ($(cat $sysdeps/target))" +fi + +tryflag CFLAGS -std=c99 +tryflag CFLAGS -fomit-frame-pointer +tryflag CFLAGS -fno-exceptions +tryflag CFLAGS -fno-unwind-tables +tryflag CFLAGS -fno-asynchronous-unwind-tables +tryflag CPPFLAGS -Werror=implicit-function-declaration +tryflag CPPFLAGS -Werror=implicit-int +tryflag CPPFLAGS -Werror=pointer-sign +tryflag CPPFLAGS -Werror=pointer-arith +tryflag CFLAGS -ffunction-sections +tryflag CFLAGS -fdata-sections + +echo " => Paths :" +cat <<EOF + -> bindir : $bindir + -> libdir : $libdir + -> incdir : $incdir + -> sharedir : $sharedir +EOF + +options= +showoption() +{ + local name=$1 + local disabled + eval disabled=\$optdisabled$name + if test $disabled -eq 0; then + local desc + eval desc=\$optdesc$name + options="$options + -> $name : $desc" + fi +} +if test $nb_options -gt 0; then + foreach optname $nb_options showoption + if test -n "$options"; then + echo " => Options :$options" + fi +fi + +echo " => Generating files..." + +echo " -> Generating config.mk..." +exec 5>&1 1>config.mk.tmp +echo "# This file was generated by:" +echo "# $0 $@" +echo "# Any changes you make in here will be lost on the next ./configure" +echo "" + +echo "CC = $CC" +echo "AR = $AR" +echo "RANLIB = $RANLIB" + +# not sure this really matters, so long as both are mentioned it will be the +# order of our vpath that will matter really - still, let's keep it that way +if test "$prefer" = "static"; then + echo "# prefer static linking" + echo ".LIBPATTERN := lib%.a lib%.so" +else + echo "# prefer shared linking" + echo ".LIBPATTERN := lib%.so lib%.a" +fi +echo $VPATHS + +setdep() +{ + local depname="$1" + local rep=$(eval "echo \$lib$depname") + rep="$(echo "$rep" | sed "s/\//\\\\\//g")" + line="$(echo "$line" | sed "s/$depname/$rep/")" +} + +echo "# dependencies" +if test -f "meta/deps-lib"; then + exec 4<"meta/deps-lib" + echo "# dependencies" + while IFS= read -r line <&4; do + foreach "dep" $nbdeps setdep + echo "lib$(echo "$line" | cut -d: -f1).a: $(echo "$line" | cut -d: -f2-)" + line="$(echo "$line" | sed "s/\.o/\.lo/g")" + echo "lib$(echo "$line" | cut -d: -f1).so: $(echo "$line" | cut -d: -f2-)" + done + exec 4<&- +fi + +if test -f "meta/deps-bin"; then + exec 4<"meta/deps-bin" + while IFS= read -r line <&4; do + foreach "dep" $nbdeps setdep + echo $line + done + exec 4<&- +fi + +cat <<EOF +# some flags +COMMON_CPPFLAGS += $COMMON_CPPFLAGS +COMMON_CFLAGS += $COMMON_CFLAGS +COMMON_LDFLAGS += $COMMON_LDFLAGS +CPPFLAGS = $CPPFLAGS +CFLAGS = $CFLAGS +LDFLAGS = $LDFLAGS + +# special dependencies we try to make automatically +BUILD_DEPS = $BUILD_DEPS + +# paths +BINDIR = $bindir +LIBDIR = $libdir +INCDIR = $incdir +SHAREDIR = $sharedir + +# general variables +PROJECT_NAME = $name +PROJECT_VERSION = $version +EOF + +exec 1>&5 5>&- +mv -f config.mk.tmp config.mk + + +echo " -> Generating config.h..." +prefix=${name^^} + +exec 5>&1 1>config.h.tmp +cat <<EOF +/* This file was generated by: + * $0 $@ + * Any changes you make in here will be lost on the next ./configure + */ +#ifndef ${prefix}_CONFIG_H +#define ${prefix}_CONFIG_H + +#define ${prefix}_CURYEAR "$(date +%Y)" +#define ${prefix}_AUTHOR "Olivier Brunel" +#define ${prefix}_VERSION "$version" +#define ${prefix}_URL "$(cat meta/site)" +#define ${prefix}_LIBDIR "$libdir/$name" +#define ${prefix}_SHAREDIR "$sharedir/$name" +$CVARS + +#endif /* ${prefix}_CONFIG_H */ +EOF + +exec 1>&5 5>&- +mv -f config.h.tmp include/config.h + + +echo "done." diff --git a/getdeps b/getdeps new file mode 100755 index 0000000..11c33ea --- /dev/null +++ b/getdeps @@ -0,0 +1,95 @@ +#!/bin/sh + +. "$(dirname $0)"/libcomain + +usage() +{ + local r=$1 + shift + + cat <<EOF +usage: $0 [ACTION] + + default Clone repo of components & "internal" dependencies + + list List all components and dependencies + cpnt Clone repo of components only + intdeps Clone repo of "internal" dependencies only + deps Clone repo of all dependencies + + dep NAME Clone repo of dependency NAME + + help Show this help screen and exit +EOF + exit $r +} + +showdep() +{ + local dep=$1 + local depname="${dep##*/}" + local needed + eval needed=\"\$need$depname\" + echon "- $depname version $(cat $dep/version)" + if test "$needed" != "1"; then + echon " [optional: --with-$(echo $needed | sed "s/ /, --with-/g")]" + fi + echo + if test -f "$dep/site"; then echo " site : $(cat $dep/site)"; fi + if test -f "$dep/git" ; then echo " repo : $(cat $dep/git)" ; fi + if test -f "$dep/ref" ; then echo " ref : $(cat $dep/ref)" ; fi +} + +list() +{ + if test $nb_cpnt -ge 1; then echo "Components :"; fi + foreach cpnt $nb_cpnt showdep + if test $nb_cpnt -ge 1; then echo; fi + if test $nb_deps -ge 1; then echo "Dependencies :"; fi + foreach deps $nb_deps showdep +} + +getdep() +{ + local dep=$1 + local depname="${dep##*/}" + local intonly=$2 + if test $intonly -eq 1 && test ! -e "$dep/files"; then return; fi + if test -e "$depname"; then + warn "cannot clone $depname: file already exists" + return + fi + run git clone "$(cat $dep/git)" "$depname" + local ref="$(cat $dep/ref 2>/dev/null)" + if test -z "$ref"; then ref="$(cat $dep/version)"; fi + run git -C $depname checkout -b $prjname "$ref" +} + +loadoptions +loaddeps + +isdep=0 +for arg ; do + if test $isdep -eq 1; then + if test ! -d meta/deps/$arg; then error 2 "unknown dependency '$arg'"; fi + getdep meta/deps/$arg 0 + continue + fi + case "$arg" in + list) list ;; + cpnt) foreach cpnt $nb_cpnt getdep 0;; + intdeps) foreach deps $nb_deps getdep 1;; + deps) foreach deps $nb_deps getdep 0;; + dep) isdep=1 ;; + + -h|--help|help) usage 0 ;; + *) error 1 "unknown action '$arg'" ;; + esac +done + +if test -z "$arg"; then + foreach cpnt $nb_cpnt getdep 0 + foreach deps $nb_deps getdep 1 +fi + +echo "done." diff --git a/init b/init new file mode 100755 index 0000000..00ac6be --- /dev/null +++ b/init @@ -0,0 +1,57 @@ +#!/bin/sh + +if test -d meta; then + echo "Directory 'meta' already exist" >&2 + exit 2 +fi + +name=$(basename "$(pwd)") +mkdir meta +echo $name > meta/name +echo 0.0.0 > meta/version + +. "$(dirname $0)"/libcomain + +if test ! -d comain; then + error 2 "Directory 'comain' not found" +fi + +run cp -n comain/Makefile Makefile +run cp -n comain/project.mk.tpl project.mk +run mkdir include src +run cp -n comain/meta/README.git meta +run echo https://lila.oss/$name > meta/site +run echo git://lila.oss/$name.git > meta/git +run echo https://lila.oss/doc/$name > meta/doc +run echo https://lila.oss/code/$name > meta/code +run cp -n comain/meta/COPYING meta +run cp -n comain/meta/LICENSE meta +run cp -n comain/meta/AUTHORS.tpl meta/AUTHORS +run mkdir meta/deps +run mkdir meta/deps/comain +run touch meta/deps/comain/cpnt +run cp -n comain/meta/version meta/deps/comain/version +run cp -n comain/meta/git meta/deps/comain/git +run mkdir meta/options +run ln -sf ../../comain/meta/options/debug meta/options +run ln -sf meta/README.git README +run ln -sf meta/AUTHORS +run ln -sf meta/COPYING +run ln -sf meta/HISTORY +if test -e .gitignore; then error 2 "File '.gitignore' already exists"; fi +run cat > .gitignore <<EOF +/comain +/configure +/common.mk +/config.mk +/include/config.h +*.o +*.lo +*.d +EOF +if test -e .git; then error 2 "Already a git repo (.git exist)"; fi +git init . +git add . .gitignore +git commit --message="First commit" + +echo "done." diff --git a/libcomain b/libcomain new file mode 100644 index 0000000..db53d75 --- /dev/null +++ b/libcomain @@ -0,0 +1,226 @@ +#!/bin/sh + +nb_options=0 +name=$(cat meta/name 2>/dev/null) +version=$(cat meta/version 2>/dev/null) + +echo() +{ + IFS=' ' + printf %s\\n "$*" +} + +echon() +{ + IFS=' ' + printf %s "$*" +} + +error() +{ + r=$1 + shift + m="$*" + + echo "$0: fatal: $m" >&2 + exit $r +} + +warn() +{ + echo "$0: $@" >&2 +} + +quote() +{ + printf %s\\n "$1" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/'/" ; +} + +fnmatch() +{ + case "$2" in $1) return 0 ;; *) return 1 ;; esac ; +} + +save() +{ + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} + +run() +{ + "$@" + local r=$? + if test $r -ne 0; then + error 3 "Failed ($r): $@" + fi +} + +foreach() +{ + local name="$1" + local nb="$2" + local fn="$3" + shift 3 + nb=$(($nb+0)) + + while test $nb -gt 0; do + "$fn" "$(eval "echo \$$name$nb")" "$@" + nb=$(($nb-1)) + done +} + +vercmp() +{ + got="$1" + need="$2" + + if test "$got" = "$need"; then + echo 0 + return + fi + + l1="$(echo $got |tr -d '[:alnum:]')" + l2="$(echo $need|tr -d '[:alnum:]')" + l1=${#l1} + l2=${#l2} + + if test $l1 -lt $l2; then + n=$l1 + else + n=$l2 + fi + + n=$(($n+1)) + i=1 + while test $i -le $n; do + n1="$(echo $got |cut -d. -f$i)" + n2="$(echo $need|cut -d. -f$i)" + if test -z "$(echo $n1|tr -d '[:alpha:]')" \ + && test -z "$'echo $n2|tr -d '[:alpha:]')"; then + if test $n1 -lt $n2; then + echo -1 + return + elif test $n1 -gt $n2; then + echo 1 + return + fi + elif test "$n1" != "$n2"; then + # if there's a non-digit part somewhere we just assume to have a + # lower version + echo -1 + return + fi + i=$(($i+1)) + done + + if test $l1 -gt $l2; then + echo 1 + else + echo -1 + fi +} + +loadoptions() +{ + if ! test -d meta/options; then return 1; fi + local name= + local desc= + local cvar= + local cflags= + local ldflags= + local disabled= + for name in meta/options/*; do + name=${name##*/} + desc="$(cat meta/options/$name/desc 2>/dev/null)" + if test -z "$desc"; then return 0; fi + cvar="$(cat meta/options/$name/cvar 2>/dev/null)" + if test -z "$cvar"; then cvar="WITH_${name^^}"; fi + cflags="$(cat meta/options/$name/cflags 2>/dev/null)" + ldflags="$(cat meta/options/$name/ldflags 2>/dev/null)" + disabled=0 + if test -e meta/options/$name/disabled; then disabled=1; fi + dep="$(cat meta/options/$name/dep 2>/dev/null)" + + nb_options=$(($nb_options+1)) + eval optname$nb_options=$name + eval optdesc$name=\"$desc\" + eval optcvar$name=\"$cvar\" + eval optcflags$name=\"$cflags\" + eval optldflags$name=\"$ldflags\" + eval optdisabled$name=$disabled + local tmp + eval tmp=\"\$need$dep\" + if test -z "$tmp"; then + eval need$dep=$name + elif test "$tmp" == "1"; then + eval need$dep=$name + else + eval need$dep=\"$\need$dep $name\" + fi + done + return 1 +} + +setneeddep() +{ + local dep=$1 + local depname="${dep##*/}" + local optname=$2 + local tmp + eval tmp=\"\$need$depname\" + tmp="$(echo $tmp | sed s/$optname//)" + eval need$depname=\"$tmp\" +} + +setoptionsdep() +{ + local name=$1 + local disabled + eval disabled=\$optdisabled$name + if test $disabled -eq 1; then + foreach "cpnt" $nb_cpnt setneeddep $name + foreach "dest" $nb_deps setneeddep $name + fi +} + +loaddeps() +{ + nb_cpnt=0 + nb_deps=0 + if test -d meta/deps; then + for dep in meta/deps/*; do + local depname="${dep##*/}" + local tmp + if test -e "$dep/cpnt"; then + nb_cpnt=$(($nb_cpnt+1)) + tmp="cpnt$nb_cpnt" + else + nb_deps=$(($nb_deps+1)) + tmp="deps$nb_deps" + fi + eval $tmp=\"$dep\" + + eval tmp=\"\$need$depname\" + if test -z "$tmp"; then + eval need$depname=\"1\" + fi + done + foreach optname $nb_options setoptionsdep + fi +} + +getchangelog() +{ + if test ! -f meta/HISTORY; then return; fi + cat meta/HISTORY | awk ' +BEGIN { i=0 } +$1=="#" { if (++i>2) exit } +{ if ($1 != "#" && i==2) print } +' +} + +test -n "$name" || error 2 "Cannot find project's name" +test -n "$version" || error 2 "Cannot find project's version" +prjname=$name +prjver=$version diff --git a/meta/AUTHORS b/meta/AUTHORS new file mode 100644 index 0000000..6aef6f1 --- /dev/null +++ b/meta/AUTHORS @@ -0,0 +1,2 @@ +Main author: +* Olivier Brunel <jjk@jjacky.com> diff --git a/meta/AUTHORS.tpl b/meta/AUTHORS.tpl new file mode 100644 index 0000000..6aef6f1 --- /dev/null +++ b/meta/AUTHORS.tpl @@ -0,0 +1,2 @@ +Main author: +* Olivier Brunel <jjk@jjacky.com> diff --git a/meta/COPYING b/meta/COPYING new file mode 100644 index 0000000..a43ea21 --- /dev/null +++ b/meta/COPYING @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 675 Mass Ave, Cambridge, MA 02139, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + Appendix: How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) 19yy <name of author> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/meta/LICENSE b/meta/LICENSE new file mode 100644 index 0000000..f867b90 --- /dev/null +++ b/meta/LICENSE @@ -0,0 +1,15 @@ +Released under GPL-2.0, see COPYING for more. +Copyright (C) 2023 Olivier Brunel + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +version 2, as published by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/meta/README.git b/meta/README.git new file mode 100644 index 0000000..a17222c --- /dev/null +++ b/meta/README.git @@ -0,0 +1,50 @@ +If you're reading this, chances are you just cloned the git repository of some +lila software. Congratulations! :) + +Now unlike with the tarball of a release, you're not quite ready to go, there +are a few steps required in order to get things good to go : + +1. First, you need the component *comain* in order to continue. This will + provide scripts and other files needed for configure, etc + + You can simply run `make` to have comain's repo cloned and checked out at + the right version for you. If you'd rather do it yourself, or get a release + tarball, go ahead. + The minimum version needed can be found in meta/deps/comain/version + +2. Once comain is there, if you haven't already you can run `make` to create + needed symlinks such as `configure` or `common.mk` + +3. Good, but there might be other components needed to build this software. + Worry not, comain can help you and set them all up for you. To do so, simply + run `comain/getdeps` + + Each components will then be cloned and checked out as needed. Should you + want to do so manually, you can instead run `comain/getdeps list` and it will + only list all required components and their minimum version. + + By default, in addition to components `comain/getdeps` will also set up + dependencies that are marked to be included in the release tarball. Those are + usually also set to be statically linked, thus providing no runtime + dependency. + + If you do *not* want that, and would like only components to be processed, + simply run `comain/getdeps cpnt` instead. + +4. Now that components are all set up, there might be dependencies as well - + that is, librairies needed to build the software. + + Some dependencies might be classified as "internal", meaning their source + code is included in release tarballs and by default they're linked + statically, thus leading to no runtime dependencies. + Usually, there's only one such dependency, lila's very own `limb` + + If you didn't use `comain/getdeps` on step 3 and now wishes for those to be + setup by comain, you can use `comain/getdeps intdeps` + + You can also use comain to clone repos of *all* dependencies by running + `comain/getdeps alldeps` or pick one and use `comain/getdeps dep NAME` where + `NAME` is to be the name of the dependency to clone the repo of. + +5. That's it, finally you're ready! You can now use `./configure` and `make` as + usual. diff --git a/meta/code b/meta/code new file mode 100644 index 0000000..6093f62 --- /dev/null +++ b/meta/code @@ -0,0 +1 @@ +https://lila.oss/code/comain diff --git a/meta/deps.tpl/limb/configure b/meta/deps.tpl/limb/configure new file mode 100644 index 0000000..e69de29 diff --git a/meta/deps.tpl/limb/files b/meta/deps.tpl/limb/files new file mode 100644 index 0000000..e69de29 diff --git a/meta/deps.tpl/limb/git b/meta/deps.tpl/limb/git new file mode 100644 index 0000000..109fd23 --- /dev/null +++ b/meta/deps.tpl/limb/git @@ -0,0 +1 @@ +git://lila.oss/limb.git diff --git a/meta/deps.tpl/limb/static b/meta/deps.tpl/limb/static new file mode 100644 index 0000000..e69de29 diff --git a/meta/deps.tpl/limb/version b/meta/deps.tpl/limb/version new file mode 100644 index 0000000..8acdd82 --- /dev/null +++ b/meta/deps.tpl/limb/version @@ -0,0 +1 @@ +0.0.1 diff --git a/meta/deps.tpl/md4c/cpnt b/meta/deps.tpl/md4c/cpnt new file mode 100644 index 0000000..e69de29 diff --git a/meta/deps.tpl/md4c/files b/meta/deps.tpl/md4c/files new file mode 100644 index 0000000..e465d02 --- /dev/null +++ b/meta/deps.tpl/md4c/files @@ -0,0 +1,3 @@ +LICENSE.md +src/md4c.h +src/md4c.c diff --git a/meta/deps.tpl/md4c/git b/meta/deps.tpl/md4c/git new file mode 100644 index 0000000..f9f17ec --- /dev/null +++ b/meta/deps.tpl/md4c/git @@ -0,0 +1 @@ +git://lila.oss/md4c.git diff --git a/meta/deps.tpl/md4c/version b/meta/deps.tpl/md4c/version new file mode 100644 index 0000000..af684dd --- /dev/null +++ b/meta/deps.tpl/md4c/version @@ -0,0 +1 @@ +0.4.8.lila.1 diff --git a/meta/deps.tpl/skalibs/get_version b/meta/deps.tpl/skalibs/get_version new file mode 100755 index 0000000..55041f5 --- /dev/null +++ b/meta/deps.tpl/skalibs/get_version @@ -0,0 +1,2 @@ +#!/bin/sh +grep SKALIBS_VERSION "$@/skalibs/config.h" | cut -d\" -f2 diff --git a/meta/deps.tpl/skalibs/git b/meta/deps.tpl/skalibs/git new file mode 100644 index 0000000..5965139 --- /dev/null +++ b/meta/deps.tpl/skalibs/git @@ -0,0 +1 @@ +git://lila.oss/skalibs.git diff --git a/meta/deps.tpl/skalibs/incdir b/meta/deps.tpl/skalibs/incdir new file mode 100644 index 0000000..e4484e2 --- /dev/null +++ b/meta/deps.tpl/skalibs/incdir @@ -0,0 +1 @@ +src/include diff --git a/meta/deps.tpl/skalibs/include b/meta/deps.tpl/skalibs/include new file mode 100644 index 0000000..e69de29 diff --git a/meta/deps.tpl/skalibs/libdir b/meta/deps.tpl/skalibs/libdir new file mode 100644 index 0000000..5baacc7 --- /dev/null +++ b/meta/deps.tpl/skalibs/libdir @@ -0,0 +1 @@ +skalibs diff --git a/meta/deps.tpl/skalibs/library b/meta/deps.tpl/skalibs/library new file mode 100644 index 0000000..39971a0 --- /dev/null +++ b/meta/deps.tpl/skalibs/library @@ -0,0 +1 @@ +skarnet diff --git a/meta/deps.tpl/skalibs/version b/meta/deps.tpl/skalibs/version new file mode 100644 index 0000000..48c7359 --- /dev/null +++ b/meta/deps.tpl/skalibs/version @@ -0,0 +1 @@ +2.13.0.0 diff --git a/meta/desc b/meta/desc new file mode 100644 index 0000000..6e157da --- /dev/null +++ b/meta/desc @@ -0,0 +1,3 @@ +build system for lila softwares + +A set of scripts, Makefiles and other helpers to build softwares diff --git a/meta/git b/meta/git new file mode 100644 index 0000000..fb8c94f --- /dev/null +++ b/meta/git @@ -0,0 +1 @@ +git://lila.oss/comain.git diff --git a/meta/name b/meta/name new file mode 100644 index 0000000..ee84ea4 --- /dev/null +++ b/meta/name @@ -0,0 +1 @@ +comain diff --git a/meta/options/debug/cflags b/meta/options/debug/cflags new file mode 100644 index 0000000..2523057 --- /dev/null +++ b/meta/options/debug/cflags @@ -0,0 +1 @@ +-g -Og diff --git a/meta/options/debug/desc b/meta/options/debug/desc new file mode 100644 index 0000000..cee1bd6 --- /dev/null +++ b/meta/options/debug/desc @@ -0,0 +1 @@ +debug mode diff --git a/meta/options/debug/disabled b/meta/options/debug/disabled new file mode 100644 index 0000000..e69de29 diff --git a/meta/site b/meta/site new file mode 100644 index 0000000..af5babe --- /dev/null +++ b/meta/site @@ -0,0 +1 @@ +https://lila.oss/comain diff --git a/meta/version b/meta/version new file mode 100644 index 0000000..77d6f4c --- /dev/null +++ b/meta/version @@ -0,0 +1 @@ +0.0.0 diff --git a/mkreadme b/mkreadme new file mode 100755 index 0000000..ade7be5 --- /dev/null +++ b/mkreadme @@ -0,0 +1,159 @@ +#!/bin/sh + +. "$(dirname $0)"/libcomain + +isprj=0 +if test "$1" == "--project"; then isprj=1; fi + +loadoptions +loaddeps + +if test ! -e meta/desc; then error 2 "File 'meta/desc' missing"; fi +if test ! -e meta/LICENSE; then error 2 "File 'meta/LICENSE' missing"; fi + +links() +{ + local lnks= + local label="official site" + if test -f meta/upstream; then + label="lila's version" + if test $isprj -eq 0; then + echo "- [upstream]" + lnks="$links +[upstream]: $(cat meta/upstream)" + else + echo "- '<li><a href=\"$(cat meta/upstream)\">Upstream</a>'" + fi + fi + if test $isprj -eq 0; then + if test -f meta/site; then + echo "- [$label]" + lnks="$lnks +[$label]: $(cat meta/site)" + fi + fi + if test -f meta/git; then + if test $isprj -eq 0; then + echo "- [repository]" + lnks="$lnks +[repository]: $(cat meta/git)" + else + echo "- '<li>Repository:<br><code>$(cat meta/git)</code>'" + fi + fi + if test -f meta/code; then + if test $isprj -eq 0; then + echo "- [source code]" + lnks="$lnks +[source code]: $(cat meta/code)" + else + echo "- '<li><a href=\"$(cat meta/code)\">Source Code</a>'" + fi + fi + if test -f meta/doc; then + if test $isprj -eq 0; then + echo "- [documentation]" + lnks="$lnks +[documentation]: $(cat meta/doc)" + else + echo "- ' <li><a href=\"$(cat meta/doc)\">Documentation</a>'" + fi + fi + if test $isprj -eq 0; then cat <<EOF +$lnks +$LINKS +EOF + fi +} + +if test $isprj -eq 1; then + cat <<EOF +--- +layout: project +title: $name: $(head -1 meta/desc) +links: +$(links) +--- + +EOF +fi + +echo "# $name: $(head -1 meta/desc)" +tail -n +2 meta/desc + +if test ! -f meta/released-on; then + cat <<EOF + +# Not yet released + +* Still in development +EOF +else + cat <<EOF + +# Latest release: $version ($(cat meta/released-on)) +$(getchangelog) +EOF +fi + +LINKS= +echodep() +{ + local dep="$1" + local depname="${dep##*/}" + local name="$depname" + local needed + eval needed=\"\$need$depname\" + local site="$(cat $dep/site 2>/dev/null)" + if test -z "$site"; then site="$(cat $depname/meta/site 2>/dev/null)"; fi + if test -n "$site"; then + name="[$name]" + LINKS="$LINKS +$name: $site" + fi + echon " * $name version $(cat $dep/version)" + if test "$needed" != "1"; then + echon " [optional: --with-$(echo $needed | sed "s/ /, --with-/g")]" + fi + echo +} +if test $nb_cpnt -gt 0; then +cat <<EOF + +## Components + +Those are /internal components/, the required source code is included in +the tarball and they lead to no runtime dependency. + +EOF +foreach "cpnt" $nb_cpnt echodep +fi + +if test $nb_deps -gt 0; then +cat <<EOF + +## Dependencies + +Those are dependencies on librairies that will need to be present at build +time. A runtime dependency will be set, unless static linking was used. + +EOF +foreach "deps" $nb_deps echodep +fi + +cat <<EOF + +# Free Software + +$(cat meta/LICENSE) + +EOF +if test $isprj -eq 1; then + echo "$LINKS" +else + cat <<EOF +# Links + +$(links) +EOF +fi diff --git a/mkrelease b/mkrelease new file mode 100755 index 0000000..85c4a76 --- /dev/null +++ b/mkrelease @@ -0,0 +1,74 @@ +#!/bin/sh + +. "$(dirname $0)"/libcomain + +if test ! -e meta/version; then error 2 "File 'meta/version' missing"; fi +ver="$(cat meta/version)" + +major=$(echo $ver | cut -d. -f1) +minor=$(echo $ver | cut -d. -f2) +rev=$(echo $ver | cut -d. -f3) + +case "$1" in + major) major=$(($major + 1)); minor=0; rev=0 ;; + minor) minor=$(($minor + 1)); rev=0 ;; + rev) rev=$(($rev + 1)) ;; + *) error 1 "you need to specify 'major', 'minor' or 'rev'" +esac + +new=$major.$minor.$rev +echo " => bumping $ver to $new..." +date="$(date +%Y-%m-%d)" + +if test "$(git symbolic-ref --short HEAD)" != "next"; then + error 2 "next is not checked out" +fi +if test -n "$(git status -s)"; then + error 2 "working tree not clean" +fi + +echo " -> Updating meta/version : $new" +echo $new > meta/version + +echo " -> Updating meta/released-on : $date" +echo $date > meta/released-on + +echo " -> Updating meta/HISTORY" +line="# version $new [released on $date]" +if test ! -e meta/HISTORY; then + cat >meta/HISTORY.tmp <<EOF +# Current development + +- Nothing yet. + +$line + +- First release. +EOF +else + exec 5>&1 >meta/HISTORY.tmp + head -2 meta/HISTORY + cat <<EOF +- Nothing yet. + +$line + +EOF + tail -n +3 meta/HISTORY + exec 1>&5 5<&- +fi +mv -f meta/HISTORY{.tmp,} + +echo " -> Commit meta/{version,released-on,HISTORY}" +git add meta/{version,released-on,HISTORY} +git commit -m "Release version $new" + +echo " -> Tag & fast-forward" +git checkout master +git merge --ff-only next +git tag -a $new -m "Release version $new + +$(getchangelog)" +git checkout next + +echo "done." diff --git a/mktarball b/mktarball new file mode 100755 index 0000000..566b67b --- /dev/null +++ b/mktarball @@ -0,0 +1,66 @@ +#!/bin/sh + +. "$(dirname $0)"/libcomain + +if test ! -e meta/version; then error 2 "File 'meta/version' missing"; fi +ver="$(cat meta/version)" + +echo " => Prepare new directory..." +tb="$name-$version" +if test -e $tb; then error 2 "File '$tb' already exists"; fi +if test -e $tb.tar.xz; then error 2 "File '$tb.tar.xz' already exists"; fi + +echo " -> Check out new worktree (branch tarball)..." +run git worktree add $tb -b tarball master + +adddep() +{ + local dep=$1 + local depname="${dep##*/}" + local intonly=$2 + if test $intonly -eq 1 && test ! -e "$dep/files"; then return; fi + + local ref="$(cat $dep/ref 2>/dev/null)" + if test -z "$ref"; then ref="$(cat $dep/version)"; fi + run git -C ../$depname worktree add ../$tb/$depname -b tarball $ref +} +echo " -> Add components & \"internal\" dependencies..." +cd $tb +loaddeps +foreach cpnt $nb_cpnt adddep 0 +foreach deps $nb_deps adddep 1 +cd .. + +echo " -> Set up configure & common.mk..." +make -C $tb + +echo " -> Generate README..." +run rm $tb/README +run comain/mkreadme > $tb/README + +echo " => Create tarball..." +run tar -cJp --owner=0 --group=0 --numeric-owner --exclude=".git"* -f $tb.tar.xz $tb + +echo " => Clean up..." +deldep() +{ + local dep=$1 + local depname="${dep##*/}" + local intonly=$2 + if test $intonly -eq 1 && test ! -e "$dep/files"; then return; fi + + local ref="$(cat $dep/ref 2>/dev/null)" + if test -z "$ref"; then ref="$(cat $dep/version)"; fi + run git -C ../$depname worktree remove --force ../$tb/$depname + run git -C ../$depname branch -D tarball +} +echo " -> Remove components & \"internal\" dependencies..." +cd $tb +foreach cpnt $nb_cpnt deldep 0 +foreach deps $nb_deps deldep 1 +cd .. +echo " -> Remove worktree & branch tarball..." +run git worktree remove --force $tb +run git branch -D tarball + +echo "done." diff --git a/project.mk.tpl b/project.mk.tpl new file mode 100644 index 0000000..0892fd9 --- /dev/null +++ b/project.mk.tpl @@ -0,0 +1,7 @@ +$(error You need to edit project.mk) + +# binaries: -- don't forget to set meta/deps-bin with all deps & .o files +BINS = + +# librairies -- don't forget to set meta/deps-lib with all deps & .o files +LIBS =