/*
 * $Id$
 *
 * Copyright (c) 2004, Raphael Manfredi
 *
 * Jmakefile for common sources.
 *
 *----------------------------------------------------------------------
 * 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.:
 *      59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *----------------------------------------------------------------------
 */

;# $Id$

/*
 * Generation of bit_array.h and bit_field.h from a generic template.
 */

GENERIC = bit_array.h bit_field.h

bit_array.h: bit_array.ht bit_generic.t
	$(TOP)/scripts/generic-cat bit_array.ht bit_generic.t array >$@

bit_field.h: bit_field.ht bit_generic.t
	$(TOP)/scripts/generic-cat bit_field.ht bit_generic.t field >$@

all:: $(GENERIC)

local_realclean::
	$(RM) $(GENERIC)

depend:: $(GENERIC)

LSRC = \
	adns.c \
	aging.c \
	arc4random.c \
	ascii.c \
	atoms.c \
	base16.c \
	base32.c \
	base64.c \
	bg.c \
	bstr.c \
	ckalloc.c \
	cobs.c \
	compat_misc.c \
	compat_pio.c \
	compat_poll.c \
	compat_sleep_ms.c \
	compat_un.c \
	concat.c \
	cpufreq.c \
	cq.c \
	crash.c \
	crc.c \
	dbmap.c \
	dbmw.c \
	dbstore.c \
	dbus_util.c \
	debug.c \
	dualhash.c \
	entropy.c \
	eval.c \
	event.c \
	fast_assert.c \
	fd.c \
	fifo.c \
	file.c \
	filehead.c \
	filename.c \
	fragcheck.c \
	fs_free_space.c \
	getdate.c \
	getline.c \
	getgateway.c \
	getphysmemsize.c \
	glib-missing.c \
	gnet_host.c \
	halloc.c \
	hashlist.c \
	hashtable.c \
	header.c \
	host_addr.c \
	html.c \
	idtable.c \
	inputevt.c \
	iprange.c \
	iso3166.c \
	log.c \
	list.c \
	magnet.c \
	malloc.c \
	map.c \
	mime_type.c \
	mingw32.c \
	misc.c \
	nid.c \
	nv.c \
	offtime.c \
	ohash_table.c \
	omalloc.c \
	options.c \
	ostream.c \
	pagetable.c \
	parse.c \
	palloc.c \
	path.c \
	patricia.c \
	pattern.c \
	pmsg.c \
	pow2.c \
	prop.c \
	random.c \
	sectoken.c \
	sequence.c \
	sha1.c \
	signal.c \
	slist.c \
	sorted_array.c \
	stacktrace.c \
	stats.c \
	str.c \
	stringify.c \
	strtok.c \
	symtab.c \
	tea.c \
	tiger.c \
	tigertree.c \
	timestamp.c \
	tm.c \
	url.c \
	url_factory.c \
	urn.c \
	utf8.c \
	vector.c \
	vendors.c \
	vmm.c \
	walloc.c \
	watcher.c \
	wd.c \
	wordvec.c \
	wq.c \
	zalloc.c \
	zlib_util.c

/* Object files are derived from source files */
LOBJ = \
|expand f!$(LSRC)!
	!f:\.c=.o \
-expand \\

/* Additional flags for glib compilation, added in the substituted section */
++GLIB_CFLAGS $glibcflags

/* Additional flags for dbus compilation, added in the substituted section */
++DBUS_CFLAGS $dbuscflags

;# Those extra flags are expected to be user-defined
CFLAGS = -I$(TOP) -I.. $(GLIB_CFLAGS) $(DBUS_CFLAGS) -DCURDIR=$(CURRENT)
DPFLAGS = $(CFLAGS)

NormalLibraryTarget(shared,$(LSRC),$(LOBJ))
DependTarget()

/*
 * Since getdate.c is in CVS, they can compile even if they lack yacc.
 * Do that only for developpers (the ".package" file is required to be able
 * to run "metaconfig").
 */
getdate.c: getdate.y
	-@if test -f $(TOP)/.package; then \
		echo "	$(YACC) $(JYFLAGS) $<"; \
		$(YACC) $(JYFLAGS) $<; \
		echo "	$(MV) y.tab.c $@"; \
		$(MV) y.tab.c $@; else touch $@; fi

