Merge pull request #150 from benavrhm/topic_benavrhm_fixups_20201112

Topic benavrhm fixups 20201112
This commit is contained in:
Olof Hagsand 2020-11-17 15:45:08 +01:00 committed by GitHub
commit eb549b4c21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 68 additions and 12 deletions

View file

@ -58,12 +58,28 @@ SUBDIRS1 = include lib
SUBDIRS2 = apps etc yang # without include lib for circular dependency
SUBDIRS= $(SUBDIRS1) $(SUBDIRS2)
.PHONY: doc example all clean depend $(SUBDIRS) install loc TAGS .config.status docker test
.PHONY: doc example install-example clean-example all clean depend $(SUBDIRS) \
install loc TAGS .config.status docker test util checkroot mrproper \
checkinstall warnroot install-util clean-util
all: $(SUBDIRS2)
all: $(SUBDIRS2) warnroot
@echo "\e[32mAfter 'make install' as euid root, build example app and test utils: 'make example'\e[0m"
checkroot:
@if [ "$${DESTDIR}" = "" -a $$(id -u) != "0" ]; \
then echo "\e[31mThis target must be made as euid root\e[0m"; exit 1; fi;
warnroot:
@if [ $$(id -u) = 0 ]; \
then echo "\e[36mWarning: You built this target as uid root\e[0m"; exit 0; fi;
checkinstall:
@if [ ! -f $(prefix)/include/clixon/clixon.h ]; then \
echo "\e[31mclixon must be installed first to build this target. "\
"Run 'make'. Then run 'make install' as root.\e[0m"; exit 1; fi;
# May cause circular include->include,lib
$(SUBDIRS2): include lib # Cannot build app before lib (for parallel make -j)
$(SUBDIRS2): $(SUBDIRS1) # Cannot build app before lib (for parallel make -j)
(cd $@ && $(MAKE) $(MFLAGS) all)
$(SUBDIRS1):
@ -73,7 +89,8 @@ depend:
for i in $(SUBDIRS) doc example docker; \
do (cd $$i && $(MAKE) $(MFLAGS) depend); done
install:
# Needs root permissions on most systems by default
install: checkroot
for i in $(SUBDIRS) doc; \
do (cd $$i; $(MAKE) $(MFLAGS) $@)||exit 1; done;
$(MAKE) $(MFLAGS) install-include
@ -81,15 +98,39 @@ install:
install-include:
for i in $(SUBDIRS) doc; \
do (cd $$i && $(MAKE) $(MFLAGS) $@)||exit 1; done;
echo "To install example app: cd example; make; make install"
@echo "\e[32mTo install example app and test utils: make install-example\e[0m"
uninstall:
for i in $(SUBDIRS) doc example docker; \
uninstall: checkroot
for i in $(SUBDIRS) doc example util docker; \
do (cd $$i && $(MAKE) $(MFLAGS) $@)||exit 1; done;
doc:
doc: warnroot
cd $@; $(MAKE) $(MFLAGS) $@
util:
cd $@; $(MAKE) $(MFLAGS)
clean-util:
cd util; $(MAKE) $(MFLAGS) clean
install-util:
cd util; $(MAKE) $(MFLAGS) install
uninstall-util:
cd util; $(MAKE) $(MFLAGS) uninstall
clean-example:
for i in example util; \
do (cd $$i && $(MAKE) $(MFLAGS) clean) || exit 1; done;
install-example: checkroot
for i in example util; \
do (cd $$i && $(MAKE) $(MFLAGS) install) || exit 1; done;
uninstall-example: checkroot
for i in example util; \
do (cd $$i && $(MAKE) $(MFLAGS) uninstall) || exit 1; done;
config.status: configure
$(SHELL) config.status --recheck
@ -97,14 +138,19 @@ configure: configure.ac
cd $(srcdir) && autoconf
clean:
for i in $(SUBDIRS) doc example docker; \
for i in $(SUBDIRS) doc example util docker; \
do (cd $$i && $(MAKE) $(MFLAGS) $@); done;
# Uninstall and clean all the targets used for testing, but without cloning or
# checking-out from git. Provides a reliabily clean slate for testing changes
# before commit.
mrproper: uninstall uninstall-example uninstall-util clean clean-example clean-util
distclean:
rm -f Makefile TAGS config.status config.log *~ .depend
rm -rf autom4te.cache build-root/rpmbuild
rm -f build-root/*.tar.xz build-root/*.rpm extras/rpm/Makefile
for i in $(SUBDIRS) doc example docker; \
for i in $(SUBDIRS) doc example util docker; \
do (cd $$i && $(MAKE) $(MFLAGS) $@); done
export BR=$(CURDIR)/build-root
@ -146,8 +192,10 @@ pkg-rpm: dist
pkg-srpm: dist
make -C extras/rpm srpm
example:
# To make the example you need to run the "install-include" target first
example: checkinstall util warnroot
(cd $@ && $(MAKE) $(MFLAGS) all)
@echo "\e[36mRemember to run 'make install-example' as euid root\e[0m"
# Run a clixon test container.
# Alt: cd test; ./all.sh

View file

@ -205,6 +205,7 @@ err(){
echo "Received: $2"
fi
echo -e "\e[0m"
echo "Diff between Expected and Received:"
echo "$ret"| od -t c > $dir/clixon-ret
echo "$expect"| od -t c > $dir/clixon-expect
diff $dir/clixon-expect $dir/clixon-ret

View file

@ -19,7 +19,9 @@ s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
# -f %e gives elapsed wall clock time but is not available on all systems
# so we use time -p for POSIX compliance and awk to get wall clock time
# Note sometimes time -p is used and sometimes $TIMEFN, cant get it to work same everywhere
# time function (this is a mess to get right on freebsd/linux)
: ${TIMEFN:=time -p} # portability: 2>&1 | awk '/real/ {print $2}'
if ! $TIMEFN true; then err "A working time function" "'$TIMEFN' does not work"; fi
APPNAME=example

View file

@ -20,7 +20,9 @@ s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
# -f %e gives elapsed wall clock time but is not available on all systems
# so we use time -p for POSIX compliance and awk to get wall clock time
# Note sometimes time -p is used and sometimes $TIMEFN, cant get it to work same everywhere
# time function (this is a mess to get right on freebsd/linux)
: ${TIMEFN:=time -p} # portability: 2>&1 | awk '/real/ {print $2}'
if ! $TIMEFN true; then err "A working time function" "'$TIMEFN' does not work"; fi
APPNAME=example

View file

@ -21,6 +21,7 @@ s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
# so we use time -p for POSIX compliance and awk to get wall clock time
# Note sometimes time -p is used and sometimes $TIMEFN, cant get it to work same everywhere
: ${TIMEFN:=time -p} # portability: 2>&1 | awk '/real/ {print $2}'
if ! $TIMEFN true; then err "A working time function" "'$TIMEFN' does not work"; fi
APPNAME=example

View file

@ -20,6 +20,7 @@ fin=$dir/fin
# time function (this is a mess to get right on freebsd/linux)
: ${TIMEFN:=time -p} # portability: 2>&1 | awk '/real/ {print $2}'
if ! $TIMEFN true; then err "A working time function" "'$TIMEFN' does not work"; fi
APPNAME=example

View file

@ -20,6 +20,7 @@ s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
# time function (this is a mess to get right on freebsd/linux)
: ${TIMEFN:=time -p} # portability: 2>&1 | awk '/real/ {print $2}'
if ! $TIMEFN true; then err "A working time function" "'$TIMEFN' does not work"; fi
APPNAME=example