VERSION=1.3
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= toascii todos fromdos
MANS= toascii.1 todos.1 fromdos.1
MANGZ= toascii.1.gz todos.1.gz fromdos.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) -s -m 755 $$h $(prefix)/bin/; done
	for h in $(MANGZ); do $(INSTALL) -m 644 $$h $(prefix)/man/man1/; done

release: all
	rm -f *.o *~ core $(EXECS) $(MANGZ)
	(cd .. && tar cvzf 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 Makefile
	$(GZIP) -c $< >$@

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

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

#avoid implicit checking
Makefile:
	@echo Error

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