makefile 2.24 KB
Newer Older
Miroslav Shaltev's avatar
Miroslav Shaltev committed
1
2
3
4
UNAME := $(shell uname)


EXE                             = user_search.exe
5
6
EXE_MPI				= user_search_MPI.exe

Miroslav Shaltev's avatar
Miroslav Shaltev committed
7
8
9
10
11
12
13
14
15
16
17
18
19
20
COMPILATOR                      = g++
COMPILATOR_MPI                  = mpic++

COMPILATOR_OPTIONS              = -O2 -ansi 
COMPILATOR_OPTIONS_MPI          = $(COMPILATOR_OPTIONS) -DUSE_MPI

LIB_DIR                         = $(NOMAD_HOME)/lib
LIB_NOMAD                       = libnomad.so 
LIB_NOMAD_MPI                   = libnomad.MPI.so

CXXFLAGS                        =           
ifeq ($(UNAME), Linux)
CXXFLAGS                       += -Wl,-rpath,'$(LIB_DIR)'
CXXFLAGS                       += -ansi
21
endif
Miroslav Shaltev's avatar
Miroslav Shaltev committed
22
23
24
25
CXXFLAGS_MPI 	                = $(CXXFLAGS) -DUSE_MPI

LDLIBS                          = -lm -lnomad
LDLIBS_MPI                      = -lm -lmpi -lnomad.MPI
26

Miroslav Shaltev's avatar
Miroslav Shaltev committed
27
28
INCLUDE                         = -I$(NOMAD_HOME)/src -I.
COMPILE                         = $(COMPILATOR) $(COMPILATOR_OPTIONS) $(INCLUDE) -c
29
COMPILE_MPI			= $(COMPILATOR_MPI) $(COMPILATOR_OPTIONS_MPI) $(INCLUDE) -c
Miroslav Shaltev's avatar
Miroslav Shaltev committed
30
31
32

OBJS                            = user_search.o
OBJS_MPI                        = user_search_MPI.o
33
34
35
36
37
38
39
40
41
42


ifndef NOMAD_HOME
define ECHO_NOMAD
	@echo Please set NOMAD_HOME environment variable!
	@false
endef
endif


Miroslav Shaltev's avatar
Miroslav Shaltev committed
43
$(EXE): $(OBJS)
44
45
46
	$(ECHO_NOMAD)
	@echo "   building the scalar version ..."
	@echo "   exe file : "$(EXE)
Miroslav Shaltev's avatar
Miroslav Shaltev committed
47
48
49
50
51
	@$(COMPILATOR) -o $(EXE) $(OBJS) $(LDLIBS) $(CXXFLAGS) -L$(LIB_DIR) 
ifeq ($(UNAME), Darwin)
	@install_name_tool -change $(LIB_NOMAD) $(NOMAD_HOME)/lib/$(LIB_NOMAD) $(EXE)
endif

52

Miroslav Shaltev's avatar
Miroslav Shaltev committed
53
$(EXE_MPI): $(OBJS_MPI) 
54
55
56
	$(ECHO_NOMAD)
	@echo "   building the MPI version ..."
	@echo "   exe file : "$(EXE_MPI)
Miroslav Shaltev's avatar
Miroslav Shaltev committed
57
58
59
60
61
	@$(COMPILATOR_MPI) -o  $(EXE_MPI) $(OBJS_MPI) $(LDLIBS_MPI) $(CXXFLAGS_MPI) -L$(LIB_DIR)
ifeq ($(UNAME), Darwin)
	@install_name_tool -change $(LIB_NOMAD_MPI) $(NOMAD_HOME)/lib/$(LIB_NOMAD_MPI) $(EXE_MPI)
endif

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

user_search.o: user_search.cpp
	$(ECHO_NOMAD)
	@$(COMPILE) user_search.cpp

user_search_MPI.o: user_search.cpp 
	$(ECHO_NOMAD)
	@$(COMPILE_MPI) user_search.cpp -o user_search_MPI.o

mpi: $(EXE_MPI)

all: $(EXE) $(EXE_MPI)

clean: ;
	@echo "   cleaning obj files"
	@rm -f $(OBJS) $(OBJS_MPI)

del: ;
	@echo "   cleaning trash files"
	@rm -f core *~
	@echo "   cleaning obj files"
	@rm -f $(OBJS) $(OBJS_MPI)
	@echo "   cleaning exe file"
	@rm -f $(EXE) $(EXE_MPI)