CFLAGS    = $(CFLAGSIN)
LDFLAGS   = $(LDFLAGSIN)
LIBTARGET = $(LIBTARGETIN)

SIMPLE_OBJS   = charsets.o \
                is_ws.o \
                strsearch.o

NEWSTR_OBJS   = entities.o \
                gb18030.o \
                latex.o \
		latex_parse.o \
                str.o \
                str_conv.o \
                unicode.o \
                utf8.o

CONTAIN_OBJS  = fields.o \
                intlist.o \
                slist.o \
                vplist.o \
                xml.o \
                xml_encoding.o

BIBL_OBJS     = bibl.o \
                bu_auth.o \
                iso639_1.o \
                iso639_2.o \
                iso639_3.o \
                marc_auth.o \
                name.o \
                notes.o \
                pages.o \
                reftypes.o \
                serialno.o \
                title.o \
		type.o \
                url.o

INPUT_OBJS    = bibtexin.o bibtextypes.o \
		biblatexin.o bltypes.o \
		copacin.o copactypes.o \
		endin.o endtypes.o \
		endxmlin.o \
		generic.o \
		isiin.o isitypes.o \
		medin.o \
		nbibin.o nbibtypes.o \
		modsin.o modstypes.o marc_auth.o \
		risin.o ristypes.o \
		ebiin.o wordin.o

OUTPUT_OBJS   = adsout.o \
		biblatexout.o \
                bibtexout.o \
                endout.o \
                isiout.o \
                modsout.o \
		nbibout.o \
                risout.o \
                wordout.o

BIBCORE_OBJS  = $(SIMPLE_OBJS) \
                $(NEWSTR_OBJS) \
                $(CONTAIN_OBJS) \
                $(BIBL_OBJS) \
                bibcore.o

BIBUTILS_OBJS = $(INPUT_OBJS) \
                $(OUTPUT_OBJS) \
                bibutils.o

SONAME=libbibutils.so.$(MAJORVERSION)
SOMINOR=$(MINORVERSION)
SOFULL=$(SONAME).$(SOMINOR)

all: $(LIBTARGET)

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

libbibutils.so: $(BIBCORE_OBJS) $(BIBUTILS_OBJS)
	$(CC) $(LDFLAGS) -shared -Wl,-soname,$(SONAME) -o $(SOFULL) $^
	ln -sf $(SOFULL) $(SONAME)
	ln -sf $(SOFULL) libbibutils.so

bibutils.dll: $(BIBCORE_OBJS) $(BIBUTILS_OBJS)
	$(CC) $(LDFLAGS) -shared -Wl,-soname,$(SONAME) -o $@ $^
	cp $@ ../bin
	cp $@ ../test

install:
	echo INSTALLING LIBRARIES TO $(LIBINSTALLDIR)
	mkdir -p $(LIBINSTALLDIR)
	cp -P $(SOFULL) $(SONAME) $(LIBTARGET) $(LIBINSTALLDIR)

clean: 
	rm -f *.o core

realclean:
	rm -f *.o *.a *.so $(SONAME) $(SOFULL) core

test:
