Linux Environment:
Regardless of when the operating system starts a new program, the parameters argc and argv are set and passed to main (even if the main function does not declare parameters, these parameters are only available at this time). These parameters are usually provided by another program, typically the shell, which requires the operating system to start the new program. The shell accepts the command line entered by the user, breaks the command line into words, and then puts the words into the argv array.
Command-line arguments are useful for passing information to a program, and many utility programs use command-line arguments to change the behavior of a program or SET options (which we are familiar with, but may rarely associate with the ARGC, argv parameters).
Although command-line options are common and useful, you should be careful to follow the same approach. Recommendation: In an application, all command-line switches begin with a dash, followed by a single letter or number, and, if desired, the option to merge together after a dash, if a value is required, immediately after the option as a separate parameter.
A word gnu/linux history: In order to replace the Multics system, Thompson and Ritchie developed the original UNIX system; Richard Stallman to build a free Unix-like operating system that anyone can use, The GNU and Fsf;linus Torvalds created the Linux kernel on Minix basis, and eventually, the Linux and GNU hit it off were born gnu/linux operating systems.
BSD is another important UNIX-like operating system that is a powerful competitor to Gnu/linux.
Generate executable files from source code:
Manual compilation: GCC commands-no automatic, no intelligence
Generate scripts-automated, not intelligent
Make tools-automated, intelligent
Most large Linux software project developers do not use make directly, but instead use the GNU automake/autoconf tool
Makefile is a dependency tree that unfolds from top to bottom.
While make is still a powerful tool when the project is large, it is very difficult to maintain the makefile, so the GNU automatic Tool "automake/autoconf" was created to automatically generate the appropriate makefile file for the build project.
The biggest benefit of using the AUTOMAKE/AUTOCONF automatic tool is that the makefile files required for the Make tool can be automatically generated based on the environment, and greatly facilitates the maintenance of the makefile later.
Use of automated tools:
1. Add a three class file for the source code project
(1) autogen.sh shell script to run the Automatic tool (located at the project root directory)
(2) Configure.ac autoconf Tool input file (located at the project root directory)
(3) makefile.am top layer of Makefile template (project root directory and the source code to compile all levels of subdirectories must have their own makefile.am files)
2. Execute the following command at the command line
#./autogen.sh
#./configure
# make
--------------------------------------------------------------------------------------------------------------- ------------
Split-Step parsing:
(1) Run script autogen.sh: Establish the local environment needed for Automake and autoconf tools to work;
Run the Automake tool to convert the makefile.am file to a makefile.in file;
Run the Autoconf tool to convert the Configure.ac file into a pure shell script named "Configure".
(2) Run script Configure: Collect information of execution system;
Convert the makefile.in template into a usable makefile file (possibly multiple makefile files) by replacing the steps.
(3) Run make tool: Compile links to all levels of source files based on the generated makefile file, and generate the final executable file.
--------------------------------------------------------------------------------------------------------------- ------------
It is not easy to realize the superiority of automake and autoconf tools, but this is a widely used method in large open-source projects today.