Skip to content

Commit 9b2f3ff

Browse files
committed
* Readme
1 parent 09f9885 commit 9b2f3ff

File tree

2 files changed

+128
-128
lines changed

2 files changed

+128
-128
lines changed

README.md

Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
# Autark – A self-contained build system for C and C++
22

3+
## Quick links
4+
5+
- [meta](#meta-)
6+
- [option](#option-)
7+
- [check](#check-)
8+
- [set](#set-)
9+
- [env](#env-)
10+
- [${}](#-variable-evaluation)
11+
- [@{}](#-program-output-evaluation)
12+
- [^{}](#-expressions-concatenation)
13+
- [if](#if--condition)
14+
- [echo](#echo-)
15+
- [configure](#configure-)
16+
- [path helpers](#s--ss--c--cc---path-helpers)
17+
- [run](#run-)
18+
- [in-sources](#in-sources-)
19+
- [run-on-install](#run-on-install-)
20+
- [foreach](#foreach-)
21+
- [cc/cxx](#cc-----cxx---)
22+
- [library](#library-)
23+
- [install](#install-)
24+
325
[Autark source code repository](https://github.com/Softmotions/autark)
426

527
**Autark** is a self-contained build system that resides entirely within
@@ -14,7 +36,7 @@ The `build.sh` script automatically initializes the Autark build system, and the
1436
Autark handles both internal and external project dependencies much more precisely and cleanly than is typically done with Makefiles by hands.
1537
Build rules are defined using a specialized DSL in Autark files, which is mostly declarative in nature.
1638

17-
## Key features of Autark
39+
## Key features
1840

1941
- To initialize the project build system on the target system, nothing is required except a C99-compliant compiler.
2042
- The build process does not modify the project's source tree.
@@ -326,30 +348,8 @@ It is primarily used for rules that install the built project artifacts.
326348
may be vague or imprecise. This is due to the use of the `leg` PEG parser generator,
327349
which can produce generic error reports for malformed input.
328350

329-
# Autark script rules
330-
331-
- [meta](#meta-)
332-
- [option](#option-)
333-
- [check](#check-)
334-
- [set](#set-)
335-
- [env](#env-)
336-
- [${}](#-variable-evaluation)
337-
- [@{}](#-program-output-evaluation)
338-
- [^{}](#-expressions-concatenation)
339-
- [if](#if--condition)
340-
- [echo](#echo-)
341-
- [configure](#configure-)
342-
- [path helpers](#s--ss--c--cc---path-helpers)
343-
- [run](#run-)
344-
- [in-sources](#in-sources-)
345-
- [run-on-install](#run-on-install-)
346-
- [foreach](#foreach-)
347-
- [cc/cxx](#cc-----cxx---)
348-
- [library](#library-)
349-
- [install](#install-)
350-
351351

352-
## meta {...}
352+
# meta {...}
353353

354354
Sets script variables using a simple convention:
355355
each variable name is automatically prefixed with `META_`.
@@ -371,7 +371,7 @@ If variable is defined using the `let` clause inside `meta`,
371371
the `META_` prefix is not added to its name.
372372

373373

374-
## option {...}
374+
# option {...}
375375

376376
```cfg
377377
option { <OPTION NAME> [OPTION DESCRIPTION] }
@@ -401,7 +401,7 @@ To list all documented build options, use:
401401
./build.sh -l
402402
```
403403

404-
## check {...}
404+
# check {...}
405405

406406
This construct is the workhorse for checking system configuration and capabilities
407407
before compiling the project. Checks are performed using `dash` shell scripts.
@@ -517,7 +517,7 @@ set {
517517
}
518518
```
519519

520-
## set {...}
520+
# set {...}
521521

522522
The `set` rule assigns a value to a variable in the build script.
523523

@@ -580,15 +580,15 @@ set {
580580
}
581581
```
582582

583-
## env {...}
583+
# env {...}
584584

585585
Similar to `set`, but sets an **environment variable** for the build process
586586
using `setenv(3)` at the operating system level.
587587

588588
Unlike `set`, the value of this rule is evaluated at the time it is executed,
589589
which happens during the `setup` phase of the build.
590590

591-
## ${...} Variable evaluation
591+
# ${...} Variable evaluation
592592

593593
```cfg
594594
${VARIABLE [DEFAULT]}`
@@ -599,7 +599,7 @@ as an argument to another rule.
599599
If the variable is not defined in the current script context, the `DEFAULT` value will be used if provided.
600600

601601

602-
## @{...} Program output evaluation
602+
# @{...} Program output evaluation
603603

604604
```cfg
605605
# Run program every build
@@ -613,7 +613,7 @@ Invokes the specified program `PROGRAM` and returns its standard output as a str
613613
The `@@` form caches the program’s output and reuses it in subsequent builds,
614614
which is useful for time-consuming invocations such as `pkg-config`.
615615

616-
### Example:
616+
## Example:
617617

618618
```cfg
619619
set {
@@ -626,7 +626,7 @@ In this example, the output of `pkgconf --libs --static libcurl` is appended to
626626
**Note** what `..` in pkgconf instruction means what space separated output of pkgconf programm
627627
will be converted to list and merged with LDFLAGS list.
628628

629-
## ^{...} Expressions concatenation
629+
# ^{...} Expressions concatenation
630630

631631
```cfg
632632
^{EXPR1 [EXPR2]...}
@@ -657,7 +657,7 @@ set {
657657

658658
Note: the space between `-DBUILD_TYPE=` and `${BUILD_TYPE}` is required.
659659

660-
## if {...} condition
660+
# if {...} condition
661661

662662
Conditional directive.
663663

@@ -692,7 +692,7 @@ If the condition `CONDITION_RULE` evaluates to a `truthy` value,
692692
the entire `if` expression is replaced by `EXPR1` in the Autark script’s instruction tree.
693693
Otherwise, if an `else` block is provided, it will be replaced by `EXPR2`.
694694

695-
### Conditions
695+
## Conditions
696696

697697
Exclamation mark `!` means expression result negation, when trufly evaluated expressions became false.
698698

@@ -732,7 +732,7 @@ Exclamation mark `!` means expression result negation, when trufly evaluated exp
732732
**Please Note:** Autark syntax does not support `else if` constructs.
733733

734734

735-
## error {...} Abort build and report error
735+
# error {...} Abort build and report error
736736

737737
Typical example `error` directive usage:
738738

@@ -742,7 +742,7 @@ if { !defined{ PTHREAD_LFLAG }
742742
}
743743
```
744744

745-
## echo {...}
745+
# echo {...}
746746

747747
Prints arbitrary information to the console (standard output, `stdout`).
748748

@@ -771,7 +771,7 @@ echo {
771771
```
772772
This will print the current values of the CFLAGS and LDFLAGS variables.
773773

774-
## configure {...}
774+
# configure {...}
775775

776776
The `configure` rule acts as a preprocessor for text files and C/C++ source templates,
777777
replacing specific sections with values of variables from the current script context.
@@ -806,7 +806,7 @@ configure {
806806
}
807807
```
808808

809-
### @...@ Substitutions
809+
## @...@ Substitutions
810810

811811
Text fragments enclosed in `@` symbols are interpreted as variable names
812812
and replaced with their corresponding values.
@@ -830,7 +830,7 @@ Cflags: -I@INSTALL_PREFIX@/@INSTALL_INCLUDE_DIR@ -I${includedir}
830830
Cflags.private: -DIW_STATIC
831831
```
832832

833-
### //autarkdef for C/C++ Headers
833+
## //autarkdef for C/C++ Headers
834834

835835
For C/C++ header files, the `//autarkdef` directive is a convenient way
836836
to conditionally generate `#define` statements based on variable presence.
@@ -862,11 +862,11 @@ If `VAR_NAME` is defined, this becomes:
862862
#define VAR_NAME 1
863863
```
864864
865-
## `S` / `SS` / `C` / `CC` / `%` Path Helpers
865+
# `S` / `SS` / `C` / `CC` / `%` Path Helpers
866866
These small helper rules are useful for computing file paths in build scripts.
867867
They help avoid hardcoding paths that may depend on the current location of the project's source code.
868868
869-
### S {...}
869+
## S {...}
870870
Computes the **absolute path** of the given argument(s) relative to the **project root**.
871871
If multiple arguments are provided, they are concatenated into a single path string.
872872
@@ -878,17 +878,17 @@ If multiple arguments are provided, they are concatenated into a single path str
878878
S{foo bar baz}
879879
```
880880

881-
### SS {...}
881+
## SS {...}
882882
Same as `S`, but relative to the directory where the current script is located.
883883

884-
### C {...}
884+
## C {...}
885885
Computes the **absolute path** to the argument(s) relative to the **project-wide autark-cache dir**.
886886

887-
### CC {...}
887+
## CC {...}
888888
Computes the **absolute path** relative to the **local cache directory** of the current script.
889889
This is the default working directory for tools and commands that operate on build artifacts.
890890

891-
### % {...}
891+
## % {...}
892892
Returns the `basename` of the given filename changing its extension optionally.
893893

894894
```cfg
@@ -903,7 +903,7 @@ Returns the `basename` of the given filename changing its extension optionally.
903903
%{hello.x .c}
904904
```
905905

906-
## run {...}
906+
# run {...}
907907

908908
The `run` rule is the most powerful construct in the Autark system.
909909
It allows you to define custom build actions and their dependency chains.
@@ -951,7 +951,7 @@ run {
951951
}
952952
```
953953

954-
## in-sources {...}
954+
# in-sources {...}
955955

956956
By default, most Autark rules are executed inside the **autark-cache dir**
957957
corresponding to the current build script.
@@ -967,7 +967,7 @@ in-sources {
967967
}
968968
```
969969

970-
### Example: Appending glob-matched source Files
970+
## Example: Appending glob-matched source Files
971971
In the example below, the `SOURCES` variable is extended with the output of a glob-matching command
972972
executed in the source directory. The result is assigned merged with `SOURCES` variable in the parent script:
973973
```cfg
@@ -982,7 +982,7 @@ set {
982982
}
983983
```
984984

985-
### Example: Finding Java Source Files
985+
## Example: Finding Java Source Files
986986
```cfg
987987
set {
988988
JAVA_SOURCES
@@ -995,7 +995,7 @@ set {
995995
This example populates `JAVA_SOURCES` with the full paths of all `.java` files under `src/main/java`,
996996
resolved from the script's source directory.
997997

998-
## run-on-install {...}
998+
# run-on-install {...}
999999

10001000
`run-on-install` is a special form of the `run` rule that is executed during the `post-build` phase.
10011001

@@ -1022,7 +1022,7 @@ with the proper build flags and installation prefix.
10221022
Reference:
10231023
https://github.com/Softmotions/iwnet/blob/master/Autark
10241024

1025-
## foreach {...}
1025+
# foreach {...}
10261026

10271027
When you need to perform many similar actions for a list of files or objects,
10281028
`foreach` provides a concise and powerful solution.
@@ -1089,7 +1089,7 @@ In this example:
10891089

10901090
This approach enables clean, scalable test orchestration without hardcoding individual test names.
10911091

1092-
## `cc { ... }` / `cxx { ... }`
1092+
# `cc { ... }` / `cxx { ... }`
10931093

10941094
This rule compiles C or C++ source files into object files,
10951095
while automatically tracking all required dependencies including header files.
@@ -1105,7 +1105,7 @@ cc|cxx {
11051105
}
11061106
```
11071107

1108-
### SOURCES
1108+
## SOURCES
11091109

11101110
The first argument must be an expression that returns a list of source files.
11111111
It can be a single string (for one file) or a list defined by a `set` rule.
@@ -1117,14 +1117,14 @@ Paths to source files can be:
11171117
- Paths relative to the cache directory corresponding to the script
11181118
(this is useful when compiling generated sources from other rules)
11191119

1120-
### COMPILER_FLAGS
1120+
## COMPILER_FLAGS
11211121

11221122
A list of compiler flags, typically defined using a set rule.
11231123

11241124
**Note:** the `-I.` flag is automatically added to the compiler flags,
11251125
which includes the current cache directory in the include path for header files.
11261126

1127-
### COMPILER_CMD
1127+
## COMPILER_CMD
11281128

11291129
The compiler to use.
11301130

@@ -1136,7 +1136,7 @@ If not explicitly specified:
11361136
**Note:** The compiler must support dependency generation using the `-MMD` flag
11371137
to allow Autark to correctly track header file dependencies.
11381138

1139-
### objects { NAME }
1139+
## objects { NAME }
11401140

11411141
By default, the `cc` rule sets a variable named `CC_OBJS`
11421142
containing the list of object files produced during compilation.
@@ -1146,7 +1146,7 @@ you may want to assign different output variable names using the `objects { NAME
11461146

11471147
This allows you to manage multiple sets of object files independently.
11481148

1149-
### consumes { ... }
1149+
## consumes { ... }
11501150

11511151
This section declares **additional dependencies** for the `cc` compilation rule.
11521152

@@ -1165,7 +1165,7 @@ You can change this using the `-J` option on the command line. For example:
11651165
This will run up to 8 compilation jobs in parallel.
11661166

11671167

1168-
## library {...}
1168+
# library {...}
11691169

11701170
Search for a library file by name.
11711171

@@ -1207,13 +1207,13 @@ This will search for `libm.a`, and if found, store its absolute path in `LIB_M`
12071207
If the library is not found, the script will terminate with an error.
12081208

12091209

1210-
## install {..}
1210+
# install {..}
12111211

12121212
If `build.sh` is run with the `-I` or `--install` option (to install all built artifacts),
12131213
or if an install prefix is explicitly specified using `-R` or `--prefix=<dir>`,
12141214
then all `install` rules will be executed after the `build` phase completes.
12151215

1216-
### Available variables when install is enabled
1216+
## Available variables when install is enabled
12171217

12181218
- `INSTALL_PREFIX` – Absolute path to the installation prefix.
12191219
**Default:** `$HOME/.local`

0 commit comments

Comments
 (0)