implement SailfishOS support, made in collaboration with vakkov

sorry for building your hopes up, it currently segfaults:
https://bpaste.net/show/319c346897f6
i hope someone can help me out there

i've continued what vakkov started with cleanups and i tried to make it so that other platforms still work (but i cannot test all of them :()
Instead of calling this twice with `$(shell ...)`, just assign the result once and then use the variable, to avoid calling pkg-config twice:

```
LIBPNG_MOD_VERSION := $(shell $(PKG_CONFIG) --modversion libpng)
ifeq ($(LIBPNG_MOD_VERSION),)
    $(error No libpng development libaries found)
else
    LIBPNG_CFLAGS += ...
    ...
endif
ifeq ($(LIBPNG_MOD_VERSION,1.2)
    CFLAGS += -DLIBPNG_LEGACY
endif
```