[LC++]Appending to a file from Makefile

robert at ncdesigns.net robert at ncdesigns.net
Wed Jul 21 21:36:01 UTC 2004


> How do I append a few lines to a file? Also is it

in a makefile this is easy to do.
If this is dynamically generated stuff then use some of the macros.
But you don't want to add this each and everytime you make
otherwise you'll be adding the same thing multiple times.

here is an example....

RC_PATH=/etc/rc.d/init.d/rc.local
MYPATH=/usr/local/bin/myprog
GREP=/usr/bin/grep

all=RC


RC:
        if [ `$(GREP) -c $(MYPATH) $(RC_PATH)` -eq 0 ]; then \
                echo $(MYPATH) >> $(RC_PATH); \
        fi;


If you want to supress the output then add a @ before the if statement

-Robert






More information about the tuxCPProgramming mailing list