NikitaIvanovV / ctpv

Image previews for lf file manager
https://www.nikitaivanov.com/man1/ctpv
MIT License
264 stars 24 forks source link

Make buildable on macOS #43

Closed suhailskhan closed 1 year ago

suhailskhan commented 1 year ago

closed

NikitaIvanovV commented 1 year ago

Just curious, did you figure out a better way to support macOS?

suhailskhan commented 1 year ago

My apologies for the haphazard pull request. Technically it builds correctly on macOS, no changes needed on ctpv’s end. The changes I made as part of the PR were to the Makefile, and they were not strictly necessary.

The only real issue I initially encountered was that sys/stat.h from macOS’s standard library has a slightly different name for st_mtim. After using export CFLAGS="$CFLAGS -D st_mtim=st_mtimespec", it builds successfully provided libcrypto and libmagic are present.

That said, one may use an ifdef in the code (e.g. as shown below) to prevent the need for that compilation flag.

#ifdef __APPLE__
#define st_mtim st_mtimespec
#endif

Anyway, after building ctpv I tested it with chafa and kitty, in lf and zsh, and it’s working great. Thanks for this project!

NikitaIvanovV commented 1 year ago

Anyway, after building ctpv I tested it with chafa and kitty, in lf and zsh, and it’s working great. Thanks for this project!

Awesome! Glad to see that someone uses it on macOS as well!

Fixed for macOS in 2936aba143012caad52018a1b50785c118d9a795, could you please test?

suhailskhan commented 1 year ago

Fixed for macOS in https://github.com/NikitaIvanovV/ctpv/commit/2936aba143012caad52018a1b50785c118d9a795, could you please test?

Here is what stderr looks like after running make on a fresh clone, no compilation flags added:

src/ctpv.c:174:5: warning: 'MD5' is deprecated [-Wdeprecated-declarations]
    MD5((const unsigned char *)s, strlen(s), out);
    ^
/opt/local/include/openssl/md5.h:52:1: note: 'MD5' has been explicitly marked deprecated here
OSSL_DEPRECATEDIN_3_0 unsigned char *MD5(const unsigned char *d, size_t n,
^
/opt/local/include/openssl/macros.h:193:49: note: expanded from macro 'OSSL_DEPRECATEDIN_3_0'
#   define OSSL_DEPRECATEDIN_3_0                OSSL_DEPRECATED(3.0)
                                                ^
/opt/local/include/openssl/macros.h:62:52: note: expanded from macro 'OSSL_DEPRECATED'
#     define OSSL_DEPRECATED(since) __attribute__((deprecated))
                                                   ^
1 warning generated.

Here's a kitty terminal window with ctpv output:

image
NikitaIvanovV commented 1 year ago

So everything works as expected? Great! I get those warnings as well, will fix those some time later.

Thank you for testing! I don't own an Apple device, so I could not test if that works.