Unix/Linux Go Back    


Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

Makefiles: Writing list to screen

Shell Programming and Scripting


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 01-18-2013
kristinu kristinu is offline
Registered User
 
Join Date: Dec 2009
Last Activity: 26 May 2015, 10:05 PM EDT
Posts: 868
Thanks: 63
Thanked 8 Times in 8 Posts
Makefiles: Writing list to screen

I have a make file and want to write some information and am doing


Code:
@echo "  RAYPK_LIBSRC = $(RAYPK_LIBSRC)"

The line of code produces


Code:
RAYPK_LIBSRC = ./source/library/raypk/time.f ./source/library/raypk/model.f ./source/library/raypk/tomo.f ./source/library/raypk/plt.f ./source/library/raypk/blkdat.f

I want the information displayed as follows


Code:
RAYPK_LIBSRC = ./source/library/raypk/time.f 
               ./source/library/raypk/model.f
               ./source/library/raypk/tomo.f 
               ./source/library/raypk/plt.f 
               ./source/library/raypk/blkdat.f

---------- Post updated at 06:31 AM ---------- Previous update was at 06:09 AM ----------

I have done this


Code:
    @echo "RAYPK_LIBOBJ ="
    for i in $(RAYPK_LIBOBJ); do \
      echo "                 $$i"; \
    done

producing


Code:
RAYPK_LIBOBJ =
for i in ./BUILD_DIR/obj/time.o ./BUILD_DIR/obj/model.o ./BUILD_DIR/obj/tomo.o ./BUILD_DIR/obj/plt.o ./BUILD_DIR/obj/blkdat.o; do \
      echo "                 $i"; \
    done
                 ./BUILD_DIR/obj/time.o
                 ./BUILD_DIR/obj/model.o
                 ./BUILD_DIR/obj/tomo.o
                 ./BUILD_DIR/obj/plt.o
                 ./BUILD_DIR/obj/blkdat.o

This is almost what I want. Got to remove the printing of the for loop. On addition, the first string


Code:
 ./BUILD_DIR/obj/time.o

needs to be next to


Code:
RAYPK_LIBOBJ =

---------- Post updated at 06:39 AM ---------- Previous update was at 06:31 AM ----------

And doing something like this


Code:
$(foreach s,$(RAYPK_LIBOBJ), @echo "                 $(s)"\n;)

gives errors


Code:
RAYPK_LIBOBJ =
                 ./BUILD_DIR/obj/time.on
/bin/sh: @echo: command not found
/bin/sh: @echo: command not found
/bin/sh: @echo: command not found
/bin/sh: @echo: command not found
make: *** [list] Error 127

---------- Post updated at 11:00 AM ---------- Previous update was at 06:39 AM ----------

I have made some progress on this


Code:
    @echo "RAYPK_LIBOBJ = $(word 1, $(RAYPK_LIBOBJ))"
    @$(foreach s,$(RAYPK_LIBOBJ), echo "               $(s)";)

This produces


Code:
RAYPK_LIBOBJ = ./BUILD_DIR/obj/time.o
               ./BUILD_DIR/obj/time.o
               ./BUILD_DIR/obj/model.o
               ./BUILD_DIR/obj/tomo.o
               ./BUILD_DIR/obj/plt.o
               ./BUILD_DIR/obj/blkdat.o

So the last thing remaining is not to print again


Code:
./BUILD_DIR/obj/time.o

when dong the foreach loop.
Sponsored Links
    #2  
Old Unix and Linux 01-23-2013
DGPickett DGPickett is offline Forum Advisor  
Registered User
 
Join Date: Oct 2010
Last Activity: 17 February 2015, 1:56 PM EST
Location: Southern NJ, USA (Nord)
Posts: 4,671
Thanks: 8
Thanked 586 Times in 559 Posts
I like
Code:
echo ... | while read l ;do ...; done

Sponsored Links
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Makefiles for different programs kristinu Programming 1 01-03-2013 05:56 PM
makefiles klam UNIX for Advanced & Expert Users 0 09-23-2006 02:56 PM
How can I print variables im using in makefiles? umen Shell Programming and Scripting 1 05-07-2006 09:57 AM
makefiles in a directory and subdirectories benjie_asu UNIX for Dummies Questions & Answers 0 10-28-2005 01:34 PM
Combining makefiles Dan Rooney UNIX for Advanced & Expert Users 4 05-07-2004 08:19 AM



All times are GMT -4. The time now is 09:51 AM.