Dynamically generating .h file

Hi, I need to dynamically generate a .h file before compiling the source
code. I am using the QNX recursive make file.
In common.mk, I used PRE_BUILD = macro, it appears this macro executes
the instruction before the linking and after compiling the object. I am
getting “can not find .h file” error. Is there any way I can generate my
…h file before compiling inside common.mk file?

Any help would appreciate.

-Beth

Beth <id@address.com> wrote:

Hi, I need to dynamically generate a .h file before compiling the source
code. I am using the QNX recursive make file.
In common.mk, I used PRE_BUILD = macro, it appears this macro executes
the instruction before the linking and after compiling the object. I am
getting “can not find .h file” error. Is there any way I can generate my
.h file before compiling inside common.mk file?
Any help would appreciate.

Do you have some more context on what you are trying to do? How is this
header file being generated? You could put this header into EXTRA_CCDEPS,
and then have a rule specifying the generation of the header … I have
used the following to get dependancies on the YACC-generated header …

EXTRA_CCDEPS = $(PROJECT_ROOT)/yacc.tab.h
$(PROJECT_ROOT)/yacc.tab.h: $(PROJECT_ROOT)/yacc.tab.c
$(PROJECT_ROOT)/yacc.tab.c: $(PROJECT_ROOT)/yacc.y
yacc -b $(PROJECT_ROOT)/yacc -d $<

You should post your macro.

A usual problem I have is forgot where to create the .h file. Usually you
want to
create it in $(PROJECT_ROOT)/my.h.

-xtang

Beth <id@address.com> wrote in message news:3DE2B4AC.874CB22F@address.com

Hi, I need to dynamically generate a .h file before compiling the source
code. I am using the QNX recursive make file.
In common.mk, I used PRE_BUILD = macro, it appears this macro executes
the instruction before the linking and after compiling the object. I am
getting “can not find .h file” error. Is there any way I can generate my
.h file before compiling inside common.mk file?

Any help would appreciate.

-Beth

Beth <id@address.com> wrote:

Hi, I need to dynamically generate a .h file before compiling the source
code. I am using the QNX recursive make file.
In common.mk, I used PRE_BUILD = macro, it appears this macro executes
the instruction before the linking and after compiling the object. I am
getting “can not find .h file” error. Is there any way I can generate my
.h file before compiling inside common.mk file?

Define the PRE_TARGET macro to be your .h file before including qtargets.mk.
E.g.:

PRE_TARGET = $(PROJECT_ROOT)/my.h

After including qtargets.mk, define the rule for creating the .h file. E.g.:

$(PROJECT_ROOT)/my.h
create_the_sucker

\

Brian Stecher (bstecher@qnx.com) QNX Software Systems, Ltd.
phone: +1 (613) 591-0931 (voice) 175 Terence Matthews Cr.
+1 (613) 591-3579 (fax) Kanata, Ontario, Canada K2M 1W8

The PRE_TARGET did the trick. Thank you very much.

Here is my common.mk file.

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

NAME=log

TOPDIR=…/…/…/…/…/…/…
INSTALL_ROOT_nto=$(TOPDIR)/rel
INSTALLDIR=test
EXTRA_INCVPATH = $(PROJECT_ROOT)/…/include
$(PROJECT_ROOT)/…/platform/qnx
$(PROJECT_ROOT)/…/
CCFLAGS += -nostdinc -shared
include $(MKFILES_ROOT)/qmacros.mk
PRE_TARGET = $(PROJECT_ROOT)/wc_msg.h
USEFILE=
include $(MKFILES_ROOT)/qtargets.mk
$(PROJECT_ROOT)/msg.h:
echo “#define NO_MSG -1” >> $(PROJECT_ROOT)/msg.h;
cat $(PROJECT_ROOT)/msg_proto | grep ‘^[0-9]’ | awk ‘{print "#define "
$$2 "_NUM " $$1}’ >> $(PROJECT_ROOT)/msg.h;
echo “” >> $(PROJECT_ROOT)/msg.h;
echo “#endif” >> $(PROJECT_ROOT)/msg.h;


Brian Stecher wrote:

Beth <> id@address.com> > wrote:
Hi, I need to dynamically generate a .h file before compiling the source
code. I am using the QNX recursive make file.
In common.mk, I used PRE_BUILD = macro, it appears this macro executes
the instruction before the linking and after compiling the object. I am
getting “can not find .h file” error. Is there any way I can generate my
.h file before compiling inside common.mk file?

Define the PRE_TARGET macro to be your .h file before including qtargets.mk.
E.g.:

PRE_TARGET = $(PROJECT_ROOT)/my.h

After including qtargets.mk, define the rule for creating the .h file. E.g.:

$(PROJECT_ROOT)/my.h
create_the_sucker


Brian Stecher (> bstecher@qnx.com> ) QNX Software Systems, Ltd.
phone: +1 (613) 591-0931 (voice) 175 Terence Matthews Cr.
+1 (613) 591-3579 (fax) Kanata, Ontario, Canada K2M 1W8