# GNUmakefile
#
#      Makefile for src directory of Veil
#
#      Copyright (c) 2005 Marc Munro
#      Author:  Marc Munro
#      License: BSD
#
# $Id: GNUmakefile,v 1.1.1.1 2005/10/04 20:23:32 bloodnok Exp $
# 
# Do not attempt to use this makefile directly: its targets are available
# and should be built from the main GNUmakefile in the parent directory.
# 

SRC_DIR = src
SRC_SOURCES = $(wildcard $(SRC_DIR)/*.c)
SRC_HEADERS = $(wildcard $(SRC_DIR)/*.h)

SRC_OBJECTS = $(SRC_SOURCES:%.c=%.o)
SRC_DEPS = $(SRC_SOURCES:%.c=%.d)
SRC_GARBAGE = $(garbage:%=$(SRC_DIR)/%)
SRC_SQL = veil_interface.sql

SQL_SRC = $(wildcard $(SRC_DIR)/*.sqs)
SQL_INSTALLTARG = $(SQL_SRC:%.sqs=%.sql) 
SQL_TARG = $(SQL_SRC:$(SRC_DIR)/%.sqs=%.sql)

.PHONY: src_all src_clean veil

LIB = veil$(DLSUFFIX)

# Include dependency files for each source file
include $(SRC_DEPS)

# Build veil shared library from sources.
src_all:  $(LIB) $(SQL_TARG) $(SQL_INSTALLTARG)

$(SQL_TARG): $(SQL_SRC)
	sed -e 's!@LIBDIR@!$(top_builddir)!g' <$(SQL_SRC) >$@

$(SQL_INSTALLTARG): $(SQL_SRC)
	sed -e 's!@LIBDIR@!$$libdir!g' <$(SQL_SRC) >$@

$(LIB): $(SRC_OBJECTS)

#
src_install:
	$(INSTALL_SCRIPT) $(LIB) $(pglibdir)
	$(INSTALL_SCRIPT) $(SQL_INSTALLTARG) $(pgsharedir)

# Remove the shared library and all generated/intermediate files
src_clean:
	@echo Cleaning src...
	@rm -f $(SRC_OBJECTS) $(SRC_DEPS) $(LIB) $(SRC_SQL) \
	       $(SRC_GARBAGE) $(SQL_TARG) $(SQL_INSTALLTARG)

src_distclean: src_clean
	@rm -f src/veil_version.h src/veil_mainpage.c 