hi everyone,
i've started playing around with the DPS library that comes with
XFree86 (as well as other X servers). up to now i've been creating
Makefiles by hand but i have used the autotools, i just am not sure how
to apply them to this type of project. your help would be most
appreciated.
i created a very simple project that demonstrates what i'd like to do.
the project's root folder contains nothing more than the "configure.in"
and "Makefile.am" files. there is one subfolder called "code" which
contains a "Makefile.am", the source file "example.c", and a wrap
called "wraps.psw".
one of the first steps that must take place in order to compile is to
apply a function called "pswrap" to the "*.psw" file to generate both a
*.h and a *.c file; much the same as using LEX and YACC.
the "Makefile.am" that i came up with for the "code" folder looks like
this:
----------------------------------------------------------------
SUFFIXES = .psw .h
noinst_PROGRAMS = example
example_SOURCES = example.c wraps.c
example_DEPENDENCIES = wraps.h wraps.c
EXTRA_DIST = wraps.psw
example_LDADD = $(X_LIBS) $(X_PRE_LIBS) -lX11 $(X_EXTRA_LIBS)
INCLUDES = $(X_CFLAGS)
.psw.c:
pswrap -a -o ${@} $<
.psw.h:
pswrap -a -h ${@} $< &> /dev/null
----------------------------------------------------------------
this works and gets the job done but there are some things i'd like to
ask about it.
1) is this okay? is this a decent Makefile.am file to accomplish that
which i am trying to do?
2) when i do the "make" it compiles perfectly fine and everything is
nice. but i noticed that although i've clearly specified that both
"wraps.h" and "wraps.c" are prerequisites for "example", only "wraps.h"
gets created before "example.c" gets "gcc -c". this isn't a problem
since everything works out well enough since at this stage it's doing a
compile only. i'm just wondering why i get this behaviour.
3) it's a bit of a lie to say that "wraps.c" is a source, since it
doesn't exist until the "pswrap" utility is executed. but if i don't
specify it this way then when the final link is performed it won't link
in "wraps.o" in with "example.o" to create "example". is there a better
way to do this?
4) when i do a "make dist", a "wraps.c" file gets included in the
distribution (even if i explicitly delete it before the "make dist"), i
assume this is because of the "example_SOURCES" line including
"wraps.c". i don't want to include my "wraps.c" since different
platforms might create this file differently. any ideas how i can do
this (i guess this is probably still more of the same with regards to
my previous point (3))?
5) i would like to create a "clean::" target that would $(RM) the
"wraps.[ch]" files, but "make" complains that the "Makefile" contains
both "clean:" and "clean::" targets. how to i add my own "clean"
targets?
6) i think it would be nicer to modularize this (much the same as with
LEX and YACC) how would i go about this? should i create my own *.m4
file with the necessary scripts? i'm not an autotools expert but i
think having a "example_WRAPS = wraps.psw" line would be nice.
i look forward to your observations.
best regards,
trevor
ps. please CC me if you reply
--
http://home.ica.net/~vjbtlw/