-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglobalVar.mk
122 lines (100 loc) · 3.22 KB
/
globalVar.mk
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
119
120
121
#################
# WINDOWS MACRO #
#################
# Macros for windows. A scripted or C version of this should be dev as a make toolkit...
# TODO 'ifdef unix' and implement counterpart
CP =@copy "$(subst /,\,$(1))" "$(subst /,\,$(2))"
CPD =@xcopy "$(subst /,\,$(1))" "$(subst /,\,$(2))" /Y /E /I
MKD =@if NOT exist $(subst /,\,$(1)) mkdir $(subst /,\,$(1))
RMD =@if exist $(1) FOR /D %%p IN ($(1)) DO rmdir "%%p" /s /q
MKJ =if exist $(subst /,\,$(1)) mklink /J $(subst /,\,$(2)) $(subst /,\,$(1))
RMJ =@if exist $(subst /,\,$(1)) rmdir $(subst /,\,$(1))
RWX =$(wildcard $(1)/*$(2)) $(if $(wildcard $(1)/*/),$(call RWX,$(1)/*,$(2)),)
#######################
# DEFAULT COMPILATION #
#######################
C =g++
CSTANDARD =-std=c++11
CC =$(C) $(CSTANDARD)
# default WARNING flags
WFLAGS =-W -Wall -Wextra
# default LINKAGE flags
LFLAGS =
ifdef sharedLib
LFLAGS =-shared -Wl,--out-implib,$(obj)/$(implibFile)
endif
# default COMPILATION flags
CFLAGS =$(WFLAGS) -Og -ggdb -DDEBUG=true
ifdef release
CFLAGS =$(WFLAGS) -O3 -s -DNDEBUG=true
endif
##########################
# ARCHITECTURE DETECTION #
##########################
DUMPM := $(shell $(C) -dumpmachine)
CVERS := $(shell $(C) -dumpversion)
CPATH := $(patsubst %\$(C).exe,%,$(shell where $(C)))
arch :=wtf
ifneq ($(findstring i686, $(DUMPM)),)
arch :=x86
else ifneq ($(findstring x86_64, $(DUMPM)),)
arch :=x64
endif
########################
# REPO PROJECT PACKING #
########################
# a library has a repo folder in name-version-arch
productName =$(name)-$(version)-$(arch)$(tag)
localRepoRoot =repo
localBuildRoot =.build
localBuildFolder =$(localBuildRoot)/$(productName)
localRepoFolder =$(localRepoRoot)/$(productName)
binPackFolder =$(localRepoFolder)/bin
libPackFolder =$(localRepoFolder)/lib
includePackFolder =$(localRepoFolder)/include
repoFolder =$(STUDIO)/repo
#######################
# project description #
#######################
name =no-name
version =0.0.0
# root folder of compilable ressources
src =src
srcExt =.cpp
# external dependencies root (ntfs junction, link...)
ext =ext
# folder to be copied when exported. not used at compil-time
inc =include
# folder added to -I parameters
includesDir =include
CPP_FILES =$(call RWX ,$(src),$(srcExt))
TRANSLATUNIT=$(patsubst $(src)/%$(srcExt),%,$(CPP_FILES))
OBJECTS =$(patsubst %,$(obj)/%.o,$(TRANSLATUNIT))
DEPENDENCIES=$(patsubst %,$(dep)/%.d,$(TRANSLATUNIT))
IFOLDERS =$(addprefix -I,$(includesDir))
LIBFOLDERS =$(addprefix -L,$(librariesDir))
LIBNAMES =$(addprefix -l,$(libraries))
##############################
# DEFAULT TEMP FILE LOCATION #
##############################
# dependency *.d files will be here
dep =$(localBuildFolder)/.dep
# native object *.o files will be here
obj =$(localBuildFolder)/.obj
###########################
# DEFAULT PROJECT PRODUCT #
###########################
dllFile =$(name).dll
implibFile =lib$(name).dll.a
exeFile =$(name).exe
ifdef sharedLib
binFile =$(dllFile)
else
binFile =$(exeFile)
endif
#################
# MISCELLANEOUS #
#################
#Don't create dependencies when we're cleaning, for instance
noDepInclude=clean info cleandep cleanAll extInstall extUninstall
.PHONY: test cleanAll extInstall extUninstall pack