##   Makefile for Lucid Widget Library
##   Copyright (C) 1994 Lucid, Inc.
##   Copyright (C) 1995 Tinker Systems and INS Engineering Corp.
##   Copyright (C) 1994, 1995 Board of Trustees, University of Illinois
##   Copyright (C) 1996, 1997 Sun Microsystems, Inc.

## This file is part of the Lucid Widget Library.

## The Lucid Widget Library 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, or (at your option)
## any later version.

## The Lucid Widget Library 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 XEmacs; see the file COPYING.  If not, write to
## the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
## Boston, MA 02111-1307, USA.

## For performance and consistency, no built-in rules
.SUFFIXES:
.SUFFIXES: .c .o .i .h

srcdir=@srcdir@

@SET_MAKE@
SHELL=/bin/sh
RM = rm -f
AR = ar cq

CC=@CC@
CPP=@CPP@
CFLAGS=@CFLAGS@
LDFLAGS=@LDFLAGS@
CPPFLAGS=@CPPFLAGS@
RANLIB=@RANLIB@

#define NOT_C_CODE
#include "../src/config.h"

#ifdef USE_GNU_MAKE
vpath %.c @srcdir@
vpath %.h @srcdir@
#else
VPATH=@srcdir@
#endif

#ifdef ENERGIZE
EZ_OBJS =\
 energize/blpsheet.o energize/build.o energize/classbr_ps.o\
 energize/ctreebr_ps.o energize/debuggerps.o energize/editmode.o\
 energize/leb_psheet.o energize/projectdisp.o energize/projectps.o\
 energize/search.o energize/target.o
ENERGIZEP = -DENERGIZE
EZ_SUBDIR = ez_dialog
#endif

objs = lwlib.o lwlib-utils.o lwlib-config.o $(EZ_OBJS) @lwlib_objs@

all: $(EZ_SUBDIR) liblw.a

c_switch_general=@c_switch_general@
c_switch_window_system=@c_switch_window_system@
c_switch_all=@c_switch_all@
ld_switch_general=@ld_switch_general@
ld_switch_window_system=@ld_switch_window_system@
ld_switch_all=@ld_switch_all@
ld_libs_general=@ld_libs_general@
ld_libs_window_system=@ld_libs_window_system@
ld_libs_all=@ld_libs_all@

cppflags = $(CPPFLAGS) -I. $(c_switch_all) $(ENERGIZEP)
cflags = $(CFLAGS) $(cppflags)

ALL_CFLAGS= $(CFLAGS) $(CPPFLAGS) -I. $(c_switch_all) $(ENERGIZEP)
#ifdef SOLARIS2
%.o : %.c
#else
.c.o:
#endif
	$(CC) -c $(cflags) $<

## Create preprocessor output (debugging purposes only)
.c.i:
	$(CC) -P $(cppflags) $<

liblw.a: $(objs)
	$(RM) $@
	$(AR) $@ $(objs)
	@-test -n "$(RANLIB)" && $(RANLIB) $@

#ifdef ENERGIZE
ez_dialog:
	cd energize && $(RECURSIVE_MAKE)
#endif

.PHONY: mostlyclean clean distclean realclean extraclean
mostlyclean:
	$(RM) liblw.a liblw_pure_*.a *.o *.i core
clean: mostlyclean
#ifdef ENERGIZE
	cd energize && $(RECURSIVE_MAKE) clean
#endif
distclean: clean
	$(RM) Makefile Makefile.in config.h TAGS
realclean: distclean
extraclean: distclean
	$(RM) *~ \#*

CONFIG_H = ../src/config.h config.h

lwlib-config.o:	lwlib.h $(CONFIG_H)
lwlib-Xaw.o:	lwlib.h lwlib-internal.h lwlib-Xaw.h $(CONFIG_H)
lwlib-Xlw.o:	lwlib.h lwlib-internal.h lwlib-Xlw.h xlwmenu.h $(CONFIG_H)
lwlib-Xm.o:	lwlib.h lwlib-internal.h lwlib-utils.h lwlib-Xm.h $(CONFIG_H)
lwlib-Xm.o:	$(CONFIG_H)
lwlib-utils.o:	lwlib-utils.h $(CONFIG_H)
lwlib.o:	lwlib.h lwlib-internal.h lwlib-utils.h $(CONFIG_H)
lwlib.o:	lwlib-Xlw.h lwlib-Xm.h lwlib-Xaw.h $(CONFIG_H)
xlwmenu.o:	lwlib.h xlwmenu.h xlwmenuP.h $(CONFIG_H)
xlwscrollbar.o:	lwlib.h xlwscrollbar.h xlwscrollbarP.h $(CONFIG_H)
