mkcxxconfig_h.sh revision 1.1.8.2
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# 3. The name of the author may not be used to endorse or promote products 15# derived from this software without specific prior written permission. 16# 17# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 24# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27# SUCH DAMAGE. 28 29# 30# Generate a c++config.h that will include the correct multilib c++config.h 31# 32# mkcxxconfig_h.sh [[<arch> <define>] ...] <arch> 33# 34# generates a series of #ifdef 's with the final <arch> being the default 35# 36 37emit_intro() { 38 cat <<'__EOH1__' 39/* $NetBSD: mkcxxconfig_h.sh,v 1.1.8.2 2014/08/19 23:56:55 tls Exp $ */ 40 41/* This file is automatically generated. DO NOT EDIT! */ 42__EOH1__ 43 44 netbsd_id=$(echo '$NetBSD: mkcxxconfig_h.sh,v 1.1.8.2 2014/08/19 23:56:55 tls Exp $' | sed 's,[#$],,g;s,.*,&,') 45 cat <<__EOH2__ 46/* Generated from: $netbsd_id */ 47 48__EOH2__ 49} 50 51emit_final() { 52 echo "#endif" 53} 54 55# $1 - arch to include 56emit_include() { 57 echo "#include "'"'"bits/$1/c++config.h"'"' 58} 59 60# $1 - define to ifdef 61ifdef=ifdef 62emit_ifdef() { 63 echo "#$ifdef $1" 64 ifdef="elif" 65} 66 67main() { 68 emit_intro 69 while [ $# -gt 0 ]; do 70 if [ $# -eq 1 ]; then 71 echo '#else' 72 emit_include $1 73 break 74 fi 75 emit_ifdef $2 76 emit_include $1 77 shift 78 shift 79 done 80 emit_final 81} 82 83main "$@" 84