From: Niki Roo Date: Sun, 27 Feb 2022 08:50:20 +0000 (+0100) Subject: improve makefile/doc X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=5166b96ab3ca32916b5e87be8f0f63caa990e98b;p=nsub.git improve makefile/doc --- diff --git a/Makefile b/Makefile index 56367c8..dd1423f 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,20 @@ -.PHONY: all doc install uninstall clean mrpropre mrpropre love debug +NAME=nsub -all: bin/nsub +.PHONY: all build rebuild install uninstall clean mrpropre mrpropre love debug \ + doc man + +all: build + +build: bin/nsub + @echo Build successful. + +rebuild: clean build doc: doxygen -bin/nsub: bin/utils.o - $(MAKE) -C src -f nsub.d - -bin/utils.o: - $(MAKE) -C src -f utils.d +man: VERSION README*.md + $(MAKE) -f man.d NAME=$(NAME) love: @echo " ...not war." @@ -17,19 +22,34 @@ love: debug: $(MAKE) DEBUG=1 -clean: - $(MAKE) -C src -f utils.d clean - $(MAKE) -C src -f nsub.d clean - mrproper: mrpropre mrpropre: clean $(MAKE) -C src -f utils.d mrpropre $(MAKE) -C src -f nsub.d mrpropre + rm -f man/man1/*.1 man/*/man1/*.1 + rmdir man/*/man1 man/* man || true + rm -rf doc/html doc/latex doc/man + rmdir doc || true + +clean: + $(MAKE) -C src -f utils.d clean + $(MAKE) -C src -f nsub.d clean install: $(MAKE) -C src -f nsub.d install + @if [ -e "man/man1/$(NAME).1" ]; then \ + cp -r man/ "$(PREFIX)"/share/; \ + else \ + echo "No manual has been built (see \`make man')"; \ + fi uninstall: $(MAKE) -C src -f nsub.d uninstall +bin/nsub: bin/utils.o + $(MAKE) -C src -f nsub.d DEBUG=$(DEBUG) + +bin/utils.o: + $(MAKE) -C src -f utils.d DEBUG=$(DEBUG) + diff --git a/README-fr.md b/README-fr.md new file mode 100644 index 0000000..c82b6ca --- /dev/null +++ b/README-fr.md @@ -0,0 +1,64 @@ +[English](README.md) Français + +# NSub + +Converti entre les formats Subtitle/Lyrics (webvtt/srt/lrc). + +## Synopsis + +- `nsub --help` +- `nsub` (`--from FMT`) (`--to FMT`) (`--apply-offset`) (`IN` (`OUT`)) +- `nsub` (`-f FMT`) (`-t FMT`) (`-o`) (`IN` (`OUT`)) + +## Description + +Ce programme est extrêmement simple. +Il converti simplement entre les différents formats subtitle/lyrics. + +Il ne nécessite pas de librairies externes. + +(Bref, j'avais besoin de convertir quelques fichiers et j'ai été surpris de voir que `apt-get install` ne semblait pas connaître ça.) + +### Formats supportés + +- `LRC` fichiers lyrics : ils accompagnent en général de la musique +- `SRT` fichiers sous-titres SubRip, ils accompagnent en général des films +- `WebVTT` Web Video Text Tracks, un nouveau standard W3C + +Note : ce programme ne peut pas encore ouvrir des fichiers WebVTT ni SRT (il supporte toutefois les 3 formats en écriture) + +## Options + +- **--help** (or **-h**) : information sur la syntaxe du programme +- **--from** (or **-f**) **FMT** : choisi le format d'entrée +- **--to** (or **-t**) **FMT** : choisi le format de sortie +- **--apply-offset** (or **-o**) : applique l'offset interne au fichier dans les calcul de temps des paroles +- **IN** : le fichier source ou '-' pour stdin (défaut) +- **OUT** : le fichier destination ou '-' pour stdout (défaut) + +Note : les formats in/out seront devinés en fonction de l'extension si nécessaire/possible +Note : pour spécifier un fichier appelé tiret (-), préfixez-le avec un chemin (ex : './-') + +### Formats supportés + +- **lrc** : fichiers lyrics files +- **srt** : fichiers sous-titres SubRip +- **vtt** (ou **webvtt**) : Web Video Text Tracks + +## Compilation + +Lancez simplement `make`. + +Vous pouvez aussi utiliser ces options make : + +- `make install PREFIX=/usr/local` : installe le programme dans PREFIX (par défaut, /usr/local) +- `make uninstall` : désinstalle le programme de PREFIX +- `make clear` : efface les fichiers temporaires +- `make mrpropre` : efface les fichiers temporaires mais aussi l'exécutable principal et la documentation +- `make doc` : génère la documentation Doxygen (`doxygen` est requis) +- `make man` : génère le manuel (`pandoc` est requis) + +## Auteur + +NSub a été écrit par Niki Roo + diff --git a/README.md b/README.md index 1269f20..2e6217d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,16 @@ -# NSub: Subtitle/Lyrics conversion program (webvtt/srt/lrc) +English [Français](README-fr.md) + +# NSub + +Converts between Subtitle/Lyrics formats (webvtt/srt/lrc). + +## Synopsis + +- `nsub --help` +- `nsub` (`--from FMT`) (`--to FMT`) (`--apply-offset`) (`IN` (`OUT`)) +- `nsub` (`-f FMT`) (`-t FMT`) (`-o`) (`IN` (`OUT`)) + +## Description This program is a very simple thing. It just converts between different subtitle/lyrics formats. @@ -7,37 +19,46 @@ It does not require external libraries. (I.E., I needed to convert some files and was surprised to see that it was not available via `apt-get install`.) -Supported formats: -* `LRC` lyrics files: usually distributed with music -* `SRT` SubRip subtitle files, usually distributed with films -* `WebVTT` Web Video Text Tracks, a new W3C standard +### Supported formats -Note: this program can not yet open WebVTT nor SRT files (it supports all 3 formats as output, though). +- `LRC` lyrics files: usually distributed with music +- `SRT` SubRip subtitle files, usually distributed with films +- `WebVTT` Web Video Text Tracks, a new W3C standard -## Compile +Note: this program can not yet open WebVTT nor SRT files (it supports all 3 formats as output, though) -Just run `make`. -You can also use those make targets: -* `make install` -* `make uninstall` -* `make clear` -* `make mrpropre` +## Options -## Syntax - -`bin/nsub` (`--from FMT`) (`--to FMT`) (`--apply-offset`) (`IN_FILE` (`OUT_FILE`)) -* **--help** (or **-h**): this help message -* **--from** (or **-f**) **FMT**: select the input format FMT -* **--to** (or **-t**) **FMT**: select the output format FMT -* **--apply-offset** (or **-o**): apply the offset tag value to the lyrics -* **IN_FILE**: the input file or '-' for stdin (which is the default) -* **OUT_FILE**: the output file or '-' for stdout (which is the default) +- **--help** (or **-h**): information about the syntax +- **--from** (or **-f**) **FMT**: select the input format FMT +- **--to** (or **-t**) **FMT**: select the output format FMT +- **--apply-offset** (or **-o**): apply the offset tag value to the lyrics +- **IN**: the input file or '-' for stdin (which is the default) +- **OUT**: the output file or '-' for stdout (which is the default) Note: the in/out formats will be guessed from the extension if needed/possible Note: to specify a file named dash (-), prefix it with a path (e.g., './-') -Supported formats: -* **lrc**: lyrics files -* **srt**: SubRip subtitles files -* **vtt** (or **webvtt**): Web Video Text Tracks +### Supported formats + +- **lrc**: lyrics files +- **srt**: SubRip subtitles files +- **vtt** (or **webvtt**): Web Video Text Tracks + +## Compilation + +Just run `make`. + +You can also use those make targets: + +- `make install PREFIX=/usr/local`: install the program into PREFIX (default is `/usr/local`) +- `make uninstall`: uninstall the program from the given PREFIX +- `make clear`: clear the temporary files +- `make mrpropre`: clear everything, including the main executable and the documentation +- `make doc`: build the Doxygen documentation (`doxygen` required) +- `make man`: build the man page (`pandoc` required) + +## Author + +NSub was written by Niki Roo diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..3eefcb9 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +1.0.0 diff --git a/man.d b/man.d new file mode 100644 index 0000000..3d50066 --- /dev/null +++ b/man.d @@ -0,0 +1,43 @@ +# Requires variable: NAME + +.PHONY: man + +man: README*.md + @echo Checking for possible manual pages... + @if [ -e README.md ]; then \ + echo Sources found for man pages; \ + if pandoc -v >/dev/null 2>&1; then \ + ls README*.md 2>/dev/null \ + | grep 'README\(-..\|\)\.md' \ + | while read man; do \ + echo " Processing page $$lang..."; \ + lang="`echo "$$man" \ + | sed 's:README\.md:en:' \ + | sed 's:README-\(.*\)\.md:\1:'`"; \ + mkdir -p man/"$$lang"/man1; \ + ( \ + echo ".TH \"${NAME}\" 1 `\ + date +%Y-%m-%d\ + ` \"version `cat VERSION`\""; \ + echo; \ + UNAME="`echo "${NAME}" \ + | sed 's:\(.*\):\U\1:g'`"; \ + ( \ + cat "$$man" | head -n1 \ + | sed 's:.*(README\(-fr\|\)\.md).*::g'; \ + cat "$$man" | tail -n+2; \ + ) | sed 's:^#\(#.*\):\1:g' \ + | sed 's:^\(#.*\):\U\1:g;s:# *'"$$UNAME"':# NAME\n'"${NAME}"' \\- :g' \ + | sed 's:--:——:g' \ + | pandoc -f markdown -t man | sed 's:——:--:g' ; \ + ) > man/"$$lang"/man1/"${NAME}.1"; \ + done; \ + mkdir -p "man/man1"; \ + cp man/en/man1/"${NAME}".1 man/man1/; \ + else \ + echo "man pages generation: pandoc required" >&2; \ + false; \ + fi; \ + fi; + + diff --git a/src/nsub.d b/src/nsub.d index da878cf..d9d5c71 100644 --- a/src/nsub.d +++ b/src/nsub.d @@ -7,7 +7,7 @@ CFLAGS += -ggdb -O0 CXXFLAGS += -ggdb -O0 endif -.PHONY: all install uninstall clean mrpropre mrpropre debug +.PHONY: all install uninstall clean mrpropre mrpropre all: ../bin/nsub @@ -32,9 +32,6 @@ HEADERS=$(wildcard nsub/*.h) ../bin/nsub: $(SOURCES) $(HEADERS) ../bin/libutils.o $(CC) $(CFLAGS) $^ -o $@ -debug: - $(MAKE) -f nsub.d DEBUG=1 - clean: rm -f nsub/*.o @@ -42,11 +39,12 @@ mrproper: mrpropre mrpropre: clean rm -f ../bin/nsub + rmdir ../bin || true install: @echo "installing nsub to $(PREFIX)..." mkdir -p "$(PREFIX)/bin" \ - && cp ../bin/nsub "$(PREFIX)/bin/" \ + && cp ../bin/nsub "$(PREFIX)/bin/" uninstall: @echo "uninstalling nsub from $(PREFIX)..." diff --git a/src/utils.d b/src/utils.d index 7cf29f1..ecec32c 100644 --- a/src/utils.d +++ b/src/utils.d @@ -7,7 +7,7 @@ CFLAGS += -ggdb -O0 CXXFLAGS += -ggdb -O0 endif -.PHONY: all install uninstall clean mrpropre mrpropre debug +.PHONY: all install uninstall clean mrpropre mrpropre all: ../bin/libutils.o @@ -25,9 +25,6 @@ utils/desktop.o: utils/desktop.[ch] utils/array.h mkdir -p ../bin $(LD) --relocatable $(OBJECTS) -o $@ -debug: - $(MAKE) -f utils.d DEBUG=1 - clean: rm -f utils/*.o