Improved build for Mac https://github.com/waywardgeek/sonic/commit/eebb020958f0fa84ee831a55f7158cee8d108819 --- Makefile.orig 2021-08-17 17:58:09.000000000 -0500 +++ Makefile 2021-08-17 17:58:40.000000000 -0500 @@ -5,22 +5,30 @@ # safe. We call malloc, and older Linux versions only linked in the thread-safe # malloc if -pthread is specified. -SONAME=soname +PREFIX=/usr/local +BINDIR=$(PREFIX)/bin +LIBDIR=$(PREFIX)/lib +INCDIR=$(PREFIX)/include + +SONAME=-soname, +SHARED_OPT=-shared +LIB_NAME=libsonic.so +LIB_TAG=.0.2.0 + UNAME := $(shell uname) ifeq ($(UNAME), Darwin) - SONAME=install_name + SONAME=-install_name,$(LIBDIR)/ + SHARED_OPT=-dynamiclib + LIB_NAME=libsonic.dylib + LIB_TAG= endif CFLAGS ?= -O3 CFLAGS += -Wall -ansi -fPIC -pthread -LIB_TAG=0.2.0 -CC=gcc -PREFIX=/usr -LIBDIR=$(PREFIX)/lib -all: sonic libsonic.so.$(LIB_TAG) libsonic.a +all: sonic $(LIB_NAME)$(LIB_TAG) libsonic.a -sonic: wave.o main.o libsonic.so.$(LIB_TAG) - $(CC) $(CFLAGS) $(LDFLAGS) -o sonic wave.o main.o libsonic.so.$(LIB_TAG) +sonic: wave.o main.o $(LIB_NAME)$(LIB_TAG) + $(CC) $(CFLAGS) $(LDFLAGS) -o sonic wave.o main.o $(LIB_NAME)$(LIB_TAG) sonic.o: sonic.c sonic.h $(CC) $(CPPFLAGS) $(CFLAGS) -c sonic.c @@ -31,30 +39,37 @@ main.o: main.c sonic.h wave.h $(CC) $(CPPFLAGS) $(CFLAGS) -c main.c -libsonic.so.$(LIB_TAG): sonic.o - $(CC) $(CFLAGS) $(LDFLAGS) -shared -Wl,-$(SONAME),libsonic.so.0 sonic.o -o libsonic.so.$(LIB_TAG) - ln -sf libsonic.so.$(LIB_TAG) libsonic.so - ln -sf libsonic.so.$(LIB_TAG) libsonic.so.0 +$(LIB_NAME)$(LIB_TAG): sonic.o + $(CC) $(CFLAGS) $(LDFLAGS) $(SHARED_OPT) -Wl,$(SONAME)$(LIB_NAME) sonic.o -o $(LIB_NAME)$(LIB_TAG) +ifneq ($(UNAME), Darwin) + ln -sf $(LIB_NAME)$(LIB_TAG) $(LIB_NAME) + ln -sf $(LIB_NAME)$(LIB_TAG) $(LIB_NAME).0 +endif libsonic.a: sonic.o $(AR) cqs libsonic.a sonic.o -install: sonic libsonic.so.$(LIB_TAG) sonic.h - install -d $(DESTDIR)$(PREFIX)/bin $(DESTDIR)$(PREFIX)/include $(DESTDIR)$(PREFIX)/lib - install sonic $(DESTDIR)$(PREFIX)/bin - install sonic.h $(DESTDIR)$(PREFIX)/include - install libsonic.so.$(LIB_TAG) $(DESTDIR)$(PREFIX)/lib +install: sonic $(LIB_NAME)$(LIB_TAG) sonic.h + install -d $(DESTDIR)$(BINDIR) $(DESTDIR)$(INCDIR) $(DESTDIR)$(LIBDIR) + install sonic $(DESTDIR)$(BINDIR) + install sonic.h $(DESTDIR)$(INCDIR) install libsonic.a $(DESTDIR)$(LIBDIR) - ln -sf libsonic.so.$(LIB_TAG) $(DESTDIR)$(PREFIX)/lib/libsonic.so - ln -sf libsonic.so.$(LIB_TAG) $(DESTDIR)$(PREFIX)/lib/libsonic.so.0 + install $(LIB_NAME)$(LIB_TAG) $(DESTDIR)$(LIBDIR) +ifneq ($(UNAME), Darwin) + ln -sf $(LIB_NAME)$(LIB_TAG) $(DESTDIR)$(LIBDIR)/$(LIB_NAME) + ln -sf $(LIB_NAME)$(LIB_TAG) $(DESTDIR)$(LIBDIR)/$(LIB_NAME).0 +endif uninstall: - rm -f $(DESTDIR)$(PREFIX)/bin/sonic - rm -f $(DESTDIR)$(PREFIX)/include/sonic.h - rm -f $(DESTDIR)$(PREFIX)/lib/libsonic.so.$(LIB_TAG) - rm -f $(DESTDIR)$(PREFIX)/lib/libsonic.so - rm -f $(DESTDIR)$(PREFIX)/lib/libsonic.so.0 + rm -f $(DESTDIR)$(BINDIR)/sonic + rm -f $(DESTDIR)$(INCDIR)/sonic.h rm -f $(DESTDIR)$(LIBDIR)/libsonic.a + rm -f $(DESTDIR)$(LIBDIR)/$(LIB_NAME)$(LIB_TAG) + rm -f $(DESTDIR)$(LIBDIR)/$(LIB_NAME).0 + rm -f $(DESTDIR)$(LIBDIR)/$(LIB_NAME) clean: - rm -f *.o sonic libsonic.so* libsonic.a + rm -f *.o sonic $(LIB_NAME)* libsonic.a test.wav + +check: + ./sonic -s 2.0 ./samples/talking.wav ./test.wav