Question

In: Computer Science

in unix(bash) Write a Makefile with a recipe which can be used to compile myprog.c into...

in unix(bash)

Write a Makefile with a recipe which can be used to compile myprog.c into myprog. Be sure to indicate that "myprog" depends on myprog.c!

Solutions

Expert Solution

SOLUTION:

The following solution has been implemented in such a way that the Makefile specifies that the Output "myprog" depends on the file to be compiled being "myprog.c".

Makefile

# Select the Compiler
COMPILER = gcc

# Select the flags
FLAGS  = -g -Wall

# Select the File
FILE = myprog

# Describe the Target Functionality
all: $(FILE)

$(FILE): $(FILE).c
        $(COMPILER) $(FLAGS) -o $(FILE) $(FILE).c

clean:
        $(RM) $(FILE)

*** Target "clean" is not mangatory***

SCREENSHOT:

Note:

The Makefile has 2 targets, i) all ii) clean

Since all comes first it will be executed first by default, unless a target for execution is specified.

You can either issue the command "make" or "make all".

The "clean" target can be executed using the command "make clean".

Hope this helps..!


Related Solutions

UNIX ONLY Write a bash script that will accept a filename as a command line argument....
UNIX ONLY Write a bash script that will accept a filename as a command line argument. Your script should first check whether the filename has been passed as argument or not (hint: at least one argument has to be provided). If no argument has been provided your script should display appropriate message and exit. If a file name has been provided, your script should check if the file exists in the current directory and display the contents of the file....
Program in Bash: Write a program using bash script that can read a file from the...
Program in Bash: Write a program using bash script that can read a file from the same directory, sort the nonrepeating integers from 0-9 from smallest to largest, and output the results on the same line. Do not use the sort function.
Program in Bash: Write a program using bash script that can read a file from the...
Program in Bash: Write a program using bash script that can read a file from the same directory, sort the nonrepeating integers from 0-9 from smallest to largest, and output the results on the same line. Do not use the sort function.
create a questionaire that can be used to compile a report for the assignment below "The...
create a questionaire that can be used to compile a report for the assignment below "The students are expected to visit any company of their choice and find out how they do their maintenance budget. Conduct interviews with va rious levels of personnel. The student is expected to present a typed three- pages report (detailed report) toget her with the completed interview question with responses from the company maintenance personnel. Company maintenance budget must be attached to the report. Proof...
1) Define a C struct that can be used to represent an ingredient in a recipe....
1) Define a C struct that can be used to represent an ingredient in a recipe. You must include the ingredient, the amount to use, and the unit of measurement. When allocated, the struct must be self-contained; do not rely on information being stored anywhere else in memory. 2) Define a C function that will print an array of ingredients to the standard output stream, one per line. You must use the struct definition from the first part. 3) Define...
UNIX/LINUX LAB   (1) Compile hello.c program: gcc hello.c -o hello (2) Compile hello.c program with -static...
UNIX/LINUX LAB   (1) Compile hello.c program: gcc hello.c -o hello (2) Compile hello.c program with -static option: gcc -static hello.c -o hello1 (3) Use size command to see the memory layout of these two programs (hello and hello1). (4) Write a brief summary of what you have noted here. Submit the session history (log) of this activity and a brief summary. hello.c program bottom //////////// #include <stdio.h> #include <stdlib.h> int main() { printf("Hello World\n"); // waw hello Richard and ok...
Write a recipe for someone else to make a good mayo. In your recipe include the...
Write a recipe for someone else to make a good mayo. In your recipe include the ingredients, their amounts and directions on how to combine the ingredients in order to end up with a stable emulsion.
Use the Design Recipe to write a function count_vowels, which consumes a string and returns the...
Use the Design Recipe to write a function count_vowels, which consumes a string and returns the number of vowels in that string. For these purposes, the vowels are a, e, i, o, and u, but never y. Include a Docstring! Note: Count both upper and lowercase vowels! Write 3 assert_equal statements to test your function.
UNIX/LINUX LAB (1) Review the sample shell program (tryShell.c), and compile/run the program (tryShell) with the...
UNIX/LINUX LAB (1) Review the sample shell program (tryShell.c), and compile/run the program (tryShell) with the following commands, and at the end, use CTRL+C to terminate the program: ls ls -l tryShell* date whoami hostname uname -a ctrl+C    (2) Run the program (tryShell) with "time -p" with a few commands: time -p ./tryShell (3) Edit the program (tryShell.c) so that it will exit (terminate the program) when the input command string is "exit" try shell.c code at bottom //////////// #include...
Write a C program in Unix which uses a function called search to find the location...
Write a C program in Unix which uses a function called search to find the location of a value in THREE arrays of floats. The function should take three parameters :          the value to be found          the array to be searched          the size of the array N.B.!!!! The main program should read in three arrays of varying size          example : array a has twelve elements                    array b has six elements                    array c has nine...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT