-
Notifications
You must be signed in to change notification settings - Fork 1
/
makefile
85 lines (60 loc) · 1.89 KB
/
makefile
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
ifndef ($(VARIANT))
VARIANT = release
endif
UNAME := $(shell uname)
EXE = hypernomad.exe
COMPILATOR = g++
COMPILATOR_OPTIONS = -std=c++14
LIB_DIR = $(NOMAD_HOME)/lib
LIB_NOMAD = libnomad.so
CXXFLAGS =
ifeq ($(UNAME), Linux)
CXXFLAGS += -Wl,-rpath,'$(LIB_DIR)'
CXXFLAGS += -ansi
endif
LDLIBS = -lm -lnomad
INCLUDE = -I$(NOMAD_HOME)/src -I$(NOMAD_HOME)/ext/sgtelib/src -I.
COMPILE = $(COMPILATOR) $(COMPILATOR_OPTIONS) $(INCLUDE) -c
TOP = $(abspath .)
BUILD_DIR = $(TOP)/build/$(VARIANT)
SRC = $(TOP)/src/nomad_optimizer
BIN_DIR = $(TOP)/bin
EXE := $(addprefix $(BIN_DIR)/,$(EXE))
OBJS = fileutils.o hypernomad.o hyperParameters.o
OBJS := $(addprefix $(BUILD_DIR)/,$(OBJS))
ifndef NOMAD_HOME
define ECHO_NOMAD
@echo Please set NOMAD_HOME environment variable!
@false
endef
endif
$(EXE): $(OBJS)
$(ECHO_NOMAD)
@mkdir -p $(BIN_DIR)
@echo " building HyperNOMAD ..."
@$(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
@ln -fs $(EXE) $(TOP)/examples/.
@echo
@echo To be able to run the example
@echo the HYPERNOMAD_HOME environment variable
@echo must be set to $(TOP)
$(BUILD_DIR)/%.o: $(SRC)/%.cpp $(SRC)/hyperParameters.hpp $(SRC)/fileutils.hpp
$(ECHO_NOMAD)
@mkdir -p $(BUILD_DIR)
@$(COMPILE) $< -o $@
all: $(EXE)
clean: ;
@echo " cleaning obj files"
@rm -f $(OBJS)
del: ;
@echo " cleaning trash files"
@rm -f core *~
@echo " cleaning obj files"
@rm -f $(OBJS)
@echo " cleaning exe file"
@rm -f $(EXE)
@echo " cleaning build dir"
@rm -rf $(BUILD_DIR)