38.2k views
1 vote
"Write a makefile based on the following information.

1. Files associated with the system:
a. course.c application driver
b. student.c provides functions used by course.c
c. student.h included by student.c and course.c
d. id.h included by student.c
2. Main targets
a. course we should be able to create an executable named ""course""
b. clean this will remove .o files and executables
c. Any other targets you understand are necessary.
3. The compiler to use is gcc with the -Wall flag.
4. You may not use implicit rules."

User Manika
by
8.3k points

1 Answer

3 votes

Final answer:

To create a makefile based on the given information, follow these steps: 1. Create a target for the 'course' executable with its dependencies and compile command. 2. Create a 'clean' target to remove .o files and the 'course' executable. 3. Add any other necessary targets. Here is an example makefile:

Step-by-step explanation:

To create a makefile based on the given information, you can use the following steps:

  1. Create a target for the 'course' executable by specifying its dependencies (course.c, student.c, and id.h) and the command to compile them using gcc with the -Wall flag.
  2. Create a 'clean' target that removes the .o files and the 'course' executable by specifying the appropriate commands.
  3. If there are any other necessary targets, create them according to the requirements.

Here is an example of a makefile that follows these steps:

course: course.c student.c id.h
gcc -Wall -o course course.c student.c

clean:
rm -f course *.o

User Jorge Arimany
by
8.5k points