Hi there! I am a undergraduate student and recently submitted an assignment for my coursework - however there was one function I could not get to work properly before the due date. Although I don't need to complete this work anymore I would still like to in order to know what was going wrong. If this needs to be in the student/homework forum I am sorry! This is my first post so I'm new to the site and unsure.
The problem: I have a function that is meant to compile any .c files that it finds in the current directory. It allows the user to either use their own Makefile (where the error is) - or use the Makefile within the .sh script which works. The Makefile is created with this function:
And a .c file that is created with this function:
Both of these functions are then used to fill two files as shown below:
Both files are populated with the data correctly. I know the .c file can be compiled as it will do so if I compile it using the terminal. However, whenever I try to use the Makefile from within my bash script it returns the error message "ERROR: Makefile is incorrect - will not compile." which is defined in the method. The method in question is:
As you can see, the function will attempt to detect a Makefile already in the current directory and if there is it will ask the user if they wish to use it. If the user does decide to use it the function calls the makeall command which will always throw up the error described previously. Why does it not work correctly?
Further information: The $currentPath variable stores which directory the user is currently accessing and takes the form: /tmp/Assignment1/Repository/Repository_Alpha I thought the error could be with the Makefile itself so I've tried countless different Makefile formats taken from other forums/website - so I don't think the problem is with that. I've also tried calling the Makefile commands without the 'all' suffix i.e. just make but still returns the same error message.
Any help would be greatly appreciated, thank you! - cherryTango
Judging by populateMFiles, which prints the contents of the makefile, the indentation is wrong. Perhaps removing leading spaces from the targets, and replacing the leading spaces of the commands with a tab would help?
Are those spaces or a TAB character before rm ..., gcc ... and clean ...? Changing your function as-is as I suggested, it works fine. It needs to be a TAB, spaces won't work. If I click to edit your post, just see exactly what you pasted, I see spaces, not a TAB.
They are all tab characters. Still returning same error message. Also have changed the Makefile so that 'clean' does not remove the cfile.c before it is compiled:
It will now only remove any previous compilations of the file (I think?) - if I manage to get it working!
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)