cake
/
libg1m
Archived
1
0
Fork 0

Added configuration tool generation

This commit is contained in:
Thomas Touhey 2016-12-20 17:29:54 +01:00
parent 5173ccd2be
commit df1a8de797
5 changed files with 163 additions and 30 deletions

3
.gitignore vendored
View File

@ -1,5 +1,6 @@
/Makefile.cfg
/obj
/libg1m.so*
/libg1m-*.dll
/libg1m.dll
/man
/bin

View File

@ -9,14 +9,14 @@ include Makefile.msg
# General targets #
#******************************************************************************#
# Build everything.
all: all-lib all-doc
all: all-lib all-doc all-cfgtool
# Mostly clean everything. (remove everything but the end results)
mostlyclean: mostlyclean-lib mostlyclean-doc
mclean: mostlyclean
# Clean everything.
clean: clean-lib clean-doc
clean: clean-lib clean-doc clean-cfgtool
fclean: clean
# Clean everything, and configuration.
@ -28,10 +28,11 @@ mrproper: clean
re: clean all
# Install everything.
install: install-lib $(if $(INSTALL_MANPAGES),install-doc)
install: install-lib $(if $(INSTALL_MANPAGES),install-doc) \
$(if $(INSTALL_DEVEL),install-cfgtool)
# Uninstall everything. (EXPERIMENTAL)
uninstall: uninstall-lib uninstall-doc
uninstall: uninstall-lib uninstall-doc uninstall-cfgtool
# Reinstall everything. (EXPERIMENTAL)
reinstall: uninstall install
@ -103,54 +104,86 @@ $(eval $(call make-moduleobj-rule,$(mod))))
# Remove the objects directory.
mostlyclean-lib:
$(call rmsg,Removing object directory.)
$(call rcmd,$(OBJDIR),$(RM) -r $(OBJDIR))
$(call qcmd,$(RM) -r $(OBJDIR))
mclean-lib: mostlyclean-lib
# Clean and remove the built library.
clean-lib: mclean-lib
$(call rmsg,Removing the library.)
$(call rcmd,$(SONAMES),$(RM) $(SONAMES))
$(call qcmd,$(RM) $(SONAMES))
# Remake the library.
re-lib: clean-lib all-lib
# Install the library, development files and udev rule.
install-lib: $(CHECKCFG) lib$(NAME).so.$(MAJOR)
LINK_TO_MAJOR := $(if $(INSTALL_DEVEL),$(if $(FOR_WINDOWS),,y))
install-lib: $(CHECKCFG) $(SONAME)
$(call imsg,Installing the library.)
$(call qcmd,$(INST) -m 755 -d "$(ILIBDIR)")
$(call icmd,lib$(NAME).so.$(MAJOR),\
$(INST) -m 755 -t "$(ILIBDIR)" lib$(NAME).so.$(MAJOR))
$(call qcmd,$(INST) -m 755 -t "$(ILIBDIR)" $(SONAME))
$(if $(INSTALL_DEVEL),\
$(if $(LINK_TO_MAJOR),\
$(call imsg,Linking lib$(NAME).so to lib$(NAME).so.$(MAJOR).))
$(if $(INSTALL_DEVEL),\
$(call qcmd,$(LN) lib$(NAME).so.$(MAJOR) \
"$(ILIBDIR)/lib$(NAME).so"))
$(if $(LINK_TO_MAJOR),\
$(call qcmd,$(LN) lib$(NAME).so.$(MAJOR) "$(ILIBDIR)/lib$(NAME).so"))
$(if $(INSTALL_DEVEL),\
$(call imsg,Installing development files.))
$(if $(INSTALL_DEVEL),\
$(call qcmd,$(INST) -m 755 -d $(patsubst %,"$(IINCDIR)/%",\
$(sort $(dir $(INCPUB))))))
$(if $(INSTALL_DEVEL),\
$(foreach i,$(INCPUB),\
$(call icmd,$(i).h,\
$(INST) -m 644 $(INCDIR)/$(i).h "$(IINCDIR)/$(i).h"$(\n))))
$(if $(INSTALL_DEVEL),$(foreach i,$(INCPUB),\
$(call qcmd,$(INST) -m 644 $(INCDIR)/$(i).h "$(IINCDIR)/$(i).h"$(\n))))
# Uninstall the library, development files and udev rule. (experimental)
uninstall-lib: $(CHECKCFG)
$(call rmsg,Uninstalling the library.)
$(call rcmd,lib$(NAME).a)
$(call rcmd,lib$(NAME).so.*)
$(call qcmd,$(RM) "$(ILIBDIR)/lib$(NAME).a" "$(ILIBDIR)/lib$(NAME).so"*)
$(call rcmd,include/lib$(NAME).h)
$(call rcmd,include/lib$(NAME))
$(call qcmd,$(RM) "$(ILIBDIR)/lib$(NAME).a" \
"$(ILIBDIR)/lib$(NAME).so"* "$(ILIBDIR)/lib$(NAME).dll")
$(call qcmd,$(RM) "$(IINCDIR)/lib$(NAME).h")
$(call qcmd,$(RM) -r "$(IINCDIR)/lib$(NAME)")
.PHONY: all-lib mostlyclean-lib mclean-lib clean-lib re-lib
.PHONY: install-lib uninstall-lib
#******************************************************************************#
# Configuration tool-related #
#******************************************************************************#
# Make it all!
all-cfgtool: $(CHECKCFG) $(BINDIR)/lib$(NAME)-config
# Make the directory.
$(BINDIR):
$(call bcmd,md,$@,$(MD) $@)
# Build it.
$(BINDIR)/lib$(NAME)-config:| $(BINDIR)
$(call bcmd,writecfg,lib$(NAME),\
tools/write-config --name=lib$(NAME) --version=$(VERSION) \
--author-name="$(AUTHOR)" --author-mail="$(AUTHOR_MAIL)" \
--incdir="$(IINCDIR)" --libdir="$(IBINDIR)" >$@ && chmod 755 $@)
# Clean it.
clean-cfgtool:
$(call rmsg,Removing configuration tool.)
$(call qcmd,$(RM) -r $(BINDIR))
# Remake it.
re-cfgtool: clean-cfgtool all-cfgtool
# Install it.
install-cfgtool: $(CHECKCFG) all-cfgtool
$(call imsg,Installing the configuration tool.)
$(call qcmd,$(INST) -m 755 -d "$(IBINDIR)")
$(call qcmd,$(INST) -m 755 -t "$(IBINDIR)" $(BINDIR)/lib$(NAME)-config)
# Uninstall it
uninstall-cfgtool: $(CHECKCFG)
$(call rmsg,Uninstalling configuration tool.)
$(call qcmd,$(RM) "$(IBINDIR)/lib$(NAME)-config"
.PHONY: all-cfgtool clean-cfgtool re-cfgtool
.PHONY: install-cfgtool uninstall-cfgtool
#******************************************************************************#
# Documentation-related #
#******************************************************************************#
# Make all manpages.
@ -175,7 +208,7 @@ mclean-doc: mostlyclean-doc
# Remove all built manpages.
clean-doc:
$(call rmsg,Removing manpages directory.)
$(call rcmd,$(MANDIR),$(RM) -r $(MANDIR))
$(call qcmd,$(RM) -r $(MANDIR))
# Remake all manpages.
# (I don't really know why some people would want to do that though)
@ -186,7 +219,6 @@ define make-installmansection-rule
install-doc-$1: $(MAN_$1:%=$(MANDIR)/man$1/%.$1)
$(call imsg,Installing manpages section $1.)
$(call qcmd,$(INST) -m 755 -d "$(IMANDIR)/man$1")
$(foreach i,$(MAN_$1),$(call icmd,man$1/$(i).$1))
$(call qcmd,$(INST) -m 644 -t "$(IMANDIR)/man$1" \
$(MAN_$1:%=$(MANDIR)/man$1/%.$1))
$(call qcmd,$(GZIP) $(MAN_$1:%="$(IMANDIR)/man$1/%.$1"))

View File

@ -48,12 +48,15 @@
# Manpages directory - where the manpages will be put.
MANDIR := ./man
# Executables directory - where the executables will be put.
BINDIR := ./bin
#******************************************************************************#
# Object names #
#******************************************************************************#
# Dynamic library name
SONAME := $(if $(FOR_WINDOWS),lib$(NAME)-$(VERSION).dll,lib$(NAME).so.$(MAJOR))
SONAMES := $(if $(FOR_WINDOWS),lib$(NAME)-*.dll,lib$(NAME).so.*)
SONAME := $(if $(FOR_WINDOWS),lib$(NAME).dll,lib$(NAME).so.$(MAJOR))
SONAMES := $(if $(FOR_WINDOWS),lib$(NAME).dll,lib$(NAME).so.*)
#******************************************************************************#
# Binary utilities #
@ -145,7 +148,7 @@ $(eval $(call check-man,$(patsubst .%,%,$(suffix $(doc))),$(basename $(doc)))))
define add-dest-dir
$1 = $(DESTDIR)$($1)
endef
$(if $(DESTDIR), $(foreach idir,ILIBDIR IINCDIR IMANDIR UDEVDIR, \
$(if $(DESTDIR), $(foreach idir,IBINDIR ILIBDIR IINCDIR IMANDIR, \
$(eval $(call add-dest-dir,$(idir)))))
# END OF FILE

13
configure vendored
View File

@ -27,6 +27,7 @@ loglevel=none # none, info, warn, error, fatal
# Installation directories
root=''
prefix='${root}/usr'
prefix_set=
bindir='${prefix}/bin'
libdir='${prefix}/lib'"$platform"
includedir='${prefix}/include'"$platform"
@ -53,7 +54,7 @@ General options:
Build options:
--target=TARGET the target [$target]
--loglevel library log level [$loglevel]
--loglevel=LOGLEVEL library log level [$loglevel]
Installation options:
--noinstall-manpages should not install manpages
@ -123,7 +124,7 @@ got '$level'"
--noinstall-manpages) install_manpages= ;;
--noinstall-devel) install_devel= ;;
--root=*) root="${arg#*=}" ;;
--prefix=*) prefix="${arg#*=}" ;;
--prefix=*) prefix="${arg#*=}"; prefix_set=y ;;
--bindir=*) bindir="${arg#*=}" ;;
--libdir=*) libdir="${arg#*=}" ;;
--includedir=*) includedir="${arg#*=}" ;;
@ -131,6 +132,14 @@ got '$level'"
*) echo "$arg: didn't read" ;;
esac; done
#******************************************************************************#
# Check for defaults #
#******************************************************************************#
# MS-Windows things
if [ ! $prefix_set ] && [ $(echo $target | grep mingw) ]; then
prefix='${root}/usr/'"$target"
fi
#******************************************************************************#
# Evaluate variables #
#******************************************************************************#

88
tools/write-config Executable file
View File

@ -0,0 +1,88 @@
#!/bin/sh
#******************************************************************************#
# Defaults #
#******************************************************************************#
# Project variables
name="libg1m"
version="<unknown version>"
# Author
author_name="Unknown name"
author_mail="unknown@mail"
# Directories
libdir=''
incdir=''
#******************************************************************************#
# Read arguments #
#******************************************************************************#
for arg ; do case "$arg" in
--name=*) name="${arg#*=}" ;;
--version=*) version="${arg#*=}" ;;
--author-name=*) author_name="${arg#*=}" ;;
--author-mail=*) author_mail="${arg#*=}" ;;
--libdir=*) libdir="${arg#*=}" ;;
--incdir=*) incdir="${arg#*=}" ;;
esac; done
#******************************************************************************#
# Write result #
#******************************************************************************#
cat <<_EOF
#!/bin/sh
#******************************************************************************#
# Help message #
#******************************************************************************#
usage() {
cat <<EOF
Usage: \$cfgtool [--help] [--version] [--cflags] [--libs]
Report bugs to ${author_name} <${author_mail}>.
EOF
exit 0
}
#******************************************************************************#
# Version message #
#******************************************************************************#
version() {
cat <<EOF
${name} configuration tool v${version}
Written by ${author_name}.
This configuration tool is public domain.
EOF
exit 0
}
#******************************************************************************#
# Check for help and version #
#******************************************************************************#
put_version=
put_help=
for arg ; do case "\$arg" in
--help|-h) put_help=1 ;;
--version|-v) put_version=1 ;;
esac; done
[ \$put_version ] && version
[ \$put_help ] && usage
#******************************************************************************#
# Parse arguments #
#******************************************************************************#
# Defaults
put_cflags=
put_libs=
for arg ; do case "\$arg" in
--cflags) put_cflags=y ;;
--libs) put_libs=y ;;
*) echo "\$arg: did not read" >&2 ;;
esac; done
# Put
[ \$put_cflags ] && echo "-I$incdir"
[ \$put_libs ] && echo "-L$libdir -lg1m"
[ \$put_cflags\$put_libs ] || usage
# End of file
_EOF