Hi,

I'm playing with the Click Modular router on my FreeBSD box. Out of curiosity, I decided to switch its GNU makefile to BSD style. I managed to do it, but I would like to polish it a bit more (and learn some things along).

Old GNUmakefile relies heavily on OBJS and *_OBJS, as it fills these variables. I would like to switch to using SRCS. I managed to do it partially, for the files which are in the ${.CURDIR}.

Click has a certain dir hierarchy of elements. First, it builds its elements, where each group of elements is in a different directory. Then it places all generated .o files in ${.CURDIR}. Finally, it links the whole shebang. Element building is done in another Makefile, which is generated by a script. (Main) GNUmakefile calls this script, then it includes that makefile via '-include'.

The script traverses the dir hierarchy, and based on some variables, creates a Makefile which outlines like this:
# subdir0
ELEMENT_OBJS__x= \
file0.o \
file1.o

#subdir1
ELEMENT_OBJS__y= \
file2.o \
file3.o \

...

ELEMENT_OBJS= \
$(ELEMENT_OBJS__x) \
$(ELEMENT_OBJS__y)


$(ELEMENT_OBJS__x): %.o: subdir0/%.cc
        $(call cxxcompile,-c $< -o $@,CXX)
$(ELEMENT_OBJS__y): %.o: subdir1/%.cc
        $(call cxxcompile,-c $< -o $@,CXX)


I'm interested in how can I transfer this into BSD-style makefile?

I tried to move from OBJS into SRCS (main BSDmakefile now has: SRCS+=$ (ELEMENT_SRCS)), by using something like:
# subdir0
ELEMENT_SRCS__x =\
subdir1/file0.cc \
subdir1/file1.cc

...

But this fails during the linking phase, because the linker is called with subdir1/file0.o, instead of just file0.o.

To make something clear, I didn't just rewrite the GNUmakefile to BSDmakefile, I also followed some of the logic used to build kernel modules. I'm including bsd.kmod.ko, list sources in SRCS, don't have any explicit rule to build .o out of .cc/.c. There is no all: target, as well.

Thanks,
Nikola
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to