Benutzer-Werkzeuge

Webseiten-Werkzeuge


becki:linux:build_tools

Dies ist eine alte Version des Dokuments!


Build Tools

This page about How to build applications on Linux. ISO C and its standard library are described in C Tips. POSIX/Linux specific features and enhancements are described in Linux Programming.

indent

Use indent to constistently format your C-code. Here a configuration example for indent to be put in $HOME/.indent.pro:

/* Default Config: Use Kernighan & Ritchie coding style: */
--k-and-r-style
 
/* My minor variants to Kernighan & Ritchie Style: */
--line-length 80  /* Because default is 75 */
--no-tabs         /* Use spaces instead of tabs */
-brf              /* Place function opening brace after function declaration */

Usage:

find -name '*.c' -print0 | xargs -0 indent
indent needs files with Unix line ends (\n) as input. Files with other line endings can be converted with fromdos or sbfromdos

gcc / g++

Manual (Current Development)

  • -c : Do not link
  • -o file : Place output in file file. Applies to object files and executables
  • -Wall : enable most warnings

See also: Journey of a C Program to Linux Executable in 4 Stages

Make

Misc

  • A line beginning with # is a comment
  • The variable $* contains FIXME
  • The variable $@ or $(@) contains the name of the target (tested)
  • '@' at the beginning of a command runs the command but does not copy the line to stdout
  • '-' at the beginning of a command runs the command but does not abort make if command fails
  • Implicit rules example: file.o is made automatically from file.c with a command of the form `$(CC) -c $(CPPFLAGS) $(CFLAGS)'
  • make -n or make --dry-run - Don't actually run any commands; just print them.

Variable assignment

a = Peter
c =  $(a)
d := $(a)
a = Franz
 
test:
        @echo c expands to $(c) # Franz
        @echo d expands to $(d) # Peter

rules for overwriting variables

  1. Every environment variable that make sees when it starts up is transformed into a make variable with the same name and value.
  2. An explicit assignment in the makefile overrides the environment
  3. An assignment in the makefile can be overridden by the command line argument, eg make CFLAGS='-g -O' [target]

Sources: 1 2

CFLAGS usage

Implicit rules

FIXME

Automatic variables

$@ does oviously not work in prerequsites, only in recipie!

pkg-config

Automake

Manual

[Makefile.am] → (automake) ⇒ [Makefile.in]

Autoconf

Manual

                               [Makefile.in]
                                     ⇓
[configure.ac] → (autoconf) ⇒ [(configure)] ⇒ [Makefile] -> make ⇒ ...
Cookies helfen bei der Bereitstellung von Inhalten. Diese Website verwendet Cookies. Mit der Nutzung der Website erklären Sie sich damit einverstanden, dass Cookies auf Ihrem Computer gespeichert werden. Außerdem bestätigen Sie, dass Sie unsere Datenschutzerklärung gelesen und verstanden haben. Wenn Sie nicht einverstanden sind, verlassen Sie die Website. Weitere Information
becki/linux/build_tools.1506345806.txt.gz · Zuletzt geändert: 2017-09-25 13:23 von becki

Impressum - Datenschutzerklärung