+include ../../config.mak
+
TARGET = miracle
-OBJS = miracle.o \
- miracle_log.o \
+ifneq ($(targetos), Darwin)
+LIBNAME = libmiracle$(LIBSUF)
+LIBTARGET = $(LIBNAME).$(version)
+SHFLAGS += -Wl,-soname,$(LIBTARGET)
+else
+LIBNAME = libmiracle$(LIBSUF)
+LIBTARGET = libmiracle.$(version)$(LIBSUF)
+SHFLAGS += -install_name $(libdir)/$(LIBTARGET)
+endif
+
+APP_OBJS = miracle.o
+
+LIB_OBJS = miracle_log.o \
miracle_server.o \
miracle_connection.o \
miracle_local.o \
miracle_commands.o \
miracle_unit_commands.o
-CFLAGS = -I .. -Wall -g -D_FILE_OFFSET_BITS=64 -pthread -rdynamic
+INCS = miracle_server.h \
+ miracle_local.h \
+ miracle_log.h
-LDFLAGS = -L ../valerie -lvalerie -L ../framework -lmlt
+OBJS = $(APP_OBJS) $(LIB_OBJS)
+
+CFLAGS += -I.. $(RDYNAMIC)
+
+LDFLAGS += -L../valerie -lvalerie -L../framework -lmlt
SRCS := $(OBJS:.o=.c)
-all: $(TARGET)
+all: $(TARGET)
-$(TARGET): $(OBJS)
- $(CC) -o $@ $(OBJS) $(LDFLAGS)
+$(TARGET): $(APP_OBJS) $(LIBTARGET)
+ $(CC) -o $@ $(APP_OBJS) -L. -lmiracle $(LDFLAGS)
-depend: $(SRCS)
- $(CC) -MM $(CFLAGS) $^ 1>.depend
+$(LIBTARGET): $(LIB_OBJS)
+ $(CC) $(SHFLAGS) -o $@ $(LIB_OBJS) $(LDFLAGS)
+ ln -sf $(LIBTARGET) $(LIBNAME)
-dist-clean: clean
- rm -f .depend
+depend: $(SRCS)
+ $(CC) -MM $(CFLAGS) $^ 1>.depend
+
+distclean: clean
+ rm -f .depend
clean:
- rm -f $(OBJS) $(TARGET)
+ rm -f $(OBJS) $(TARGET) $(LIBNAME) $(LIBTARGET)
+
+install: all
+ install -d "$(DESTDIR)$(bindir)"
+ install -c -s -m 755 $(TARGET) "$(DESTDIR)$(bindir)"
+ install -m 755 $(LIBTARGET) $(DESTDIR)$(libdir)
+ ln -sf $(LIBTARGET) $(DESTDIR)$(libdir)/$(LIBNAME)
+ mkdir -p "$(DESTDIR)$(prefix)/include/mlt/miracle"
+ install -m 644 $(INCS) "$(DESTDIR)$(prefix)/include/mlt/miracle"
ifneq ($(wildcard .depend),)
include .depend