On Fri, Jul 3, 2009 at 1:07 PM, Cyril Hrubis<[email protected]> wrote:
> Hi,
> following patch introduces ltp buildsystem cleanup, not all the source are
> fixed
> but it's big enough to show you the direction. I would gladly write
> comprehensive HOWTO for creating makefiles the new way in case this cleanup
> patch will be accepted.
>
> This patch introduces Makefile.include, where all the hard work is done. If
> you
> have any questions or edhancements don't hesitate to ask. Most of this file
> contains definitions of generic make rules so that you don't need to say make
> how to create binary test from source test.c. The rest of the file are rules
> for subdirectory handling. There are two rules, one for make and one for make
> install as quite lot of directories contains only shell scripts so make
> entering this directories only slows down building process. Also it turns on
> warnings for all sources, so furhter code cleanups are easier to do.
>
> Every Makefile starts with definition of subdirectories to build and
> subdirectories to install followed by including the Makefile.include from the
> top of ltp directory. So if there are some directories to run make in;
> makefile
> should look like:
>
> SUBDIRS=test_a test_b
> SUBDIRS_INSTALL=$(SUBDIRS) test_c
> TOPDIR=../../../../
> include $(TOPDIR)Makefile.include
>
> And that's it, nothing more is needed for running make in subdirectories. Also
> subdirs are defined as targets (in Makefile.include) so make can execute
> submakes in paralel.
>
> If some directories are needed to build before the others (for example because
> they contain code used by the rest of the tests in subdirectories) one
> additional rule is needed.
>
> SUBDIRS=test_a test_b libtest
> SUBDIRS_INSTALL=$(SUBDIRS) test_c
> TOPDIR=../../../../
> include $(TOPDIR)Makefile.include
> libtest: test_a test_b
>
> This will work allways correctly with make -jN where N > 2 (when make runs in
> paralel).
>
> When we need to create binaries, objectfiles or libraries we start with
> including Makefile.include. Then we define additional libraries here we need
> -lm and we use ltp tst_* calls. In the end we define what to build, binary
> names and source names must match.
>
> TOPDIR=../../../../
> include $(TOPDIR)Makefile.include
>
> LDFLAGS+=-lm
> LOADLIBES+=$(TOPDIR)lib/libltp.a
>
> SOURCES=$(wildcard *.c)
> TARGETS=$(SOURCES:.c=)
>
> all: $(TARGETS)
>
> If we need to add additional compile flags for one file, we need to add line:
>
> test.c: LDFLAGS+=-lpthread
>
> That's all folks! Now waiting for your comments.
Cyril,
This is what I have to do over the following month (along with a
coworker) at Cisco because we have to migrate and this time we're
going to contribute back the changes. Please join in if you have the
resources and the time. LTP is huge and the quicker we can chip away
at the required work, the better.
Your general ideas are ok, but there are some issues that I'm
bringing up now:
1. TOPDIR isn't ideal IMO. srcdir is what we should be aiming for to
maintain parity with GNU autotools, and in order to work with that
we're sticking with reldir.
2. SOURCES =, TARGETS = is just plain silly as it wastes internal
variables and increases Makefile length. This is better: TARGETS :=
$(patsubst %.c,%.o,$(wildcard *.c))
3. LOADLIBES is less of a standard variable than LDLIBS is.
4. Subdirectories that need to be traversed by make can generally be
determined with $(patsubst %/Makefile,%,$(wildcard */Makefile)).
Thanks,
-Garrett
------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list