#
#  Copyright (c) 1993 Thomas W. Corson
#  Copyright (c) 1993 VetMark Systems, Inc. d.b.a Information Dynamics
# 
#  Permission to use, copy, modify, distribute, and sell this software and 
#  its documentation for any purpose is hereby granted without fee, provided
#  that (i) the above copyright notices and this permission notice appear in
#  all copies of the software and related documentation, and (ii) the names of
#  Thomas W. Corson, VetMark Systems, or Information Dynamics may not be used 
#  in any advertising or publicity relating to the software without the 
#  specific, prior written permission of Thomas W. Corson and VetMark Systems.
#  
#  THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
#  EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
#  WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
#  
#  IN NO EVENT SHALL THOMAS W. CORSON OR VETMARK SYSTEMS, INC. BE LIABLE FOR
#  ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
#  OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
#  WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
#  LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
#  OF THIS SOFTWARE.
#
# This file was generated by `gxv' from `faxtool.G'.

# Parameters.

# This is the base directory for installation.
BASEDIR=/usr/local

# This is the directory where the binary will be installed.
BINDIR = $(BASEDIR)/bin

# This is the directory where the man pages will be installed.
MANDIR = $(BASEDIR)/man

# This is the directory where the online help files will be installed.
HELPDIR = $(BASEDIR)/lib/help

PROGRAM = faxtool
SOURCES.c = faxtool.c
SOURCES.h = faxtool.h
SOURCES.G = faxtool.G
STUBS.G = faxtool.G

PL_LOCALEDIR = locale/piglatin/LC_MESSAGES
EEC_LOCALEDIR = locale/EEC/LC_MESSAGES
I18N_LOCALEDIR = locale/I18N/LC_MESSAGES

VERSION = Linux
V_MAJOR = 1.3
V_MINOR = 32
DATE = 95/11/07
LANG = C

# Derived parameters.

SOURCES = \
	$(SOURCES.G) \
	$(SOURCES.h) \
	$(SOURCES.l) \
	$(SOURCES.y) \
	$(SOURCES.cps) \
	$(SOURCES.c)

TARGETS.c = \
	$(SOURCES.G:%.G=%_ui.c) \
	$(STUBS.G:%.G=%_stubs.c)

TARGETS.h = \
	$(SOURCES.G:%.G=%_ui.h) \
	$(SOURCES.l:%.l=%.h) \
	$(SOURCES.y:%.y=%.h) \
	$(SOURCES.cps:%.cps=%.h)

TARGETS.c.po = \
	$(SOURCES.c:%.c=%_labels.po) \
	$(TARGETS.c:%.c=%_labels.po)

TARGETS.c.mo = \
	$(TARGETS.c.po:%_labels.po=$(PL_LOCALEDIR)/%_labels.mo) \
	$(TARGETS.c.po:%_labels.po=$(EEC_LOCALEDIR)/%_labels.mo) \
	$(TARGETS.c.po:%_labels.po=$(I18N_LOCALEDIR)/%_labels.mo)

TARGETS.other = \
	$(TARGETS.c.po) \
	$(SOURCES.G:%.G=%.info)

TARGETS = \
	$(TARGETS.other) \
	$(TARGETS.h) \
	$(TARGETS.c)

OBJECTS = \
	$(SOURCES.c:%.c=%.o) \
	$(TARGETS.c:%.c=%.o)

RM = rm -rf
MV = mv -f

MP = makepo
MF = msgfmt

# Compiler flags.

.KEEP_STATE:

#
# If you are using gcc, comment out the above 2 defines and uncomment the 
# following 2 defines
#
CC = gcc
CFLAGS = -pipe -O2 -DSVR4

GXVFLAGS = -ansi -g -d faxtool_ui_labels
GUIDE_DIR = $(GUIDEHOME)

CPPFLAGS += -I$(GUIDE_DIR)/include -I$(OPENWINHOME)/include -DMAIN -DV_MAJOR=$(V_MAJOR) -DV_MINOR=$(V_MINOR)
#CPPFLAGS += -I/usr/local/src/faxtool-1.3/include/SunOS5 -I$(GUIDEHOME)/include -I$(OPENWINHOME)/include -DMAIN -DV_MAJOR=$(V_MAJOR) -DV_MINOR=$(V_MINOR)
LDFLAGS += -L$(GUIDEHOME)/lib -L$(OPENWINHOME)/lib

LDLIBS = -pipe -lguidexv -lguide -lxview -lolgx -lX11 -lc

debug:
	 CFLAGS = -g -DTRACE # -DSVR4

# Standard targets.

.INIT: lib include

all:	 $(TARGETS.other) $(PROGRAM) send-pr
objects: $(SOURCES.c) $(TARGETS.c) $(TARGETS.h) $(OBJECTS)
sources: $(SOURCES)
targets: $(SOURCES) $(TARGETS)

install: all
	if [ ! -d $(BINDIR) ]; then \
		mkdir -p $(BINDIR); \
	fi
	$(RM) $(BINDIR)/faxtool
	cp faxtool $(BINDIR)/faxtool
	chmod a+rx $(BINDIR)/faxtool
	if [ ! -d $(MANDIR)/man1 ]; then \
		mkdir -p $(MANDIR)/man1; \
	fi
	$(RM) $(MANDIR)/man1/faxtool.1
	cp faxtool.man $(MANDIR)/man1/faxtool.1
	chmod a+r $(MANDIR)/man1/faxtool.1
	if [ ! -d $(HELPDIR) ]; then \
		mkdir -p $(HELPDIR); \
	fi
	$(RM) $(HELPDIR)/faxtool.info
	cp faxtool.info $(HELPDIR)/faxtool.info
	chmod a+r $(HELPDIR)/faxtool.info
	if [ -d send-pr ]; then \
		cd send-pr; \
		make prefix=$(BASEDIR) install; \
		$(BASEDIR)/bin/install-sid net; \
		cd ..; \
	fi

$(PROGRAM) debug: $(SOURCES.c) $(TARGETS.c) $(TARGETS.h) $(OBJECTS)
	$(LINK.c) -o $(PROGRAM) $(OBJECTS) $(LDLIBS)

send-pr: FORCE
	if [ -d send-pr ]; then \
		cd send-pr; \
		make prefix=$(BASEDIR) all; \
		cd ..; \
	fi

dist:	$(SOURCES.c) $(SOURCES.h) $(SOURCES.G) $(STUBS.G) README faxtool.man
	if [ ! -d send-pr ]; then \
		mkdir send-pr; \
	else \
		cd send-pr; \
		make clean; \
	fi
	cd gnats; \
	chmod u+x mkdist; \
	mkdist ../send-pr $(VERSION); \
	cd ..
	$(RM) lib/*.a include/*.h
	tar cf faxtool$(VERSION).tar SCCS include lib *.icon faxtool.G *.c \
			 	     send-pr *.h faxtool.man *.info \
				     README Makefile VERSION

lib: FORCE
	@$(RM) -f $@/libguide.a; ln -s SunOS`uname -r | cut -c1`/libguide.a $@
	@$(RM) -f $@/libguidexv.a; ln -s SunOS`uname -r | cut -c1`/libguidexv.a $@

include: FORCE
	@$(RM) -f $@/c_varieties.h; ln -s SunOS`uname -r | cut -c1`/c_varieties.h $@
	@$(RM) -f $@/gcm.h; ln -s SunOS`uname -r | cut -c1`/gcm.h $@
	@$(RM) -f $@/gdd.h; ln -s SunOS`uname -r | cut -c1`/gdd.h $@
	@$(RM) -f $@/gfm.h; ln -s SunOS`uname -r | cut -c1`/gfm.h $@
	@$(RM) -f $@/gfm_ui.h; ln -s SunOS`uname -r | cut -c1`/gfm_ui.h $@
	@$(RM) -f $@/group.h; ln -s SunOS`uname -r | cut -c1`/group.h $@

locale:
	@test -d $@ || mkdir $@
	@test -d $@/piglatin/LC_MESSAGES || mkdir -p $@/piglatin/LC_MESSAGES
	@test -d $@/EEC/LC_MESSAGES || mkdir -p $@/EEC/LC_MESSAGES
	@test -d $@/I18N/LC_MESSAGES || mkdir -p $@/I18N/LC_MESSAGES

faxtool.man: faxtool.man.in
	sed -e 's/{VERSION}/$(VERSION)/g' \
	    -e 's@{DATE}@$(DATE)@g' faxtool.man.in > faxtool.man

README: README.in
	sed -e 's/{VERSION}/$(VERSION)/g' \
	    -e 's@{DATE}@$(DATE)@g' README.in > README

I18N-test: locale $(TARGETS.c.mo)

FORCE:

# Targets to be used by Saber-C.

saber_src:
	#load $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH) \
		$(SOURCES.c) $(TARGETS.c) $(LDLIBS)

saber_obj:
	#load $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH) $(OBJECTS) $(LDLIBS)

clean:
	if [ "$(GUIDEHOME)" ]; then \
		$(RM) $(SOURCES.G:%.G=%_ui.c) $(TARGETS.other) $(TARGETS.h) \
		$(OBJECTS) *.BAK *.delta core lib/*.a include/*.h \
		*% .make* .nse* *.po *.mo locale .sb/* ,*; \
		if [ -d send-pr ]; then \
			cd send-pr; \
			make clean; \
			cd ..; \
		fi;\
	else \
		$(RM) $(OBJECTS) *.BAK *.delta core lib/*.a include/*.h \
		*% .make* .nse* *.po *.mo locale .sb/* ,*; \
		if [ -d send-pr ]; then \
			cd send-pr; \
			make clean; \
			cd ..; \
		fi;\
	fi

%_ui.c: %.G
	@if [ "$(GUIDEHOME)" ]; then \
		if [ -f $*_stubs.c -a ! -w $*_stubs.c ]; then \
			$(RM) $*_stubs.c; \
			sccs edit -s $*_stubs.c; \
			$(GUIDEHOME)/bin/gxv $(GXVFLAGS) $*; \
			sccs delget -s -y"Generated by gxv" $*_stubs.c; \
		else \
			$(GUIDEHOME)/bin/gxv $(GXVFLAGS) $*; \
		fi \
	fi

%_ui.h: %_ui.c
	@touch $@

%_stubs.c: %_ui.c
	@touch $@

%.info: %_ui.c
	@touch $@

%_labels.po: %.c
	@$(RM) $*_labels.po

	@if [ `uname -r | cut -c1` = 4 ]; then \
		xgettext -n -p $(@D) -o $(@F) $*.c; \
		$(RM) $*_labels.po.po; \
	else \
		xgettext -n -j -p $(@D) $*.c; \
	fi

	@if [ ! -f  $*_labels.po ]; then \
		touch $*_labels.po; \
	fi

$(PL_LOCALEDIR)/%_labels.po: %_labels.po
	@cp $*_labels.po $(PL_LOCALEDIR)/$*_labels.po
	@echo "$(MP) -p $(PL_LOCALEDIR)/$*_labels.po"
	-@/bin/sh -c "cd $(PL_LOCALEDIR); $(MP) -p $*_labels.po"
	-@$(RM) $(PL_LOCALEDIR)/$*_labels.po

	@if [ ! -f  $(PL_LOCALEDIR)/$*_labels.po.new ]; then \
		touch  $(PL_LOCALEDIR)/$*_labels.po.new; \
	fi

	@if [ "$(OSVER)" = "4" ]; then \
		$(MV) $(PL_LOCALEDIR)/$*_labels.po.new \
			$(PL_LOCALEDIR)/$*_labels.po; \
	else \
		sed -e "s/msgstr\"/msgstr \"/g" \
			$(PL_LOCALEDIR)/$*_labels.po.new > \
			$(PL_LOCALEDIR)/$*_labels.po; \
		$(RM) $(PL_LOCALEDIR)/$*_labels.po.new; \
	fi

$(EEC_LOCALEDIR)/%_labels.po: %_labels.po
	@cp $*_labels.po $(EEC_LOCALEDIR)/$*_labels.po
	@echo "$(MP) -e $(EEC_LOCALEDIR)/$*_labels.po"
	-@/bin/sh -c "cd $(EEC_LOCALEDIR); $(MP) -e $*_labels.po"
	-@$(RM) $(EEC_LOCALEDIR)/$*_labels.po

	@if [ ! -f  $(EEC_LOCALEDIR)/$*_labels.po.new ]; then \
		touch  $(EEC_LOCALEDIR)/$*_labels.po.new; \
	fi

	@if [ "$(OSVER)" = "4" ]; then \
		$(MV) $(EEC_LOCALEDIR)/$*_labels.po.new \
			$(EEC_LOCALEDIR)/$*_labels.po; \
	else \
		sed -e "s/msgstr\"/msgstr \"/g" \
			$(EEC_LOCALEDIR)/$*_labels.po.new > \
			$(EEC_LOCALEDIR)/$*_labels.po; \
		$(RM) $(EEC_LOCALEDIR)/$*_labels.po.new; \
	fi

$(I18N_LOCALEDIR)/%_labels.po: %_labels.po
	@cp $*_labels.po $(I18N_LOCALEDIR)/$*_labels.po
	@echo "$(MP) -v 3 $(I18N_LOCALEDIR)/$*_labels.po"
	-@/bin/sh -c "cd $(I18N_LOCALEDIR); $(MP) -v 3 $*_labels.po"
	-@$(RM) $(I18N_LOCALEDIR)/$*_labels.po

	@if [ ! -f  $(I18N_LOCALEDIR)/$*_labels.po.new ]; then \
		touch  $(I18N_LOCALEDIR)/$*_labels.po.new; \
	fi

	@if [ "$(OSVER)" = "4" ]; then \
		$(MV) $(I18N_LOCALEDIR)/$*_labels.po.new \
			$(I18N_LOCALEDIR)/$*_labels.po; \
	else \
		sed -e "s/msgstr\"/msgstr \"/g" \
			$(I18N_LOCALEDIR)/$*_labels.po.new > \
			$(I18N_LOCALEDIR)/$*_labels.po; \
		$(RM) $(I18N_LOCALEDIR)/$*_labels.po.new; \
	fi

$(PL_LOCALEDIR)/%_labels.mo: $(PL_LOCALEDIR)/%_labels.po
	-@$(RM) $(PL_LOCALEDIR)/$*_labels.mo
	@echo "$(MF) $(PL_LOCALEDIR)/$*_labels.po"
	-@/bin/sh -c "cd $(PL_LOCALEDIR); $(MF) $*_labels.po"

	@if [ ! -f  $(PL_LOCALEDIR)/$*_labels.mo ]; then \
		touch  $(PL_LOCALEDIR)/$*_labels.mo; \
	fi

$(EEC_LOCALEDIR)/%_labels.mo: $(EEC_LOCALEDIR)/%_labels.po
	-@$(RM) $(EEC_LOCALEDIR)/$*_labels.mo
	@echo "$(MF) $(EEC_LOCALEDIR)/$*_labels.po"
	-@/bin/sh -c "cd $(EEC_LOCALEDIR); $(MF) $*_labels.po"

	@if [ ! -f  $(EEC_LOCALEDIR)/$*_labels.mo ]; then \
		touch  $(EEC_LOCALEDIR)/$*_labels.mo; \
	fi

$(I18N_LOCALEDIR)/%_labels.mo: $(I18N_LOCALEDIR)/%_labels.po
	-@$(RM) $(I18N_LOCALEDIR)/$*_labels.mo
	@echo "$(MF) $(I18N_LOCALEDIR)/$*_labels.po"
	-@/bin/sh -c "cd $(I18N_LOCALEDIR); $(MF) $*_labels.po"

	@if [ ! -f  $(I18N_LOCALEDIR)/$*_labels.mo ]; then \
		touch  $(I18N_LOCALEDIR)/$*_labels.mo; \
	fi

