@cyysu
2017-10-23T11:43:27.000000Z
字数 1826
阅读 831
- 时间:2017年10月18日
- 作者:Kali
- 邮箱:cyysu.github.io@gmail.com/2869905223@qq.com/微信lwyx1413
- 版本:4.0
- 描述:自动生成Makefile脚本
脚本编写
#!/bin/bash#==============================================================================# Author : MJ_DZ chenyuan## Email : cyysu.github.io@gmail.com## Last modified : 2017-10-18 14:54## Filename : 桌面/test/generateMakefile.sh## Description : 自动生成Makefile脚本####==============================================================================# 设置信息FULL_PACKAGE_NAME=MJVERSION=4.0BUG_REPORT_ADDRESS=MJ@cyysu.github.io# 删除信息info="[FULL-PACKAGE-NAME]"# 添加源代码SOURCE="main.c test.c test.h"# 添加临时文件夹TEMP=temp# 非root用户不可登录function checkLogin(){if [ "$UID" -eq 0 ];thenecho -e "\033[32m[INFO] Begin to generate necessary files!\033[0m"elseecho -e "\033[41m[ERROR] System permission denied!\033[0m"exit 0fi}# 首先解决依赖问题,自动安装所需软件包function autoInstall(){# 判断系统类型分别执行if [ -f /etc/issue ];thenOS=`cat /etc/issue | grep -i ubuntu | cut -d " " -f 1 | tr '[:lower:]' '[:upper:]'`case "$OS" inUBUNTU)sudo apt-get install -y automake >/dev/null 2>& 1;;CENTOS)yum install -y automake >/dev/null 2>& 1;;*)echo -e "$(OS)\033[41m[ERROR] The current script does not support the current operating system type!\033[0m"exit 3esacfi}# 其次处理makefile几个步骤function autoScan(){# 生成文件(autoscan) && [[ $? -eq 0 ]] && (cp configure.scan configure.ac)# 替换变量sed -i '/AC_INIT/d' configure.acsed -i "s/AC_OUTPUT*/AC_OUTPUT(Makefile)/" configure.acline=`awk '/AC_PREREQ/{print NR}' configure.ac`sed -i "$line a\AC_INIT(${FULL_PACKAGE_NAME},${VERSION},${BUG_REPORT_ADDRESS})" configure.aclet line++sed -i "$line a\AM_INIT_AUTOMAKE(${FULL_PACKAGE_NAME},${VERSION})" configure.ac# aclocal(aclocal)# autoconf(autoconf)# atuoheader(autoheader)# 修改变量(touch Makefile.am)echo "AUTOMAKE_OPTIONS=foreign" >> Makefile.amecho "bin_PROGRAMS=${FULL_PACKAGE_NAME}" >> Makefile.amecho "MJ_SOURCES=${SOURCE}" >> Makefile.am# automake(automake --add-missing) && (rm -rf *.o )}autoScan
支付宝 微信