Rework build system v2 (#71)

* Remove non-POSIX extensions and commands
* Drop autodetection in favor of OPT_DEP_DEFAULT
* Use += for LDLIBS as some BSD distros need to add extra flags
* Change DOCPREFIX -> EGPREFIX
* Use ?= for MANPREFIX and EGPREFIX
* Update docs

With this, we should have a stable build system. No further significant
changes should be needed.
master
N-R-K 2021-10-03 22:52:12 +06:00 committed by GitHub
parent 1dc936d0ee
commit e8d08ba67e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 51 additions and 54 deletions

1
.gitignore vendored
View File

@ -3,4 +3,3 @@ version.h
*.d
*.o
nsxiv
config.mk

View File

@ -1,18 +1,21 @@
# Include configure options
ifneq (clean,$(filter clean,$(MAKECMDGOALS)))
-include config.mk
endif
# nsxiv version
VERSION = 27.1
# PREFIX for install
PREFIX ?= /usr/local
MANPREFIX = $(PREFIX)/share/man
DOCPREFIX = $(PREFIX)/share/doc/nsxiv
MANPREFIX ?= $(PREFIX)/share/man
EGPREFIX ?= $(PREFIX)/share/doc/nsxiv/examples
# autoreload backend: inotify/nop
AUTORELOAD = inotify
# default value for optional dependencies. 1 = enabled, 0 = disabled
OPT_DEP_DEFAULT ?= 1
# autoreload backend: 1 = inotify, 0 = none
HAVE_INOTIFY ?= $(OPT_DEP_DEFAULT)
# optional dependencies, see README for more info
HAVE_LIBGIF ?= $(OPT_DEP_DEFAULT)
HAVE_LIBEXIF ?= $(OPT_DEP_DEFAULT)
HAVE_LIBWEBP ?= $(OPT_DEP_DEFAULT)
# CFLAGS, any optimization flags goes here
CFLAGS ?= -std=c99 -Wall -pedantic
@ -20,30 +23,25 @@ CFLAGS ?= -std=c99 -Wall -pedantic
# icons that will be installed via `make icon`
ICONS = 16x16.png 32x32.png 48x48.png 64x64.png 128x128.png
ifeq ($(HAVE_LIBEXIF), 1)
OPTIONAL_LIBS += -lexif
else
HAVE_LIBEXIF = 0
endif
ifeq ($(HAVE_LIBGIF), 1)
OPTIONAL_LIBS += -lgif
else
HAVE_LIBGIF = 0
endif
ifeq ($(HAVE_LIBWEBP), 1)
OPTIONAL_LIBS += -lwebpdemux -lwebp
else
HAVE_LIBWEBP = 0
endif
CPPFLAGS = -D_XOPEN_SOURCE=700 \
-DHAVE_LIBGIF=$(HAVE_LIBGIF) -DHAVE_LIBEXIF=$(HAVE_LIBEXIF) \
-DHAVE_LIBWEBP=$(HAVE_LIBWEBP) \
-I/usr/include/freetype2 -I$(PREFIX)/include/freetype2
LDLIBS = -lImlib2 -lX11 -lXft -lfontconfig $(OPTIONAL_LIBS)
lib_exif_0 =
lib_exif_1 = -lexif
lib_gif_0 =
lib_gif_1 = -lgif
lib_webp_0 =
lib_webp_1 = -lwebpdemux -lwebp
autoreload_0 = nop
autoreload_1 = inotify
# using += because certain *BSD distros may need to add additional flags
LDLIBS += -lImlib2 -lX11 -lXft -lfontconfig \
$(lib_exif_$(HAVE_LIBEXIF)) $(lib_gif_$(HAVE_LIBGIF)) \
$(lib_webp_$(HAVE_LIBWEBP))
OBJS = autoreload_$(AUTORELOAD).o commands.o image.o main.o options.o \
OBJS = autoreload_$(autoreload_$(HAVE_INOTIFY)).o commands.o image.o main.o options.o \
thumbs.o util.o window.o
.PHONY: all clean install uninstall install-all install-icon uninstall-icon install-desktop
@ -60,19 +58,10 @@ nsxiv: $(OBJS)
@echo "CC $@"
$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
$(OBJS): Makefile nsxiv.h commands.lst config.h config.mk
$(OBJS): Makefile nsxiv.h commands.lst config.h
options.o: version.h
window.o: icon/data.h
config.mk:
@echo "GEN $@"
@echo "# 0 = disable, 1 = enable" > config.mk
@for lib in exif gif webp; do \
if echo "int main(){}" | $(CC) "-l$$lib" -o /dev/null -x c - 2>/dev/null ; then \
echo "HAVE_LIB$$lib=1" | tr '[:lower:]' '[:upper:]' >> config.mk ; \
fi \
done
config.h:
@echo "GEN $@"
cp config.def.h $@
@ -85,7 +74,7 @@ version.h: Makefile .git/index
.git/index:
clean:
$(RM) *.o nsxiv
rm -f *.o nsxiv version.h
install-all: install install-desktop install-icon
@ -112,14 +101,18 @@ uninstall-icon:
install: all
@echo "INSTALL bin/nsxiv"
install -Dt $(DESTDIR)$(PREFIX)/bin nsxiv
mkdir -p $(DESTDIR)$(PREFIX)/bin
cp nsxiv $(DESTDIR)$(PREFIX)/bin/
chmod 755 $(DESTDIR)$(PREFIX)/bin/nsxiv
@echo "INSTALL nsxiv.1"
mkdir -p $(DESTDIR)$(MANPREFIX)/man1
sed "s!DOCPREFIX!$(DOCPREFIX)!g; s!PREFIX!$(PREFIX)!g; s!VERSION!$(VERSION)!g" nsxiv.1 \
sed "s!EGPREFIX!$(EGPREFIX)!g; s!PREFIX!$(PREFIX)!g; s!VERSION!$(VERSION)!g" nsxiv.1 \
>$(DESTDIR)$(MANPREFIX)/man1/nsxiv.1
chmod 644 $(DESTDIR)$(MANPREFIX)/man1/nsxiv.1
@echo "INSTALL share/nsxiv/"
install -Dt $(DESTDIR)$(DOCPREFIX)/examples examples/*
mkdir -p $(DESTDIR)$(EGPREFIX)
cp examples/* $(DESTDIR)$(EGPREFIX)
chmod 755 $(DESTDIR)$(EGPREFIX)/*
uninstall: uninstall-icon
@echo "REMOVE bin/nsxiv"
@ -129,5 +122,5 @@ uninstall: uninstall-icon
@echo "REMOVE nsxiv.desktop"
rm -f $(DESTDIR)$(PREFIX)/share/applications/nsxiv.desktop
@echo "REMOVE share/nsxiv/"
rm -rf $(DESTDIR)$(DOCPREFIX)
rm -rf $(DESTDIR)$(EGPREFIX)

View File

@ -49,11 +49,16 @@ nsxiv requires the following software to be installed:
* freetype2
* fontconfig
The following libraries are optional. They are automatically enabled if installed.
The following dependencies are optional.
* inotify : Used for auto-reloading images on change.
Disabled via `HAVE_INOTIFY=0`
* giflib : Used for animated gif playback.
Disabled via `HAVE_LIBGIF=0`.
* libexif : Used for auto-orientation and exif thumbnails.
Disable via `HAVE_LIBEXIF=0`
* libwebp : Used for animated webp playback.
Disabled via `HAVE_LIBWEBP=0`.
Please make sure to install the corresponding development packages in case that
you want to build nsxiv on a distribution with separate runtime and development
@ -67,14 +72,14 @@ nsxiv is built using the commands:
$ make
Running make will automatically detect if libexif and libgif are available and
enable them if so. CLI arguments will override any automatic detection.
You can pass `HAVE_X=0` to `make` to disable an optional dependency.
For example:
$ make HAVE_LIBGIF=0
$ make HAVE_LIBEXIF=0
will always disable libgif.
Alternatively, they can be disabled via editing `config.mk`.
will disable `libexif` support. Alternatively they can be disabled via editing
the `Makefile` directly. `OPT_DEP_DEFAULT=0` can be used to disable all
optional dependencies.
Installing nsxiv:
@ -102,9 +107,9 @@ You can install nsxiv into a directory of your choice by changing this command t
$ make PREFIX="/your/dir" install
Example scripts are installed using `DOCPREFIX` which defaults to
`/usr/local/share/doc/nsxiv`. You can change `DOCPREFIX` the same way you can
change `PREFIX` shown above.
Example scripts are installed using `EGPREFIX` which defaults to
`/usr/local/share/doc/nsxiv/examples`. You can change `EGPREFIX` the same way
you can change `PREFIX` shown above.
The build-time specific settings of nsxiv can be found in the file *config.h*.
Please check and change them, so that they fit your needs.

View File

@ -428,7 +428,7 @@ and the arguments given to it are: 1) path to image file, 2) image width,
3) image height.
.P
There is also an example script installed together with nsxiv as
.IR DOCPREFIX/examples/image-info .
.IR EGPREFIX/image-info .
.SH EXTERNAL KEY HANDLER
Additional external keyboard commands can be defined using a handler program
located in
@ -446,7 +446,7 @@ where C/M/S indicate Ctrl/Meta(Alt)/Shift modifier states and KEY is the X
keysym as listed in /usr/include/X11/keysymdef.h without the "XK_" prefix.
There is also an example script installed together with nsxiv as
.IR DOCPREFIX/examples/key-handler .
.IR EGPREFIX/key-handler .
.SH THUMBNAIL CACHING
nsxiv stores all thumbnails under
.IR $XDG_CACHE_HOME/nsxiv/ .