/usr/bin/amr is in acr 1.2-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 | #!/bin/sh
#
# Copyright (C) 2005-2014
# pancake <pancake@nopcode.org>
#
# acr is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# acr is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with acr; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
#===========================================================================
#
# AMR : Auto Make Replacement
# @author: pancake@nopcode.org
VERSION="0.2"
NESTED=0
S=\$
show_usage() {
cat <<EOF
Usage: amr [options]
-a : recursive scan directories and prints the configure.amr
-c : parse configure.amr to print a configure.acr
-m : parse configure.amr and generate the propers Makefile.acr
-s : shellscript that simulates a makefile
-d : prints all directories where amr must run
-r : show report
-g : print out autogen.sh
-v : show version information"
EOF
exit $1
}
autogen_sh() {
cat <<EOF
#!/bin/sh
# amr: autogenerated autogen.sh
echo "Autogenerating configure.amr..."
amr -a > configure.amr
DIRS=\`amr -d\`
echo "Source directories: ${S}{DIRS}"
for A in ${S}{DIRS}; do
echo " - ${S}{A}"
(cd ${S}{A} && amr -a > configure.amr)
done
echo "Generating configure.acr..."
amr -c > configure.acr
echo "Generating final configure script..."
acr -p
EOF
exit 0
}
case "$1" in
"-g")
autogen_sh
;;
"-a")
AMR="gen-configure"
;;
"-m")
AMR="gen-makefile"
;;
"-c")
AMR="gen-acr"
;;
"-r")
AMR="show-report"
;;
"-s")
AMR="gen-shellscript"
;;
"-d")
AMR="print-dirs"
;;
"-w")
echo "Write output to the proper file"
;;
"-v")
echo "amr: version ${VERSION}"
exit 0
;;
""|"-h")
show_usage 0
;;
*)
show_usage 1
;;
esac
CSOURCES=""
CDEPS_VARS=""
CDIRS=""
CDIR=""
COLDIR=""
CDEPS_VAR_IS_DEFINED=0
CINCLUDES=""
_MODE=0
_COMMENT=0
check_cidep() {
FILE=$1
for A in $CINCLUDES ; do
[ "$A" = "$FILE" ] && return
done
echo "CInclude ${FILE} not found" > /dev/stderr
exit 1
}
check_cdep() {
FILE=$1
for A in $CSOURCES ; do
[ "$A" = "$FILE" ] && return
done
echo "CSource ${FILE} not found" > /dev/stderr
exit 1
}
# Check if we're in the root.
MYDIR=${PWD}
RTDIR=${PWD}
NESTED=0
while : ; do
cd ..
if [ -e "configure.amr" ]; then
RTDIR=${PWD}
NESTED=1
break
fi
[ "${PWD}" = "/" ] && break
done
cd ${RTDIR}
PKGNAME=`basename ${PWD}`
cd ${MYDIR}
if [ "gen-configure" = "$AMR" ]; then
FILES=`find . -type f -name "*.c"`
for A in $FILES ; do
case "$A" in
*c$)
CDIR="`echo $A| awk -F / '{ for(i=1;i<NF;i++){ str=str$i"/" } print str }'`"
if [ -z "`echo $CDIRS|grep $CDIR`" ]; then
CDIRS="${CDIRS} ${CDIR}"
fi
CSOURCES="${CSOURCES} $A"
_INCLUDES=`grep '#include <' "${A}" | sed -e 's,<,,' -e 's,>,,' | cut -d \ -f 2`
for INC in ${_INCLUDES}; do
if [ -z "`echo ${CINCLUDES} | grep ${INC}`" ]; then
CINCLUDES="${CINCLUDES} ${INC}"
fi
done
;;
*)
esac
done
COLDIR=$CDIRS
echo "## sample configure.amr ##"
for A in $CDIRS ; do
CDIR=$A
echo "CDIR $CDIR"
[ ! "${CDIR}" = "./" ] && continue
echo
CFILES=""
for B in $CSOURCES; do
FILE="`echo $CDIR $B | awk '{print substr($2,length($1)+1); }'`"
CFILES="${CFILES} ${FILE}"
done
[ "${CFILES}" ] && echo "CSOURCES ${CFILES} ;"
HFILES=""
HFILES=`find . | grep \.h | sed -e 's,\./,,'`
#for B in ${CINCLUDES}; do
# FILE="`echo $CDIR $B | awk '{print substr($2,length($1)+1); }'`"
# FILE="`echo $CDIR $B | awk '{print substr($2,length($1)+1); }'`"
# HFILES="${HFILES} ${FILE}"
#done
echo "CINCLUDES ${CINCLUDES} ;"
echo
for B in $HFILES ; do
STR=""
for C in $CFILES ; do
if [ -n "`cat ${CDIR}/$C | grep '#include "' | grep $B`" ]; then
STR="${STR} ${C}"
fi
done
[ -n "${STR}" ] && echo "CDEPS ${B}${STR} ;"
done
done
exit 0
fi
if [ ! -e "configure.amr" ]; then
echo "amr: 'configure.amr' file not found. Use 'amr -a > configure.amr' first."
exit 1
fi
parse_configure_amr() {
FILE=$1
echo "Parsing ${FILE}..." >/dev/stderr
CONFIGURE_AMR="`cat ${FILE} 2>/dev/null`"
for A in $CONFIGURE_AMR ; do
# TODO: Support for oneline commands and /* */
# COMMENT
if [ "$A" = "##" ]; then
if [ "$_COMMENT" = 0 ]; then
_COMMENT=1 ; else _COMMENT=0; fi
fi
[ "${_COMMENT}" = 1 ] && continue
case "$A" in
"##")
;;
"CSOURCES")
_MODE=csources
;;
"CINCLUDES")
_MODE=cincludes
;;
"CDEPS")
_MODE=cdeps
;;
"CDIR")
_MODE=cdir
;;
*)
case "${_MODE}" in
"csources")
if [ ";" = "$A" ]; then
_MODE=0 ; continue ; fi
CSOURCES="${CSOURCES} ${CDIR}/${A}"
COBJECTS="${COBJECTS} `echo ${CDIR}/${A} | sed -e 's,\.c,\.o,g'`"
;;
"cdir")
CDIR=$A
_MODE=0
;;
"cincludes")
if [ ";" = "$A" ]; then
_MODE=0 ; continue ; fi
CINCLUDES="${CINCLUDES} ${A}"
;;
"cdeps")
if [ ";" = "$A" ]; then
_MODE=0 ; CDEPS_VAR_IS_DEFINED=0 ; continue ; fi
if [ "${CDEPS_VAR_IS_DEFINED}" = 0 ]; then
CDEPS_VAR="`echo ${CDIR}/${A} | sed -e 's,^\.,,' -e 's,//,/,g' -e 's,\.,_,g' -e 's,/,_,g'`"
CDEPS_VARS="${CDEPS_VARS} ${CDEPS_VAR}"
CDEPS_VAR_IS_DEFINED=1
continue
fi
check_cdep "${CDIR}/$A"
eval "${CDEPS_VAR}=\"\$${CDEPS_VAR} ${A}\""
;;
*|0)
echo "Invalid keyword '$A'" > /dev/stderr
exit 1
;;
esac
;; esac
done
}
parse_configure_amr "configure.amr"
COBJECTS=`echo ${COBJECTS} | sed -e 's,\.//,,g'`
case "$AMR" in
"gen-makefile")
echo "## Sample Makefile.acr ##"
echo "VPATH=@VPATH@"
if [ -n "${CSOURCES}" ]; then
echo "CC=@CC@"
echo "CFLAGS=@CFLAGS@"
echo "LDFLAGS=@LDFLAGS@"
fi
# TODO: handle multiple subdirectories
if [ "${CDIR}" = "./" ]; then
echo "OBJ=${COBJECTS}"
echo "BIN=@PKGNAME@"
echo "VERSION=@VERSION@"
echo
echo "all: \${OBJ}"
echo " \${CC} \${LDFLAGS} \${OBJ} -o \${BIN}"
echo
for A in ${COBJECTS}; do
CFILE="`echo ${A} | sed -e 's,\.o,\.c,g'`"
DEPS=`cat ${CFILE} | grep '#include "' | sed -e 's,",,g' | cut -d \ -f 2`
DEPS="${CFILE} $(echo $DEPS)"
echo "${A}: ${DEPS}" | sed -e 's,//,/,g'
printf "\t \${CC} \${CFLAGS} -c -o ${A} $<"
echo
echo
done
echo "clean:"
echo " -rm -f \${OBJ} \${BIN}"
echo
echo "mrproper:"
echo " -rm -f Makefile"
else
echo
echo "all:"
echo " cd ${CDIR} && ${S}{MAKE} all"
echo
echo "install:"
echo " cd ${CDIR} && ${S}{MAKE} install"
echo
echo "clean:"
echo " cd ${CDIR} && ${S}{MAKE} clean"
echo
echo "mrproper:"
echo " cd ${CDIR} && ${S}{MAKE} mrproper"
echo
echo "dist: mrproper"
echo " cd .. && mv ${S}{PKGNAME}-${S}{VERSION}"
echo " -cd .. && tar czvf ${S}{PKGNAME}-${S}{VERSION}.tar.gz \\"
echo " \`find ${S}{PKGNAME}-${S}{VERSION} -type f|grep -v git\`"
echo " cd .. && mv ${S}{PKGNAME}-${S}{VERSION} ${S}{PKGNAME}"
echo
fi
;;
"print-dirs")
echo $CDIR
;;
"gen-acr")
# Recursive parse configure.acr
CDIR_ORIG=${CDIR}
for A in ${CDIR}; do
parse_configure_amr "${A}/configure.amr"
done
CDIR=${CDIR_ORIG}
echo "## sample configure.acr ##"
if [ "${NESTED}" = 0 ]; then
echo "PKGNAME ${PKGNAME}"
echo "VERSION 0.1" # TODO
echo "CONTACT your name ; your@email" # TODO
echo
fi
[ -n "${CSOURCES}" ] && echo "LANG_C!"
echo
for A in ${CINCLUDES} ; do
echo "CHKINC! ${A}"
done
echo
SFILES=`find .| grep acr| grep -v Makefile| grep -v configure | sed -e 's,\.acr,,g'`
echo "SUBDIRS . ${CDIR} ${SFILES} ;"
;;
"gen-shellscript")
;;
"show-report")
echo "CSOURCES = ${CSOURCES}"
echo "CINCLUDES = ${CINCLUDES}"
echo "CDEPS_VARS = ${CDEPS_VARS}"
S="\$"
for A in ${CDEPS_VARS} ; do
echo "-. $A"
for B in `eval echo ${S}${A}`;do
echo " |- $B"
done
done
;;
esac
# if [ main.h > main.o ]; then
# rm -f main.o usage.o engine.o
# fi
|