What is make clean in linux

What are the differences between make clean, make clobber, make distclean, make mrproper and make realclean?

I don’t always write make files but when I do I like to try and write them well. Trying to make the interface consistent with what other developers might expect is always a struggle. What I am looking for is a summary of all the common make something cleaner (GNU) make targets. What are the commonly found cleaning make targets? When is each target normally used? How does each target compare to others? I have worked with a system using make clean , make clobber and make mrproper before. Those got steadily more extream with; make clean only tidying up temporaries, make clobber getting rid of most configuration and make mrproper almost going back to a just checked out state. Is that the normal order of things? Should make mrproper always remove the generated binaries and shared libraries for deployment? Reading around suggests that make distclean tidies things up to the point of being ready to make a distribution package. I would imagine that leaves behind some automatically generated version tagging files, file manifests and shared libraries but possibly strips out temporary files that you would not want archived? make realclean was completely new to me when I spied it on the GNU Make Goals manual page. As it is listed with distclean and clobber I would guess it had similar effects. Have I never come across it as it is a historical artifact or just quite specific to a set of projects I have to worked on? Sorry, that is is a bit rambling. I have found various questions and answers that compare one target to the other but none that seemed to give a good overview.

1 Answer 1

Trying to form my own answer based on some research. I think the approximate order of severity is; mostlyclean , clean , maintainer-clean , mrproper , distclean and finally clobber (which is combined distclean and uninstall ).

make clean is the most basic level. It cleans up most generated files but not anything that records configuration. GNU Make Manual’s Goals page states:

Delete all files that are normally created by running make.

Delete all files in the current directory that are normally created by building the program. Also delete files in other directories if they are created by this makefile. However, don’t delete the files that record the configuration. Also preserve files that could be made by building, but normally aren’t because the distribution comes with them. There is no need to delete parent directories that were created with ‘mkdir -p’, since they could have existed anyway.

Delete .dvi files here if they are not part of the distribution.

make mostlyclean

make mostlyclean is the only gentler form of clean I have found, it behaves like clean but leaves behind files that would take a long time to compile and do not often need to be regenerated.

Like ‘clean’, but may refrain from deleting a few files that people normally don’t want to recompile. For example, the ‘mostlyclean’ target for GCC does not delete libgcc.a, because recompiling it is rarely necessary and takes a lot of time.

make distclean

Читайте также:  Canon f151300 драйвер linux

make distclean is the first step up from the basic make clean on many GNU Make systems. It seems to be pseudonymous or at least very similar to with make realclean and make clobber in many, but not all cases. It will delete everything that make clean does and remove the configuration.

In the Linux system this is one step beyond make mrpropper , see the section below for details.

I am not sure if the name implies that things are being made clean enough for distribution (the forming of a tar archive) or that the process is returning them to the state equal to what was distributed (just as things were immediately after unpacking a tar archive).

Any of these targets might be defined to delete more files than ‘clean’ does. For example, this would delete configuration files or links that you would normally create as preparation for compilation, even if the makefile itself cannot create these files.

Delete all files in the current directory (or created by this makefile) that are created by configuring or building the program. If you have unpacked the source and built the program without creating any other files, ‘make distclean’ should leave only the files that were in the distribution. However, there is no need to delete parent directories that were created with ‘mkdir -p’, since they could have existed anyway.

make uninstall

make uninstall will uninstall software installed via make install or one of the install-* variants. This is similar to part of the behaviour to make clobber on some systems but make uninstall should not touch the build area as make clobber will.

Delete all the installed files—the copies that the ‘install’ and ‘install-*’ targets create.

This rule should not modify the directories where compilation is done, only the directories where files are installed.

make maintainer-clean

make maintainer-clean seems to be one step back from the more common make distclean . It deletes almost everything apart from the configuration. This makes it very similar to make clean .

Delete almost everything that can be reconstructed with this Makefile. This typically includes everything deleted by distclean, plus more: C source files produced by Bison, tags tables, Info files, and so on.

It is also highlighted that this is not a commonly used target as it is for a specific set of users:

The ‘maintainer-clean’ target is intended to be used by a maintainer of the package, not by ordinary users.

make mrproper

make mrproper seems to be a Linux Kernel version of make distclean or make clobber . that stops short of removing backup and patch files. It does everything that the make clean target does and strips out configuration.

I believe the name comes from a cleaning product known in the USA as Mr. Clean and the UK as Flash (which is why I had not heard of the product as named). Linus Torvalds being Finnish-American was presumably familiar with the Mr. Propper brand name.

# Cleaning is done on three levels. # make clean Delete most generated files # Leave enough to build external modules # make mrproper Delete the current configuration, and all generated files # make distclean Remove editor backup files, patch leftover files and the like 

make clobber

make clobber gets a mention on the Wikipedia article for Clobbering too. That also states that it is more severe than make clean , possibly one that even uninstalls the software. It is possible a combination of make uninstall and make distclean .

Читайте также:  Pantum m6500 драйвер linux ppd

There is no single source for make clean levels. As things have evolved over time terminology and behaviour is inconsistent. The above is the best I have managed to piece together so far.

Источник

How do I clean my Makefile?

The Cleanup Rule clean: rm *.o prog3 This is an optional rule. It allows you to type ‘make clean’ at the command line to get rid of your object and executable files. Sometimes the compiler will link or compile files incorrectly and the only way to get a fresh start is to remove all the object and executable files.

What does make clean do in Linux?

We generally use make clean as a generic way to tell clean up the code.ie; remove all the compiled object files from the source code. You can name it as anything you like.

What is .phony Makefile?

A phony target is one that is not really the name of a file; rather it is just a name for a recipe to be executed when you make an explicit request. Once this is done, ‘ make clean ‘ will run the recipe regardless of whether there is a file named clean .

What is make clean?

It’s not changing your Makefile that triggers it. make clean removes all the object files that had been created in the meantime. Normally, it’s no big deal to partially recompile, i.e. only to recompile the files you changed and finally link the newly created object files with the pre-existing ones.

How does make clean work?

make clean removes all the object files that had been created in the meantime. Normally, it’s no big deal to partially recompile, i.e. only to recompile the files you changed and finally link the newly created object files with the pre-existing ones.

When should you run clean?

3 Answers. The recompilation must be done if the source file, or any of the header files named as dependencies, is more recent than the object file, or if the object file does not exist. It’s not changing your Makefile that triggers it. make clean removes all the object files that had been created in the meantime.

What is @echo in makefile?

The ‘ @ ‘ is discarded before the line is passed to the shell. Typically you would use this for a command whose only effect is to print something, such as an echo command to indicate progress through the makefile: @echo About to make distribution files.

What does the option in GCC do?

When you invoke GCC, it normally does preprocessing, compilation, assembly and linking. The “overall options” allow you to stop this process at an intermediate stage. For example, the -c option says not to run the linker. Then the output consists of object files output by the assembler.

What is the default make target?

By default, the goal is the first target in the makefile (not counting targets that start with a period). Therefore, makefiles are usually written so that the first target is for compiling the entire program or programs they describe.

What are the prerequisites for making a makefile?

How do I run a makefile from the command prompt?

How to compile C files using GCC in Linux?

What is the use of Makefiles in C++?

Источник

What does Sudo make clean do?

make clean is something you do before recompiling, to make sure you get a clean build and don’t have left-over by-products from previous runs. You can do it after a make install if you want to free some space but keep the source and configuration around. You should not do it before installing.

Читайте также:  Calculate linux установка wine

How does make work?

The make utility requires a file, Makefile (or makefile ), which defines set of tasks to be executed. You may have used make to compile a program from source code. Most open source projects use make to compile a final executable binary, which can then be installed using make install .

What is make clean all?

The make program uses the makefile data base and the last-modification times of the files to decide which of the files need to be updated. We generally use make clean as a generic way to tell clean up the code.ie; remove all the compiled object files from the source code. You can name it as anything you like.

What is Makefile Ubuntu?

Makefile is a program building tool which runs on Unix, Linux, and their flavors. It aids in simplifying building program executables that may need various modules. To determine how the modules need to be compiled or recompiled together, make takes the help of user-defined makefiles.

What does make clean do in Linux?

It allows you to type ‘make clean’ at the command line to get rid of your object and executable files. Sometimes the compiler will link or compile files incorrectly and the only way to get a fresh start is to remove all the object and executable files.

How do I use the clean command in Linux?

  1. sudo apt-get autoclean. This terminal command deletes all .
  2. sudo apt-get clean. This terminal command is used to free up the disk space by cleaning up downloaded .
  3. sudo apt-get autoremove.

How do makefile rules work?

As a makefile is a list of shell commands, it must be written for the shell which will process the makefile. A makefile that works well in one shell may not execute properly in another shell. The makefile contains a list of rules. These rules tell the system what commands you want to be executed.

What is the purpose of a makefile?

The purpose of a makefile is to be easily build an executable that might take many commands to create (which would be a pain to compile over and over again manually).

How do you clean your Makefile?

The Cleanup Rule clean: rm *.o prog3 This is an optional rule. It allows you to type ‘make clean’ at the command line to get rid of your object and executable files. Sometimes the compiler will link or compile files incorrectly and the only way to get a fresh start is to remove all the object and executable files.

How do you clean a build?

On the menu bar, choose Build, and then choose one of the following commands:

  1. Choose Build or Build Solution to compile only those project files and components that have changed since the most recent build.
  2. Choose Rebuild Solution to “clean” the solution and then build all project files and components.

What is $$ in makefile?

$$ means be interpreted as a $ by the shell. the $(UNZIP_PATH) gets expanded by make before being interpreted by the shell.

What should I save a makefile as?

When I create makefile by ed editor, it is saved as file type which is found by make. Notepad will generally supply a . txt extension. Notepad is also not the most friendly editor for coding.

Источник

Оцените статью
Adblock
detector