Makefile 3.7 KB
Newer Older
German Leon's avatar
German Leon committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# Makefile for LU Decomposition
#
#

# DEBUG can be set to YES to include debugging info, or NO otherwise
DEBUG          := YES

# PROFILE can be set to YES to include profiling info, or NO otherwise
PROFILE        := NO

# ------------  name of the executable  ----------------------------------------
EXECUTABLE      := lud_base

# ------------  list of all source files  --------------------------------------
SOURCES         := lud.c lud_base.c ../common/common.c 

# ------------  compiler  ------------------------------------------------------
CC              := gcc
CXX             := g++

# ------------  compiler flags  ------------------------------------------------
DEBUG_CFLAGS    := -Wall -O0 -g
RELEASE_CFLAGS  := -Wall -O3 
COMMON_CFLAGS   := 

# ------------  compiler defs  ------------------------------------------------
DEBUG_CDEFS    := -D_DEBUG_RESULT
RELEASE_CDEFS  := 
COMMON_CDEFS   := 

# ------------  linker flags  --------------------------------------------------
DEBUG_LDFLAGS    := -g
RELEASE_LDFLAGS  := 
COMMON_LDFLAGS   := 

ifeq (YES, ${DEBUG})
  CFLAGS       := ${DEBUG_CFLAGS} ${DEBUG_CDEFS}
  CXXFLAGS     := ${DEBUG_CXXFLAGS} ${DEBUG_CDEFS}
  LDFLAGS      := ${DEBUG_LDFLAGS}
else
  CFLAGS       := ${RELEASE_CFLAGS} ${RELEASE_CDEFS}
  CXXFLAGS     := ${RELEASE_CXXFLAGS} ${RELEASE_CDEFS}
  LDFLAGS      := ${RELEASE_LDFLAGS}
endif

CFLAGS         := ${CFLAGS} ${COMMON_CFLAGS}
CXXFLAGS       := ${CXXFLAGS} ${COMMON_CFLAGS}
LDFLAGS        := ${LDFLAGS} ${COMMON_LDFLAGS}

ifeq (YES, ${PROFILE})
  CFLAGS       := ${CFLAGS}   -pg -O3
  CXXFLAGS     := ${CXXFLAGS} -pg -O3
  LDFLAGS      := ${LDFLAGS}  -pg
endif

# ------------  additional system include directories  -------------------------
GLOBAL_INC_DIR  =

# ------------  private include directories  -----------------------------------
LOCAL_INC_DIR   = ../common

# ------------  system libraries  (e.g. -lm )  ---------------------------------
SYS_LIBS        = 

# ------------  additional system library directories  -------------------------
GLOBAL_LIB_DIR  =

# ------------  additional system libraries  -----------------------------------
GLOBAL_LIBS     =

# ------------  private library directories  -----------------------------------
LOCAL_LIB_DIR   = 

# ------------  private libraries  (e.g. libxyz.a )  ---------------------------
LOCAL_LIBS      =


C_SOURCES       = $(filter     %.c, $(SOURCES))
CPP_SOURCES     = $(filter-out %.c, $(SOURCES))
ALL_INC_DIR     = $(addprefix -I, $(LOCAL_INC_DIR) $(GLOBAL_INC_DIR))
ALL_LIB_DIR     = $(addprefix -L, $(LOCAL_LIB_DIR) $(GLOBAL_LIB_DIR))
GLOBAL_LIBSS    = $(addprefix $(GLOBAL_LIB_DIR)/, $(GLOBAL_LIBS))
LOCAL_LIBSS     = $(addprefix $(LOCAL_LIB_DIR)/, $(LOCAL_LIBS))
ALL_CFLAGS      = $(CFLAGS) $(ALL_INC_DIR)
ALL_LFLAGS      = $(LDFLAGS) $(ALL_LIB_DIR)
BASENAMES       = $(basename $(SOURCES))

# ------------  generate the names of the object files  ------------------------
OBJECTS         = $(addsuffix .o,$(BASENAMES))
 
# ------------  make the executable (the default goal)  ------------------------
$(EXECUTABLE):	$(OBJECTS)
ifeq ($(strip $(CPP_SOURCES)),)
	$(CC)  $(ALL_LFLAGS) -o $(EXECUTABLE) $(OBJECTS) $(LOCAL_LIBSS) $(GLOBAL_LIBSS) $(SYS_LIBS)
else
	$(CXX) $(ALL_LFLAGS) -o $(EXECUTABLE) $(OBJECTS) $(LOCAL_LIBSS) $(GLOBAL_LIBSS) $(SYS_LIBS)
endif

# ------------  make the objects  ----------------------------------------------
%.o:		%.c
				$(CC)  -c $(ALL_CFLAGS) $< -o $@

%.o:		%.cc
				$(CXX) -c $(ALL_CFLAGS) $< -o $@

%.o:		%.cpp
				$(CXX) -c $(ALL_CFLAGS) $< -o $@

%.o:		%.C
				$(CXX) -c $(ALL_CFLAGS) $< -o $@

clean:
	-rm --force $(EXECUTABLE) $(OBJECTS) *~

.PHONY: clean

# ==============================================================================
# vim: set tabstop=2: set shiftwidth=2: