Home | History | Annotate | Download | only in sonic
      1 # This file was written by Bill Cox in 2010, and is licensed under the Apache
      2 # 2.0 license.
      3 #
      4 # Note that -pthread is only included so that older Linux builds will be thread
      5 # safe.  We call malloc, and older Linux versions only linked in the thread-safe
      6 # malloc if -pthread is specified.
      7 
      8 SONAME=soname
      9 UNAME := $(shell uname)
     10 ifeq ($(UNAME), Darwin)
     11   SONAME=install_name
     12 endif
     13 #CFLAGS=-Wall -g -ansi -fPIC -pthread
     14 CFLAGS=-Wall -O3 -ansi -fPIC -pthread
     15 LIB_TAG=0.2.0
     16 CC=gcc
     17 PREFIX=/usr
     18 LIBDIR=$(PREFIX)/lib
     19 
     20 all: sonic libsonic.so.$(LIB_TAG) libsonic.a
     21 
     22 sonic: wave.o main.o libsonic.so.$(LIB_TAG)
     23 	$(CC) $(CFLAGS) -o sonic wave.o main.o libsonic.so.$(LIB_TAG)
     24 
     25 sonic.o: sonic.c sonic.h
     26 	$(CC) $(CFLAGS) -c sonic.c
     27 
     28 wave.o: wave.c wave.h
     29 	$(CC) $(CFLAGS) -c wave.c
     30 
     31 main.o: main.c sonic.h wave.h
     32 	$(CC) $(CFLAGS) -c main.c
     33 
     34 libsonic.so.$(LIB_TAG): sonic.o
     35 	$(CC) $(CFLAGS) -shared -Wl,-$(SONAME),libsonic.so.0 sonic.o -o libsonic.so.$(LIB_TAG)
     36 	ln -sf libsonic.so.$(LIB_TAG) libsonic.so
     37 	ln -sf libsonic.so.$(LIB_TAG) libsonic.so.0
     38 
     39 libsonic.a: sonic.o
     40 	$(AR) cqs libsonic.a sonic.o
     41 
     42 install: sonic libsonic.so.$(LIB_TAG) sonic.h
     43 	install -d $(DESTDIR)$(PREFIX)/bin $(DESTDIR)$(PREFIX)/include $(DESTDIR)$(PREFIX)/lib
     44 	install sonic $(DESTDIR)$(PREFIX)/bin
     45 	install sonic.h $(DESTDIR)$(PREFIX)/include
     46 	install libsonic.so.$(LIB_TAG) $(DESTDIR)$(PREFIX)/lib
     47 	install libsonic.a $(DESTDIR)$(LIBDIR)
     48 	ln -sf libsonic.so.$(LIB_TAG) $(DESTDIR)$(PREFIX)/lib/libsonic.so
     49 	ln -sf libsonic.so.$(LIB_TAG) $(DESTDIR)$(PREFIX)/lib/libsonic.so.0
     50 
     51 uninstall: 
     52 	rm -f $(DESTDIR)$(PREFIX)/bin/sonic 
     53 	rm -f $(DESTDIR)$(PREFIX)/include/sonic.h
     54 	rm -f $(DESTDIR)$(PREFIX)/lib/libsonic.so.$(LIB_TAG)
     55 	rm -f $(DESTDIR)$(PREFIX)/lib/libsonic.so
     56 	rm -f $(DESTDIR)$(PREFIX)/lib/libsonic.so.0
     57 	rm -f $(DESTDIR)$(LIBDIR)/libsonic.a
     58 
     59 clean:
     60 	rm -f *.o sonic libsonic.so* libsonic.a
     61