# $Id: Makefile,v 1.12 1991/09/20 18:05:29 steve Exp $

ifndef MAKEINCDIR
  MAKEINCDIR	:= $(shell pwd)
endif

#
# Uncomment the following if you are only interested in UDAPE because of the
# components it contains that are needed by XGKS.
#
#XGKS_ONLY	:= xxx

#
# No further modifications *should* be necessary.
#

NAME		:= udape
VERSION_FILE	:= patchlevel.h
LIBOBJS		:= $(addprefix udposix/, \
			$(shell $(MAKE) -C udposix LIBOBJS.echo \
			    MAKEINCDIR=$(MAKEINCDIR)))
ifndef XGKS_ONLY
  LIBOBJS	:= $(LIBOBJS) \
		   $(addprefix misc/, \
			$(shell $(MAKE) -C misc    LIBOBJS.echo \
			    MAKEINCDIR=$(MAKEINCDIR))) \
		   $(addprefix udres/, \
			$(shell $(MAKE) -C udres   LIBOBJS.echo \
			    MAKEINCDIR=$(MAKEINCDIR))) \
		   $(addprefix udunits/, \
			$(shell $(MAKE) -C udunits LIBOBJS.echo \
			    MAKEINCDIR=$(MAKEINCDIR)))
SA_OBJS		:= $(addprefix udunits/, \
			$(shell $(MAKE) -C udunits SA_OBJS.echo \
			    MAKEINCDIR=$(MAKEINCDIR)))
endif

#
# The following is user-contributed and may be incorrect in that the
# LIBO_LIBS variable is for AIX shared-library generation.
#
ifeq (domainos, $(OS_NAME))
  LIBO_LIBS   := -L/usr/lib/X11 -lX11 -lm -lc
else
  ifeq (hpux, $(OS_NAME))
    LIBO_LIBS := -Wl,-L,/usr/lib/X11R4 -lX11 -lm -lc
  else
    LIBO_LIBS := -lX11 -lm -lc
  endif
endif


include		$(MAKEINCDIR)/defs.gmk

SUBDIRS		:= udposix fortc
ifndef XGKS_ONLY
  SUBDIRS	:= $(SUBDIRS) misc udres udunits
endif

#
# The sources in this directory:
#
MANIFEST	:= README udape.1 udape.3 patchlevel.h Makefile defs.gmk \
		   rules.gmk

all:		all.subdirs
ifdef LIBOBJS
all:		lib$(NAME).a
endif
ifeq (sunos_sharable, $(OS_NAME)_$(LIBTYPE))
  ifdef SA_OBJS
    all:	lib$(NAME).sa.$(release_no) 
  endif
  all:		lib$(NAME).so.$(release_no)
endif
ifndef XGKS_ONLY
	@$(MAKE) _subdirs SUBDIRS=udres	  GOAL=udrdb
	@$(MAKE) _subdirs SUBDIRS=udunits GOAL=udunits
endif

ifdef LIBOBJS
install::	$(LIBDIR) $(LIBDIR)/lib$(NAME).a
endif
install::	$(BINDIR) \
		$(ETCDIR) \
		$(INCDIR) \
		$(MANDIR) \
		$(MANDIR)/man1 \
		$(MANDIR)/man3 \
		install.subdirs \
		$(MANDIR)/man1/udape.1 \
		$(MANDIR)/man3/udape.3
ifeq ($(MAKELEVEL),0)
  ifdef CATMAN
	$(CATMAN) -w -M $(MANDIR) 13
  endif
endif

ifeq (sunos_sharable, $(OS_NAME)_$(LIBTYPE))
  ifdef SA_OBJS
    install:	$(LIBDIR)/lib$(NAME).sa.$(release_no)
  endif
  install:	$(LIBDIR)/lib$(NAME).so.$(release_no)
endif

clean::		clean.subdirs
	rm -f lib$(NAME).*

realclean::	realclean.subdirs
	rm -f lib$(NAME).*

%.o:;

include $(MAKEINCDIR)/rules.gmk
