I don't think your all: rule is working either, but it's that long since I've written a makefile, have forgotten more than I know It doesn't help that your script is obfuscating the actual make error with its own. If you run just the function on its own, you would see the actual make error.
There are TABs after clean: build: and all: and there are TABS before rm, gcc and clean. I have also changed the compileRepository method to:
Code:
#Check repository for .c files
#Compile all .c files within the current directory
compileRepository () {
tput cup $[$lineCount] 5 ; echo "============================================================"
if [ -f $currentPath/*Makefile* ]; then # Detect makefiles in repository and allow user to use if desired
tput cup $[1+$lineCount] 5 ; echo "Is there an existing make file within the repository"
tput cup $[2+$lineCount] 5 ; echo "you would like to use? (y/n) "
read useMakefile
if [[ $useMakefile == Y || $useMakefile == y ]]; then
cd $currentPath/
make
exit
So it will just attempt to make it - then exit. This leaves the output on the screen which was an error message until I removed the 'all' from the make command. Now it outputs:
Code:
rm -rf cfile.out
Which is the code in the clean function of the Makefile. Have I set up my Makefile incorrectly do you think?
This does work fine, as far as I can see, so it would help to see the actual make error, not the one your script is displaying.
Saying nothing as to the rest of your code because I haven't read it, it would be slightly cleaner using cat instead of echo to print the Makefile and C file.
Your makefile may remove the cfile.c file, so you need to run "populateCFiles" every time before you run make (as clean is the first rule), make all or make clean.
After making the changes you suggested to my program the first error I recieved was:
Code:
Makefile:2: *** missing separator (did you mean TAB instead of 8 spaces?). Stop.
This was because I copy and pasted directly from the forum.. after correcting it and re-running the program I then recieved:
Code:
rm -rf cfile.c cfile.out
gcc -g -Wall -pedantic -Wextra cfile.c -w -o cfile.out
gcc: error: cfile.c: No such file or directory
gcc: fatal error: no input files
compilation terminated.
Makefile:4: recipe for target 'build' failed
make: *** [build] Error 1
Originally I thought this meant I was in the wrong directory to call the makefile but clearly not if it can actually interpret the lines from the file. I realised I had been deleting the .c file before compiling it so there was nothing to compile. After changing the clean statement to:
I have written this makefile and am getting an error saying
make nfd
gfortran -O -Wall -fbacktrace -fno-align-commons -c -o fd.o fd.f
fd.f:49: Error: Can't open included file 'fd.par'
make: *** Error 1
The directory structure is as follows
.
├── library
│ ├── fd
│ │ ├──... (3 Replies)
Hello,
I have a Makefile that converts wrl (vrml) files to html files...
how can I use a shell script in that makefile which works on all html files after converting?
The Shell Script have to find and replace a String in every createt html file.
sorry I'm a Newbie, so I hope someone can... (0 Replies)
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
Basically, the prompt is make a makefile with various sub makefiles in their respective subdirectories. All code... (1 Reply)
Hi, I'm trying to run the module load command in a Makefile and i'm getting the following error:
make: module: command not found
Why is this? Is there any way to run this command in a Makefile?
NOTE: command - module load msjava/sunjdk/1.5.0 works fine outside of the Makefile (2 Replies)
Hi,
Can we execute a shell script by makefile.
I mean we will write a shell script in a make file and it will be executed when we compile the C++ program using make file. (2 Replies)
Hi
I am new to shell scripting and makefile. I want a command's output in
makefile to process further, can anyone plz suggest me a way ?
I want ls -d *.dsm output in a variable and want to process it in makefile itself.
It's urgent
Thanks In advance (0 Replies)
Hello World ! ! !
I need libraries to use grib files. I only know the C language at the moment and I am working at the University under Red Hat 9.0. I downloaded the g2clib library (the best that I found) but I did not success to run the makefile. Here is the original file. I modified some... (4 Replies)