Note that there are some explanatory texts on larger screens.

plurals
  1. POLinux shell command to read text file and open documents listed within
    primarykey
    data
    text
    <p>I have written a shell script (bin/bash). The script takes a look inside folders startup, source and objects that are all located in current folder. Then it makes lists (text files) named <strong>startup_list</strong> (includes files with extension .s), <strong>sources_list</strong> (files with extension .c) and <strong>objects_list</strong> (includes files with extension .o). We asign all .s files to variable ASFILE, all .c files to GCCFILE and all .o to LDFILE. </p> <pre><code>ASDIR="$(pwd)/startup" GCCDIR="$(pwd)/source" LDDIR="$(pwd)/objects" INCDIR="$(pwd)/include" ls $ASDIR/*.s &gt; startup_list sed -i 's|..*/||g' startup_list ASFILE=$(cat startup_list) ls $GCCDIR/*.c &gt; sources_list sed -i 's|..*/||g' sources_list GCCFILE=$(cat sources_list) cat startup_list sources_list &gt; objects_list sed -e 's/\.c/\.o/g' objects_list &gt; objects_list_tmp sed -e 's/\.s/\.o/g' objects_list_tmp &gt; objects_list LDFILE=$(cat objects_list) </code></pre> <p>This script will be integrated into a <strong>makefile</strong> later, but i now need a shell comand to open .c files one after another and check what are the dependancies listed behind #include command. One more thing. Text documents startup_list, sources_list and object_list have files listed one in each line. It looks like this:</p> <pre><code>ea3131_startup_entry.c pad.c ea3131_board.c lpc313x_cgu_default.c lpc313x_cgu_driver.c lpc313x_dma_driver.c lpc313x_evt_driver.c </code></pre> <p>If I omit commands </p> <pre><code>sed -i 's|..*/||g' sources_list sed -i 's|..*/||g' startup_list </code></pre> <p>I can also get an absolute path to the file in front of it, so the text files look like this:</p> <pre><code>/home/ziga/Dropbox/diploma/86x_linux/IDE_eclipse/eclipse_projects/LPC3141_SHELL_timer_makefile/startup/ea3131_startup_entry.c /home/ziga/Dropbox/diploma/86x_linux/IDE_eclipse/eclipse_projects/LPC3141_SHELL_timer_makefile/startup/pad.c /home/ziga/Dropbox/diploma/86x_linux/IDE_eclipse/eclipse_projects/LPC3141_SHELL_timer_makefile/source/ea3131_board.c /home/ziga/Dropbox/diploma/86x_linux/IDE_eclipse/eclipse_projects/LPC3141_SHELL_timer_makefile/source/lpc313x_cgu_default.c /home/ziga/Dropbox/diploma/86x_linux/IDE_eclipse/eclipse_projects/LPC3141_SHELL_timer_makefile/source/lpc313x_cgu_driver.c </code></pre> <p>So what are my options here? How can i open these .c files and check what i need to check?</p> <p>Regards Ziga </p> <hr> <p>Here is my full makefile I did write taking your advices. It is not finished yet. I still need to add lines that compile *.c files.</p> <pre><code>#!/bin/bash # najprej nastavimo shell, ki je v nasem primeru bash # nastavitev asemblerja, compilerja in linkerja AS="arm-none-eabi-as" GCC="arm-none-eabi-gcc" LD="arm-none-eabi-ld" # nastavitev nastavitev za asembler, compiler in linker ASOPT="-mcpu=arm926ej-s -c -Wall" GCCOPT="-mcpu=arm926ej-s -c -Wall" LDOPT="-Tldscript_iram_gnu.ld" # nastavitev direktorij v katerih se nahajajo kljucne datoteke za sestavo programa ASDIR="$(pwd)/startup" GCCDIR="$(pwd)/source" LDDIR="$(pwd)/objects" INCDIR="$(pwd)/include" # potrebno je locirati vse startup, source in objektne datoteke. Ker objektnih datotek še ni, jih je potrebno sproti narediti in jih vse premakniti v mapo objects ls $ASDIR/*.s &gt; startup_list sed -i 's|..*/||g' startup_list ASFILE=$(cat startup_list) ls $GCCDIR/*.c &gt; sources_list sed -i 's|..*/||g' sources_list GCCFILE=$(cat sources_list) cat startup_list sources_list &gt; objects_list sed -e 's/\.c/\.o/g' objects_list &gt; objects_list_tmp sed -e 's/\.s/\.o/g' objects_list_tmp &gt; objects_list LDFILE=$(cat objects_list) all: executable executable: $(LDFILE) $(GCC) -M $(LDFILE) clean: rm startup_list sources_list objects_list objects_list_tmp echo Pocistili ste vse datoteke. </code></pre> <p>For some reason when i run "make" or "make clean" command i get an error:</p> <pre><code>makefile:21: *** missing separator. Stop. </code></pre> <p>I am not sure what i am doing wrong but i think i dont quite understand how to properly use bash comands within makefile, especially variables. Sometimes i use them as $(BOO) and sometimes as $BOO. First one works in a makefile but fails in a command line interface, whereas second works opposite. How can i fix this? </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload