#
# (C) Copyright 2002
# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
#
# See file CREDITS for list of people who contributed to this
# project.
#
# This program 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 2 of
# the License, 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.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#


CFLAGS += -Wall
LIBXML=libxml.a
LIBXML_SHARED=libxml.so
LIBXML_SHARED_FULLNAME=libxml-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so

SOURCES := $(wildcard *.c)
OBJS := $(patsubst %.c, %.o, $(SOURCES))

#all:	$(LIBXML)
all:	$(OBJS)



# The variable $@ has the value of the target. In this case $@ = prog
#
#.c.o:
%.o: %.c
	${CC} ${CFLAGS} -c $<
#	$(STRIPTOOL) -x -R .note -R .comment $*.o
#

shared: all
	$(LD) $(LDFLAGS) -soname=$(LIBXML_SHARED).$(MAJOR_VERSION) \
		-o $(LIBXML_SHARED_FULLNAME) --whole-archive $(LIBXML) \
		--no-whole-archive $(TOPDIR)libc/misc/internals/interp.o \
		-L$(TOPDIR)lib -lc $(LDADD_LIBFLOAT) $(LIBGCC);
	$(INSTALL) -d $(TOPDIR)lib
	$(RM) $(TOPDIR)lib/$(LIBXML_SHARED_FULLNAME) $(TOPDIR)lib/$(LIBXML_SHARED).$(MAJOR_VERSION)
	$(INSTALL) -m 644 $(LIBXML_SHARED_FULLNAME) $(TOPDIR)lib
	$(LN) -sf $(LIBXML_SHARED_FULLNAME) $(TOPDIR)lib/$(LIBXML_SHARED)
	$(LN) -sf $(LIBXML_SHARED_FULLNAME) $(TOPDIR)lib/$(LIBXML_SHARED).$(MAJOR_VERSION)

$(LIBXML) ar-target: $(OBJS)
	$(AR) $(ARFLAGS) $(LIBXML) $(OBJS)
	$(INSTALL) -d $(TOPDIR)lib
	$(RM) $(TOPDIR)lib/$(LIBXML)
	$(INSTALL) -m 644 $(LIBXML) $(TOPDIR)lib

%.d: %.c
	@set -e; rm -f $@; \
	$(CC) -MM $(CPPFLAGS) $< > $@.$$$$; \
	sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g'< $@.$$$$ > $@; \
	rm -f $@.$$$$
clean:
	$(RM) *.[doa] $(LIBXML_SHARED)* $(LIBXML_SHARED_FULLNAME)*

-include $(SOURCES:.c=.d)
