Question

Make File you should create a Makefile containing targets for all the exercises; by default, the...

Make File

you should create a Makefile containing targets for all the exercises; by default, the Makefile should compile all the files, and the output of each of them should be an executable file named i. Further, when the make is called with a number, your Makefile should compile only that exercise. Examples:

•make 1 compiles only 1.c into the executable file 1

•make compiles all C files

•make clean removes all generated executable files

OBS( I Have different programs in C (1.c, 2 .c , 3.c etc) and i should do an Makefile with this instructions.. thx)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h> /* for fork */
#include <sys/types.h> /* for pid_t */
#include <process.h>
int main()    // considering 3 files 1.c,2.c,3.c
{
int choice;
printf("This is the main program\n");
int fileMade[3];      //This variable keeps the count that which which file is currently made
fileMade[0]=0;        //Initialising 0 that represents that file is not made till yet
fileMade[1]=0;
fileMade[1]=0;
while(1)
{
    printf("Enter a choice: \n1)Make 1\n2)Make 2\n3)Make 3\n4)make\n5)Make clean\n6)Exit\nCHoice : ");
    scanf("%d",&choice);
    if(choice==1)
    {
      system("gcc -o 1.exe 1.c");   //system( string), system executes string in cmd as it is
      fileMade[0]=1;
    }
    else if(choice==2)
    {
      system("gcc -o 2.exe 2.c");
      fileMade[1]=1;
    }
    else if(choice==3)
    {
      fileMade[2]=1;
      system("gcc -o 3.exe 3.c");
    }
    else if(choice==4)
    {
      fileMade[0]=1;
      fileMade[1]=1;
      fileMade[2]=1;
      system("gcc -o 1.exe 1.c");
      system("gcc -o 2.exe 2.c");
      system("gcc -o 3.exe 3.c");
    }
    else if(choice==5)
    {
      if(fileMade[0]==1)
      {
        system("del 1.exe");
        fileMade[0]=0;
      }
      if(fileMade[1]==1)
      {
        system("del 2.exe");
        fileMade[1]=0;
      }
      if(fileMade[2]==1)
      {
        system("del 3.exe");
        fileMade[2]=0;
      }
    }
    else if(choice==6)
    {
      break;
    }
}

}

Add a comment
Know the answer?
Add Answer to:
Make File you should create a Makefile containing targets for all the exercises; by default, the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C language. A Makefile should have (at least) the following rules: Rules to compile .c files...

    C language. A Makefile should have (at least) the following rules: Rules to compile .c files into .o files (input.o, display.o, and main.o) An all rule that will combine input.o, display.o, and main.o into an executable called "scroll". A clean rule that will remove the executable scroll and all .o files A run rule that will run the program. Any extra rules you find helpful.

  • The code in project2 is for a program that plays a simple game called Chomp. The...

    The code in project2 is for a program that plays a simple game called Chomp. The programmers of this project have opted to package some of their code in a “module” called chomp.adt, from which the related files cookie.h and cookie.cpp files can be generated. The steps necessary to produce this program are: Run the command csplit chomp.adt "/Split Here/" and copy the resulting file xx00 to cookie.h. Run the command csplit chomp.adt "/Split Here/" and copy the resulting file...

  • OUTPUT MUST MATCH THE IMAGE TO THE TEE. I have the majority of the program written,...

    OUTPUT MUST MATCH THE IMAGE TO THE TEE. I have the majority of the program written, just having issues with the output. Please make sure to have the right alignment, variable data types and number padding/decimals as shown below! ​ MUST BE IN C NOT C++/C#! Assume the Item Num is an int that must be padded with zeros (ex: 1234 ---> 00001234) Write a C program for a shopping list to run on ocelot. Use the listed items and...

  • Write a bash script to find all the files ending with .c recursively for every directory...

    Write a bash script to find all the files ending with .c recursively for every directory in your current working directory, then copy each one to a folder called programs, need handle duplicates by appending the number to the end of the file (ex main.c main-1.c ) compile them and generate a report report should look like: main.c compiles prog2.c failed main-2.c compiles etc.

  • For this project a Date class(specifiedin the file Project_10.h) will be constructed and all function definitions will be written in the file Project_10.cpp. A makefileis provided to compile this project. The file Project_10_main.cppcontainsthe main fun

    Project_10_base_files.zipMakefile (2).txtProject_10_main 1.JPGProject_10_main 2.JPGProject_10_main 3.JPGProject_10 h.JPGProject_10 cpp.JPGAny C++ technique covered in Chapters 1 through 12is allowedexcept for global variablesYou are not allowed to use any global variables.If necessary, global constants may be used.Project 10DescriptionFor this project a Date class(specifiedin the file Project_10.h) will be constructed and all function definitions will be written in the file Project_10.cpp.  A makefileis provided to compile this project.  The file Project_10_main.cppcontainsthe main functionthat is used to run the program.On Canvas, download the files Project_10.h, Project_10_main.cpp...

  • Goals . Understand how to implement operator overloading in C++ Warning: Programs must compile us...

    c++ format Goals . Understand how to implement operator overloading in C++ Warning: Programs must compile using gt+ on the Computer Science Linux systems. If your code does not compile on CS machines you will get 0 for the assignment. Organize your files into folders by lab assignment. For this assignment, create a folder called Lab9. A. Read Chapter 18 B. Create a new class called RationalNumber to represent fractions. The class should have the following capabilities: 1) It should...

  • Question! Problem 1.c Problem 2.c Problem 3.c .Use make -f Makefile to compile the three problem...

    Question! Problem 1.c Problem 2.c Problem 3.c .Use make -f Makefile to compile the three problem C programs Within Problem1.c we will use gdb ions . Within Problem2.c we will use assert then turn off . Within Problem3.c we will use gdb again and I will begin but you will need to finish . Assignment: run gdb and file Problem3.o ve odisplay val.cnt, out, tot (variables) o Set breakpoints on main and the line that throws the segmentation fault o...

  • IN C++ MUST INCLUDE HEADER FILE, IMPLEMENTATION FILE, AND DRIVER FILE. IN C++ Create a header...

    IN C++ MUST INCLUDE HEADER FILE, IMPLEMENTATION FILE, AND DRIVER FILE. IN C++ Create a header and implementation file to define an apartment class. Create a driver program to test the class, and create a make file to compile the driver program. Create two files called apartment.h and appartmentImp.cpp along with creating a driver program named testApartment.cpp containing the main function. Program Requirements: • Class attributes should include integers for number of rooms, monthly rent, and square feet, as well...

  • 1. (40 pts) Note: All programs MUST run in Ubuntu. Following the example C program in...

    1. (40 pts) Note: All programs MUST run in Ubuntu. Following the example C program in Folio consisting of three files (a.c, a.h, main.c), write a C program that consists of three files mysquare.h, mysquare.c andmyMain.c. Below is the mysquare.h prototype #include <stdlib.h> #include <stdio.h> void generateNums(int *myarr, int len); void squareNums(int *myarr, int len); void printNums(int *myarr, int len); mysquare.h must contain only the function declarations (prototypes) listed above generateNums function should generate len random integers in the range...

  • n this programming assignment, you need to create 3 files. 1. DateType.h 2. DateType.cpp 3. A...

    n this programming assignment, you need to create 3 files. 1. DateType.h 2. DateType.cpp 3. A test driver for testing the class defined in the other 2 files. You can name your file in the way you like. Remember it must be a .cpp file. In DateType.h file, type these lines: // To declare a class for the Date ADT // This is the header file DateType.h class DateType { public: void Initialize(int newMonth, int newDay, int newYear); int GetYear()...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT