Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

*Create a Makefile (named Makefile) with the following requirements: To define the generate target that creates 3 empty files: file1.txt, file2.txt and file3.txt Because the

*Create a Makefile (named Makefile) with the following requirements:

To define the generate target that creates 3 empty files: file1.txt, file2.txt and file3.txt

Because the target (generate) is not a file itself, but the name of a recipe, make sure you define a phony target

To have a special target to clean-up (delete) the 3 files

The Makefile should not display the commands it executes, except for the cleanup commands

*Part 2 Compiling C programs

Write a C program, main.c, that accepts the name of an environment variable as input and prints the value of the environment variable, if the environment variable exists. Use the C function genenv() to get the value of an environment variable.

Possible executions of the program:

tux> main USER

The value of environment variable USER is dv35

tux> main PATH

The value of environment variable PATH is /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:.

tux> main Pepper

The environment variable Pepper was not found

*Now extend the Makefile of Part 1 with the following requirements:

To compile the program main.c, naming the executable main.

For the compilation, we want the Makefile to display the compilation command it uses.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions