head	1.1;
access;
symbols
	pkgsrc-2026Q1:1.1.0.16
	pkgsrc-2026Q1-base:1.1
	pkgsrc-2025Q4:1.1.0.14
	pkgsrc-2025Q4-base:1.1
	pkgsrc-2025Q3:1.1.0.12
	pkgsrc-2025Q3-base:1.1
	pkgsrc-2025Q2:1.1.0.10
	pkgsrc-2025Q2-base:1.1
	pkgsrc-2025Q1:1.1.0.8
	pkgsrc-2025Q1-base:1.1
	pkgsrc-2024Q4:1.1.0.6
	pkgsrc-2024Q4-base:1.1
	pkgsrc-2024Q3:1.1.0.4
	pkgsrc-2024Q3-base:1.1
	pkgsrc-2024Q2:1.1.0.2
	pkgsrc-2024Q2-base:1.1;
locks; strict;
comment	@# @;


1.1
date	2024.05.04.11.21.26;	author pho;	state Exp;
branches;
next	;
commitid	ESRVmD4K0r9HOF8F;


desc
@@


1.1
log
@mk/haskell.mk: New package-settable variable: HASKELL_DISABLE_LIBRARIES
@
text
@# $NetBSD: disable-executables.awk,v 1.2 2024/04/28 14:17:49 pho Exp $
#
# Prevent executables specified with -v "exe=foo bar ..." from being built
# or installed. Do the same for libraries specified with -v "exe=foo bar
# ...".
#
BEGIN {
    split(exe, exev, /[[:space:]]+/);
    split(lib, libv, /[[:space:]]+/);
}

{
    print;

    matched = 0;
    if (tolower($1) == "executable") {
        for (i in exev) {
            if (exev[i] == $2) {
                matched = 1;
                break;
            }
        }
    }
    else if (tolower($1) == "library") {
        for (i in libv) {
            if (libv[i] == $2) {
                matched = 1;
                break;
            }
        }
    }

    if (matched) {
        # The Cabal format requires that indentation levels are
        # aligned. Read the next line and use the same indentation for
        # "buildable: False".
        if ((getline next_line) > 0) {
            match(next_line, /[[:space:]]+/);
            print substr(next_line, RSTART, RLENGTH) "buildable: False";
            print next_line;
        }
        else {
            print "Invalid cabal file: premature end of file right after \"executable\" or \"library\" line." > "/dev/stderr"
            exit 1
        }
    }
}
@
