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

OBJS = gd.o            gdfontg.o       gdfontl.o       gdfontmb.o      \
        gdfonts.o       gdfontt.o       gdlucidab10.o   gdlucidab12.o   \
        gdlucidab14.o   gdlucidan10.o   gdlucidan12.o   gdlucidan14.o \
        gdlucidan10l2.o  gdlucidab12l2.o

all: $(EXEC)

CFLAGS += -I../include

%.o: %.c
	$(CC) $(CFLAGS) -c $< -o $*.o

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

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

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

romfs:

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

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