# inkf - yet another nkf with international language support
# Masashi Astro Tachibana

CONFIG_FILE = config
include $(CONFIG_FILE)

CXXFLAGS          += -I. -I./libapolloron/include
LDFLAGS           +=
LIBS              = libapolloron/lib/libapolloron.a
OBJS              = inkf.o
TARGET            = inkf
PREFIX            = /usr/local

ifeq ($(OS),Windows_NT)
  CXXFLAGS        +=
  #LDFLAGS        += -mno-cygwin
  TARGET          = inkf.exe
endif

.cc.o:
	$(CXX) $(CXXFLAGS) -c $<

$(TARGET): $(LIBS) $(OBJS)
	$(CXXLD) -o $@ $(OBJS) $(LIBS) $(LDFLAGS)
	$(STRIP) $@

libapolloron/lib/libapolloron.a: libapolloron/include/apolloron.h
	cd ./libapolloron && CXX=$(CXX) ./configure $(CONFIG_OPTIONS) && $(MAKE)
inkf.o: inkf.cc


install:
	$(CP) $(TARGET) $(PREFIX)/bin/
	mkdir -p $(PREFIX)/man
	mkdir -p $(PREFIX)/man/man1
	$(CP) inkf.1 $(PREFIX)/man/man1/

uninstall:
	$(RM) $(PREFIX)/bin/$(TARGET)
	$(RM) $(PREFIX)/man/man1/inkf.1
	@rmdir $(PREFIX)/man/man1 2>/dev/null || :
	@rmdir $(PREFIX)/man 2>/dev/null || :

clean:
	cd ./libapolloron; $(MAKE) clean
	$(RM) ./libapolloron/config
	$(RM) $(TARGET) $(OBJS) core $(TARGET).core *.stackdump .DS_Store ._*

distclean:
	cd ./libapolloron; $(MAKE) distclean
	$(RM) $(TARGET) $(OBJS) core $(TARGET).core *.stackdump
	$(RM) $(CONFIG_FILE)
