I think 六祖惠能經, Zen Master Hui Neng has answer it quite clearly.
We should not caught up with the notion of merits, just practise
with the flow.
Prefect Wei ask, “that at Bodhidharma’s first interview with
Emperor Wu of Liang he was asked what merits the Emperor would get
for the work of his life in building temples, allowing new monks to
be ordained (royal consent was necessary at that time), giving alms
and entertaining the Order; and his reply was that these would
bring no merits ar all. Now, I cannot understand why he gave such
an answer. Will you please explain.”
“These would bring no merits,” replied the Patriarch. “Don’t
doubt the words of the Sage. Emperor Wu’s mind was under an
erroneous impression, and he did not know the orthodox teaching.
Such deeds as building temples, allowing new monks to be ordained,
giving alms and entertaining the Order will bring you only
felicities, which should not be taken for merits. Merits are to be
found within the Dharmakaya, and they have nothing to do with
practices for attaining felicities.”
The Patriarch went on, “Realization of the Essence of Mind is
Gong 功, and equality is De德. When our mental activity works without
any impediment, so that we are in a position to know constantly the
true state and the mysterious functioning of our own mind, we are
said to have acquired Gong De (merits). Within, to keep the mind in
a humble mood is Gong; and without, to behave oneself according to
propriety is De. That all things are the manifestation of the
Essence of Mind is Gong, and that the quintessence of mind is free
from idle thoughts is De. Not to go astray from the Essence of Mind
is , and not to pollute the mind in using it is De. If you seek for
merits within the Dharmakaya, and do what I have just said, what
you acquire will be real merits. He who works for merits does not
slight others; and on all occasions he treats everybody with
respect. He who is in the habit of looking down upon others has not
got rid of the erroneous idea of a self, which indicates his lack
of Gong. Because of his egotism and his habitual contempt for all
others, he knows not the real Essence of Mind; and this shows his
lack of De. Learned Audience, when our mental activity works
without interruption, then it is Gong; and when our mind functions
in a straightforward manner, then it is De. To train our own mind
is Gong, and to train our own body is De. Learned Audience, merits
should be sought within the Essence of Mind and they cannot be
acquired by almsgiving, entertaining the monks, etc. We should
therefore distinguish between felicities and merits. There is
nothing wrong in what our Patriarch said. It is Emperor Wu himself
who did not know the true way.”
http://www.dharmaweb.org/index.php/Sutra_of_Hui…
師曰。實無功德。勿疑先聖之言。武帝心邪不知正法。造寺度僧布施設齋。名為求福。不可將福便為功德。功德在法身中。不在修福。
師又曰。見性是功。平等是德。念念無滯常見本性真實妙用。名為功德。內心謙下是功。外行於禮是德。自性建立萬法是功。心體離念是德。不離自性是功。應用無染是德。若覓功德法身但依此作。是真功德。
若修功德之人。心即不輕常行普敬。心常輕人吾我不斷。即自無功。自性虛妄不實。即自無德。為吾我自大常輕一切故。
善知識。念念無間是功。心行平直是德。自修性是功。自修身是德。善知識。功德須自性內見。不是布施供養之所求也。是以福德與功德別。武會不識真理。非我祖師有過。
http://sm21.net/jing/lztj/i6je6c9p.htm