% Copyright 1996-2001 John D. Polstra.
% All rights reserved.
%
% Redistribution and use in source and binary forms, with or without
% modification, are permitted provided that the following conditions
% are met:
% 1. Redistributions of source code must retain the above copyright
%    notice, this list of conditions and the following disclaimer.
% 2. Redistributions in binary form must reproduce the above copyright
%    notice, this list of conditions and the following disclaimer in the
%    documentation and/or other materials provided with the distribution.
% 3. All advertising materials mentioning features or use of this software
%    must display the following acknowledgment:
%      This product includes software developed by John D. Polstra.
% 4. The name of the author may not be used to endorse or promote products
%    derived from this software without specific prior written permission.
%
% THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
% IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
% OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
% IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
% INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
% NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
% DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
% THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
% (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
% THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
%
% $Id: m3makefile,v 1.80 2001/09/17 18:34:53 jdp Exp $

include(path() & "/../../quake/cvsup.quake")

no_shared_lib()

%m3_option("-commands")
override("suptcp", path() & "/../..")
import("libm3")
import("set")
import("suptcp")
import("tempfiles")
import_lib("z", "/usr/local/lib")
if not equal(M3_VARIANT, "PM3")
  Module("RegEx")
end

readonly DevTPieces = {
  "LINUXLIBC6" : [ "dev_t_linux" ],
  "default"    : [ "dev_t_posix" ]
}

readonly TextPieces = {
  "CM3"     : [ "text_cm3" ],
  "default" : [ "text_pm3" ]
}

proc doPieces(tbl, key) is
  local pieces = tbl{"default"}
  if tbl contains key
    pieces = tbl{key}
  end
  foreach d in pieces
    include_dir(d)
  end
end

if equal(TARGET, "FreeBSD2") or equal(TARGET, "FreeBSD2p")
or equal(TARGET, "FreeBSD3") or equal(TARGET, "FreeBSD4")
or equal(TARGET, "FBSD_ALPHA")
  include_dir("FreeBSD")
  import_lib("md", "/usr/lib")
else
  include_dir("POSIX")
  include_dir("libmd")
end

include_dir("libglob")

Generic_module("Merger")
template("merger")

interface("CText")
interface("Uglob")
module("PathComp")
module("ChannelMux")
module("Logger")
interface("LoggerClass")
module("SplitLogger")
module("SysLogger")
module("TimeStampLogger")
module("WrLogger")
interface("ProcTitle")
module("Ugzip")
interface("UgzipP")
interface("Umd5")
interface("MySyslog")
module("WatchDog")
module("IOWatchDog")
module("MD5Digest")
module("MD5")
module("AuthMD5")
module("TokScan")
interface("DevT")
module("FileAttr")
interface("FileAttrRep")
module("FileID")
module("CVProto")
module("EscapedRd")
module("EscapedWr")
module("MD5Wr")
module("ErrMsg")
module("DirEntry")
list("DirEntry", "DirEntry")
list_sort("DirEntry", "DirEntry")
module("Glob")
module("GlobTree")
Table("TextGlobTree", "Text", "GlobTree")
module("LockFile")
interface("ExecRec")
sequence("ExecRec", "ExecRec")
interface("RCSError")
module("RCSString")
module("RCSPhrase")
module("RCSPhrases")
module("RCSDate")
module("RCSRevNum")
module("RCSTag")
List("RCSTag", "RCSTag")
List_sort("RCSTag", "RCSTag")
interface("RCSEdit")
table("RCSEdit", "Integer", "RCSEdit")
sorted_table("RCSEdit", "Integer", "RCSEdit")
module("RCSDelta")
interface("RCSDeltaClass")
List("RCSDelta", "RCSDelta")
List_sort("RCSDelta", "RCSDelta")
Table("RCSDelta", "RCSRevNum", "RCSDelta")
Sorted_table("RCSDelta", "RCSRevNum", "RCSDelta")
module("RCSKeyword")
module("RCSFile")
module("SupFileRec")
module("SupMisc")
module("FileStatus")
interface("FileStatusRaw")
module("StatusFile")
module("CVTree")
module("GzipError")
module("GzipRd")
module("GzipWr")
module("RsyncBlock")
Array_sort("RsyncBlock", "RsyncBlock")
module("RsyncFile")
module("Reaper")
module("SigHandler")
module("UnixMisc")
c_source("UnixMiscC")
module("Attic")

doPieces(DevTPieces, TARGET)
doPieces(TextPieces, M3_VARIANT)

export_interface("Attic")
export_interface("AuthMD5")
export_interface("CText")
export_interface("CVProto")
export_interface("CVTree")
export_interface("ChannelMux")
export_interface("ErrMsg")
export_interface("EscapedRd")
export_interface("EscapedWr")
export_interface("ExecRec")
export_interface("ExecRecSeq")
export_interface("FileAttr")
export_interface("FileID")
export_interface("FileStatus")
export_interface("Glob")
export_interface("GlobTree")
export_interface("GzipRd")
export_interface("GzipWr")
export_interface("IOWatchDog")
export_interface("LockFile")
export_interface("Logger")
export_interface("LoggerClass")
export_interface("MD5")
export_interface("MD5Digest")
export_interface("MD5Wr")
export_interface("PathComp")
export_interface("ProcTitle")
export_interface("RCSDate")
export_interface("RCSDelta")
export_interface("RCSError")
export_interface("RCSFile")
export_interface("RCSKeyword")
export_interface("RCSPhrase")
export_interface("RCSPhrases")
export_interface("RCSRevNum")
export_interface("RCSString")
export_interface("RCSTag")
export_interface("Reaper")
export_interface("RsyncBlock")
export_interface("RsyncFile")
export_interface("SigHandler")
export_interface("SplitLogger")
export_interface("StatusFile")
export_interface("SupFileRec")
export_interface("SupMisc")
export_interface("SysLogger")
export_interface("TimeStampLogger")
export_interface("TokScan")
export_interface("UnixMisc")
export_interface("WatchDog")
export_interface("WrLogger")

library("suplib")
