What is the $@ symbol for in a makefile?

  • Thread starter Thread starter jf22901
  • Start date Start date
  • Tags Tags
    Symbol
Click For Summary
SUMMARY

The $@ symbol in a Makefile represents the target name of the rule, specifically the name of the file that is generated by the rule. In the provided example, it is used in the command `ifort $(LOADFLAGS) -o $@ $(OBJECTS) $(LIBRARIES)`, where $@ expands to the name of the executable defined by the target `$(EXECUTABLE)`. This automatic variable is essential for correctly specifying output files in build processes using GNU Make.

PREREQUISITES
  • Understanding of Makefile syntax and structure
  • Familiarity with GNU Make and its automatic variables
  • Basic knowledge of the Intel Fortran Compiler (ifort)
  • Experience with linking object files and libraries in build processes
NEXT STEPS
  • Review the GNU Make manual, specifically the section on automatic variables
  • Explore advanced Makefile techniques for managing complex build processes
  • Learn about the Intel Fortran Compiler (ifort) command-line options
  • Investigate dependency management in Makefiles for large projects
USEFUL FOR

Software developers, particularly those working with C/C++ and Fortran, build engineers, and anyone involved in automating compilation processes using Makefiles.

jf22901
Messages
55
Reaction score
1
Hi.

Can anyone please tell me what purpose $@ serves in the dependency line below? I've tried looking online, and in the make and ifort documentation, but can't find anything. :confused:

Code:
$(EXECUTABLE) : $(OBJECTS)
                ifort $(LOADFLAGS) -o $@ $(OBJECTS) $(LIBRARIES)

where:

OBJECTS = list of object files
LOADFLAGS = -O3 -align dcommons
LIBRARIES = -L$(LIBRARY) -lfft -lnetcdf

Many thanks. :smile:
 
Technology news on Phys.org

Similar threads

Replies
1
Views
2K
  • · Replies 34 ·
2
Replies
34
Views
4K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 3 ·
Replies
3
Views
14K
  • · Replies 6 ·
Replies
6
Views
4K
Replies
6
Views
4K