Example of Autoconf and automake

Source: Internet
Author: User
Tags automake

Explanation of Configure. In in mde-1.3.0

DNL process this file with Autoconf to produce a configure script.
/* DNL is the beginning of the comment */
Ac_prereq (2.13)
/* Ac_prereq macro specifies the Autoconf version required by this file */
Ac_init (mginit/mginit. c)
/* The Configure. In file must call the ac_init macro before starting all work, and call the ac_output macro after finishing all work.
In fact, only these two macros are required by the configure. In file. The ac_init syntax is as follows:
Ac_init (unique_file_in_source_dir)
Unique_file_in_source_dir is a file in the source code directory.
Generate a shell command and check whether the unique_file_source_dir exists to verify whether the current directory is correct. */

DNL = ======================================
DNL needed for cross-Compiling
Ac_canonical_system
/* Check the system type and set the output variable to the standard system type. After ac_canonical_system is called, the following output variables contain the system type information.
Build, host, and target. Therefore, you can set cross-compilation through -- Host = arm_linux In the configure command line.
Build is the machine you are using, host is the platform on which compiled programs can run, and target is the platform on which compiled programs can process. this build is easier to understand than the host, but the target is not easy to do. What does it mean? In general, we usually say that we cannot use the target for the compilation of the intersection, for example. /configure -- Build = i386-linux, -- Host = arm-Linux will be able to compile programs that can run on the arm board on the 386 platform. however, we generally compile programs rather than compilation tools. If we compile tools such as GCC, this target will be useful. if we need to compile a GCC program capable of processing MIPS program for the arm R & D board on one of our machines, then the target is MIPS */
DNL = ======================================
DNL checks for programs.
Ac_prog_make_set
/* If you run make in a subdirectory, you should use make variable to run it. In most versions of make, make is set to the name of the make program and any required options. (However, many versions do not include the variable values set in the command line, so they are not automatically passed .) Some old versions of make do not set this variable. The following macros allow you to use them in these versions.
MACRO: ac_prog_make_set
If make predefines the variable make, it defines the output variable set_make as null. Otherwise, define set_make as 'make = make '. Call ac_subst for set_make.
To use this macro, add a line in 'makefile. in' in each other directory that runs make:
@ Set_make @*/

Ac_prog_cc
/* Check the available C compiler. If the source code is written in C, this macro is required. */

Am_init_automake (MDE, 1.3.0)
/* Am_init_automake (package, Version)
This is a necessary macro to use automake. Package is the name of the software suite to be generated, and version is the version number.
Make Dist
Package programs and related documents as a compressed document for release (distribution ). After the execution is complete, a file named package-version.tar.gz will be created under the directory. The package and version parameters are defined according to the am_init_automake (package, Version) in the configure. In file. */

DNL = ======================================
DNL checks for typedefs, structures, and compiler characteristics.
Ac_c_const
/* If the C compiler does not fully support the keyword const, define const as null. Some compilers do not define _ stdc __, but support Const. Some compilers DEFINE _ stdc __, but do not fully support Const. The program can assume that all c compilers support const and use it directly. for compilers that do not fully support const, 'makefile' or the configuration header file defines const as null. */

DNL = ======================================
DNL checks for header files.
Ac_header_stdc
/* If the header file contains the standard C (ansi c), stdc_headers is defined. In particular, this macro checks 'stdlib. h', 'stdarg. h', 'string. H 'and 'float. H '; if the system contains these header files, it may also contain other standard C header files. This macro also checks 'string. H 'Whether memchr is defined (and assumptions are made for other mem functions accordingly), 'stdlib. H 'determines whether free (and makes assumptions about malloc and other related functions accordingly) and 'ctype. h 'macro can be used to set high-level characters according to the requirements of standard C. */
Ac_header_sys_wait
Ac_header_time
Ac_check_headers (sys/time. h unistd. h)

DNL = ======================================
DNL check for libminigui
Have_libminigui = "no"
Ac_check_headers (MiniGUI/common. H, have_libminigui = Yes, foo = bar)
/*
Ac_check_headers (header-file..., [Action-if-found], [Action-if-not-found])
If the system header file header-file is usable, execute shell commands action-if-found, otherwise execute action-if-not-found.
*/
DNL = ======================================
DNL check for lite or threads version of MiniGUI
Lite_version = "no"
Ac_check_decls (_ lite_version, lite_version = "yes", foo = bar, [# include <MiniGUI/common. h>])
/* Ac_check_decls (symbols, [Action-if-found], [Action-if-not-found], [primary des = default-Primary des]) Macro
For each of the symbols (comma-separated list), define have_decl_symbol (in all capitals) to 1 If symbol is declared, otherwise to 0. if action-if-not-found is given, it is additional shell code to execute when one of the function declarations is needed, otherwise action-if-found is executed. */
DNL = ======================================
DNL check for standalone version of MiniGUI-Lite
Stand_alone = "no"
Ac_check_decls (_ stand_alone, stand_alone = "yes", foo = bar, [# include <MiniGUI/common. h>])

DNL = ======================================
DNL check for newgal or oldgal interface.
Use_newgal = "no"
Ac_check_decls (_ use_newgal, use_newgal = "yes", foo = bar, [# include <MiniGUI/common. h>])

DNL = ======================================
DNL write output

If test "$ ac_cv_prog_gcc" = "yes"; then
Cflags = "$ cflags-wall-wstrict-prototypes-pipe"
Fi

If test "x $ lite_version" = "xyes"; then
Libs = "$ libs-lminigui"
Else
Cflags = "$ cflags-d_reentrant"
Libs = "$ libs-lpthread-lminigui"
Fi

Am_conditional (lite_version, test "x $ lite_version" = "xyes ")
Am_conditional (stand_alone, test "x $ stand_alone" = "xyes ")
Am_conditional (use_newgal, test "x $ use_newgal" = "xyes ")
/* The macro am_conditional accepts two parameters.
Arg1: The name of a conditional,
Arg2: A shell statement that is used to determine whether the conditional shocould be true or false.
The macro-defined conditional can be used in makefile. am.
*/
Ac_output (
Makefile
Notebook/makefile
Notebook/RES/makefile
Tools/makefile
Same/makefile
Same/RES/makefile
Bomb/makefile
Bomb/RES/makefile
Russia/makefile
Housekeeper/makefile
Housekeeper/RES/makefile
Controlpanel/makefile
Controlpanel/RES/makefile
Vacs/makefile
Vacs/RES/makefile
Gdidemo/makefile
Gdidemo/RES/makefile
Fontdemo/makefile
Dlgdemo/makefile
Ctrldemo/makefile
Ctrldemo/RES/makefile
Picview/makefile
Picview/RES/makefile
Painter/makefile
Mginit/makefile
Mginit/RES/makefile
)

If test "x $ have_libminigui "! = "Xyes"; then
Ac_msg_warn ([
MiniGUI is not properly installed on the system. You need MiniGUI-lite ver 1.2.6 or later for building this package. Please configure and install MiniGUI-lite ver 1.2.6 first.
])
Fi

/* Print the message in the standard error output */

Makefile. am is a higher level rule than makefile. You only need to specify the target to be generated, the source document to be generated, and the directory to be installed.
The following table lists Executable documents, static libraries, header documents, and data documents. Four General formats are used to write makefile. Am documents.
File Type writing format
Executable File bin_programs = foo
Foo_sources = XXXX. c
Foo_ldadd =
Foo_ldlfags =
Static library lib_libraries = libfoo.
Foo_a_sources =
Foo_a_ldadd =
Foo_a_libadd =
Header file include_headers = Foo. h
Data File data_data = data1 data2

For Executable documents and static library types, if you only want to compile and do not want to install them in the system, you can replace bin_programs with noinst_libraries instead of lib_libraries.

Analysis of mde-1.3.0/makefile. Am File

Common_subdirs = notebook tools bomb housekeeper same Russia controlpanel vacs/
Fontdemo dlgdemo ctrldemo picview

If lite_version
If stand_alone
Lite_subdirs =
Else
Lite_subdirs = mginit
Endif
Else
Lite_subdirs =
Endif

If use_newgal
Newgal_subdirs = gdidemo painter
Else
Newgal_subdirs =
Endif

Dist_subdirs = $ (common_subdirs) gdidemo painter mginit
Subdirs = $ (common_subdirs) $ (lite_subdirs) $ (newgal_subdirs)
/* Subdirectory to be recursively processed before processing the local directory */
Extra_dist = autogen. Sh version
/* Add the extra_dist-defined file when packaging with make Dist */

Mde-1.3.0/mginit/makefile. Am Analysis
Subdirs = res

Extra_dist = mginit. RC

Noinst_programs = mginit

Mginit_sources = mginit. c taskbar. c taskbar. h

Mginit_ldadd =-lmgext/* Add-lmgext to the connection line */

For more information, see the Autoconf and automake manuals.

 

Aclocal
Automake -- add-Missing
Autoconf
./Configure -- prefix =/usr/local/ARM/2.95.3/-- Host = arm-Linux to configure cross-compilation options
Run the preceding command to generate a makefile that meets your needs.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.