Project

General

Profile

Wiki » History » Version 4

Kolan Sh, 10/25/2014 11:05 PM

1 4
h1. Why
2
3
There is a reasonable question. Why do we need yet another build system when there are other nice like CMake, Automake etc.
4
It's very simple. During the start of a large project hierarchy of units continually changing. And every time to change the relevant configs assembly is time consuming.
5
SMake can perform these operations in a fraction of a second.
6
The developer does not need to be distracted from its primary mission. He just put _smake.sh_ in a console and it automatically recreates Makefile with all parameters saved in it on last SMake execution.
7
For me it was easy to create Makefile-s for all my old program in one second by one command
8
<pre>
9
for dir in projects/* ; do cd $dir && target=`ls main.{c,cpp} *.{c,cpp} 2>/dev/null | head -n1` && smake.sh -t ${target%.*} && cd - ; done
10
</pre>
11
It really saved my time ;-)
12
13
Other reason for this project are explicit source dependencies. Have you heard the phrase among developers "make clean"? ;-)
14
With strong explicit dependencies no need to clean the build. It saves time on building when develop any project.
15
16
h1. Keys
17
18
h3. -S [SRC], --sources [SRC]
19
20
Set SRC as path for search sources (ex: -S/home/user/src).
21
22
h3. -P [PKG], --package [PKG]
23
24
Set PKG as used package (ex: -Pglib-2.0).
25
26
h3. -I [INC], --include [INC]
27
28
Set INC as system include path (ex: -I/usr/include/glib-2.0).
29
30
h3. -l [LIB], --libs [LIB]
31
32
Set LIB as libraries that must be linked with (ex: -lglib-2.0).
33
34
h3. -c [CC], --cc [CC]
35
36
Use CC as C compiler (ex: -cgcc).
37
38
h3. -x [CXX], --cxx [CXX]
39
40
Use CXX as C++ compiler (ex: -xg++).
41
42
h3. -t [TGT], --target [TGT]
43
44
Set TGT as target name (ex: -tmain).
45
46
h1. Examples
47
48
This command tries to create Makefile for program.c main project source file with _main ()_ function and warn about not found sources.
49
<pre>
50
smake.sh -t program
51
</pre>
52
53
Next command creates Makefile for main.c with custom sources in _~/inc_ and _../include_ directories and headers (without sources) in _/usr/local/include_. Also it creates appropriate rules to build with _glu_ package and custom user _mylib_ library.
54
<pre>
55
smake.sh -t main -S~/inc -S../include -I/usr/local/include -Pglu -lmylib -cicc -xg++
56
</pre>
57
58
h1. Runing make
59
60
When You debug your project it is enouth to tap.
61
<pre>
62
make
63
</pre>
64
It activates _debug_ mode by default.
65
66
To speed up building _--jobs_ option for _make_ specified.
67
<pre>
68
make -j5
69
</pre>
70
71
To profile your code need to set _mode_ variable.
72
<pre>
73
make mode=profile
74
</pre>
75
76
When you give your compiled source to your colleguies developers you can sed _develop_ mode.
77
<pre>
78
make mode=develop
79
</pre>
80
81
And finally when release is ready it is prefer to set _release_ mode or write appropriate CMake or Automake configs.
82
<pre>
83
make mode=release
84
</pre>
85
86
Also several options can be specified through environment variables.
87
Examples:
88
<pre>
89
# CFLAGS="-O2 -march=core2 -mtune=core2 -msse4.1 -mfpmath=sse -fomit-frame-pointer -pipe" LDFLAGS="-Wl,-O1" make mode=develop
90
# CFLAGS="-O2 -march=amdfam10 -mtune=amdfam10 -msse4a --mfpmath=sse -fomit-frame-pointer -pipe" LDFLAGS="-Wl,-O1" make mode=profile
91
# CFLAGS="-O2 -march=k6-2 -mtune=k6-2 -m3dnow --mfpmath=387 -fomit-frame-pointer -pipe" LDFLAGS="-Wl,-O1" make mode=release
92
</pre>