Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
#!/bin/bash


modules=$*

function makegen
{
    mod=$1
    cat >> gen.mk <<EOF

# module.mk appends to FILES and DICTFILES
FILES :=
DICTFILES :=

# including the module.mk file
-include \$(patsubst %, %/module.mk,${mod})

# appending the values found in FILES to the variable SRC
SRC += \$(patsubst %,${mod}/%,\$(FILES))

# appending the values found in DICTFILES to DICTH_modulename
DICTH_${mod} := \$(foreach i, \$(patsubst %,${mod}/%,\$(DICTFILES)), \$(wildcard \$(i).h) \$(wildcard \$(i).hh))
# if dict header files exist, append to variable SRC
ifneq (\$(DICTH_${mod}),)
SRC += ${mod}/\$(PKGNAME)_dict_${mod}
endif

PROG += \$(patsubst %,\$(BINDIR)/%,\$(PROGRAMS))

# appending the values found in FILES to the variable SRC
PROGSRC += \$(patsubst %,${mod}/%,\$(PROGRAMS))

# VPATH += :${mod}

# make sure the output directories are there
__dummy := \$(shell mkdir -p \$(DEPDIR)/${mod} \$(OBJDIR)/${mod})

# a couple of rules to copy executable files correctly
\$(BINDIR)/%: ${mod}/%
	cp \$^ \$@

#\$(BINDIR)/%: ${mod}/%.bin
#	cp \$^ \$@

\$(BINDIR)/%: ${mod}/bin/%
	cp \$^ \$@

\$(BINDIR)/%: \${OBJDIR}/${mod}/%.bin
	cp \$^ \$@

EOF
}

function makedictgen
{
    mod=$1
    cat >> dictgen.mk <<EOF
${mod}/\$(PKGNAME)_dict_${mod}.cc: \$(DICTH_${mod})
	@echo "Generating dictionary \$@..."
	@\$(ROOTCINT) -f \$@ -c \$(filter -I% -D%,\$(CXXFLAGS)) \$^
EOF
}


rm -f gen.mk dictgen.mk

for i in $modules; do
    makegen $i
    makedictgen $i
done