Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Automake

2025-03-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

Editor to share with you how to use Automake, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's learn about it!

Summary of AutoMake usage

1. Generate source code

two。 Use autoscan to generate configure.scan file, edit the file to generate a new file configure.in file

3. Execute aclocal to generate aclocal.m4

4. Execute autoconf to generate configure

5. Create a Makefile.am file and edit it to look like

6. Executing automake--add-missing,Automake results in some files based on Makefile.am, including the most important Makefile.in

7. Execute. / configure to generate Makefile documents

8. Execute make to generate executable file

Execute makeinstall to copy the executable file to the system path.

Here is a short summary of my use of Automake.

1 step summary

(1) autoscan generates configure.scan.

(2) Manual editing on the basis of configure.scan, mainly to add: AM_INIT_AUTOMAKE (myprojectname,version) AC_OUTPUT (* * Makefile to be generated, including those in subdirectories separated by spaces), such as AC_OUTPUT (Makefilesubdir/Makefilesubdir1/Makefile) AC_PROG_RANLIB (for meaning, see the end of Article 4)

(3) aclocalautoconf generates configure script.

(4) I basically rely on my hands at this step, hehe, is there a script to complete this? Write a Makefile.am in the directory where each Makefile needs to be generated. The top layer should write AUTOMAKE_OPTIONS=foreign. If this directory has no files to compile and contains only subdirectories, then only write a SUBDIRS=dir1 and ok. For example, in my project, the top layer only contains the source directory, so I wrote

AUTOMAKE_OPTIONS=foreign

SUBDIRS=src

If you have a file to compile, specify target first. For example, if there are both files and directories under my src directory, and the files in this layer of the src directory are compiled into an executable file, then the Makefile.am under the src directory is written like this.

Bin_PROGRAMS=myprogram

SUBDIRS=sub1

Myprogram_SOURCES=\ a.cpp\

B.cpp\

# the source file to compile. The _ SOURCES here is the keyword

EXTRA_DIST=\ a.h\

B.h

# do not need to be compiled into .o, but to generate targetmyprogram, you also need to put the header file processed by the compiler here

Myprogram_LDADD=libsub1.a this _ LDADD is the keyword

# * generate the execution file myprogram, and linksrc/sub1 the contents of this directory into a lib:libsub1.a,myprogram_LDFLAGS=-lpthread-lglib-2.0-L/usr/bin$ (all_libraries)

# myprogram also needs dynamic so in the link system, and so on, even the self-compiled so needs to be written after the keyword _ LDFLAGS.

AM_CXXFLAGS=-D_LINUX

# some compiled macro definitions passed to the glisten + compiler, options

INCLUDES=-IPassport-Isub1/-I/usr/include/glib-2.0\-I _ all_includes _

# the header file path passed to the compiler.

The following is the Makefile.am for the sub1 species to generate lib

Noinst_LIBRARIES=libprotocol.a# does not generate executable files, but static libraries. Target uses noinst_LIBRARIESlibprotocol_a_SOURCES=\

Alib.cpp

EXTRA_DIST=mylib.h\ alib.h

INCLUDES=-I../$ (all_includes)

AM_CXXFLAGS=-D_LINUX-DONLY_EPOLL-D_SERVER

Ok,*** adds the meaning of AC_PROG_RANLIB. If you want to generate your own lib and then link it to the final executable file, you need to add this macro, otherwise you don't need it.

two。 The rest is that automake--add-missingOk,Makefile.in should be placed in various directories.

Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=547235

The above is all the content of this article "how to use Automake". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report