Project

General

Profile

Actions

Why

There is a reasonable question. Why do we need yet another build system when there are other nice like CMake, Automake etc.
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.
SMake can perform these operations in a fraction of a second.
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.
For me it was easy to create Makefile-s for all my old program in one second by one command

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

It really saved my time ;-)

Other reason for this project are explicit source dependencies. Have you heard the phrase among developers "make clean"? ;-)
With strong explicit dependencies no need to clean the build. It saves time on building when develop any project.

Keys

-S [SRC], --sources [SRC]

Set SRC as path for search sources (ex: -S/home/user/src).

-P [PKG], --package [PKG]

Set PKG as used package (ex: -Pglib-2.0).

-I [INC], --include [INC]

Set INC as system include path (ex: -I/usr/include/glib-2.0).

-l [LIB], --libs [LIB]

Set LIB as libraries that must be linked with (ex: -lglib-2.0).

-c [CC], --cc [CC]

Use CC as C compiler (ex: -cgcc).

-x [CXX], --cxx [CXX]

Use CXX as C++ compiler (ex: -xg++).

-t [TGT], --target [TGT]

Set TGT as target name (ex: -tmain).

Examples

This command tries to create Makefile for program.c main project source file with main () function and warn about not found sources.

smake.sh -t program

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.

smake.sh -t main -S~/inc -S../include -I/usr/local/include -Pglu -lmylib -cicc -xg++

Runing make

When You debug your project it is enouth to tap.

make

It activates debug mode by default.

To speed up building --jobs option for make specified.

make -j5

To profile your code need to set mode variable.

make mode=profile

When you give your compiled source to your colleguies developers you can sed develop mode.

make mode=develop

And finally when release is ready it is prefer to set release mode or write appropriate CMake or Automake configs.

make mode=release

Also several options can be specified through environment variables.
Examples:

# CFLAGS="-O2 -march=core2 -mtune=core2 -msse4.1 -mfpmath=sse -fomit-frame-pointer -pipe" LDFLAGS="-Wl,-O1" make mode=develop
# CFLAGS="-O2 -march=amdfam10 -mtune=amdfam10 -msse4a --mfpmath=sse -fomit-frame-pointer -pipe" LDFLAGS="-Wl,-O1" make mode=profile
# CFLAGS="-O2 -march=k6-2 -mtune=k6-2 -m3dnow --mfpmath=387 -fomit-frame-pointer -pipe" LDFLAGS="-Wl,-O1" make mode=release

Updated by Kolan Sh about 10 years ago ยท 4 revisions

Also available in: PDF HTML TXT