vdr-plugin-skindesigner/libskindesignerapi/Makefile

100 lines
2.5 KiB
Makefile
Raw Normal View History

2015-04-02 15:09:41 +02:00
# Makefile for libskindesignerapi
2015-04-02 11:39:43 +02:00
NAME = skindesignerapi
LIBNAME = lib$(NAME)
MAJOR = 0
2015-05-30 16:43:59 +02:00
MINOR = 0.2
2015-04-02 11:39:43 +02:00
VERSION = $(MAJOR).$(MINOR)
SONAME = $(LIBNAME).so.$(MAJOR)
TARGET_LIB = $(SONAME).$(MINOR)
PREFIX ?= /usr/local
INCDIR ?= $(PREFIX)/include
LIBDIR ?= $(PREFIX)/lib
2015-04-06 15:34:08 +02:00
PCDIR ?= $(PREFIX)/lib/pkgconfig
2015-04-02 11:39:43 +02:00
TMPDIR ?= /tmp
### The name of the distribution archive:
ARCHIVE = $(LIBNAME)-$(VERSION)
PKGCFG = $(if $(VDRDIR),$(shell pkg-config --silence-errors --variable=$(1) $(VDRDIR)/vdr.pc),$(shell pkg-config --silence-errors --variable=$(1) vdr || pkg-config --variable=$(1) ../../../../vdr.pc))
CXXFLAGS = $(call PKGCFG,cxxflags)
2015-04-02 11:39:43 +02:00
LDFLAGS = -shared -Wl,-soname,$(SONAME)
DEFINES += -DLIBAPIVERSION=$(MAJOR) -DLIBVERSION=\"$(VERSION)\"
2015-04-02 11:39:43 +02:00
INCLUDES +=
SRCS = $(wildcard *.c)
OBJS = $(SRCS:.c=.o)
.PHONY: all
all: ${TARGET_LIB} ${LIBNAME}.pc
%.o: %.c
$(CXX) $(CXXFLAGS) -c $(DEFINES) $(INCLUDES) -o $@ $<
# Dependencies:
MAKEDEP = $(CXX) -MM -MG
DEPFILE = .dependencies
$(DEPFILE): Makefile
@$(MAKEDEP) $(DEFINES) $(INCLUDES) $(OBJS:%.o=%.c) > $@
-include $(DEPFILE)
# The main lib
$(TARGET_LIB): $(OBJS)
$(CXX) ${LDFLAGS} -o $@ $^
if [ -n "$(LCLBLD)" ] ; then \
ln -s $(TARGET_LIB) $(LIBNAME).so ; \
ln -s $(TARGET_LIB) $(SONAME) ; \
fi
2015-04-02 11:39:43 +02:00
# pkg-config
.PHONY: $(LIBNAME).pc
$(LIBNAME).pc:
@echo "includedir=$(INCDIR)" > $@
@echo "libdir=$(LIBDIR)" >> $@
@echo "" >> $@
@echo "Name: $(LIBNAME)" >> $@
@echo "Description: skindesigner API Library" >> $@
@echo "Version: $(VERSION)" >> $@
@echo "Cflags: -I$(INCDIR)" >> $@
@echo "Libs: -L$(LIBDIR) -l$(NAME)" >> $@
# install targets
install-lib: $(TARGET_LIB)
install -D $^ $(DESTDIR)$(LIBDIR)/$^
if [ -z "$(DESTDIR)" ] ; then ldconfig; fi
cd $(DESTDIR)$(LIBDIR) ; if [ ! -e $(LIBNAME).so ] ; then ln -s $(TARGET_LIB) $(LIBNAME).so; fi
install-includes:
@mkdir -p $(DESTDIR)$(INCDIR)/$(LIBNAME)
@cp -pLR *.h $(DESTDIR)$(INCDIR)/$(LIBNAME)
install-pc: $(LIBNAME).pc
if [ -n "$(PCDIR)" ] ; then\
mkdir -p $(DESTDIR)$(PCDIR) ;\
cp $(LIBNAME).pc $(DESTDIR)$(PCDIR) ;\
fi
install: install-lib install-pc install-includes
# clean & dist
.PHONY: clean
clean:
-rm -f ${TARGET_LIB} ${OBJS} $(DEPFILE) $(LIBNAME).pc $(LIBNAME).so $(SONAME) $(ARCHIVE).tgz
2015-04-02 11:39:43 +02:00
dist: clean
@-rm -rf $(TMPDIR)/$(ARCHIVE)
@mkdir $(TMPDIR)/$(ARCHIVE)
@cp -a * $(TMPDIR)/$(ARCHIVE)
@tar czf $(ARCHIVE).tgz --exclude .git* --exclude *.o --exclude *.rej --exclude *.orig -C $(TMPDIR) $(ARCHIVE)
@-rm -rf $(TMPDIR)/$(ARCHIVE)
@echo Distribution package created as $(ARCHIVE).tgz