# automatically created by config.sh - do not modify
# CC=gcc
# CFLAGS=-g -Wall
# AR=ar
GRUTATXT=no
MP_DOCCER=no
DOCS=$(ADD_DOCS)
VERSION=1.0.9
PREFIX=$(DESTDIR)/usr
DOCDIR=$(DESTDIR)/usr/share/doc/mp-5

# -*- Mode: sh

TARGET=libmpdm.a
LIB=$(TARGET)

all: $(TARGET) docs

PROJ=mpdm

ADD_DOCS=RELEASE_NOTES
GRUTATXT_DOCS=doc/mpdm_overview.html
MP_DOCCER_DOCS=doc/mpdm_api.txt
G_AND_MP_DOCS=doc/mpdm_api.html

OBJS=mpdm_v.o mpdm_a.o mpdm_h.o mpdm_d.o mpdm_s.o mpdm_f.o \
	mpdm_r.o gnu_regex.o

DIST_TARGET=/tmp/$(PROJ)-$(VERSION)

##################################################################

version:
	@echo $(VERSION)

.c.o:
	$(CC) $(CFLAGS) `cat config.cflags` -c $<

dep:
	gcc -MM *.c > makefile.depend

$(LIB): $(OBJS)
	$(AR) rv $(LIB) $(OBJS)

stress: stress.c $(LIB)
	$(CC) $(CFLAGS) `cat config.ldflags` stress.c -L. -lmpdm -o $@

.SUFFIXES: .txt .html

.txt.html:
	grutatxt < $< > $@

doc/mpdm_api.txt: mpdm_*.c
	mp_doccer mpdm_*.c -o doc/mpdm_api -f grutatxt \
	-t "MPDM C API" \
	-b "This reference documents version $(VERSION) of the C API." \
	-a 'Angel Ortega - angel@triptico.com'

docs: $(DOCS)

docsclean:
	rm -f doc/mpdm_api.txt doc/*.html

clean:
	rm -f $(TARGET) $(LIB) $(OBJS) *.o tags *.tar.gz stress

distclean: clean
	rm -f config.h config.cflags config.ldflags makefile.opts .config.log Makefile

realclean: distclean docsclean

realdistclean: realclean

distcopy: distclean
	mkdir -p $(DIST_TARGET) ; \
	tar cf - * | (cd $(DIST_TARGET) ; tar xf -)

dist: distcopy
	(cd /tmp ; tar czf - $(PROJ)-$(VERSION)/* ) > $(PROJ)-$(VERSION).tar.gz ; \
	rm -rf $(DIST_TARGET)

.po.mo:
	msgfmt -o $@ $<

build-mo:
	for a in po/*.po ; do \
		B=`basename $$a .po` ; \
		mkdir -p po/$$B/LC_MESSAGES ; \
		msgfmt -o po/$$B/LC_MESSAGES/stress.mo $$a ; \
	done

installdoc:
	install -d $(DOCDIR)
	install -m 644 doc/* $(DOCDIR)/
	for f in README AUTHORS COPYING TODO RELEASE_NOTES ; do \
		[ -f $$f ] && install -m 644 $$f $(DOCDIR)/$$f.$(PROJ) ; \
	done
gnu_regex.o: gnu_regex.c config.h
mpdm_a.o: mpdm_a.c config.h mpdm.h
mpdm_d.o: mpdm_d.c config.h mpdm.h
mpdm_f.o: mpdm_f.c config.h mpdm.h
mpdm_h.o: mpdm_h.c config.h mpdm.h
mpdm_r.o: mpdm_r.c config.h mpdm.h
mpdm_s.o: mpdm_s.c config.h mpdm.h
mpdm_v.o: mpdm_v.c config.h mpdm.h
stress.o: stress.c mpdm.h
