#!/bin/sh
# vim: ts=4 sw=4 et ft=sh
#---------------------------------------------------------------------------#
# Copyright (C) 2020 The Mercury team.
# This file may only be copied under the terms of the GNU General
# Public License - see the file COPYING in the Mercury distribution.
#---------------------------------------------------------------------------#
#
# This script constructs (or reconstructs) the contents of
# compiler/optimization_options.m. The initial and final parts
# are hand_written, in make_optimization_options_{start,end}
# respectively, while the middle is generated by
# make_optimization_options_middle from make_optimization_options_db.
#
# make_optimization_options_middle also generates handler_file,
# which is a code fragment that is intended to comprise part of
# the code of the special_handler predicate in compiler/options.m.
#

if test -f ../compiler/optimization_options.m
then
    chmod u+w ../compiler/optimization_options.m
fi

(
cat make_optimization_options_start;
awk -f make_optimization_options_middle make_optimization_options_db;
cat make_optimization_options_end
) > ../compiler/optimization_options.m

chmod a-w ../compiler/optimization_options.m
