INSTDIR=../inst
PKG_CPPFLAGS = -Ilibunrtf -DHAVE_CONFIG_H -DPKGDATADIR=\"../share\"

LIBUNRTF = \
	libunrtf/attr.o libunrtf/convert.o libunrtf/error.o libunrtf/hash.o libunrtf/main.o \
	libunrtf/malloc.o	libunrtf/my_iconv.o libunrtf/output.o libunrtf/parse.o libunrtf/path.o \
	libunrtf/unicode.o libunrtf/user.o libunrtf/util.o libunrtf/word.o

UNRTF = unrtf$(WIN)

# On OSX we need to link iconv
MACFLAGS = $(subst -framework,-liconv -framework,$(FOUNDATION_LIBS))

# On Windows we need to link Riconv and winsock
WINFLAGS = $(subst 64,-lws2_32 $(LIBR) -lRiconv,$(subst 32,64,$(WIN)))

all: clean $(UNRTF)

$(UNRTF): $(LIBUNRTF) 
	$(CC) $(CFLAGS) -o $(UNRTF) $(LIBUNRTF) $(MACFLAGS) $(WINFLAGS) 
	mkdir -p $(INSTDIR)/bin
	cp -f $(UNRTF) $(INSTDIR)/bin/
	cp -Rf share $(INSTDIR)/

clean:
	rm -Rf $(LIBUNRTF) $(OBJECTS) $(SHLIB) $(UNRTF)
