From 13a522b804f4bf5bcc396326ac59a93ab86a68a6 Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Sun, 21 Oct 2007 10:49:00 +0000 Subject: [PATCH 1/1] More documentation and some test to what is written in documentation. darcs-hash:20071021104959-f2ef6-49de76246d45a4a42f51f439276affdebe520f38.gz --- doc/manual.texinfo | 77 ++++++++++++++++++++++++-- tests/programs/includes/Makefile | 16 ++++++ tests/programs/includes/Makefile.omk | 5 ++ tests/programs/includes/inc/mynumber.h | 1 + tests/programs/includes/runtest | 4 ++ tests/programs/includes/test.c | 7 +++ tests/programs/runtest-defs | 9 +++ 7 files changed, 114 insertions(+), 5 deletions(-) create mode 100644 tests/programs/includes/Makefile create mode 100644 tests/programs/includes/Makefile.omk create mode 100644 tests/programs/includes/inc/mynumber.h create mode 100755 tests/programs/includes/runtest create mode 100644 tests/programs/includes/test.c create mode 100755 tests/programs/runtest-defs diff --git a/doc/manual.texinfo b/doc/manual.texinfo index eaa287e..a8d4ccf 100644 --- a/doc/manual.texinfo +++ b/doc/manual.texinfo @@ -61,6 +61,8 @@ Cygwin and MinGW. MS DOS was not tested. @c Cygwin, MS DOS and maybe others. @c @end itemize +@section Why to Use OMK? + @section Quick Start If you get some sources, which are distributed with OMK, usually the @@ -466,21 +468,84 @@ intermediate compilation products (object files, dependency files etc.). @section Dependency Tracking OMK automatically handles tracking of dependencies of compiled -projects. It uses gcc's @option{-Mx} options to do this for object -files. This way, whenever you change some header file, OMK recompiles -only those files, where the changed header was really included. +projects. It uses gcc's @option{-M@var{x}} options to do this for +object files. This way, whenever you change some header file, OMK +recompiles only those files, where the changed header was really +included. Dependencies are also kept for libraries and binaries. OMK parses linker -map files, so a change to some library causes all programs using this -library to be recompiled. +map files, so a change to some library causes recompilation of all +programs using this library. @section Compiling Simple Programs +To tell OMK to compile a program, you need to set some variables in +@file{Makefile.omk} (usually) in the directory where program sources are +located. + +In the example bellow a program @command{test} will be compiled from +source @file{test.c}. + +@example +@verbatiminclude ../tests/programs/Makefile.omk +@end example + +@noindent The variables are: + +@defvar bin_PROGRAMS +Contains a list of names (whitespace separated) of programs to be +compiled in this directory. +@end defvar + +@defvar @var{program name}_SOURCES +For every program name in @code{bin_PROGRAMS}, this variable contains a +list of sources that are needed to compile the executable. OMK uses an +extension of the filename to determine the compiler to compile this +source. +@end defvar + +@defvar @var{program name}_LIBS +This variable contains a list of libraries the program @var{program +name} needs to be linked to. +@end defvar + +@defvar LOADLIBES +This variable contains a list of libraries all programs in this +directory needs to be linked to. +@end defvar + +@defvar INCLUDES +Directives passed to the C or C++ compiler with additional directories +to be searched for header files. This variable applies to all +compilations invoked in the current directory. +@example +INCLUDES = -Imy_include_dir +@end example +@end defvar + +@defvar DEFS +Directives passed to the C or C++ compiler with preprocessor macro +definitions. This variable applies to all compilations invoked in the +current directory. +@example +DEFS = -DDEBUG=1 +@end example +@end defvar + + + +@c FIXME: INCLUDES variable should not be set by rtlinux rules. + @section Libraries LN_INCLUDES +@section Multiple Directories + +ALL_OMK_SUBDIRS +SUBDIRS + @node Configuration and Conditional Compilation @section Configuration and Conditional Compilation @@ -490,6 +555,8 @@ LN_INCLUDES Renaming of some file => dependency problems. +Manual compilation ... V=1 + @chapter OMK Reference diff --git a/tests/programs/includes/Makefile b/tests/programs/includes/Makefile new file mode 100644 index 0000000..aa6b442 --- /dev/null +++ b/tests/programs/includes/Makefile @@ -0,0 +1,16 @@ +# Generic directory or leaf node makefile for OCERA make framework + +ifndef MAKERULES_DIR +MAKERULES_DIR := $(shell ( old_pwd="" ; while [ ! -e Makefile.rules ] ; do if [ "$$old_pwd" == `pwd` ] ; then exit 1 ; else old_pwd=`pwd` ; cd -L .. 2>/dev/null ; fi ; done ; pwd ) ) +endif + +ifeq ($(MAKERULES_DIR),) +all : default +.DEFAULT:: + @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n" +else +include $(MAKERULES_DIR)/Makefile.rules +endif + +print_vars: + echo $(COMPILED_DIR) \ No newline at end of file diff --git a/tests/programs/includes/Makefile.omk b/tests/programs/includes/Makefile.omk new file mode 100644 index 0000000..2d87a10 --- /dev/null +++ b/tests/programs/includes/Makefile.omk @@ -0,0 +1,5 @@ +bin_PROGRAMS = test + +test_SOURCES = test.c + +INCLUDES = -I$(SOURCES_DIR)/inc diff --git a/tests/programs/includes/inc/mynumber.h b/tests/programs/includes/inc/mynumber.h new file mode 100644 index 0000000..5ff1730 --- /dev/null +++ b/tests/programs/includes/inc/mynumber.h @@ -0,0 +1 @@ +#define NUMBER 456 diff --git a/tests/programs/includes/runtest b/tests/programs/includes/runtest new file mode 100755 index 0000000..81dd9fc --- /dev/null +++ b/tests/programs/includes/runtest @@ -0,0 +1,4 @@ +#!/bin/sh + +touch config.omk-default +make diff --git a/tests/programs/includes/test.c b/tests/programs/includes/test.c new file mode 100644 index 0000000..03b1a93 --- /dev/null +++ b/tests/programs/includes/test.c @@ -0,0 +1,7 @@ +#include +#include +int main() +{ + printf("NUMBER is %d\n", NUMBER); + return 0; +} diff --git a/tests/programs/runtest-defs b/tests/programs/runtest-defs new file mode 100755 index 0000000..88a6c68 --- /dev/null +++ b/tests/programs/runtest-defs @@ -0,0 +1,9 @@ +#!/bin/sh + +source ../functions.sh + +touch config.omk-default +echo "DEFS=-DNUMBER=123" > config.omk +make||canttest "Can't compile" +[ $OMK_RULES != linux ] && canttest "Should work only with Linux rules" +_compiled/bin/test|grep 123 || error "Variable DEFS didn't influence the output" -- 2.39.2