#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL.  You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation.  Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation.  All Rights
# Reserved.

DEPTH=../../..
topsrcdir	= @top_srcdir@
srcdir		= @srcdir@
VPATH		= @srcdir@

include $(DEPTH)/config/autoconf.mk

include $(topsrcdir)/config/config.mk

TOOLKIT_GFX_LIB     = -lgfx$(MOZ_TOOLKIT)
TOOLKIT_WIDGET_LIB  = -lwidget$(MOZ_TOOLKIT)
TOOLKIT_BASE_LIB    = -lgmbase$(MOZ_TOOLKIT)

ifneq (,$(filter gtk, $(MOZ_TOOLKIT)))
TOOLKIT_CFLAGS = \
	-DWIDGET_DLL=\"libwidgetgtk.so\" \
	-DGFXWIN_DLL=\"libgfxgtk.so\" \
	$(TK_GTK_CFLAGS)

TOOLKIT_CPPSRCS = \
	nsGTKMain.cpp \
	nsGTKMenu.cpp

TOOLKIT_LIBS = $(TK_GTK_LIBS)
else
ifneq (,$(filter motif, $(MOZ_TOOLKIT)))
TOOLKIT_CFLAGS = \
	-DWIDGET_DLL=\"libwidgetmotif.so\" \
	-DGFXWIN_DLL=\"libgfxmotif.so\" \
	$(TK_MOTIF_CFLAGS)

TOOLKIT_CPPSRCS = \
	nsMotifMenu.cpp \
	nsUnixMain.cpp

TOOLKIT_LIBS = $(TK_MOTIF_LIBS) $(XLDFLAGS) $(XLIBS)

endif
endif

CPPSRCS = \
	Scribble.cpp    \
	main.cpp	\
	$(NULL)

CFLAGS += $(TOOLKIT_CFLAGS)

INCLUDES+= -I$(PUBLIC)/raptor -I$(PUBLIC)/xpcom -I$(PUBLIC)/shell

DIRS	=

ifdef MOZ_OJI
	JSJ_LIB = -ljsj
endif

OBJS	= $(CPPSRCS:.cpp=.o)

EX_LIBS = \
	-L$(DIST)/bin \
	-lraptorbase    \
	-lpref \
	-lraptorbase \
	$(TOOLKIT_WIDGET_LIB) \
	-lraptorgfx \
	$(TOOLKIT_GFX_LIB) \
	-lraptorhtml \
	$(DIST)/lib/libraptorhtmlforms_s.a \
	$(TOOLKIT_BASE_LIB) \
	-lraptorhtmlpars \
	-lraptorview \
	-lreg \
	-labouturl \
	-lfileurl \
	-lftpurl \
	-lgophurl \
	-lhttpurl \
	-limg \
	$(PNG_LIBS) \
	$(JPEG_LIBS) \
	-ljs \
	-ljsdom \
	$(DIST)/lib/libjsdomcore_s.a \
	$(JSJ_LIB) \
	-lmimetype \
	-lnetcache \
	-lnetcnvts \
	-lnetlib \
	-lnetutil \
	-lnetwork \
	-lpwcac \
	-lraptorwebwidget \
	-lreg \
	-lremoturl \
	-lsecfree \
	-lstubnj \
	-lstubsj \
	-ltestdynamic \
	-lutil \
	-lxp \
	-lxpcom \
	-lutil \
	-lxp \
	-lxpcom \
	$(ZLIB_LIBS) \
	-lraptorplugin \
	-ldbm \
	$(NULL)

PROGS   = main

TARGETS = $(PROGS)

include $(topsrcdir)/config/rules.mk

$(PROGS): $(OBJS) # $(EX_LIBS)
	@$(MAKE_OBJDIR)
ifeq ($(OS_ARCH),Linux)
	$(CCC) -rdynamic -o $@ $(OBJS) $(LDFLAGS) $(EX_LIBS) $(NSPR_LIBS) $(TOOLKIT_LIBS) $(OS_LIBS)
else
ifeq ($(OS_ARCH),IRIX)
	$(CCC) -o $@ -woff 84,85 $(LDFLAGS) $(OBJS) $(EX_LIBS) $(NSPR_LIBS) $(TOOLKIT_LIBS) $(OS_LIBS)
else
	$(CCC) -o $@ $(LDFLAGS) $(OBJS) $(EX_LIBS) $(NSPR_LIBS) $(TOOLKIT_LIBS) $(OS_LIBS)
endif
endif

#$(OBJDIR)/Scribble.o::	Scribble.cpp
#	$(CCC) -o $@ -c $(CFLAGS) Scribble.cpp $(LDFLAGS) 


#$(OBJDIR)/%.o: %.cpp
#	@$(MAKE_OBJDIR)
#	$(CCC) -o $@ $(CFLAGS) -c $*.cpp

#$(PROGS):$(OBJDIR)/%: $(OBJDIR)/%.o $(OBJDIR)/Scribble.o $(EX_LIBS)
#	@$(MAKE_OBJDIR)
#ifeq ($(OS_ARCH),Linux)
#	$(CCC) -rdynamic -o $@ $@.o $(OBJDIR)/Scribble.o $(LDFLAGS) $(EX_LIBS) $(NSPR_LIBS) $(OS_LIBS)
#else
#	$(CCC) -o $@ $@.o -woff 84,85 $(LDFLAGS) $(OBJDIR)/Scribble.o $(EX_LIBS) $(NSPR_LIBS) $(OS_LIBS)
#endif

export::



install:: $(TARGETS)
	$(INSTALL) $(PROGS) $(DIST)/bin

clobber::
	rm -f $(DIST)/bin/viewer.exe


