tldr-pages / tldr-c-client

C command-line client for tldr pages
MIT License
293 stars 50 forks source link

Make fails to find libzip and curl when using /opt/homebrew #80

Closed MasterOdin closed 1 year ago

MasterOdin commented 2 years ago

Steps to Reproduce

  1. Install homebrew to /opt/homebrew (which is the default for the M1 machines)
  2. Run make
  3. See compilation error

Result

<What is the result of this?>

$ make
CC src/tldr.c
LD tldr
ld: warning: directory not found for option '-L/usr/local/opt/curl/lib'
ld: warning: directory not found for option '-L/usr/local/opt/libzip/lib'
ld: library not found for -lzip
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [tldr] Error 1

Expected Result

Compilation passes.

Additional Information

This diff fixes it at the expense of breaking other platforms:

diff --git a/Makefile b/Makefile
index bda31e8..e958f7d 100644
--- a/Makefile
+++ b/Makefile
@@ -48,14 +48,16 @@ ALL_CPPFLAGS    += -D_GNU_SOURCE
 ALL_CPPFLAGS   += $(shell pkg-config --cflags libzip)
 ALL_CPPFLAGS   += -I/usr/include
 ALL_CPPFLAGS   += -I/usr/local/include
-ALL_CPPFLAGS   += -I/usr/local/opt/curl/include
-ALL_CPPFLAGS   += -I/usr/local/opt/libzip/include
+ALL_CPPFLAGS  += -I/opt/homebrew/include
+ALL_CPPFLAGS   += -I/opt/homebrew/opt/curl/include
+ALL_CPPFLAGS   += -I/opt/homebrew/opt/libzip/include

 # Linker Flags
 ALL_LDFLAGS        := $(LDFLAGS) -L/usr/lib
 ALL_LDFLAGS        += -L/usr/local/lib
-ALL_LDFLAGS        += -L/usr/local/opt/curl/lib
-ALL_LDFLAGS        += -L/usr/local/opt/libzip/lib
+ALL_LDFLAGS        += -L/opt/homebrew/lib
+ALL_LDFLAGS        += -L/opt/homebrew/opt/curl/lib
+ALL_LDFLAGS        += -L/opt/homebrew/opt/libzip/lib
 ALL_LDLIBS     := -lc -lm -lcurl -lzip

Leaving the old directories I think works, but it does also emit a warning when running make about those directories not existing. Not sure what best practices around make are with regards to maybe optionally including directories if they exist or not, or if it's standard to ignore "missing directory" warnings.