From: Andre Noll Date: Fri, 17 May 2019 08:26:56 +0000 (+0200) Subject: Merge branches 't/debian', 't/dynamic-lib', 't/lls_check_arg_count' and 't/news' X-Git-Tag: v1.0.3~1 X-Git-Url: http://git.tuebingen.mpg.de/?p=lopsub.git;a=commitdiff_plain;h=61a906e6192f139b366cba68bf481a48a6fba45a;hp=4636c7a90e91633d0196860f5f5531a633f782b7 Merge branches 't/debian', 't/dynamic-lib', 't/lls_check_arg_count' and 't/news' This octopus merge combines four branches, two of which were created with the aim of making the package acceptable for inclusion into Debian: The t/dynamic-lib branch instructs make to create a dynamic library instead of the static one, the t/debian branch adds the usual files below debian/. The remaining two branches, t/lls_check_arg_count and t/news, contain only a single commit each. The first improves the wording of an error message while the second introduces the NEWS file, respectively. The tree which corresponds to this commit was accepted for Debian unstable on May 15 2019 as version 1.0.2-1. --- diff --git a/.gitignore b/.gitignore index 3dc13ed..e7965bb 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,7 @@ config_file.c lopsubgen.c version.c lopsub.h -liblopsub.a +liblopsub.* lopsubex lopsubgen lopsubgen-stage1 diff --git a/Makefile b/Makefile index 7e44330..408e3a5 100644 --- a/Makefile +++ b/Makefile @@ -23,9 +23,14 @@ ZCAT := zcat 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) @@ -64,25 +69,25 @@ lopsubgen.lsg.c lopsubgen.lsg.h: lopsubgen.suite lopsubgen-stage1 \ 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, \ @@ -104,7 +109,9 @@ install: $(all) $(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 diff --git a/NEWS b/NEWS new file mode 100644 index 0000000..97daa7b --- /dev/null +++ b/NEWS @@ -0,0 +1,18 @@ +Noteworthy changes in lopsub-1.0.3 (tba) +======================================== +* build a shared library instead of a static one +* debianize the package by adding the usual files below debian/ +* add this NEWS file +* minor documentation improvements + +Noteworthy changes in lopsub-1.0.2 (2019-03-27) +=============================================== +* fix an invalid free bug +* install liblopsub.a with mode 644 rather than 755 +* compress man pages +* install man pages to $PREFIX/share/man rather than $PREFIX/man + +Noteworthy changes in lopsub-1.0.1 (2017-11-28) +=============================================== +* reentrant scanners +* documentation improvements diff --git a/README b/README index a6ffa0b..9f77d9e 100644 --- a/README +++ b/README @@ -10,3 +10,27 @@ Alternatively, run 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. diff --git a/debian/Makefile.debian b/debian/Makefile.debian new file mode 100644 index 0000000..e69de29 diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..3779a2a --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +liblopsub (1.0.2-1) unstable; urgency=low + + * Initial Release. Closes: #925911 + + -- Andre Noll Sun, 3 Mar 2019 00:37:31 +0100 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..f599e28 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +10 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..dec91e9 --- /dev/null +++ b/debian/control @@ -0,0 +1,39 @@ +Source: liblopsub +Section: libdevel +Priority: optional +Maintainer: Andre Noll +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. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..95fcd00 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,16 @@ +Copyright 2016 Andre Noll + +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. diff --git a/debian/liblopsub-dev.install b/debian/liblopsub-dev.install new file mode 100644 index 0000000..8e6c62d --- /dev/null +++ b/debian/liblopsub-dev.install @@ -0,0 +1,5 @@ +usr/include/* +usr/lib/*/liblopsub.so +usr/bin/lopsubgen +usr/share/man/man1/lopsubgen* +usr/share/man/man5/lopsub-suite* diff --git a/debian/liblopsub1.install b/debian/liblopsub1.install new file mode 100644 index 0000000..6234859 --- /dev/null +++ b/debian/liblopsub1.install @@ -0,0 +1,2 @@ +debian/tmp/usr/share/man/man7/* +debian/tmp/usr/lib/*/liblopsub.so.* diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..3ba7a74 --- /dev/null +++ b/debian/rules @@ -0,0 +1,62 @@ +#!/usr/bin/make -f +# Invoke each target with `./debian/rules '. 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 diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..163aaf8 --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/lopsub.7.m4 b/lopsub.7.m4 index c728e8b..0813fe1 100644 --- a/lopsub.7.m4 +++ b/lopsub.7.m4 @@ -29,6 +29,9 @@ . \} .TH lopsub 7 "DATE()" GIT_VERSION() +.SH NAME +lopsub \- Long option parser for subcommands + .SH About .B Lopsub @@ -103,56 +106,9 @@ while the 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 @@ -176,11 +132,26 @@ Alternatively, examine 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 + diff --git a/version-gen.sh b/version-gen.sh index b20e4c8..bdeeca2 100755 --- a/version-gen.sh +++ b/version-gen.sh @@ -11,6 +11,8 @@ if [ -e '.git' -o -e '../.git' ]; then # 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