Seed7 - The extensible programming language
Seed7 FAQ Manual Screenshots Examples Libraries Algorithms Download Links
Screenshots Panic Mandelbr Planets Comanche Calc7 Savehd7 Compiler Dnafight Sudoku Wator Tar7 Sydir7 Ftp7 Castle Tetris Make7 Ftpserv Basic Pairs Shisen Eliza Toutf8 Lander Wiz Startrek Mahjong
Screenshots
Make7 Source Code
 previous   up   next 

Make7 is the Seed7 version of the make utility. Make is used to manage the compilation process of a program. This is done with the help of a makefile. A makefile describes the relationships among files in the program, and the commands for updating each file. In a program, typically the executable file is updated from object files, which are in turn made by compiling source files.

Make7 is designed to process makefiles from Unix and Windows make utilities. Therefore the characteristics of several make utilities can be found in make7. Make7 concentrates to provide basic make features in a portable way. Many advanced features of other make utilities are left out in make7.

Usage

Make7 can be called from a command window with:

make7 [options] [targets]

Targets specifies the target rules to be processed. When no targets are specified make7 processes the first rule of the makefile. The following options are supported by make7:

-h
Write make7 usage.
-C dir
Change to dir before reading the makefile or doing anything else.
-f file
Use file as a makefile.
-i
Ignore all errors in commands executed.
-n
Print the commands that would be executed, but do not execute them.
-s
Silent operation. Do not print the commands as they are executed.

Make7 uses the option -f to determine the name of the makefile. If no -f option is present, make7 will look for the makefiles makefile, and Makefile, in that order.

Example of a make7 usage:

../prg/make7 depend

Makefile

The description of makefile properties below applies to makefiles accepted by make7. Lines starting with the number sign (#) are interpreted as comments up to the end of the line. The rules in a makefile look like:

target: dependencies ...
        commands

Target names consist of printable ASCII characters except space, tab, colon (:) and equal (=). The dependencies are a possibly empty list of target names. In the dependency list the target names are separated by spaces or tabs. The dependencies can span two or more lines, when all lines except the last end with a backslash (\). Lines with commands are introduced with tabs or spaces (Historically make only allowed tabs). There can be several lines with commands (all introduced with spaces or tabs). It is also allowed to put several semicolon separated commands in a line. When the first character after the tab and space characters is a number sign (#) the command line is interpreted as comment up to the end of the line. When a command is prefixed with an at sign (@) the command is not printed, when it is executed. When a command is prefixed with a minus sign (-) possible errors of the command are ignored. Combinations of this prefixes (@- and -@) are also possible. The following built-in commands are supported:

rm    Remove files (Unix command)
del    Delete files (Dos/Windows command)
erase    Delete files (Dos/Windows command)
cp    Copy files (Unix command)
copy    Copy files (Dos/Windows command)
xcopy    Copy files and directories (Dos/Windows command)
mv    Move files (Unix command)
move    Move files (Dos/Windows command)
pwd    Print current working directory
echo    Echo string(s) to standard output
cd    Change directory
make    Call make7 command
rem    Windows omment (remark) line
#    Unix comment (remark) line

The built-in commands are operating system independent, but they support only a limited set of options:

rm   -f   Ignore nonexistent files
rm   -r   Remove directories and their contents recursively
rm   -R   Remove directories and their contents recursively
del   /S   Remove directories and their contents recursively
erase   /S   Remove directories and their contents recursively
cp   -n   Do not overwrite existing files
cp   -a   Preserve mode, ownership and timestamps
cp   -p   Preserve mode, ownership and timestamps
cp   -r   Copy directories recursively
cp   -R   Copy directories recursively
copy   /Y   Overwrite existing files
xcopy   /E   Copies all subdirectories
xcopy   /O   Copies file ownership
xcopy   /Y   Overwrite existing files
mv   -n   Do not overwrite existing files
move   /Y   Overwrite existing files
pwd   -W   Write windows path (option is ignored)

Other commands are executed with the operating system shell. The output of a command can be redirected into a file. E.g.:

    echo "#define PATH_DELIMITER '/'" > version.h
    echo "#define USE_DIRENT" >> version.h
    echo "#define OBJECT_FILE_EXTENSION \".o\"" >> version.h
    echo "#define C_COMPILER \"$(CC)\"" >> version.h

Echo works also without quotation marks. E.g.:

    echo #define PATH_DELIMITER '\\' > version.h
    echo #define USE_DIRWIN >> version.h
    echo #define OBJECT_FILE_EXTENSION ".obj" >> version.h
    echo #define C_COMPILER "$(CC)" >> version.h

The caret can be used in unquoted strings to describe certain special characters (which would be interpreted wrongly by some make utilities):

    echo ^#define PATH_DELIMITER '\\' > version.h
    echo ^#define USE_DIRENT >> version.h
    echo ^#define OBJECT_FILE_EXTENSION ".obj" >> version.h
    echo ^#define EXECUTABLE_FILE_EXTENSION ".exe" >> version.h
    echo ^#define C_COMPILER "$(CC)" >> version.h

Echo commands are allowed to contain a backtick (`) command. E.g.:

    cd ../bin; echo "#define SEED7_LIB \"`pwd`/$(SEED7_LIB)\"" >> ../src/version.h; cd ../src
    cd ../bin; echo "#define COMP_DATA_LIB \"`pwd`/$(COMP_DATA_LIB)\"" >> ../src/version.h; cd ../src
    cd ../bin; echo "#define COMPILER_LIB \"`pwd`/$(COMPILER_LIB)\"" >> ../src/version.h; cd ../src
    cd ../lib; echo "#define SEED7_LIBRARY \"`pwd`\"" >> ../src/version.h; cd ../src

The following pattern rules are predefined, when they are not defined in the makefile:

%.o: %.c
    $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@
%.obj: %.c
    $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@

The following suffix rules are supported:

.c.o
.c.obj

Lines to define makefile macros look like:

macro=value

Macro names consist of printable ASCII characters except space, tab, closing parenthesis ()) and equal (=). The value of the macro is the string after = up to, but not including, the end of the line. Leading whitespace is not part of the value. A macro definition is:

CFLAGS = -O2 -g -Wall -Wstrict-prototypes -Winline

A macro can be used by surrounding its name with parentheses and prefixing the expression with a dollar sign ($). E.g.:

$(CFLAGS)

Macros can be used in targets, dependencies, commands or macro values. The following internal macros are predefined:

$@    The full target name of the current target
$<    The first dependency of the current rule
$?    The dependencies of the current rule without double entries
$^    The dependencies of the current rule without double entries
$+    The dependencies of the current rule
$$    The character $

There are functions that can be used to transform text:

FunctionDescriptionExampleExample result
$(strip string) Removes leading and trailing whitespace. $(strip a b c ) a b c
$(subst from,to,text) Replace from by to in text $(subst ld,ne,old gold) one gone
$(patsubst pat,to,text) Replace words that match the pattern pat with to. $(patsubst %.c,%.o,x.c y.c) x.o y.o
$(wildcard pat) Create list of file names that match the pattern pat. $(wildcard dep*) depend

For the replacement function shorthands are defined:

ShorthandLong versionComment
$(var:pat=to)$(patsubst pat,to,$(var))Both pat and to contain a percent character (%).
$(var:suffix=to)$(patsubst %suffix,%to,$(var))One of suffix and to contains no percent character (%).

Operation method

Processing a makefile starts with processing the specified target rule, or with processing the first rule when no target was specified. When a rule is processed the dependency rules are called recursively. When a rule is processed and the target file is missing the commands of the rule are executed. When a rule is processed and at least one dependency file is newer than the targed file the commands of the rule are executed.

Download

Make7 is written in the Seed7 programming language and can be downloaded as part of the Seed7 package. To use make7 it is necessary to compile the Seed7 interpreter. Afterwards Make7 can be started from the directory 'seed7/prg' with:

./s7 make7

Make7 can be also compiled with:

./s7 s7c make7

This creates an executable which can be used without the 's7' interpreter.


Write make7 usage with option -h

Do make depend for Seed7

Do make for Seed7

 previous   up   next