lopsubgen.c
version.c
lopsub.h
-liblopsub.a
+liblopsub.*
lopsubex
lopsubgen
lopsubgen-stage1
DATE := $(shell date '+%B %Y')
GIT_VERSION := $(shell ./version-gen.sh)
+PLAIN_VERSION := $(firstword $(subst -, , $(GIT_VERSION)))
+MAJOR_VERSION := $(firstword $(subst ., , $(PLAIN_VERSION)))
+SONAME := liblopsub.so.$(MAJOR_VERSION)
+REALNAME := liblopsub.so.$(PLAIN_VERSION)
+LINKERNAME:=liblopsub.so
m4_man_pages := lopsub-suite.5.gz lopsub.7.gz
-all := $(m4_man_pages) liblopsub.a lopsubgen lopsubgen.1.gz \
+all := $(m4_man_pages) $(REALNAME) lopsubgen lopsubgen.1.gz \
lopsubex lopsubex.1.gz
all: $(all)
lsg1_objs := lopsubgen.o lsg1.o version.o
lsg_objs := lopsubgen.o lsg.o lopsubgen.lsg.o lopsub.o version.o
liblopsub_objs := config_file.o lopsub.o version.o
-lopsubex_objs := lopsubex.o lopsubex.lsg.o version.o
+lopsubex_objs := lopsubex.o lopsubex.lsg.o $(liblopsub_objs)
$(lsg_objs) $(liblopsub_objs) $(lopsubex_objs): %.o: %.c
lopsubgen.o config_file.o:
- $(CC) -g -c -o $@ ${@:.o=.c}
+ $(CC) -g -c -fPIC -o $@ ${@:.o=.c}
lsg1.o: lsg.c lsg.h
$(CC) -g -DSTAGE1 -Wall -g -c $< -o $@
%.o: %.c
- $(CC) -Wall -I. -g -c -o $@ $<
+ $(CC) -Wall -I. -g -c -fPIC -o $@ $<
# linking
lopsubgen-stage1: $(lsg1_objs)
$(CC) -Wall -g $(lsg1_objs) -o $@
lopsubgen: $(lsg_objs)
$(CC) -Wall -g -o $@ $(lsg_objs)
-liblopsub.a: $(liblopsub_objs)
- $(AR) -rcs $@ $^
-lopsubex: $(lopsubex_objs) liblopsub.a
- $(CC) -Wall -g -o $@ $^
+$(REALNAME): $(liblopsub_objs)
+ $(CC) --shared -Wl,-soname,liblopsub.so.$(MAJOR_VERSION) -o $@ $^
+lopsubex: $(lopsubex_objs) $(REALNAME)
+ $(CC) -Wall -g -o $@ $(lopsubex_objs)
# web
html := $(addprefix web/, $(addsuffix .html, \
$(INSTALL) -d $(DESTDIR)$(PREFIX)/lib $(DESTDIR)$(PREFIX)/include \
$(DESTDIR)$(PREFIX)/share/man/man1 $(DESTDIR)$(PREFIX)/share/man/man5 \
$(DESTDIR)$(PREFIX)/share/man/man7 $(DESTDIR)$(PREFIX)/bin
- $(INSTALL) -m 644 liblopsub.a $(DESTDIR)$(PREFIX)/lib
+ $(INSTALL) -m 644 $(REALNAME) $(DESTDIR)$(PREFIX)/lib
+ $(LN) -s $(REALNAME) $(DESTDIR)$(PREFIX)/lib/$(SONAME)
+ $(LN) -s $(SONAME) $(DESTDIR)$(PREFIX)/lib/$(LINKERNAME)
$(INSTALL) -m 755 lopsubgen $(DESTDIR)$(PREFIX)/bin
$(INSTALL) -m 644 lopsub.h $(DESTDIR)$(PREFIX)/include
$(INSTALL) -m 644 lopsub-internal.h $(DESTDIR)$(PREFIX)/include
man -l ./lopsub.7.m4
to show build and installation instructions.
+
+Installation
+------------
+Build the package with
+
+ make
+
+The suite parser and the config file parser of the lopsub library are
+both generated by running flex(1), a tool for generating programs
+that perform pattern-matching on text. Hence the flex package must
+be installed for the build to succeed. Next, run
+
+ sudo make install
+
+This will install the package in /usr/local. If you prefer to install
+as an unprivileged user in /somewhere/else, run
+
+ make PREFIX=/somewhere/else install
+
+instead. In this case, you need to specify -I/somewhere/else/include to
+compile the source files of your application and -L/somewhere/else/lib
+for linking. Alternatively, don't run make install at all and specify
+the path to the top level directory of the repository for both -I
+and -L.
--- /dev/null
+liblopsub (1.0.2-1) unstable; urgency=low
+
+ * Initial Release. Closes: #925911
+
+ -- Andre Noll <maan@tuebingen.mpg.de> Sun, 3 Mar 2019 00:37:31 +0100
--- /dev/null
+Source: liblopsub
+Section: libdevel
+Priority: optional
+Maintainer: Andre Noll <maan@tuebingen.mpg.de>
+Build-Depends: m4, flex, debhelper (>= 10.0)
+Standards-Version: 3.9.8
+Homepage: http://people.tuebingen.mpg.de/maan/lopsub
+Vcs-Browser: http://git.tuebingen.mpg.de/lopsub.git
+Vcs-Git: git://git.tuebingen.mpg.de/lopsub.git
+
+Package: liblopsub1
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: Long Option Parser for Subcommands
+ Lopsub is an open source library written in C which aims to ease
+ the task of creating, documenting and parsing the options of Unix
+ command line utilities. It is suitable for simple commands as well
+ as complex command line utilities with many subcommands where each
+ subcommand has its own set of options. Options and documentation are
+ kept together in a single file which can be translated to C code (to
+ be included in the application), or to a manual page. The library
+ supports single-character short options and GNU-style long options.
+ The public API is well documented and stable.
+Homepage: http://people.tuebingen.mpg.de/maan/lopsub
+
+Package: liblopsub-dev
+Architecture: any
+Depends: ${shlibs:Depends}, liblopsub1 (= ${binary:Version}), ${misc:Depends}
+Description: Long Option Parser for Subcommand - headers
+ Lopsub is an open source library written in C which aims to ease
+ the task of creating, documenting and parsing the options of Unix
+ command line utilities. It is suitable for simple commands as well
+ as complex command line utilities with many subcommands where each
+ subcommand has its own set of options. Options and documentation are
+ kept together in a single file which can be translated to C code (to
+ be included in the application), or to a manual page. The library
+ supports single-character short options and GNU-style long options.
+ The public API is well documented and stable.
+ This package contains the development environment for the lopsub library.
--- /dev/null
+Copyright 2016 Andre Noll <maan@tuebingen.mpg.de>
+
+This package is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License, version 3
+(lopsubgen), or the GNU Library General Public License, version 3
+(liblopsub).
+
+On Debian GNU systems, the complete text of the GNU General Public
+License can be found in `/usr/share/common-licenses/GPL-3'. The
+complete text of the GNU Library General Public License can be found in
+'/usr/share/common-licenses/LGPL-3'.
+
+The examples and all code generated by the utilities are in the
+public domain. You are free to do anything you like with the generated
+code, including incorporating it into or linking it with proprietary
+software.
--- /dev/null
+usr/include/*
+usr/lib/*/liblopsub.so
+usr/bin/lopsubgen
+usr/share/man/man1/lopsubgen*
+usr/share/man/man5/lopsub-suite*
--- /dev/null
+debian/tmp/usr/share/man/man7/*
+debian/tmp/usr/lib/*/liblopsub.so.*
--- /dev/null
+#!/usr/bin/make -f
+# Invoke each target with `./debian/rules <target>'. All targets should be
+# invoked with the package root as the current directory.
+
+sourcepackage := liblopsub
+package := liblopsub1
+devpackage := liblopsub-dev
+
+define checkdir
+ @test -f debian/rules -a -f lopsub.c || \
+ (echo Not in correct source directory; exit 1)
+endef
+
+SRCTOP := $(shell pwd)
+TMPDIR := $(SRCTOP)/debian/tmp
+DESTDIR := $(SRCTOP)/debian/$(package)
+DEVDIR := $(SRCTOP)/debian/$(devpackage)
+DOCS_DIR := $(DESTDIR)/usr/share/doc/$(package)
+DEVDOCS_DIR := $(DEVDIR)/usr/share/doc/$(devpackage)
+TRIPLET := $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
+
+build-arch:
+ $(checkdir)
+ $(MAKE)
+build-indep:
+build: build-indep build-arch
+
+clean:
+ $(checkdir)
+ -rm -f debian/substvars
+ $(MAKE) distclean
+ dh_clean
+
+INST_OWN = -o root -g root
+MAKE_DIR = install -p -d $(INST_OWN) -m 755
+INST_FILE = install -c $(INST_OWN) -m 644
+
+binary: build
+ $(checkdir)
+ $(MAKE) PREFIX=/usr install DESTDIR=$(TMPDIR)
+ mv $(TMPDIR)/usr/lib $(TMPDIR)/usr/lib-$(TRIPLET)
+ $(MAKE_DIR) $(TMPDIR)/usr/lib
+ mv $(TMPDIR)/usr/lib-$(TRIPLET) $(TMPDIR)/usr/lib/$(TRIPLET)
+ dh_install -p $(package)
+ dh_install -p $(devpackage)
+ $(MAKE_DIR) $(DESTDIR)/DEBIAN $(DOCS_DIR) $(DEVDOCS_DIR)
+ echo 'activate-noawait ldconfig' > $(DESTDIR)/DEBIAN/triggers
+ $(INST_FILE) debian/copyright $(DOCS_DIR)/copyright
+ $(INST_FILE) debian/copyright $(DEVDOCS_DIR)/copyright
+ $(INST_FILE) debian/changelog $(DOCS_DIR)/changelog.Debian
+ $(INST_FILE) debian/changelog $(DEVDOCS_DIR)/changelog.Debian
+ gzip -f9 $(DOCS_DIR)/changelog.Debian
+ gzip -f9 $(DEVDOCS_DIR)/changelog.Debian
+ dh_makeshlibs
+ dh_shlibdeps
+ dh_strip
+ dh_shlibdeps
+ dh_gencontrol
+ dh_builddeb
+
+binary-indep binary-arch: binary
+.PHONY: clean build binary-arch binary-indep binary
--- /dev/null
+3.0 (quilt)
. \}
.TH lopsub 7 "DATE()" GIT_VERSION()
+.SH NAME
+lopsub \- Long option parser for subcommands
+
.SH About
.B Lopsub
utility is licensed under the
.BR GPLv3 .
The examples and all code generated by the utilities, however, is
-licensed with a simple all-permissive license. You are free to do
-anything you like with the generated code, including incorporating
-it into or linking it with proprietary software.
-
-.SH Installation
-Grab your copy with
-.IP
-.EX
-git clone git://git.tuebingen.mpg.de/lopsub.git
-.EE
-.PP
-Then build the package with
-.IP
-.EX
-make
-.EE
-.PP
-The suite parser and the config file parser of the
-.B lopsub
-library are both generated by running
-.MONO_ROMAN flex ,
-a tool for generating programs that perform pattern-matching on text. Hence the
-.B flex
-package must be installed for the build to succeed. Next, run
-.IP
-.EX
-sudo make install
-.EE
-.PP
-This will install the package in
-.MONO_ROMAN /usr/local .
-If you prefer to install as an unprivileged user in
-.MONO_ROMAN /somewhere/else ,
-run
-.IP
-.EX
-make PREFIX=/somewhere/else install
-.EE
-.PP
-instead. In this case, you need to specify
-.MONO -I/somewhere/else/include
-to compile the source files of your application and
-.MONO -L/somewhere/else/lib
-for linking. Alternatively, don't run
-.MONO make install
-at all and specify the path to the top level directory of the
-repository for both
-.MONO -I
-and
-.MONO_ROMAN -L .
+licensed under the public domain. You are free to do anything you
+like with the generated code, including incorporating it into or
+linking it with proprietary software.
.SH Quick Start
Compile and run the minimal example included at the end of
or
.MONO_ROMAN lopsub.h.m4 .
-.SH Contact
-Email:
-.MT maan@tuebingen.mpg.de
-Andre Noll
-.ME ,
-Homepage:
+.SH Resources
+
+\(bu
+git clone URL:
+.UR git://git.tuebingen.mpg.de/lopsub.git
+.UE
+
+\(bu
+gitweb:
+.UR http://git.tuebingen.mpg.de/lopsub.git
+.UE
+
+\(bu
+The author's homepage:
.UR http://people.tuebingen.mpg.de/maan/
.UE
+
+\(bu
+Send feedback to
+.MT maan@tuebingen.mpg.de
+Andre Noll
+.ME
+
{
if (errctx)
*errctx = NULL;
+ assert(min_argc <= max_argc);
if (lpr->num_inputs < min_argc) {
- xasprintf(errctx, "at least %u non-option args required, "
- "%u given", min_argc, lpr->num_inputs);
+ xasprintf(errctx, "%s %u non-option args required, %u given",
+ min_argc < max_argc? "at least" : "exactly",
+ min_argc, lpr->num_inputs);
return -E_LLS_BAD_ARG_COUNT;
}
if (lpr->num_inputs > max_argc) {
xasprintf(errctx, "no non-option args allowed, "
"%u given", lpr->num_inputs);
else
- xasprintf(errctx, "at most %u non-option args allowed, "
- "%u given", max_argc, lpr->num_inputs);
+ xasprintf(errctx, "%s %u non-option args allowed, "
+ "%u given", min_argc < max_argc?
+ "at most" : "exactly",
+ max_argc, lpr->num_inputs);
return -E_LLS_BAD_ARG_COUNT;
}
return 1;
# if there are differences (exit code 1), the working tree is dirty
git diff-index --quiet HEAD || git_ver=$git_ver-dirty
ver=$git_ver
+elif [ -f debian/changelog ]; then
+ ver="$(sed -ne '1s/.*(\(.*\)-.*/\1/1; tx; d; :x; p' debian/changelog)"
elif [ "${PWD%%-*}" = 'lopsub-' ]; then
ver=${PWD##*/lopsub-}
fi