Re: Force a file to be compiled always

2010-11-10 Thread Steffen Dettmer
On Nov 4, 2010, Benjamin Bihler  wrote:
> As to the third suggestion: I use the __DATE__ and __TIME__
> macros in my code as a kind of version information. Therefore
> the compilation result differs with every compilation, although
> my source file does not change. Is there yet a better method to
> store the compilation time stamp in a library without fiddling
> with make targets?

We do fiddle with make targets, but in this way:

--[Makefile.am]>8===
some_SOURCES=app.c
# ensure to compile-in the current date
app.$(OBJEXT): $(LIBDEPS) $(l...@mainmodulename@_a_SOURCES) Makefile
===8<---

app.c includes some

--[app.c]-->8===
   const char *const version = SYS_VERSION
#if defined(DEBUG)
   " (DEBUG), compiled " __DATE__ " " __TIME__
#endif
   /* non-debug (but release-) versions are guaranteed to have a
* unique dedicated SYS_VERSION */
   ;
===8<---

I'm not sure if this is best (correct), but seems to work well.

I think the big advantage over .PHONY is that is does not
re-genereate the binary (a new binary, actually!) if nothing was
changed at all, which IMHO would be a bad habit.

oki,

Steffen



Re: Force a file to be compiled always

2010-11-07 Thread Benjamin Bihler
Hi Ralf,


excuse me, I have sent this mail twice but in the mailing list the body
seems to be empty. I will try it a last time with another method...

>> your first suggestion (with the phony target) works great. The second
one
>> does not force compilation here (but that doesn't matter anymore since I
>> use the phony target now).

> Hmm, do you have a file named FORCE in source or build tree?

No.

>> As to the third suggestion: I use the __DATE__ and __TIME__ macros in my
>> code as a kind of version information. Therefore the compilation result
>> differs with every compilation, although my source file does not change.
Is
>> there yet a better method to store the compilation time stamp in a
library
>> without fiddling with make targets?

> People do this, but I don't think storing the date and the time is the
> most useful thing to do.  How about a different suggestion: store
> information generated from your version control repository?

This would probably be the nicest thing to do. We will have to think about
it...


> Hope that, and the other comments posted, help.

Yes, very much!



Bye,

Benjamin





Re: Force a file to be compiled always

2010-11-07 Thread Benjamin Bihler
Hi Ralf,


excuse me, I have sent this mail twice but in the mailing list the body
seems to be empty. I will try it a last time with another method...

>> your first suggestion (with the phony target) works great. The second
one
>> does not force compilation here (but that doesn't matter anymore since I
>> use the phony target now).

> Hmm, do you have a file named FORCE in source or build tree?

No.

>> As to the third suggestion: I use the __DATE__ and __TIME__ macros in my
>> code as a kind of version information. Therefore the compilation result
>> differs with every compilation, although my source file does not change.
Is
>> there yet a better method to store the compilation time stamp in a
library
>> without fiddling with make targets?

> People do this, but I don't think storing the date and the time is the
> most useful thing to do.  How about a different suggestion: store
> information generated from your version control repository?

This would probably be the nicest thing to do. We will have to think about
it...


> Hope that, and the other comments posted, help.

Yes, very much!



Bye,

Benjamin





Re: Force a file to be compiled always

2010-11-05 Thread Benjamin Bihler


Re: Force a file to be compiled always

2010-11-05 Thread Benjamin Bihler


Re: Force a file to be compiled always

2010-11-04 Thread Ralf Wildenhues
Hi Benjamin,

* Benjamin Bihler wrote on Thu, Nov 04, 2010 at 09:33:06AM CET:
> your first suggestion (with the phony target) works great. The second one
> does not force compilation here (but that doesn't matter anymore since I
> use the phony target now).

Hmm, do you have a file named FORCE in source or build tree?

> As to the third suggestion: I use the __DATE__ and __TIME__ macros in my
> code as a kind of version information. Therefore the compilation result
> differs with every compilation, although my source file does not change. Is
> there yet a better method to store the compilation time stamp in a library
> without fiddling with make targets?

People do this, but I don't think storing the date and the time is the
most useful thing to do.  How about a different suggestion: store
information generated from your version control repository?  With Git,
'git describe --dirty' output is often used, and IMVHO a lot more useful
than date information (because code often has several parallel branches
anyway, and the time at which it is compiled only vaguely corresponds to
which code is compiled).

For git, instructions and makefile rules have been discussed previously
on this list (more than once I think).

Hope that, and the other comments posted, help.

Cheers,
Ralf



Re: Force a file to be compiled always

2010-11-04 Thread Dave Hart
On Thu, Nov 4, 2010 at 13:46 UTC, Valentin David
 wrote:
> You probably want to have one object that has symbols for the date and
> the time, and this object to be depending on other objects.

The NTP reference implementation does something along these lines.
Every time any consituent libraries or objects change for a binary, an
updated version.c is generated containing the build timestamp as well
as a generation counter for repeated builds in the same directory.

version.c contains a line like:
char * Version = "ntpd 4.2.7...@1.2247-o Nov 03 19:17:08.92
(UTC-00:00) 2010  (1)" ;

(1) is the generation counter.

This is wired into the Makefile.am by omitting version.c from
program_SOURCES, adding version.o to program_LDADD, and adding a rule
to build it like:

version.o: $(ntpq_OBJECTS) ../libntp/libntp.a Makefile $(top_srcdir)/version
env CSET=`cat $(top_srcdir)/version` $(top_builddir)/scripts/mkver ntpq
$(COMPILE) -c version.c

mkver is a shell script which uses the version number from
packageinfo.sh, the repository revision from $CSET, and the current
date/time to produce version.c.

The dependency of version.o on Makefile, combined with the practice of
the NTP build shell script of invoking config.status (which
unconditionally regenerates Makefile) before make, means that a run of
the "build" script always generates updated version.c files with the
current timestamp, even if nothing else has changed.

I am not responsible for inventing this scheme, and I may have missed
an important part.

Cheers,
Dave Hart



Re: Force a file to be compiled always

2010-11-04 Thread Valentin David
You probably want to have one object that has symbols for the date and
the time, and this object to be depending on other objects.

I am not an expert of Automake. But my solution seems to work. And this is:

noinst_LTLIBRARIES=libfoo.la
lib_LTLIBRARIES=liball.la
libfoo_la_SOURCES=foo.c bar.c
liball_la_SOURCES=time.c
liball_la_LIBADD=libfoo.la
$(liball_la_OBJECTS): $(libfoo_la_OBJECTS)

time.c contains something like:
const char build_time[] = __TIME__;
const char build_date[] = __DATE__;

And then, the date and time in the .rodata of your library should
always be more recent than the build of the last object in libfoo.

On Thu, Nov 4, 2010 at 9:33 AM, Benjamin Bihler
 wrote:
>
> Hi Ralf,
>
>
> your first suggestion (with the phony target) works great. The second one
> does not force compilation here (but that doesn't matter anymore since I
> use the phony target now).
>
> As to the third suggestion: I use the __DATE__ and __TIME__ macros in my
> code as a kind of version information. Therefore the compilation result
> differs with every compilation, although my source file does not change. Is
> there yet a better method to store the compilation time stamp in a library
> without fiddling with make targets?
>
>
> Thank you very much and bye,
> Benjamin
>
>
>
>



-- 
Valentin David
valentin.da...@gmail.com



Re: Force a file to be compiled always

2010-11-04 Thread Benjamin Bihler

Hi Ralf,


your first suggestion (with the phony target) works great. The second one
does not force compilation here (but that doesn't matter anymore since I
use the phony target now).

As to the third suggestion: I use the __DATE__ and __TIME__ macros in my
code as a kind of version information. Therefore the compilation result
differs with every compilation, although my source file does not change. Is
there yet a better method to store the compilation time stamp in a library
without fiddling with make targets?


Thank you very much and bye,
Benjamin





Re: Force a file to be compiled always

2010-11-04 Thread Benjamin Bihler

Hi Ralf,


your first suggestion (with the phony target) works great. The second one
does not force compilation here (but that doesn't matter anymore since I
use the phony target now).

As to the third suggestion: I use the __DATE__ and __TIME__ macros in my
code as a kind of version information. Therefore the compilation result
differs with every compilation, although my source file does not change. Is
there yet a better method to store the compilation time stamp in a library
without fiddling with make targets?


Thank you very much and bye,
Benjamin





Re: Force a file to be compiled always

2010-11-03 Thread Ralf Wildenhues
Hi Benjamin,

* Benjamin Bihler wrote on Wed, Nov 03, 2010 at 11:00:35AM CET:
> almost ten years ago there was a question in this mailing list how to force
> a source file to be compiled always.
> 
> http://lists.gnu.org/archive/html/automake/2002-02/msg00099.html
> 
> Unfortunately the solutions mentioned there seem not to work with me. My
> Makefile.am looks like this:
> 
> ---
> lib_LTLIBRARIES = libMyLibrary.la
> 
> libMyLibrary_la_SOURCES = MySourceFile.cpp \
> MySourceFile.h
> ---
> 
> and when I add the .PHONY-line I get this Makefile.am:
> 
> ---
> lib_LTLIBRARIES = libMyLibrary.la
> 
> .PHONY : MySourceFile.cpp
> 
> libMyLibrary_la_SOURCES = MySourceFile.cpp \
> MySourceFile.h
> ---

I think for it to work you'd need something like:

lib_LTLIBRARIES = libMyLibrary.la
.PHONY : $(srcdir)/MySourceFile.cpp
libMyLibrary_la_SOURCES = $(srcdir)/MySourceFile.cpp \
MySourceFile.h


An alternative and more portable (to some non-GNU makes) way than
marking targets as phony is letting them depend upon some non-existing
pseudo target.  It is comonly named FORCE, and you need to ensure no
file with that name exists in the source or the build tree:

lib_LTLIBRARIES = libMyLibrary.la
MySourceFile.cpp: FORCE
FORCE:
libMyLibrary_la_SOURCES = MySourceFile.cpp \
MySourceFile.h


An even better alternative however is to not lie to make about the
actual dependency structure: why do you need your file to be compiled
always?  The answer to that question specifies what the file really
should depend upon (e.g., upon Makefile?).

Hope that helps.

Cheers,
Ralf



Force a file to be compiled always

2010-11-03 Thread Benjamin Bihler
Hello,


almost ten years ago there was a question in this mailing list how to force
a source file to be compiled always.

http://lists.gnu.org/archive/html/automake/2002-02/msg00099.html

Unfortunately the solutions mentioned there seem not to work with me. My
Makefile.am looks like this:

---
lib_LTLIBRARIES = libMyLibrary.la

libMyLibrary_la_SOURCES = MySourceFile.cpp \
MySourceFile.h
---

and when I add the .PHONY-line I get this Makefile.am:

---
lib_LTLIBRARIES = libMyLibrary.la

.PHONY : MySourceFile.cpp

libMyLibrary_la_SOURCES = MySourceFile.cpp \
MySourceFile.h
---


When executing make I receive this error message:
---
 Build of configuration Default for project MeshingLib 

make -j install
Making install in src
make[1]: Entering directory
`/home/bbihler/StarTeam/Bibliotheken/C++/TWTMeshingLib/build/debug/src'
 cd ../../.. && /bin/sh
/home/bbihler/StarTeam/Bibliotheken/C++/TWTMeshingLib/missing --run
automake-1.9 --foreign  src/Makefile
 cd .. && /bin/sh ./config.status src/Makefile depfiles
config.status: creating src/Makefile
config.status: executing depfiles commands
make[1]: Leaving directory
`/home/bbihler/StarTeam/Bibliotheken/C++/TWTMeshingLib/build/debug/src'
make[1]: Entering directory
`/home/bbihler/StarTeam/Bibliotheken/C++/TWTMeshingLib/build/debug/src'
if /bin/sh ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I.
-I../../../src -I..
-I/home/bbihler/StarTeam/Bibliotheken/C++/Medina-Bibliotheken/include
-I/home/bbihler/StarTeam/Bibliotheken/C++/Xerces/include -Wall
-Wno-unknown-pragmas -fopenmp -g -O0 -DTWT_CHECKS -DTR1_CONTAINERS -MT
MySourceFile.lo -MD -MP -MF ".deps/MySourceFile.Tpo" -c -o MySourceFile.lo
MySourceFile.cpp; \
  then mv -f ".deps/MySourceFile.Tpo" ".deps/MySourceFile.Plo"; else rm
-f ".deps/MySourceFile.Tpo"; exit 1; fi
 g++ -DHAVE_CONFIG_H -I. -I../../../src -I..
-I/home/bbihler/StarTeam/Bibliotheken/C++/Medina-Bibliotheken/include
-I/home/bbihler/StarTeam/Bibliotheken/C++/Xerces/include -Wall
-Wno-unknown-pragmas -fopenmp -g -O0 -DTWT_CHECKS -DTR1_CONTAINERS -MT
MySourceFile.lo -MD -MP -MF .deps/MySourceFile.Tpo -c MySourceFile.cpp
-fPIC -DPIC -o .libs/MySourceFile.o
g++: MySourceFile.cpp: Datei oder Verzeichnis nicht gefunden
g++: no input files
make[1]: *** [MySourceFile.lo] Fehler 1
make: *** [install-recursive] Fehler 1
make[1]: Leaving directory
`/home/bbihler/StarTeam/Bibliotheken/C++/TWTMeshingLib/build/debug/src'
---

"Datei oder Verzeichnis nicht gefunden" means "File or directory not
found".


Is there any easy solution? Or can someone tell me what I have done wrong?


Thank you very much,
Benjamin Bihler





Force a file to be compiled always

2010-11-03 Thread Benjamin Bihler
Hello,


almost ten years ago there was a question in this mailing list how to force
a source file to be compiled always.

http://lists.gnu.org/archive/html/automake/2002-02/msg00099.html

Unfortunately the solutions mentioned there seem not to work with me. My
Makefile.am looks like this:

---
lib_LTLIBRARIES = libMyLibrary.la

libMyLibrary_la_SOURCES = MySourceFile.cpp \
MySourceFile.h
---

and when I add the .PHONY-line I get this Makefile.am:

---
lib_LTLIBRARIES = libMyLibrary.la

.PHONY : MySourceFile.cpp

libMyLibrary_la_SOURCES = MySourceFile.cpp \
MySourceFile.h
---


When executing make I receive this error message:
---
 Build of configuration Default for project MeshingLib 

make -j install
Making install in src
make[1]: Entering directory
`/home/bbihler/StarTeam/Bibliotheken/C++/TWTMeshingLib/build/debug/src'
 cd ../../.. && /bin/sh
/home/bbihler/StarTeam/Bibliotheken/C++/TWTMeshingLib/missing --run
automake-1.9 --foreign  src/Makefile
 cd .. && /bin/sh ./config.status src/Makefile depfiles
config.status: creating src/Makefile
config.status: executing depfiles commands
make[1]: Leaving directory
`/home/bbihler/StarTeam/Bibliotheken/C++/TWTMeshingLib/build/debug/src'
make[1]: Entering directory
`/home/bbihler/StarTeam/Bibliotheken/C++/TWTMeshingLib/build/debug/src'
if /bin/sh ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I.
-I../../../src -I..
-I/home/bbihler/StarTeam/Bibliotheken/C++/Medina-Bibliotheken/include
-I/home/bbihler/StarTeam/Bibliotheken/C++/Xerces/include -Wall
-Wno-unknown-pragmas -fopenmp -g -O0 -DTWT_CHECKS -DTR1_CONTAINERS -MT
MySourceFile.lo -MD -MP -MF ".deps/MySourceFile.Tpo" -c -o MySourceFile.lo
MySourceFile.cpp; \
  then mv -f ".deps/MySourceFile.Tpo" ".deps/MySourceFile.Plo"; else rm
-f ".deps/MySourceFile.Tpo"; exit 1; fi
 g++ -DHAVE_CONFIG_H -I. -I../../../src -I..
-I/home/bbihler/StarTeam/Bibliotheken/C++/Medina-Bibliotheken/include
-I/home/bbihler/StarTeam/Bibliotheken/C++/Xerces/include -Wall
-Wno-unknown-pragmas -fopenmp -g -O0 -DTWT_CHECKS -DTR1_CONTAINERS -MT
MySourceFile.lo -MD -MP -MF .deps/MySourceFile.Tpo -c MySourceFile.cpp
-fPIC -DPIC -o .libs/MySourceFile.o
g++: MySourceFile.cpp: Datei oder Verzeichnis nicht gefunden
g++: no input files
make[1]: *** [MySourceFile.lo] Fehler 1
make: *** [install-recursive] Fehler 1
make[1]: Leaving directory
`/home/bbihler/StarTeam/Bibliotheken/C++/TWTMeshingLib/build/debug/src'
---

"Datei oder Verzeichnis nicht gefunden" means "File or directory not
found".


Is there any easy solution? Or can someone tell me what I have done wrong?


Thank you very much,
Benjamin Bihler