@cyysu
2017-10-18T07:07:00.000000Z
字数 2415
阅读 1007
- 时间:2017年10月18日
- 作者:Kali
- 邮箱:cyysu.github.io@gmail.com/2869905223@qq.com/微信lwyx1413
- 版本:4.0
- 描述:自动生成Makefile
Makefile系列教程
# 测试文件mj@DZ:~/桌面/test$ cat test.c#include "test.h"void test(){printf("Hello World");}mj@DZ:~/桌面/test$ cat test.h#include <stdio.h>void test();mj@DZ:~/桌面/test$mj@DZ:~/桌面/test$ cat main.c#include <stdio.h>#include "test.h"int main(){test();}# 脚本执行方式 我这里测试去掉了root限制mj@DZ:~/桌面/test$ ./generateMakefile.shconfigure.ac:6: warning: AM_INIT_AUTOMAKE: two- and three-arguments forms are deprecated. For more info, see:configure.ac:6: http://www.gnu.org/software/automake/manual/automake.html#Modernize-AM_005fINIT_005fAUTOMAKE-invocationconfigure.ac:12: installing './compile'configure.ac:6: installing './install-sh'configure.ac:6: installing './missing'Makefile.am: installing './depcomp'
#!/bin/bash# 设置信息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
After compiling and installing GNU automake 1.15, I get this error whenever I run automake:Unescaped left brace in regex is deprecated, passed through in regex;marked by <-- HERE in m/\${ <-- HERE ([^ \t=:+{}]+)}/at /usr/local/bin/automake line 3936
解决方案: 点我跳转


支付宝 微信