#
# "$Id: Makefile.in 316 2007-11-23 02:15:07Z mike $"
#
# Makefile for Mini-XML, a small XML-like file parsing library.
#
# Copyright 2003-2007 by Michael Sweet.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2, or (at your option) any later version.
#
# This program 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.
#

#
# Compiler tools definitions...
#

#CFLAGS := -Wall -s -O2 
#TOOLPREFIX :=mips64-octeon-linux-gnu-
LDFLAGS += -L./

#CROSS=mips64-octeon-linux-gnu-
#CC=$(CROSS)gcc
#AR=$(CROSS)ar
#LD=$(CROSS)ld
#STRIP=$(CROSS)strip


#
# Configured directories...
#

prefix		=	@prefix@
exec_prefix	=	@exec_prefix@
bindir		=	@bindir@
datarootdir	=	@datarootdir@
includedir	=	@includedir@
libdir		=	@libdir@
mandir		=	@mandir@
docdir		=	@docdir@
BUILDROOT	=	$(DSTROOT)


#
# Install commands...
#

INSTALL_BIN	=	$(LIBTOOL) $(INSTALL) -m 755 -s
INSTALL_DATA	=	$(INSTALL) -m 644
INSTALL_DIR	=	$(INSTALL) -d
INSTALL_LIB	=	$(LIBTOOL) $(INSTALL) -m 755
INSTALL_MAN	=	$(INSTALL) -m 644
INSTALL_SCRIPT	=	$(INSTALL) -m 755


#
# Rules...
#

.SUFFIXES:	.c .man .o
.c.o:
	$(CC) $(CFLAGS) -c $<


#
# Targets...
#

LIBMXML		=	libmxml.so
PUBLIBOBJS	=	mxml-attr.o mxml-entity.o mxml-file.o mxml-index.o \
			mxml-node.o mxml-search.o mxml-set.o
LIBOBJS		=	$(PUBLIBOBJS) mxml-private.o mxml-string.o
OBJS		=	mxmldoc.o $(LIBOBJS)
TARGETS		=	$(LIBMXML)


#
# Make everything...
#

all: $(TARGETS)

shared: all

#
# Clean everything...
#

clean:
	$(RM) $(OBJS) $(TARGETS)
	$(RM) mxmldoc-static libmxml.a


#
# Really clean everything...
#

distclean:	clean
	$(RM) config.cache config.log config.status
	$(RM) Makefile config.h
	$(RM) -r autom4te*.cache
	$(RM) *.bck *.bak


#
# Install everything...
#

install:	$(TARGETS) install-$(LIBMXML) install-libmxml.a
	$(INSTALL_DIR) $(BUILDROOT)$(bindir)
	$(INSTALL_BIN) mxmldoc $(BUILDROOT)$(bindir) 
	$(INSTALL_DIR) $(BUILDROOT)$(docdir)
	for file in $(DOCFILES); do \
		$(INSTALL_MAN) $$file $(BUILDROOT)$(docdir); \
	done
	$(INSTALL_DIR) $(BUILDROOT)$(includedir)
	$(INSTALL_DATA) *.h $(ROOT_PATH)/lib/include
	$(INSTALL_DIR) $(BUILDROOT)$(libdir)/pkgconfig
	$(INSTALL_DATA) mxml.pc $(BUILDROOT)$(libdir)/pkgconfig
	$(INSTALL_DIR) $(BUILDROOT)$(mandir)/man1
	$(INSTALL_MAN) doc/mxmldoc.man $(BUILDROOT)$(mandir)/man1/mxmldoc.1
	$(INSTALL_DIR) $(BUILDROOT)$(mandir)/man3
	$(INSTALL_MAN) doc/mxml.man $(BUILDROOT)$(mandir)/man3/mxml.3

install-libmxml.a:
	$(INSTALL_DIR) $(BUILDROOT)$(libdir)
	$(INSTALL_LIB) libmxml.a $(BUILDROOT)$(libdir)
	$(RANLIB) $(BUILDROOT)$(libdir)/libmxml.a

install-libmxml.so.1.4:
	$(INSTALL_DIR) $(ROOT_PATH)/lib
	$(INSTALL_LIB) libmxml.so.1.4 $(ROOT_PATH)/lib/lib
	$(RM) $(ROOT_PATH)/lib/liblibmxml.so
	$(LN) libmxml.so.1.4 $(ROOT_PATH)/lib/lib/libmxml.so
	$(RM) $(ROOT_PATH)/lib/lib/libmxml.so.1
	$(LN) libmxml.so.1.4 $(ROOT_PATH)/lib/lib/libmxml.so.1

install-libmxml.sl.1:
	$(INSTALL_DIR) $(BUILDROOT)$(libdir)
	$(INSTALL_LIB) libmxml.sl.1 $(BUILDROOT)$(libdir)
	$(RM) $(BUILDROOT)$(libdir)/libmxml.so
	$(LN) libmxml.sl.1 $(BUILDROOT)$(libdir)/libmxml.sl

install-libmxml.1.dylib:
	$(INSTALL_DIR) $(BUILDROOT)$(libdir)
	$(INSTALL_LIB) libmxml.1.dylib $(BUILDROOT)$(libdir)
	$(RM) $(BUILDROOT)$(libdir)/libmxml.dylib
	$(LN) libmxml.1.dylib $(BUILDROOT)$(libdir)/libmxml.dylib


#
# Uninstall everything...
#

uninstall: uninstall-$(LIBMXML) uninstall-libmxml.a
	$(RM) $(BUILDROOT)$(bindir)/mxmldoc
	$(RM) -r $(BUILDROOT)$(docdir)
	$(RM) $(BUILDROOT)$(includedir)/mxml.h
	$(RM) $(BUILDROOT)$(libdir)/pkgconfig/mxml.pc
	$(RM) $(BUILDROOT)$(mandir)/man1/mxmldoc.1
	$(RM) $(BUILDROOT)$(mandir)/man3/mxml.3

uninstall-libmxml.a:
	$(RM) $(BUILDROOT)$(libdir)/libmxml.a

#
# libmxml.a
#

libmxml.a:	$(LIBOBJS)	
	$(AR) -rc $@ $(LIBOBJS)
	$(STRIP) $@

$(LIBOBJS): %.o : %.c
	$(CC) $(CFLAGS) -c $< -o $@
	$(STRIPTOOL) -x -R .note -R .comment $*.o
	
libmxml.so:	$(LIBOBJS)
	$(LD) -shared -o $@ $^
	$(STRIPTOOL) $@
	$(INSTALL) -d $(ROOT_PATH)/lib/lib
	$(INSTALL) -d $(ROOT_PATH)/lib/include
	$(INSTALL) -m 644 *.h $(ROOT_PATH)/lib/include
	$(RM) $(ROOT_PATH)/lib/lib/libmxml.so
	$(INSTALL) -m 644 libmxml.so $(ROOT_PATH)/lib/lib
	
$(LIBOBJS):	mxml.h
mxml-entity.o mxml-file.o mxml-private.o: mxml-private.h

#
# mxmldoc
#

mxmldoc:	$(LIBMXML) mxmldoc.o
	$(CC) -L. $(LDFLAGS) -o $@ mxmldoc.o -lmxml $(LIBS)

mxmldoc-static:	libmxml.a mxmldoc.o
	$(CC) $(LDFLAGS) -o $@ mxmldoc.o libmxml.a $(LIBS)

mxmldoc.o:	mxml.h

root_fs:
	$(ROMFSINST) /lib/libmxml.so
#
# End of "$Id: Makefile.in 316 2007-11-23 02:15:07Z mike $".
#
