Do not use -Werror because new compilers may include new warnings that the
developer may not have anticipated.
Use -dynamiclib on macOS instead of -shared.
Fix the library target so that it only rebuilds the library if needed.
Do not use install's -D option which is a GNU extension not supported on macOS.
Mark the library target as phony.
--- Makefile.orig 2018-03-31 01:07:55.000000000 -0500
+++ Makefile 2018-10-04 12:34:00.000000000 -0500
CPPFLAGS_FAST += $(CPPFLAGS_FAST_EXTRA)
CPPFLAGS_BENCH = $(CPPFLAGS_FAST)
-CFLAGS += -Wall -Wextra -Werror
CFLAGS_DEBUG = $(CFLAGS) -O0 -g $(CFLAGS_DEBUG_EXTRA)
CFLAGS_FAST = $(CFLAGS) -O3 $(CFLAGS_FAST_EXTRA)
CFLAGS_BENCH = $(CFLAGS_FAST) -Wno-unused-parameter
CFLAGS_LIB = $(CFLAGS_FAST) -fPIC
+ifeq (darwin,$(PLATFORM))
+LDFLAGS_LIB = $(LDFLAGS) -dynamiclib
LDFLAGS_LIB = $(LDFLAGS) -shared
libhttp_parser.o: http_parser.c http_parser.h Makefile
$(CC) $(CPPFLAGS_FAST) $(CFLAGS_LIB) -c http_parser.c -o libhttp_parser.o
-library: libhttp_parser.o
- $(CC) $(LDFLAGS_LIB) -o $(LIBNAME) $<
+$(LIBNAME): libhttp_parser.o
+ $(CC) $(LDFLAGS_LIB) -o $@ $<
$(AR) rcs libhttp_parser.a http_parser.o
- $(INSTALL) -D http_parser.h $(DESTDIR)$(INCLUDEDIR)/http_parser.h
- $(INSTALL) -D $(LIBNAME) $(DESTDIR)$(LIBDIR)/$(LIBNAME)
+ $(INSTALL) -c http_parser.h $(DESTDIR)$(INCLUDEDIR)/http_parser.h
+ $(INSTALL) -c $(LIBNAME) $(DESTDIR)$(LIBDIR)/$(LIBNAME)
ln -s $(LIBNAME) $(DESTDIR)$(LIBDIR)/$(SONAME)
ln -s $(LIBNAME) $(DESTDIR)$(LIBDIR)/$(SOLIBNAME).$(SOEXT)
- $(INSTALL) -D http_parser.h $(DESTDIR)$(INCLUDEDIR)/http_parser.h
- $(INSTALL) -D -s $(LIBNAME) $(DESTDIR)$(LIBDIR)/$(LIBNAME)
+ $(INSTALL) -c http_parser.h $(DESTDIR)$(INCLUDEDIR)/http_parser.h
+ $(INSTALL) -c -s $(LIBNAME) $(DESTDIR)$(LIBDIR)/$(LIBNAME)
ln -s $(LIBNAME) $(DESTDIR)$(LIBDIR)/$(SONAME)
ln -s $(LIBNAME) $(DESTDIR)$(LIBDIR)/$(SOLIBNAME).$(SOEXT)