/*
 * $Id$
 *
 * Copyright (c) 2003, Raphael Manfredi
 *
 * Jmakefile for the GTK1 GUI.
 *
 *----------------------------------------------------------------------
 * This file is part of gtk-gnutella.
 *
 *  gtk-gnutella 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.
 *
 *  gtk-gnutella 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 gtk-gnutella; if not, write to the Free Software
 *  Foundation, Inc.:
 *      51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 *----------------------------------------------------------------------
 */

;# $Id$

;# Those files lie in the ../gtk-shared directory
REMOTE_GLADE_C = callbacks.c
REMOTE_GLADE_H = callbacks.h 
REMOTE_GLADE = $(REMOTE_GLADE_C) $(REMOTE_GLADE_H)

LSRC = \
	column_sort.c \
	fileinfo.c \
	gnet_stats.c \
	hcache.c \
	monitor.c \
	monitor_cb.c \
	nodes.c \
	nodes_cb.c \
	pbarcellrenderer.c \
	search.c \
	search_cb.c \
	search_stats.c \
	upload_stats.c \
	uploads.c

LOBJ = \
|expand f!$(LSRC) $(REMOTE_GLADE_C)!
	!f:\.c=.o \
-expand \\

GLADE_C = \
	interface-glade.c \
	support-glade.c

GLADE_H = \
|expand f!$(GLADE_C)!
	!f:\.c=.h \
-expand \\

GLADE_O = \
|expand f!$(GLADE_C) $(REMOTE_GLADE_C)!
	!f:\.c=.o \
-expand \\

GLADE_GEN = $(GLADE_C) $(GLADE_H)

SRC = $(LSRC) $(GLADE_C) $(REMOTE_GLADE_C)
OBJ = $(LOBJ) $(GLADE_O)

/* Additional flags for GTK compilation, added in the substituted section */
++GTK_CFLAGS $gtkcflags
++GTK_LDFLAGS $gtkldflags

/* Add the glade command */
++GLADE $glade

TOP_SRC = ../../..
TOP_GUI = ../..

;# Those extra flags are expected to be user-defined
CFLAGS = -I$(TOP) -I$(TOP_SRC) -I$(TOP_GUI) \
	$(GTK_CFLAGS) -DGUI_SOURCES -DCURDIR=$(CURRENT)
DPFLAGS = $(CFLAGS)

GLADEFILE = gtk-gnutella.glade

;# We allow the target to fail since we're distribute the generated files
;# with the sources, so even if they don't have glade, it will work.

;# Unfortunately there are problems with generating the sources from
;# the glade file. If the user does not have the right setup then the
;# compilation will fail, and most users won't be able to correct this
;# by using the distributed sources instead. Thus: commented out until
;# better times.
;#$(GLADE_GEN): $(GLADEFILE) $(REMOTE_GLADE)
;#	-$(GLADE) --write-source $(GLADEFILE)
;#	touch $(GLADE_GEN)

GTK_SHARED = ../gtk-shared

/*
 * Files in the GTK_SHARED directory are copied locally, so that they can
 * be compiled with the relevant -DUSE_GTK1 or -DUSE_GTK2 flag and be
 * present when "glade" runs.
 */

|expand f!$(REMOTE_GLADE)!
!f: $(GTK_SHARED)/!f
	$(RM) !f
	$(CP) $(GTK_SHARED)/!f .

-expand

/*
 * Since the copied files are compiled, they must be part of the dependency
 * for the "depend" target.  It's a multiple target, hence the "::".
 */

depend:: $(REMOTE_GLADE)

local_realclean::
	$(RM) $(REMOTE_GLADE)

/*
 * Only generate the library if configured to build for GTK2
 */

|case d_usegtk2 in define
NormalLibraryTarget(gtk2, $(SRC), $(OBJ))
-case

DependTarget()
