VERSION=1.4
CFLAGS=-DVERSION=\"$(VERSION)\" -Wall#-O2 #-DVERBOSE=1
CC= gcc
LDFLAGS= #-s # strip symbols, done while installing
GZIP= gzip
INSTALL= /usr/bin/ginstall -c

prefix=/usr

SOURCES= toascii.c todos.c fromdos.c
EXECS= $(SOURCES:.c=)
MANS= $(SOURCES:.c=.1) 
MANGZ= $(SOURCES:.c=.1.gz)

.PHONY: all clean default install man

all default: $(EXECS) $(MANGZ)

clean:
	rm -f *.o *~ core $(EXECS) $(MANGZ)

man: $(MANGZ)

install: all
	for h in $(EXECS); do $(INSTALL) -m 755 $$h $(prefix)/bin/; done
	for h in $(MANGZ); do $(INSTALL) -m 644 $$h $(prefix)/man/man1/; done

release: all clean
	(cd .. && tar czf todos-$(VERSION).tgz todos-$(VERSION) )
	cp -u todos-$(VERSION).lsm ..

fromdos: fromdos.c Makefile
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $<

toascii: toascii.c Makefile
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $<

todos: todos.c Makefile
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $<

fromdos.1.gz: fromdos.1
	$(GZIP) -c $< >$@

toascii.1.gz: toascii.1
	$(GZIP) -c $< >$@

todos.1.gz: todos.1
	$(GZIP) -c $< >$@

#avoid implicit checking
Makefile:
	@echo Error

$(SOURCES) $(MANS):
	@echo Error
