# 
# Copyright (C) 1994 
#            Olav Woelfelschneider (wosch@rbg.informatik.th-darmstadt.de)
#
# This file is part of my g3fax printer driver package
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#

##############################################################################
#
# Edit this if you are not satisfied
#
CC		=	gcc
CFLAGS		=	-O3 -fomit-frame-pointer
LDFLAGS		=	-s
LIBS		=	
#
# This is where 'make install' and 'make installman' copy the stuff
#
BINDIR		=	/usr/local/bin
MANDIR		=	/usr/local/man/man1
#
# End of configuration section
#
##############################################################################
#
# KEEP OFF! (-:
#
SRCS		=	main.c g3decode.c pnmdecode.c printer.c
OBJS		=	main.o g3decode.o pnmdecode.o printer.o

TARGET		=	g3tobj
LINKS		=	g3tolq pnmtobj pnmtolq

all: $(TARGET)

ifeq (.depend,$(wildcard .depend))
include .depend
else
DEPEND=needdepend
endif

$(TARGET): $(DEPEND) $(OBJS) $(OBJS)
	$(CC) $(LDFLAGS) -o $(TARGET) $(OBJS) $(LIBS) $(XLIBS)
	for file in $(LINKS); do \
	  if [ ! -x $$file ]; then \
	    ln -s $(TARGET) $$file; \
	  fi;\
	done

install: $(TARGET)
	install -c -m 755 $(TARGET) $(BINDIR)
	(cd $(BINDIR); for file in $(LINKS); do \
	  if [ ! -x $$file ]; then \
	    ln -s $(TARGET) $$file; \
	  fi;\
	done)

installman:
	cp $(TARGET).1 $(MANDIR)
	(cd $(MANDIR); for file in $(LINKS); do \
	  if [ ! -x $$file.1 ]; then \
	    ln -s $(TARGET).1 $$file.1; \
	  fi;\
	done)

clean:
	rm -f *.o $(TARGET) $(LINKS)

proper:
	rm -f *.o $(TARGET) $(LINKS) .depend

needdepend: depend
	@echo
	@echo "Dependency information created, please re-run make and ignore"
	@echo "the error that follows."
	@echo
	@exit 1

depend:
	$(CPP) -MM $(CFLAGS) $(SRCS) >.depend

