• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
8SONAME=soname
9UNAME := $(shell uname)
10ifeq ($(UNAME), Darwin)
11  SONAME=install_name
12endif
13#CFLAGS=-Wall -g -ansi -fPIC -pthread
14CFLAGS=-Wall -O3 -ansi -fPIC -pthread
15LIB_TAG=0.2.0
16CC=gcc
17PREFIX=/usr
18LIBDIR=$(PREFIX)/lib
19
20all: sonic libsonic.so.$(LIB_TAG) libsonic.a
21
22sonic: wave.o main.o libsonic.so.$(LIB_TAG)
23	$(CC) $(CFLAGS) -o sonic wave.o main.o libsonic.so.$(LIB_TAG)
24
25sonic.o: sonic.c sonic.h
26	$(CC) $(CFLAGS) -c sonic.c
27
28wave.o: wave.c wave.h
29	$(CC) $(CFLAGS) -c wave.c
30
31main.o: main.c sonic.h wave.h
32	$(CC) $(CFLAGS) -c main.c
33
34libsonic.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
39libsonic.a: sonic.o
40	$(AR) cqs libsonic.a sonic.o
41
42install: 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
51uninstall:
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
59clean:
60	rm -f *.o sonic libsonic.so* libsonic.a
61