Skip to content

Makefile options on FreeBSD

Makefile options on FreeBSD

CPPFLAGS

C PreProcessor flags - Passed to the PreProcessor.

CFLAGS

Passed to the compiler when compile C code.

CCFLAGS

no such option by default.

CXXFLAGS

Passed to the compiler when compile cpp (C++) code.

LDFLAGS

Linker flags - Passed to the linker.

COPTFLAGS

Optimization flags - controls the compiler settings when building kernel.

CPUTYPE

Currently only used for OpenSSL. Read man make.conf

MAKE_SHELL

Read man make.conf

MAKEFLAGS

Read man make

CC

CXX

CPP

LD

XCC

XCXX

XCPP

XLD

LINKER_TYPE

LINKER_VERSION

X_LINKER_TYPE

X_LINKER_VERSION

Instead of explaining every flags, use a script to run it:

#!/usr/local/bin/mksh

echo "====> default toolchain:"
make -V CC -V CPP -V CXX -V LD -V MAKE_SHELL -V MAKEFLAGS

echo "====> custom toolchain:"
make -V CC -V CPP -V CXX -V LD -V MAKE_SHELL \
        CC=clang \
        CPP=clang-cpp \
        CXX=clang++ \
        LD=/usr/bin/ld.lld \
        MAKE_SHELL=/usr/local/bin/mksh

echo "====> external toolchain:"
make -V XCC -V XCXX -V XCPP -V XLD

echo "====> ld.bfd linker:"
make -V LINKER_TYPE -V LINKER_VERSION LD=/usr/bin/ld.bfd

echo "====> ld.lld linker:"
make -V LINKER_TYPE -V LINKER_VERSION LD=/usr/bin/ld.lld

echo "====> external ld.lld linker:"
make -V X_LINKER_TYPE -V X_LINKER_VERSION XLD=/usr/bin/ld.lld

Put a Makefile in the same folder:

# Makefile
.include <bsd.progs.mk>

Run the script, output:

====> default toolchain:
cc
cpp
c++
ld


====> custom toolchain:
clang
clang-cpp
clang++
/usr/bin/ld.lld
/usr/local/bin/mksh
====> external toolchain:




====> ld.bfd linker:
bfd
21750
====> ld.lld linker:
lld
60000
====> external ld.lld linker:
lld
60000

Links:

FreeBSD External Toolchain https://wiki.freebsd.org/ExternalToolchain

Using LLD https://www.xjail.tiv.cc/posts/index.php?/archives/17-Using-LLD.html

 

Trackbacks

No Trackbacks

Comments

Display comments as Linear | Threaded

No comments

Add Comment

E-Mail addresses will not be displayed and will only be used for E-Mail notifications.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

Form options

Submitted comments will be subject to moderation before being displayed.