qnx makefiles

Hi,

I’m using QSSL’s Makefile format
(http://qdn.qnx.com/support/docs/neutrino/prog/make_convent.html)

How should I do to generate source files dependances?

I cannot find samples and explanations of a lot of makefiles
macroses such as MG_HOST, CP_HOST, LN_HOST etc.
Where can I find it?

Thanks,
vasa

vasa a écrit :

Hi,

I’m using QSSL’s Makefile format
(> http://qdn.qnx.com/support/docs/neutrino/prog/make_convent.html> )

How should I do to generate source files dependances?

Your dependencies take place in the common.mk. This is one of mines:

ifndef QCONFIG
QCONFIG=qconfig.mk
endif
include $(QCONFIG)


SO_VERSION=1.0

EXTRA_LIBVPATH= $(PRODUCT_ROOT)/mc_sinus_API/nto/x86/so
EXTRA_INCVPATH=$(PRODUCT_ROOT)/mc_sinus_API/public

include $(MKFILES_ROOT)/qmacros.mk
include $(MKFILES_ROOT)/qtargets.mk

LIBS+= Rieter_misc mc_sinus_API motors_management_API

ext_func.o : ext_func.c externs.h protos.h libmotors_management_API.h
fct_nto.o : fct_nto.c externs.h protos.h libmotors_management_API.h
$(PROJECT) : ext_func.o fct_nto.o



I cannot find samples and explanations of a lot of makefiles
macroses such as MG_HOST, CP_HOST, LN_HOST etc.
Where can I find it?

About explanations, I don’t know, these macros are initialised in
/usr/include/mk/qconf-nto.mk between others. It depends on your machine,
os, cpu…

Thanks,
vasa

How should I do to generate source files dependances?

Your dependencies take place in the common.mk. This is one of mines:

ifndef QCONFIG
QCONFIG=qconfig.mk
endif
include $(QCONFIG)


SO_VERSION=1.0

EXTRA_LIBVPATH= $(PRODUCT_ROOT)/mc_sinus_API/nto/x86/so
EXTRA_INCVPATH=$(PRODUCT_ROOT)/mc_sinus_API/public

include $(MKFILES_ROOT)/qmacros.mk
include $(MKFILES_ROOT)/qtargets.mk

LIBS+= Rieter_misc mc_sinus_API motors_management_API

ext_func.o : ext_func.c externs.h protos.h libmotors_management_API.h
fct_nto.o : fct_nto.c externs.h protos.h libmotors_management_API.h
$(PROJECT) : ext_func.o fct_nto.o

But I asked about how do to GENERATE dependaces
in Make.depand (e.g.)
and include that in Makefile as follows:
include Make.depand
Should I do it manually?

Thanks,
vasa

vasa <vv40in@rambler.ru> wrote:

But I asked about how do to GENERATE dependaces
in Make.depand (e.g.)
and include that in Makefile as follows:
include Make.depand
Should I do it manually?

Thanks,

I’s time to share this trick :wink:
makedepend can be used to generate dependecies for you project
This system works well BUT some defines (like cpu, endianess etc) can’t
be evaluated since dependencies MUST be benerated in project level
Some includes may be skipped depending on variant level

Ok, edit this file:

— autodeps.mk begin —
all: deps.mk
install: all
deps.mk: $(wildcard *.c *.cc)
touch deps.mk
makedepend -f deps.mk *.c *.cc 2> /dev/null
rm -rf deps.mk.bak
— autodeps.mk end —

Your PROJECT_LEVEL makefile should look like this:

— Makefile begin —
LIST=CPU

#include autodeps.mk
#include recurse.mk
— Makefile end —

Your common.mk should look like this:

— common.mk begin —
ifndef QCONFIG
QCONFIG=qconfig.mk
endif
include $(QCONFIG)

whatever…

include $(MKFILES_ROOT)/qtargets.mk
include $(PROJECT_ROOT)/deps.mk
— common.mk end —

You can place autodeps.mk in /usr/include/mk if you wish or into
your project root

Customize as needed™.

Nevertheless, QSSL should add this (or something similar) for
generating dependencies automatically in the future…
WE hope :slight_smile:

Bests

vasa


Wave++

Wave++ a écrit :

vasa <> vv40in@rambler.ru> > wrote:

But I asked about how do to GENERATE dependaces
in Make.depand (e.g.)
and include that in Makefile as follows:
include Make.depand
Should I do it manually?

Thanks,

I’s time to share this trick > :wink:
makedepend can be used to generate dependecies for you project
This system works well BUT some defines (like cpu, endianess etc) can’t
be evaluated since dependencies MUST be benerated in project level
Some includes may be skipped depending on variant level

Indeed, it only works at project level but why? and how to deal with os
level, cpu level…?
It’s unusable if it cannot be used for the entire product tree.


thanks,
Alain.

Hi,

I have found the resolution.
I have added the next lines in common.mk:

<common.mk (the last strings)>
Make.depend.pinfo:
gcc $(CCFLAGS) $(CFLAGS) -MM $(SRCS) > $@

include Make.depend.pinfo
</common.mk (the last strings)>


it works OK!!!
(“pinfo” suffix was added to clean Make.depend files by
entering make clean)

vasa

vasa a écrit :

Hi,

I have found the resolution.
I have added the next lines in common.mk:

common.mk (the last strings)
Make.depend.pinfo:
gcc $(CCFLAGS) $(CFLAGS) -MM $(SRCS) > $@

include Make.depend.pinfo
/common.mk (the last strings)

it works OK!!!
(“pinfo” suffix was added to clean Make.depend files by
entering make clean)

vasa

Hum, well, I propose a contest on the subject!

Thanks,
Alain.

Alain Bonnefoy <alain.bonnefoy@icbt.com> wrote:

Wave++ a crit :

vasa <> vv40in@rambler.ru> > wrote:

But I asked about how do to GENERATE dependaces
in Make.depand (e.g.)
and include that in Makefile as follows:
include Make.depand
Should I do it manually?

Thanks,

I’s time to share this trick > :wink:
makedepend can be used to generate dependecies for you project
This system works well BUT some defines (like cpu, endianess etc) can’t
be evaluated since dependencies MUST be benerated in project level
Some includes may be skipped depending on variant level

Indeed, it only works at project level but why? and how to deal with os
level, cpu level…?
It’s unusable if it cannot be used for the entire product tree.

It’s simple. To use significatively your variant level you should pass
ALL defines passed to the compiler to makedepend.

Actually I’ve found no variables in qnx .mk files that stores this
data.

Also, the variant level makefile all directive is not executed as first
rule as I’ve seen, so you can’t generate dependencies reliabily.

You can try this variant level makefile yourself:

Makefile:

all: deps.mk
install: all
deps.mk:
( cd $(PROJECT_ROOT); makedepend -f $$OLDPWD/deps.mk
-D$(OS) -D$(CPU) *.cc *.hh 2> /dev/null; )

include deps.mk
include …/…/common.mk

ok, I’ve wrote this now (surely must be tweaked) but you can experiment
yourself what I mean

thanks,
Alain.


Wave++

vasa <vv40in@rambler.ru> wrote:

Hi,

I have found the resolution.
I have added the next lines in common.mk:

I’ve not well understood. Can you post the complete makefiles?

common.mk (the last strings)
Make.depend.pinfo:
gcc $(CCFLAGS) $(CFLAGS) -MM $(SRCS) > $@

include Make.depend.pinfo
/common.mk (the last strings)



it works OK!!!
(“pinfo” suffix was added to clean Make.depend files by
entering make clean)

vasa













Wave++

Wave++ a écrit :

Alain Bonnefoy <> alain.bonnefoy@icbt.com> > wrote:
Wave++ a crit :

vasa <> vv40in@rambler.ru> > wrote:

But I asked about how do to GENERATE dependaces
in Make.depand (e.g.)
and include that in Makefile as follows:
include Make.depand
Should I do it manually?

Thanks,

I’s time to share this trick > :wink:
makedepend can be used to generate dependecies for you project
This system works well BUT some defines (like cpu, endianess etc) can’t
be evaluated since dependencies MUST be benerated in project level
Some includes may be skipped depending on variant level

Indeed, it only works at project level but why? and how to deal with os
level, cpu level…?
It’s unusable if it cannot be used for the entire product tree.

It’s simple. To use significatively your variant level you should pass
ALL defines passed to the compiler to makedepend.

Actually I’ve found no variables in qnx .mk files that stores this
data.

Also, the variant level makefile all directive is not executed as first
rule as I’ve seen, so you can’t generate dependencies reliabily.

You can try this variant level makefile yourself:

Makefile:

all: deps.mk
install: all
deps.mk:
( cd $(PROJECT_ROOT); makedepend -f $$OLDPWD/deps.mk
-D$(OS) -D$(CPU) *.cc *.hh 2> /dev/null; )

include deps.mk
include …/…/common.mk

ok, I’ve wrote this now (surely must be tweaked) but you can experiment
yourself what I mean

thanks,
Alain.


Wave++

Bad luck,
-D is a define option, not a directory option.
I tried all the morning to find a satisfactory solution, even writing an
autodeps.mk based on the recurse.mk, without success. There is allways
something that cause problems.

Wait and see!

Regards,
Alain.

“Wave++” <wavexx@ngweb.it> wrote in message news:9stah1$n9j$2@inn.qnx.com

vasa <> vv40in@rambler.ru> > wrote:
Hi,

I have found the resolution.
I have added the next lines in common.mk:

I’ve not well understood. Can you post the complete makefiles?

common.mk (the last strings)
Make.depend.pinfo:
gcc $(CCFLAGS) $(CFLAGS) -MM $(SRCS) > $@

include Make.depend.pinfo
/common.mk (the last strings)


it works OK!!!
(“pinfo” suffix was added to clean Make.depend files by
entering make clean)

easy – do that corections in common.mk
and all dependances will be working OK!!!

Limitation:
You should use
CCFLAGS += -I your-inc-path1 -I your-inc-path2
instead of
EXTRA_INCPATH += your-inc-path1 your-inc-path2
(AFAIR) macro
It is because:
Make.depend.pinfo:
gcc $(CCFLAGS) $(CFLAGS) -MM $(SRCS) > $@
and gcc finds includes with help of CCFLAGS macro
but not with EXTRA_INCPATH macro

vasa

I’ve thought a possible solution yeasterday…
Usually in your makefile three you have:

  • project level
  • cpu
  • variant

Or whatever, the important part is the variant level.
Simply, you can generate dependencies in your variant level and
compile the sources effectively into a sublevel:

  • project
  • cpu
  • variant (dependecies generation here)
  • build (include common.mk effectively here)

Surely is a better solution than the one proposed by vasa, however
you must enlarge your project three a bit

Since you build deps.mk into your variant level, you can pass
-D$(OS) -D$(CPU) -D$(whatever you need) to makedepend

Still searching a better solution,
this three is getting to deep :slight_smile:

Bests


Alain Bonnefoy <alain.bonnefoy@icbt.com> wrote:

Bad luck,
-D is a define option, not a directory option.
I tried all the morning to find a satisfactory solution, even writing an
autodeps.mk based on the recurse.mk, without success. There is allways
something that cause problems.

Wait and see!

Regards,
Alain.


Wave++

Wave++ a écrit :

I’ve thought a possible solution yeasterday…
Usually in your makefile three you have:

  • project level
  • cpu
  • variant

Or whatever, the important part is the variant level.
Simply, you can generate dependencies in your variant level and
compile the sources effectively into a sublevel:

  • project
  • cpu
  • variant (dependecies generation here)
  • build (include common.mk effectively here)

Surely is a better solution than the one proposed by vasa, however
you must enlarge your project three a bit

Since you build deps.mk into your variant level, you can pass
-D$(OS) -D$(CPU) -D$(whatever you need) to makedepend

Still searching a better solution,
this three is getting to deep > :slight_smile:

Bests

Alain Bonnefoy <> alain.bonnefoy@icbt.com> > wrote:
Bad luck,
-D is a define option, not a directory option.
I tried all the morning to find a satisfactory solution, even writing an
autodeps.mk based on the recurse.mk, without success. There is allways
something that cause problems.

Wait and see!

Regards,
Alain.


Wave++

I don’t really understand why you use the ‘-D’ option. It seems that you use
that as a ‘Directory search’ option but according to the doc I read, -D is
like a ‘Define’ option. Unfortunately, it seems that makedepend doesn’t
propose the equivalent to ‘-C’ option of gcc.

Could you make it clear?

Thanks,
Alain.

Alain Bonnefoy <alain.bonnefoy@icbt.com> wrote:

I don’t really understand why you use the ‘-D’ option. It seems that you use
that as a ‘Directory search’ option but according to the doc I read, -D is
like a ‘Define’ option. Unfortunately, it seems that makedepend doesn’t
propose the equivalent to ‘-C’ option of gcc.

Could you make it clear?

-D is NOT a directory option. -D (as you can read in the docs) is a define
flag. Since makedepend effectively is a preprocessor MUST know at least
the essential defines like CPU and OS. gcc also has a -D option that
works in the same manner. If you don’t pass these defines to makedepend
some includes may be skipped or (more likely) makedepend will crash into
an #error line. If you have noticed, in /etc/config/qcc (or similar)
inside the configuration files of qcc, many -D flags are passed to gcc.
All these defines should be passed to makedepend for aperfect
dependency generation. Passing only $(OS) and $(CPU) at least removes
some warnings about endianess (many includes seems to need it defined)

Hope this can clarify

Thanks,
Alain.


Wave++

Wave++ a écrit :

Alain Bonnefoy <> alain.bonnefoy@icbt.com> > wrote:
I don’t really understand why you use the ‘-D’ option. It seems that you use
that as a ‘Directory search’ option but according to the doc I read, -D is
like a ‘Define’ option. Unfortunately, it seems that makedepend doesn’t
propose the equivalent to ‘-C’ option of gcc.

Could you make it clear?

-D is NOT a directory option. -D (as you can read in the docs) is a define
flag. Since makedepend effectively is a preprocessor MUST know at least
the essential defines like CPU and OS. gcc also has a -D option that
works in the same manner. If you don’t pass these defines to makedepend
some includes may be skipped or (more likely) makedepend will crash into
an #error line. If you have noticed, in /etc/config/qcc (or similar)
inside the configuration files of qcc, many -D flags are passed to gcc.
All these defines should be passed to makedepend for aperfect
dependency generation. Passing only $(OS) and $(CPU) at least removes
some warnings about endianess (many includes seems to need it defined)

Hope this can clarify

Thanks,
Alain.


Wave++

Ok, in fact I find a good deps.mk generation with some modifications to your
makefile:
It’s ok only if you have source files at project and project/os levels. Otherwise
add a generation line.


all: deps.mk
install: all
deps.mk:
touch deps.mk
( cd $(PROJECT_ROOT); makedepend -f $$OLDPWD/deps.mk -D$(OS) -D$(CPU) $(addprefix
-I, $(INCVPATH)) *.c *.h 2>/dev/null; cd $$OLDPWD;
cd $(PROJECT_ROOT)/$(OS); makedepend -a -f $$OLDPWD/deps.mk -D$(OS) -D$(CPU)
$(addprefix -I, $(INCVPATH)) *.c *.h 2>/dev/null; )

include deps.mk
include …/…/…/common.mk

Regards,
Alain.

all: deps.mk
install: all
deps.mk:
touch deps.mk
( cd $(PROJECT_ROOT); makedepend -f $$OLDPWD/deps.mk -D$(OS) -D$(CPU)
$(addprefix
-I, $(INCVPATH)) *.c *.h 2>/dev/null; cd $$OLDPWD;
cd $(PROJECT_ROOT)/$(OS); makedepend -a -f
$$OLDPWD/deps.mk -D$(OS) -D$(CPU)
$(addprefix -I, $(INCVPATH)) *.c *.h 2>/dev/null; )

include deps.mk
include …/…/…/common.mk

AFAIU You offer to include above lines into EACH makefile highest-level
file?
i dont think it is good idea
I have offered to add some lines in common.mk only

vasa

vasa a écrit :

all: deps.mk
install: all
deps.mk:
touch deps.mk
( cd $(PROJECT_ROOT); makedepend -f $$OLDPWD/deps.mk -D$(OS) -D$(CPU)
$(addprefix
-I, $(INCVPATH)) *.c *.h 2>/dev/null; cd $$OLDPWD;
cd $(PROJECT_ROOT)/$(OS); makedepend -a -f
$$OLDPWD/deps.mk -D$(OS) -D$(CPU)
$(addprefix -I, $(INCVPATH)) *.c *.h 2>/dev/null; )

include deps.mk
include …/…/…/common.mk

AFAIU You offer to include above lines into EACH makefile highest-level
file?
i dont think it is good idea
I have offered to add some lines in common.mk only

vasa

No, only at bottom level. The resulting deps.mk will be created at bottom
level also.
In fact I followed the wave+'s idea and tried to find a satisfactory working
but, i didn’t tried other way. Maybe it could be done in the common.mk. I’ll
try to see.

Alain.

vasa a écrit :

all: deps.mk
install: all
deps.mk:
touch deps.mk
( cd $(PROJECT_ROOT); makedepend -f $$OLDPWD/deps.mk -D$(OS) -D$(CPU)
$(addprefix
-I, $(INCVPATH)) *.c *.h 2>/dev/null; cd $$OLDPWD;
cd $(PROJECT_ROOT)/$(OS); makedepend -a -f
$$OLDPWD/deps.mk -D$(OS) -D$(CPU)
$(addprefix -I, $(INCVPATH)) *.c *.h 2>/dev/null; )

include deps.mk
include …/…/…/common.mk

AFAIU You offer to include above lines into EACH makefile highest-level
file?
i dont think it is good idea
I have offered to add some lines in common.mk only

vasa

I tried to insert these lines at the end of the common.mk:
-----------After the last line of common.mk------------
all: deps.mk
install: all
deps.mk:
( cd $(PROJECT_ROOT); makedepend -f $(PROJECT_ROOT)/deps.mk -D$(OS)
-D$(CPU) $(addprefix -I, $(INCVPATH)) *.c *.h 2>/dev/null;
cd $(PROJECT_ROOT)/$(OS); makedepend -a -f $(PROJECT_ROOT)/deps.mk -D$(OS)
-D$(CPU) $(addprefix -I, $(INCVPATH)) *.c *.h 2>/dev/null; )

include $(PROJECT_ROOT)/deps.mk
-------End of common.mk-----------

It works ok!
deps.mk is generated at each make invocation. But I think it’s normal. It’s
impossible to figure out when dependencies are no more valid of course! Or
you know the dependecies yet!

Alain.

Alain Bonnefoy <alain.bonnefoy@icbt.com> wrote:

I tried to insert these lines at the end of the common.mk:
-----------After the last line of common.mk------------
all: deps.mk
install: all
deps.mk:
( cd $(PROJECT_ROOT); makedepend -f $(PROJECT_ROOT)/deps.mk -D$(OS)
-D$(CPU) $(addprefix -I, $(INCVPATH)) *.c *.h 2>/dev/null;
cd $(PROJECT_ROOT)/$(OS); makedepend -a -f $(PROJECT_ROOT)/deps.mk -D$(OS)
-D$(CPU) $(addprefix -I, $(INCVPATH)) *.c *.h 2>/dev/null; )

include $(PROJECT_ROOT)/deps.mk
-------End of common.mk-----------

It works ok!
deps.mk is generated at each make invocation. But I think it’s normal. It’s
impossible to figure out when dependencies are no more valid of course! Or
you know the dependecies yet!

There’s a problem here.
If you erase the deps.mk file make will stop.
And you can figure out why:

make parses all the common.mk, INCLUDES deps.mk and THEN executes the
directives. That’s why you should generate dependecies before the
variant level (or, build sources after it).

Another direct problem follows:

If you change some dependencies, make will ignore them until you launch
it for the second time (since in the first one dependencies will be
regenerated).

To stop make rebuilding deps.mk every time, simpy change it’s
directive:

deps.mk: $(wildcard $(PROJECT_ROOT)/*.cc)

whatever

Cheers


Wave++

Wave++ a écrit :

Alain Bonnefoy <> alain.bonnefoy@icbt.com> > wrote:
I tried to insert these lines at the end of the common.mk:
-----------After the last line of common.mk------------
all: deps.mk
install: all
deps.mk:
( cd $(PROJECT_ROOT); makedepend -f $(PROJECT_ROOT)/deps.mk -D$(OS)
-D$(CPU) $(addprefix -I, $(INCVPATH)) *.c *.h 2>/dev/null;
cd $(PROJECT_ROOT)/$(OS); makedepend -a -f $(PROJECT_ROOT)/deps.mk -D$(OS)
-D$(CPU) $(addprefix -I, $(INCVPATH)) *.c *.h 2>/dev/null; )

include $(PROJECT_ROOT)/deps.mk
-------End of common.mk-----------

It works ok!
deps.mk is generated at each make invocation. But I think it’s normal. It’s
impossible to figure out when dependencies are no more valid of course! Or
you know the dependecies yet!

There’s a problem here.
If you erase the deps.mk file make will stop.
And you can figure out why:

make parses all the common.mk, INCLUDES deps.mk and THEN executes the
directives. That’s why you should generate dependecies before the
variant level (or, build sources after it).

Ok, I saw this problem

Another direct problem follows:

If you change some dependencies, make will ignore them until you launch
it for the second time (since in the first one dependencies will be
regenerated).

I didn’t really pay attention to this problem so you propose to let the deps.mk
generation in the bottom level makefile?

To stop make rebuilding deps.mk every time, simpy change it’s
directive:

deps.mk: $(wildcard $(PROJECT_ROOT)/*.cc)

whatever

Thanks for this point, I’ll think about.


In fact I still have a problem with that. I works ok in a local shell, but I edit
my projects on NT and I build them with rsh.
rsh stop with an error after executing makedepend with the following error
message.

make[3]: *** [deps.mk] Error 127
make[2]: *** [all] Error 2
make[1]: *** [all] Error 2
make: *** [all] Error 2

I think that there is a little problem of syntax somewhere but I didn’t find it.