1#! /bin/sh 2# 3# Copyright (c) 2013 Matthew R. Green 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions 8# are met: 9# 1. Redistributions of source code must retain the above copyright 10# notice, this list of conditions and the following disclaimer. 11# 2. Redistributions in binary form must reproduce the above copyright 12# notice, this list of conditions and the following disclaimer in the 13# documentation and/or other materials provided with the distribution. 14# 15# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 20# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 22# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25# SUCH DAMAGE. 26 27# 28# Generate a c++config.h that will include the correct multilib c++config.h 29# 30# mkcxxconfig_h.sh [[<arch> <define>] ...] <arch> 31# 32# generates a series of #ifdef 's with the final <arch> being the default 33# 34 35emit_intro() { 36 cat <<'__EOH1__' 37/* $NetBSD: mkcxxconfig_h.sh,v 1.2 2021/12/11 19:24:19 mrg Exp $ */ 38 39/* This file is automatically generated. DO NOT EDIT! */ 40__EOH1__ 41 42 netbsd_id=$(echo '$NetBSD: mkcxxconfig_h.sh,v 1.2 2021/12/11 19:24:19 mrg Exp $' | sed 's,[#$],,g;s,.*,&,') 43 cat <<__EOH2__ 44/* Generated from: $netbsd_id */ 45 46__EOH2__ 47} 48 49emit_final() { 50 echo "#endif" 51} 52 53# $1 - arch to include 54emit_include() { 55 echo "#include "'"'"bits/$1/c++config.h"'"' 56} 57 58# $1 - define to ifdef 59ifdef=ifdef 60emit_ifdef() { 61 echo "#$ifdef $1" 62 ifdef="elif" 63} 64 65main() { 66 emit_intro 67 while [ $# -gt 0 ]; do 68 if [ $# -eq 1 ]; then 69 echo '#else' 70 emit_include $1 71 break 72 fi 73 emit_ifdef $2 74 emit_include $1 75 shift 76 shift 77 done 78 emit_final 79} 80 81main "$@" 82