Makefile
author Oleksandr Gavenko <gavenkoa@gmail.com>
Fri, 02 Sep 2011 02:15:39 +0300
changeset 48 5ceb37a4f386
parent 46 86c0184efac7
child 50 37931fbb857f
permissions -rw-r--r--
p.p.

# Available target:
#
#   all         build dictionaries
#   install     install dictionaries, so they been available in stardict, may require root permission
#   uninstall   remove dictionaries, they been unavailable in stardict, may require root permission
#   install-local install dictionaries in user HOME dir, so they been available in stardict for that user
#   uninstall-local remove dictionaries from user HOME directory
#   install-local-symlink create symlink from installed dir to user HOME dir, so dictionaries been available in stardict
#   uninstall-local-symlink remove symlink from user HOME directory

DICTNAME_PREFIX = gadict

ifeq '$(origin prefix)' 'undefined'
  ifeq '$(shell id -u)' '0'
    prefix = /usr/local
  else
    prefix = $(HOME)/usr
  endif
endif
datarootdir = $(prefix)/share
datadir = $(datarootdir)/dictd

C5_FILES := $(wildcard *.c5)
DICT_FILES := $(C5_FILES:.c5=.dict)
DICTDZ_FILES := $(C5_FILES:.c5=.dict.dz)
INDEX_FILES := $(C5_FILES:.c5=.index)


.PHONY: all
all: dist

.PHONY: dist
dist: $(DICTDZ_FILES) $(INDEX_FILES)

#  --case-sensitive
%.dict %.index: %.c5
	sed '/^#/d' $< | dictfmt  -c5 \
	--headword-separator '; ' --break-headwords \
	--utf8 --allchars \
	-u "`sed -n '\|http://[[:print:]]\+/|{s=^.*\(http://\)=\1=;p;q;}' $<`" \
	-s "`sed -n '/^ABOUT: /{s=ABOUT: ==;p;q;}' $<`" \
	$*

%.dict.dz: %.dict
	dictzip -c $< >$@

.PHONY: install
install: dist
	mkdir -p $(datadir)
	for f in $(DICTDZ_FILES) $(INDEX_FILES); do \
		install -m 644 $$f $(datadir); \
	done

.PHONY: uninstall
uninstall:
	for f in $(DICTDZ_FILES) $(INDEX_FILES); do \
		rm -f $(datadir)/$$f; \
	done

.PHONY: distclean
distclean: clean

.PHONY: clean
clean:
	rm -f $(DICTDZ_FILES) $(INDEX_FILES);