Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- black='\E[30m'
- red='\E[31m'
- green='\E[32m'
- yellow='\E[33m'
- blue='\E[34m'
- magenta='\E[35m'
- cyan='\E[36m'
- white='\E[37m'
- bold='\033[1m'
- normal='\033[2m'
- #set defaults
- COMPILER='gcc'
- SUBDIR='progs'
- while [ ! -z ${1} ]; do
- #compiler selection
- if [ "${1}" == "-cc" ]; then
- COMPILER='cc'
- shift
- fi
- #subdirectory selection
- if [ "${1}" == "-d" ]; then
- shift
- SUBDIR=${1}
- shift
- fi
- if [ "${1}" == "-p" ]; then
- shift
- BASENAME=${1}
- shift
- fi
- done
- #if directory doesn't exist
- if [ ! -d "${SUBDIR}" ]; then
- mkdir ${SUBDIR}
- fi
- echo -e "\n${yellow}Using ${bold}${COMPILER}${normal} to compile.\n"
- echo -e "${yellow}Compiling into ${bold}${SUBDIR}${normal} directory.\n"
- if [ -z ${BASENAME} ]; then
- for BASENAME in `ls *.c -1`
- do
- echo -e "${bold}${white}Compiling: ${bold}${green}${BASENAME}"
- ${COMPILER} ${BASENAME} -o ${SUBDIR}/${BASENAME%%.c}
- done
- else
- echo -e "${bold}${white}Compiling: ${bold}${green}${BASENAME}"
- ${COMPILER} ${BASENAME}.c -o ${SUBDIR}/${BASENAME}
- fi
- tput sgr0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement