#
# Copyright (C) 2009 Till Harbaum <till@harbaum.org>.
#
# This file is part of zeemote-conf.
#
# zeemote-conf is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# zeemote-conf is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with zeemote-conf.  If not, see <http://www.gnu.org/licenses/>.
#

MAJOR = 1
MINOR = 0

LIB = libzeemote-conf
STLIB = $(LIB).a
SHLIB = $(LIB).so
HDRDIR = /usr/include
LIBDIR = /usr/lib

CFLAGS = -O2 -c -Wall -I../include `pkg-config --cflags gconf-2.0`
OBJS = zeemote-conf.o

all: static shared

.c.o:
	$(CC) $(INCS) $(CFLAGS) -c -o$@ $<

static: $(STLIB)
shared: $(SHLIB).$(MAJOR).$(MINOR)

$(STLIB): $(OBJS)
	rm -f $(STLIB)	
	ar rcv $(STLIB) $(OBJS)
	-ranlib $(STLIB)

$(SHLIB).$(MAJOR).$(MINOR): $(OBJS)
	rm -f $(SHLIB)
	gcc -shared -Wl,-soname,$(SHLIB).$(MAJOR) -o $(SHLIB).$(MAJOR).$(MINOR) $(OBJS)
	rm -f $(SHLIB) $(SHLIB).$(MAJOR)
	ln -s $(SHLIB).$(MAJOR).$(MINOR) $(SHLIB).$(MAJOR)
	ln -s $(SHLIB).$(MAJOR) $(SHLIB)

zeemote-conf.o: ../include/zeemote-conf.h

install: $(STLIB) $(SHLIB).$(MAJOR).$(MINOR)
	install -d $(DESTDIR)$(LIBDIR)
	install $(STLIB) $(SHLIB).$(MAJOR).$(MINOR) $(DESTDIR)$(LIBDIR)
	rm -f $(DESTDIR)$(LIBDIR)/$(SHLIB)
	ln -s $(SHLIB).$(MAJOR) $(DESTDIR)$(LIBDIR)/$(SHLIB)
	rm -f $(DESTDIR)$(LIBDIR)/$(SHLIB).$(MAJOR)
	ln -s $(SHLIB).$(MAJOR).$(MINOR) $(DESTDIR)$(LIBDIR)/$(SHLIB).$(MAJOR)
	install -d $(DESTDIR)$(HDRDIR)
	install ../include/zeemote-conf.h $(DESTDIR)$(HDRDIR)

clean:
	rm -f *.[oa] *~ $(SHLIB) $(STLIB)
