Limbo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Limbo.MakeUtils

Table of Contents

Introduction

It offers various small makefile utilities to find compilers and external packages with suitable linking flags.

Examples

Example of usage in Makefile (assuming BOOST_DIR and LIMBO_DIR are exported as the environment variable to the path where Boost and limbo library are installed)

1 # ==========================================================================
2 # Compilation Platform
3 # ==========================================================================
4 
5 # detect platform
6 # determine linking flags
7 UNAME_S = $(shell uname -s)
8 ifeq ($(UNAME_S), Linux)
9  STATIC_LINK_FLAG = -Wl,-Bstatic # ld under Linux has fine control
10  DYNAMIC_LINK_FLAG = -Wl,-Bdynamic # ld under Linux has fine control
11 endif
12 ifeq ($(UNAME_S), Darwin)
13  STATIC_LINK_FLAG = # dummy flags for linker
14  DYNAMIC_LINK_FLAG = # dummy flags for linker
15 endif
16 
17 # ==========================================================================
18 # Compilation Flags
19 # ==========================================================================
20 
21 # set CC, CXX, FC, AR
22 include $(LIMBO_DIR)/include/limbo/makeutils/FindCompiler.mk
23 # dependency to Boost and get BOOST_LINK_FLAG
24 include $(LIMBO_DIR)/include/limbo/makeutils/FindBoost.mk
25 
26 # view compiler settings and BOOST_LINK_FLAG
27 $(info Compilers: CC = $(CC), CXX = $(CXX), FC = $(FC), AR = $(AR))
28 $(info Boost: BOOST_LINK_FLAG = $(BOOST_LINK_FLAG))
29 
30 all: test
31 
32 # the appending DYNAMIC_LINK_FLAG is used to recover the linking flag
33 test: test.cpp
34  $(CXX) -o $@ $< -I $(BOOST_DIR) $(BOOST_LINK_FLAG) -L $(BOOST_DIR)/lib -lboost_iostreams $(DYNAMIC_LINK_FLAG)

References