1 #!/bin/sh 2 # 3 # @(#)makeinc 1.10 20/09/04 Copyright 1998-2020 J. Schilling 4 ########################################################################### 5 # Copyright 1998-2020 by J. Schilling 6 ########################################################################### 7 # 8 # Automake script for the Schily (SING) makefile system 9 # 10 ########################################################################### 11 # 12 # Creates the following files: 13 # 14 # ./RULES/os-sunos.id included first after mk-$(XMAKEPROG).id 15 # ./RULES/os-sunos.def included next after RULES/os-sunos.id 16 # ./DEFAULTS/Defaults.sunos included after RULES/os-sunos.def 17 # Now incs/Dcc.$(PARCH)$(-O_ARCH) is 18 # included in parparation of the next 19 # file. This may call conf/cc-config.sh 20 # ./RULES/sun4c-sunos-gcc.rul included after DEFAULTS/Defaults.sunos 21 # 22 ########################################################################### 23 # The contents of this file are subject to the terms of the 24 # Common Development and Distribution License, Version 1.0 only 25 # (the "License"). You may not use this file except in compliance 26 # with the License. 27 # 28 # See the file CDDL.Schily.txt in this distribution for details. 29 # A copy of the CDDL is also available via the Internet at 30 # http://www.opensource.org/licenses/cddl1.txt 31 # 32 # When distributing Covered Code, include this CDDL HEADER in each 33 # file and include the License file CDDL.Schily.txt from this distribution. 34 ########################################################################### 35 MAILADDR=joerg@schily.net 36 37 ########################################################################### 38 # Option processing 39 ########################################################################### 40 case $1 in 41 42 -r) 43 shift 44 SRCROOT=$1 45 shift 46 ;; 47 esac 48 49 if [ $# -lt 1 ]; then 50 echo 'Usage: makeinc [-r srcroot] filename' 1>&2 51 exit 1 52 fi 53 54 ########################################################################### 55 # Find SRCROOT if not specified via option 56 ########################################################################### 57 if [ .$SRCROOT = . ]; then 58 SRCROOT=. 59 loop=1 60 while [ $loop -lt 100 ]; do 61 if [ ! -d $SRCROOT ]; then 62 # Abort on ENAMETOOLONG 63 break 64 fi 65 if [ -r $SRCROOT/RULES/rules.top ]; then 66 break 67 fi 68 if [ "$SRCROOT" = . ]; then 69 SRCROOT=".." 70 else 71 SRCROOT="$SRCROOT/.." 72 fi 73 loop="`expr $loop + 1`" 74 done 75 if [ ! -r $SRCROOT/RULES/rules.top ]; then 76 echo "Cannot find SRCROOT directory" 1>&2 77 exit 1 78 fi 79 fi 80 81 ########################################################################### 82 # Real start of automake script 83 ########################################################################### 84 echo 'NOTICE: Automake script called' 85 if [ -r $1 ]; then 86 echo "WARNING: requested file '$1' already exists" 87 exit 88 fi 89 echo "IMPORTANT: Please report your architecture to $MAILADDR" 90 echo 91 echo "Trying to create missing rule file '$1'" 92 sleep 1 93 echo 94 95 # 96 # Compiler for platforms we do not yet know. 97 # $CC is only used with *Defaults.*) 98 # 99 CC=cc 100 gcc -v 2> /dev/null && CC=gcc 101 ARG_CC=$CC 102 echo "CC: $CC" 103 104 # 105 # Call $CC and try to find out whether it might be "gcc" or "clang". 106 # 107 CC_V=`(eval "$CC -v > /dev/null") 2>&1` 108 GCC_V=`echo "$CC_V" | grep -i gcc-version ` 109 CLANG_V=`echo "$CC_V" | grep -i clang ` 110 111 if [ ".$GCC_V" != . ]; then 112 if (eval "gcc -v 2> /dev/null") 2>/dev/null; then 113 CC="gcc" 114 fi 115 elif [ ".$CLANG_V" != . ]; then 116 if (eval "clang -v 2> /dev/null") 2>/dev/null; then 117 CC="clang" 118 fi 119 fi 120 # 121 # Check whether "cc" or "gcc" are emulated by another compiler 122 # 123 if [ "$CC" != "$ARG_CC" ]; then 124 echo "$ARG_CC is $CC" 125 fi 126 127 MANSTYLE=sysv 128 if [ -r /usr/man/*man7*/man.* -o -r /usr/share/man/*man7*/man.* \ 129 -o -r /usr/man/*man7*/mandoc.* -o -r /usr/share/man/*man7*/mandoc.* \ 130 -o -r /usr/man/*man7*/ascii* -o -r /usr/share/man/*man7*/ascii* ]; then 131 MANSTYLE=bsd 132 fi 133 echo "MANSTYLE: $MANSTYLE" 134 135 case $1 in 136 137 *os-*.id) 138 echo $1 139 OSNAME=`echo $1 | sed -e 's;\(.*\)os-\(.*\)\.id;\2;'` 140 echo '###########################################################################' > $1 141 echo "# OS specific MACRO definitions for $OSNAME" >> $1 142 echo "# This file is auto generated and may be wrong" >> $1 143 echo '###########################################################################' >> $1 144 echo "O_ARCH= $OSNAME" >> $1 145 echo '-O_ARCH= -$(O_ARCH)' >> $1 146 ;; 147 148 *os-*.def) 149 echo $1 150 OSNAME=`echo $1 | sed -e 's;\(.*\)os-\(.*\)\.def;\2;'` 151 echo '###########################################################################' > $1 152 echo "# Global os definitions for $OSNAME" >> $1 153 echo "# This file is auto generated and may be wrong" >> $1 154 echo '###########################################################################' >> $1 155 echo "MANSTYLE= $MANSTYLE" >> $1 156 ;; 157 158 *Defaults.*) 159 echo $1 160 OSNAME=`echo $1 | sed -e 's;\(.*\)\.\(.*\);\2;'` 161 echo '###########################################################################' > $1 162 echo "# global definitions for $OSNAME Systems" >> $1 163 echo "# This file is auto generated and may be wrong" >> $1 164 echo '###########################################################################' >> $1 165 if [ "$CC" = clang ]; then 166 cat $SRCROOT/TEMPLATES/Defaults.clang >> $1 167 elif [ "$CC" = gcc ]; then 168 cat $SRCROOT/TEMPLATES/Defaults.gcc >> $1 169 else 170 cat $SRCROOT/TEMPLATES/Defaults.xcc >> $1 171 fi 172 echo >> $1 173 echo '###########################################################################' >> $1 174 echo "# Do compilattion with minimal warnings" >> $1 175 echo '###########################################################################' >> $1 176 echo "CWARNOPTS=" >> $1 177 ;; 178 179 *-*-cc*.rul | \ 180 *-*-gcc*.rul | \ 181 *-*-clang*.rul) 182 ARCH=`echo $1 | sed -e 's;\(.*\)/\(.*\)-\(.*\)-\(.*\).rul;\2;'` 183 OSNAME=`echo $1 | sed -e 's;\(.*\)/\(.*\)-\(.*\)-\(.*\).rul;\3;'` 184 CCOM=`echo $1 | sed -e 's;\(.*\)/\(.*\)-\(.*\)-\(.*\).rul;\4;'` 185 DIR=`echo $1 | sed -e "s;\(.*\)/$ARCH-$OSNAME-$CCOM.rul;\1;"` 186 echo "ARCH: $ARCH" 187 echo "OSNAME: $OSNAME" 188 echo "CCOM: $CCOM" 189 echo "DIR: $DIR" 190 echo $1 191 echo "Trying to find similar architecture for '$1'" 192 similar=`ls $DIR/*-$OSNAME-$CCOM.rul 2>/dev/null| head -1` 193 SARCH=`echo $similar | sed -e "s;\(.*\)/\(.*\)-$OSNAME-$CCOM.rul;\2;"` 194 195 if [ .$similar != . ]; then 196 echo 'Found similar architecture ' "'$similar'" 197 echo 'creating symlink:' ln -s $SARCH-$OSNAME-$CCOM.rul $1 198 echo "Please send a mail to $MAILADDR to report whether this works or not" 199 sleep 10 200 ln -s $SARCH-$OSNAME-$CCOM.rul $1 || cp $SARCH-$OSNAME-$CCOM.rul $1 201 exit 202 else 203 echo '###########################################################################' > $1 204 echo "# global definitions for $OSNAME Systems" >> $1 205 echo "# This file is auto generated and may be wrong" >> $1 206 echo '###########################################################################' >> $1 207 208 if [ $CCOM = clang -o $CCOM = clang32 -o $CCOM = clang64 ]; then 209 echo 'Using generic CLANG machine configuration file' 210 cat $SRCROOT/TEMPLATES/temp-$CCOM.rul >> $1 211 elif [ $CCOM = gcc -o $CCOM = gcc32 -o $CCOM = gcc64 ]; then 212 echo 'Using generic GCC machine configuration file' 213 cat $SRCROOT/TEMPLATES/temp-$CCOM.rul >> $1 214 else 215 echo 'Using generic dumb cc machine configuration file' 216 cat $SRCROOT/TEMPLATES/temp-xcc.rul >> $1 217 fi 218 fi 219 ;; 220 221 ####################################################################### 222 # This entry is not really needed... 223 ####################################################################### 224 *TARGETS/Targetdirs*) 225 echo "Linking $1 to $SRCROOT/TARGETS/Targetdirs" 226 ln -s Targetdirs $1 227 ;; 228 *) 229 echo "Unknown rule to build: '$1'." 230 exit 1 231 ;; 232 233 esac 234 235 echo "Please send a mail to $MAILADDR to report whether this works or not" 236 sleep 10