# Makefile to build the final SQL which creates the database structure.
#
# version: $Id: Makefile,v 1.2 2002/09/15 22:56:55 als Exp $
# author: Alexander Schreiber <als@thangorodrim.de>
#
#
# scass.bes - The backendsystem of SCASS (System Configuration and
#             Administration Support System)
#
# Copyright (C) 2002  Alexander Schreiber <als@thangorodrim.de>
#
# This program 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.
# 
# This program 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.
#
#
#
# some defaults

SHELL="/bin/sh"

EDITOR="vim" # there can be only one ;-)
# you don't need to change this, it's used for development only

# this is basically the content of sorted_merge_list minus table_perms.sql
SQL_SRC="stored_procedures.sql scass_config.sql scass_config__data.sql scass_fes.sql scass_fes__data.sql scass_dns.sql scass_lm.sql"

.PHONY: all
all: scass.sql
	
scass.sql: table_perms.sql sorted_merge_list
	cat `cat sorted_merge_list ` > scass.sql

table_perms.sql: tableperms
	./build_permissions_sql

.PHONY: clean
clean:
	rm scass.sql table_perms.sql 

# DO NOT TOUCH ## NO USER-SERVICABLE PARTS BELOW ## DO NOT TOUCH #
# ignore everything below - it's for development only
# running make with any of these targets _will_ wipe out files
# needed for installation
# ########## YOU HAVE BEEN WARNED ###########

buildclean:
	rm tableperms.base tableperms scass.sql

tableperms: stored_procedures.sql scass_config.sql scass_config__data.sql scass_fes.sql scass_fes__data.sql scass_dns.sql scass_lm.sql
	echo "# add the permission pattern after each table entry" > tableperms.base
	echo "# pattern is (BES|FES|USER)=(INSERT|DELETE|UPDATE)" >> tableperms.base
	echo "# pattern can be repeated as often as necessary" >> tableperms.base
	echo "# example: foo_table BES=INSERT,DELETE FES=UPDATE" >> tableperms.base
	echo "# SELECT is assumed for all users" >> tableperms.base
	echo "# ALL is assumed for DBADMIN" >>  tableperms.base
	cat *.sql | ./extract_tables >> tableperms.base
	$(EDITOR) tableperms.base
	cp tableperms.base tableperms

