[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

prerequisite generation for .cc functions

From: Stef Pillaert
Subject: prerequisite generation for .cc functions
Date: Mon, 23 Apr 2001 15:08:09 +0200

I have a large project with a lot of octave-functions (.oct).
 I'm trying to manage these with a Makefile, but I'm not
very good in generating prerequisites for the .cc files. I have a way that
works, but it seems a bit clumsy, so maybe someone has a better (cleaner) way
to do this...

I let a specific .d file (e.g.afstand.d) look like this:

afstand.o: afstand.h shiftor.h
        @echo making $@ from $^
        @mkoctfile -o temp $<
        @-rm -f temp.oct

(I'm not sure it has to be like this. Probably not, but I feel save when
running mkoctfile instead of calling gcc directly...The removal of the oct file
is because I won't need it: I'll put all the .o files in a dynamic library,
that I'll load in an octave session...I'm new to Makefiles, so I don't see a
way (yet) how to avoid the use of the temp.oct file. I probably should be able
to delete afstand.oct instead, but don't know how to change "afstand.o" to
"afstand.oct" in the commands...)

Now, I do this by putting something like this in my Makefile:

        @echo making $@
        @$(SHELL) -ec '$(CC) -MM $(CPPFLAGS) $< > $@'
        @cat $@ HOWTOCOMPILE > $*.d_tmp
        @mv $*.d_tmp $@

where ALL_D_FILES are the needed .d files. This appraoch is a bit clumsy,
since a change to a single .h file ("ALL_H_FILES") makes all the .d files to be
regenerated. Also the need for the file HOWTOCOMPILE looks silly of course. The
file HOWTOCOMPILE  looks like this:

        @echo making $@ from $^
        @mkoctfile -o temp $<
        @-rm -f temp.oct

I can see in the info pages on make that it should be able to do this shorter,
but the example on prerequisites doesn't use explicit commands in the .d file,
where I want to call mkoctfile...Also, all that "sed" stuff makes me go crazy...

Has anyone, more at ease with Makefiles, has better ideas/criticism/...


( A good question is: why do I need these .d files? Well, when an .oct function
calls other .oct functions, I took the habbit of including all the headers for
these .oct functions. Typically, a header file (e.g. afstand.h) looks like

  octave_value_list Fafstand (const octave_value_list& args, int nargout);

I know I could use F(f)eval instead of including these headers, but I was
affraid that this might slow down things a little. Is this wrong thinking of

Thanks for your time....

Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:
How to fund new projects:
Subscription information:

reply via email to

[Prev in Thread] Current Thread [Next in Thread]