# =============================================================================
# 
# @(#) Makefile,v SS7preBetaRelease(0.8.2.11) 2002/04/15 05:25:37
#
# -----------------------------------------------------------------------------
#
# Copyright (c) 2001  OpenSS7 Corporation <http://www.openss7.com>
# Copyright (c) 1997-2000  Brian F. G. Bidulock <bidulock@dallas.net>
#
# All Rights Reserved.
#
# 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.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 675 Mass
# Ave, Cambridge, MA 02139, USA.
#
# -----------------------------------------------------------------------------
#
# U.S. GOVERNMENT RESTRICTED RIGHTS.  If you are licensing this Software on
# behalf of the U.S. Government ("Government"), the following provisions apply
# to you.  If the Software is supplied by the Department of Defense ("DoD"), it
# is classified as "Commercial Computer Software" under paragraph 252.227-7014
# of the DoD Supplement to the Federal Acquisition Regulations ("DFARS") (or any
# successor regulations) and the Government is acquiring only the license rights
# granted herein (the license rights customarily provided to non-Government
# users).  If the Software is supplied to any unit or agency of the Government
# other than DoD, it is classified as "Restricted Computer Software" and the
# Government's rights in the Software are defined in paragraph 52.227-19 of the
# Federal Acquisition Regulations ("FAR") (or any success regulations) or, in
# the cases of NASA, in paragraph 18.52.227-86 of the NASA Supplement to the FAR
# (or any successor regulations).
#
# -----------------------------------------------------------------------------
#
# Last Modified 2002/04/15 05:25:37 by brian
#
# =============================================================================

export

-include /usr/src/LiS/config.in
-include $(KSRC)/.config
-include .config.in

DFLAGS := -D_SAFE
OFLAGS := -O2
WFLAGS := -Wall

MFLAGS := # -mpreferred-stack-boundary=2

LISINCL ?= /usr/src/LiS/include

MOD_INST_DIR ?= /lib/modules/$(shell uname -r)/kernel/drivers/char/streams

TOPDIR := $(shell pwd)
INCDIR := $(shell ( cd include; pwd ))
SRCDIR := $(shell ( cd drivers; pwd ))
MODDIR := $(MOD_INST_DIR)

SRCFILES = $(shell find . -name "*.c*" -o -name "*.h*")

#SUBDIRS = $(shell find . -maxdepth 1 -mindepth 1 -type d ! -name "CVS" ! -name "RCS" ! -name "include" ! -name "man" ! -name "doc")
SUBDIRS = drivers test # doc daemons include

CVSS := README INSTALL LICENSE LSM config Makefile Makefile.rules
LOGS := $(CVSS:%=%.log)

.PHONY: all
all: # depend # tags
	for subdir in $(SUBDIRS); do $(MAKE) -C $$subdir $@; done

.PHONY: debug
debug:
	touch Makefile.rules
	$(MAKE) -e $(MFLAGS) DFLAGS=-D_DEBUG OFLAGS=-O2

.PHONY: safe
safe:
	touch Makefile.rules
	$(MAKE) -e $(MFLAGS) DFLAGS=-D_SAFE OFLAGS=-O2

.PHONY: none
none:
	touch Makefile.rules
	$(MAKE) -e $(MFLAGS) DFLAGS=-D_NONE OFLAGS=-O3

.PHONY: tags
tags:   $(SRCFILES)
	find . -name "*.h*" -o -name "*.c*" > files
	ctags -L files
	rm -f files
	for subdir in $(SUBDIRS); do $(MAKE) -C $$subdir $@; done

.PHONY: clean
clean:
	rm -f .config.in
	rm -f .depend *.o *.s *_i.c *_i.cc *.log *~ core files tags
	for subdir in $(SUBDIRS); do $(MAKE) -C $$subdir $@; done

.PNONY: install
install:
	@ if [ $$(id -u) -ne 0 ]; then \
	    echo -e "\nYou must be superuser to install!\n"; \
	    exit 1; \
	fi
	for subdir in $(SUBDIRS); do $(MAKE) -C $$subdir $@; done

%::
	for subdir in $(SUBDIRS); do $(MAKE) -C $$subdir $@; done

$(LOGS): %.log: %
	cvs log $< | sed -e "1d" > $@
.PHONY: logs
logs: $(LOGS)
	for subdir in $(SUBDIRS); do $(MAKE) -C $$subdir $@; done

.config.in:
	@ ./config

