This repository was archived by the owner on May 14, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
104 lines (83 loc) · 2.11 KB
/
makefile
File metadata and controls
104 lines (83 loc) · 2.11 KB
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
# Fichier : Makefile
# Auteur : Nilo Schwencke d'apres Florent Hivert
# A propos : L3 MFA S6-Projet (rp cma-es)
#
# Date : mar. mars 24 19:10:54 CET 2015
#######################################################
# Description des differents modules
#
### DEFAULT ###
#### Extensions ####
CPP_EXTENSIONS = cc cp cxx cpp CPP c++ C
HPP_EXTENSIONS = hh H hp hxx hpp HPP h++ tcc
#### Debug ####
DEBUG = -1
#### Flags ####
CPPFLAGS =
LDFLAGS =
#### Executable ####
EXEC = exec
#### Default is exec not lib ####
IS_LIB = 0
#### Binaries ####
SHELL = /bin/sh
CCCP = g++
RM = rm -f
#project specific settings must be defined in settings.mk
-include settings.mk
#### Files ####
ifeq "$(CPP_FILES)" ""
CPP_FILES = $(foreach ext,$(CPP_EXTENSIONS),$(wildcard *.$(ext)))
endif
ifeq "$(HPP_FILES)" ""
HPP_FILES = $(foreach ext,$(HPP_EXTENSIONS),$(wildcard *.$(ext)))
endif
O_FILES = $(filter %.o,$(foreach ext,$(CPP_EXTENSIONS),$(CPP_FILES:.$(ext)=.$(ext).o)))
SRCS = $(strip $(CPP_FILES) $(HPP_FILES))
DEPS = $(O_FILES:.o=.d)
#### Settings computation ####
ifeq "$(DEBUG)" "2"
CPPFLAGS += -g3 -O0
else ifeq "$(DEBUG)" "1"
CPPFLAGS += -pg #profile
else ifeq "$(DEBUG)" "0"
CPPFLAGS += -O2
endif
ifneq "$(IS_LIB)" "0"
### Binaries ###
MD = mkdir -p
CP = cp
CPPFLAGS += -shared -fPIC
NAME = $(strip lib$(EXEC))
PATH_LIB = /usr/local/lib/
PATH_INCLUDE = /usr/local/include/
ifneq ("$(wildcard lib-settings.mk)","")
-include lib-settings.mk
endif
endif
#### Dependencies ####
all: $(EXEC)
#function to create o targets
define ofile
$(1): $(patsubst %.o,%,$(1))
@$(CCCP) $(CPPFLAGS) -o $(1) -c -MP -MMD $(patsubst %.o,%,$(1)) $(LDFLAGS)
endef
#creates the o targets from the O_FILES variable
$(foreach file,$(O_FILES),$(eval $(call ofile,$(file))))
$(EXEC): $(O_FILES)
@$(CCCP) $(CPPFLAGS) -o $@ $^ $(LDFLAGS)
#### Miscellaneous targets ####
clean:
@$(RM) $(O_FILES) $(DEPS)
mrproper: clean
@$(RM) $(EXEC)
rebuild: mrproper all
ifneq "$(IS_LIB)" "0"
install: all
$(MD) $(PATH_INCLUDE)/$(NAME)
$(CP) $(HPP_FILES) $(PATH_INCLUDE)/$(NAME)
$(MD) $(PATH_LIB)/$(NAME)
$(CP) $(EXEC) $(PATH_LIB)/$(NAME)/$(NAME).so
endif
.PHONY: clean
-include $(DEPS)