
EXEC = librrd_png.a librrd_png.o
ifdef EXTRALIBS_SHARED
EXEC += librrd_png.so
endif

OBJS =         png.o           \
        pngerror.o      \
        pngget.o        \
        pngmem.o        \
        pngpread.o      \
        pngread.o       \
        pngrio.o        \
        pngrtran.o      \
        pngrutil.o      \
        pngset.o        \
        pngtrans.o      \
        pngwio.o        \
        pngwrite.o      \
        pngwtran.o      \
        pngwutil.o

all: $(EXEC)

CFLAGS += -I../include -I../${ZLIBDIR}

librrd_png.a: $(OBJS)
	rm -f librrd_png.a
	$(AR) cr librrd_png.a $(OBJS)
	$(RANLIB) librrd_png.a

librrd_png.o: $(OBJS)
	$(LD) -r -s --warn-common --warn-once -z combreloc -o librrd_png.o $(OBJS)

librrd_png.so: librrd_png.a
	rm -f librrd_png.so
	$(LD) -s -shared --warn-common --warn-once -z combreloc \
		-soname librrd_png.so.0 -o librrd_png.so.0 \
		-rpath=/tmp/var/bin -rpath-link=$(UCLIBCDIR)lib \
		--whole-archive librrd_png.a --no-whole-archive \
		$(UCLIBCDIR)libc/misc/internals/interp.o \
		-L${UCLIBCDIR}lib \
		-lc -lm
	ln -s librrd_png.so.0 librrd_png.so

romfs:

install:
ifdef EXTRALIBS_SHARED
	install -d $(INSTALLDIR)/lib
	install librrd_png.so.0 $(INSTALLDIR)/lib/librrd_png.so.0
endif

clean:
	rm -f $(EXEC) librrd_png.so* *.gdb *.elf *.o *.s *.i
