makefile的配置之helloworld



正确的makefile流程:
1、autoscan
2、修改生成的configure.scan为configure.in
3、aclocal
4、autoheader
5、autoconf
6、创建Makefile.am并进行具体内容的写入 //大的工程,这个是重点要做的 ,面试官让你写一个makefile,你要在这里写,你需要指导要写什么内容进去,剩下的就不用过多的说了,能答上这个,你的面试就成功了。
7、automake
8、automake //主要要做的是解决这个命令的成功,这一步成功了,就差不多了,这一步生成makefile.in,
9、./configure生成Makefile
10、make得到可执行程序



在这里插入图片描述
我的总结:


aclocal命令执行后没有生成:aclocal.m4,
autoconf不是autoconfig,命令书写
关于Makefile.am中的具体内容的意思是说生成的可执行文件的名称为hello,对应的源代码为hello.c。
遇到的bug:
fanvil@ubuntu:/home/hello$ automake
configure.in: no proper invocation of AM_INIT_AUTOMAKE was found.
configure.in: You should verify that configure.in invokes AM_INIT_AUTOMAKE,
configure.in: that aclocal.m4 is present in the top-level directory,
configure.in: and that aclocal.m4 was recently regenerated (using aclocal).
automake: no `Makefile.am’ found for any configure output
automake: Did you forget AC_CONFIG_FILES([Makefile]) in configure.in?

解决:少执行了一个命令 autoheader。

configure.in文件中的AM_INIT_AUTOMAKE没有找到,只有修改configure.in文件后再从第三步进行重新执行,configure.in中的AC_INIT行下添加AM_INIT_AUTOMAKE(hello,1.0),格式为AM_INIT_AUTOMAKE(package,version),再修改AC_OUTPUT为AC_OUTPUT(Makefile);
修改完configure.in文件后,再次执行2~7; //这一步要是不执行,会一直报错。必须要返回去执行步骤2-7.

fanvil@ubuntu:/home/hello$ automake
configure.in:6: required file ./install-sh' not found configure.in:6:automake --add-missing’ can install install-sh' configure.in:6: required file./missing’ not found
configure.in:6: automake --add-missing' can installmissing’
Makefile.am: required file ./depcomp' not found Makefile.am:automake --add-missing’ can install `depcomp’

按照提示创建缺少的文件,
ufo@ufo:~/hello$ touch NEWS README AUTHORS ChangeLog
再执行: ufo@ufo:~/hello$ automake --add-missing

没有出错的情况下再次执行automake;

ufo@ufo:~/hello$ ls
aclocal.m4 ChangeLog configure.in INSTALL missing
AUTHORS config.h.in COPYING install-sh NEWS
autom4te.cache config.h.in~ depcomp Makefile.am README
autoscan.log configure hello.c Makefile.in
此时已经生成了生成Makefile文件的cinfigure脚本;




此处是原创


autom4te.cache autoscan.log config.h.in configure configure.in hello.c Makefile.am

fanvil@ubuntu:/home/hello$ automake
configure.in: no proper invocation of AM_INIT_AUTOMAKE was found.
configure.in: You should verify that configure.in invokes AM_INIT_AUTOMAKE,
configure.in: that aclocal.m4 is present in the top-level directory,
configure.in: and that aclocal.m4 was recently regenerated (using aclocal).
Makefile.am: required file ./depcomp' not found Makefile.am:automake --add-missing’ can install depcomp' /usr/share/automake-1.11/am/depend2.am: am__fastdepCC does not appear in AM_CONDITIONAL /usr/share/automake-1.11/am/depend2.am: The usual way to defineam__fastdepCC’ is to add AC_PROG_CC' /usr/share/automake-1.11/am/depend2.am: toconfigure.in’ and run aclocal' andautoconf’ again.
/usr/share/automake-1.11/am/depend2.am: AMDEP does not appear in AM_CONDITIONAL
/usr/share/automake-1.11/am/depend2.am: The usual way to define AMDEP' is to add one of the compiler tests /usr/share/automake-1.11/am/depend2.am: AC_PROG_CC, AC_PROG_CXX, AC_PROG_CXX, AC_PROG_OBJC, /usr/share/automake-1.11/am/depend2.am: AM_PROG_AS, AM_PROG_GCJ, AM_PROG_UPC /usr/share/automake-1.11/am/depend2.am: toconfigure.in’ and run aclocal' andautoconf’ again.
fanvil@ubuntu:/home/hello$ aclocal
fanvil@ubuntu:/home/hello$ ls
aclocal.m4 autom4te.cache autoscan.log config.h.in configure configure.in hello.c Makefile.am
fanvil@ubuntu:/home/hello$ autoheader
fanvil@ubuntu:/home/hello$ autoconf
fanvil@ubuntu:/home/hello$ automake
configure.in:6: required file ./install-sh' not found configure.in:6:automake --add-missing’ can install install-sh' configure.in:6: required file./missing’ not found
configure.in:6: automake --add-missing' can installmissing’
Makefile.am: required file ./depcomp' not found Makefile.am:automake --add-missing’ can install depcomp' fanvil@ubuntu:/home/hello$ touch NEWS README AUTHORS ChangeLog fanvil@ubuntu:/home/hello$ autom autom4te automake automake-1.11 fanvil@ubuntu:/home/hello$ automake configure.in:6: required file./install-sh’ not found
configure.in:6: automake --add-missing' can installinstall-sh’
configure.in:6: required file ./missing' not found configure.in:6:automake --add-missing’ can install missing' Makefile.am: required file./depcomp’ not found
Makefile.am: automake --add-missing' can installdepcomp’
fanvil@ubuntu:/home/hello$ automake --add-missing
configure.in:6: installing ./install-sh' configure.in:6: installing./missing’
Makefile.am: installing ./depcomp' fanvil@ubuntu:/home/hello$ automake --add-missing fanvil@ubuntu:/home/hello$ automake fanvil@ubuntu:/home/hello$ ls aclocal.m4 autom4te.cache ChangeLog config.h.in~ configure.in hello.c Makefile.am missing README AUTHORS autoscan.log config.h.in configure depcomp install-sh Makefile.in NEWS fanvil@ubuntu:/home/hello$ ./configure checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... /bin/mkdir -p checking for gawk... gawk checking whether make sets $(MAKE)... yes checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking for style of include used by make... GNU checking dependency style of gcc... gcc3 configure: creating ./config.status config.status: creating Makefile config.status: creating config.h config.status: executing depfiles commands fanvil@ubuntu:/home/hello$ ls aclocal.m4 autom4te.cache ChangeLog config.h.in config.log configure depcomp install-sh Makefile.am missing README AUTHORS autoscan.log config.h config.h.in~ config.status configure.in hello.c Makefile Makefile.in NEWS stamp-h1 fanvil@ubuntu:/home/hello$ make make all-am make[1]: Entering directory/home/hello’
gcc -DHAVE_CONFIG_H -I. -g -O2 -MT hello.o -MD -MP -MF .deps/hello.Tpo -c -o hello.o hello.c
mv -f .deps/hello.Tpo .deps/hello.Po
gcc -g -O2 -o hello hello.o
make[1]: Leaving directory /home/hello' fanvil@ubuntu:/home/hello$ ls aclocal.m4 autom4te.cache ChangeLog config.h.in config.log configure depcomp hello.c install-sh Makefile.am missing README AUTHORS autoscan.log config.h config.h.in~ config.status configure.in hello hello.o Makefile Makefile.in NEWS stamp-h1 fanvil@ubuntu:/home/hello$ ./hello hello wgzfanvil@ubuntu:/home/hello$ ls aclocal.m4 autom4te.cache ChangeLog config.h.in config.log configure depcomp hello.c install-sh Makefile.am missing README AUTHORS autoscan.log config.h config.h.in~ config.status configure.in hello hello.o Makefile Makefile.in NEWS stamp-h1 fanvil@ubuntu:/home/hello$ vi hello.c fanvil@ubuntu:/home/hello$ make make all-am make[1]: Entering directory/home/hello’
gcc -DHAVE_CONFIG_H -I. -g -O2 -MT hello.o -MD -MP -MF .deps/hello.Tpo -c -o hello.o hello.c
mv -f .deps/hello.Tpo .deps/hello.Po
gcc -g -O2 -o hello hello.o
make[1]: Leaving directory `/home/hello’
fanvil@ubuntu:/home/hello$ ./hello
hello wgz!


此处是原创


在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_41624617/article/details/90575983
今日推荐