Visual Studio Code: Generating a Makefile

There are several ways to generate a makefile

  • Write a makefile by hand
  • Use an already existing makefile
  • Use Code Composer to generate a makefile
  • Use a generation program like autogen
  • Use Qt qmake as a makefile generator

For purposes of demonstration, we will show how to use a Qt project file (*.pro) to generate a makefile.

This does not assume you are using Qt in your project. The technique can be used for any project.

The Qt tools are included as part of the processor SDK so they are handy.

Project File Template

Here is a relatively simple Qt qmake .pro file template.


TARGET = <your_target_name>

CONFIG -= qt
CONFIG += debug_and_release

# define variable for the project directory and the src directory
projectDir = $$_PRO_FILE_PWD_
srcDir = $$projectDir/src

# setup intermediate and final output directories
# include directories used when building a Qt app even though
# the CONFIG -= qt above says this is not a Qt app
CONFIG (debug, debug|release) {
    DESTDIR      = $$OUT_PWD/debug
    OBJECTS_DIR += $$OUT_PWD/debug
    MOC_DIR     += $$OUT_PWD/debug
    UI_DIR      += $$OUT_PWD/debug
    RCC_DIR     += $$OUT_PWD/debug
} else {
    DESTDIR      = $$OUT_PWD/release
    OBJECTS_DIR += $$OUT_PWD/release
    MOC_DIR     += $$OUT_PWD/release
    UI_DIR      += $$OUT_PWD/release
    RCC_DIR     += $$OUT_PWD/release

# #defines for the project
# uncomment when being used

# include paths for the project
# uncomment when being used
#INCLUDEPATH += $$srcDir/include

# libraries to be linked include
# uncomment when being used
#LIBS +=
#LIBS += -Ldirectory_name_to_search -llib_name

# Source files
SOURCES += $$srcDir/main.c

# header files
# uncomment when being used
#HEADERS += $$srcDir/main.h

# include info from other files
# uncomment when being used

To use for a specific project, do the following:

  • Replace <your_target_name> with your actual target name
  • Add any global definitions (DEFINES) you need to have for your project
  • Add any include paths (INCLUDEPATH) you need
  • Add any libraries needed for linking (LIBS)
  • Add SOURCES lines for each source file in the project.
  • Add HEADERS lines for each header file in the project.
  • If you want to break the project file into pieces, you can use include(pathname.pri) to include additional files

Note that any line starting with # is a comment. Several lines are included in the template that are commented out.

For a simple program like hello_world, there is just a single source file and no defines, include paths, headers, or libraries. So the above template can almost be used as is.

Generating the makefile

Before calling qmake to generate the makefile, you need to setup the environment with the paths to the cross-compiler. There is an environment-setup script in the processor-sdk at ~/ti-processor-sdk-linux-am62xx-evm- This needs to be "sourced" before generating the makefile.

There are options regarding where the output directories are relative to where the project and source directories are. See the Qt documentation for more information.

For a simple hello_world project, if we assume the project file and source files are in a directory named "project_directory" and the project file is named, then generating a makefile essentially consists of a sequence something like:

cd project_directory
source ~/ti-processor-sdk-linux-am62xx-evm-

This should result in a makefile which can be used to make the project.

Go to top
Add picture from clipboard (Maximum size: 1 GB)