-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
212 lines (170 loc) · 8.49 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
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
export PROJECT_NAME = dfcgi
export AUTHOR = bioinfornatics
export DESCRIPTION = D interface to libfcgi
export VERSION = 1
export LICENSE = Public domain
export ROOT_SOURCE_DIR = deimos
DDOCFILES =
# include some command
include command.make
SOURCES = $(getSource)
OBJECTS = $(patsubst %.d,$(BUILD_PATH)$(PATH_SEP)%.o, $(SOURCES))
PICOBJECTS = $(patsubst %.d,$(BUILD_PATH)$(PATH_SEP)%.pic.o,$(SOURCES))
HEADERS = $(patsubst %.d,$(IMPORT_PATH)$(PATH_SEP)%.di, $(SOURCES))
DOCUMENTATIONS = $(patsubst %.d,$(DOC_PATH)$(PATH_SEP)%.html, $(SOURCES))
DDOCUMENTATIONS = $(patsubst %.d,$(DDOC_PATH)$(PATH_SEP)%.html, $(SOURCES))
DDOC_FLAGS = $(foreach macro,$(DDOCFILES), $(DDOC_MACRO)$(macro))
define make-lib
$(MKDIR) $(DLIB_PATH)
$(AR) rcs $(DLIB_PATH)$(PATH_SEP)$@ $^
$(RANLIB) $(DLIB_PATH)$(PATH_SEP)$@
endef
############# BUILD #############
all: static-lib header doc pkgfile-static
@echo ------------------ Building $^ done
all-shared: static-shared header doc pkgfile-shared
@echo ------------------ Building $^ done
.PHONY : pkgfile
.PHONY : doc
.PHONY : ddoc
.PHONY : clean
static-lib: $(LIBNAME)
shared-lib: $(SONAME)
header: $(HEADERS)
doc: $(DOCUMENTATIONS)
@echo ------------------ Building Doc done
ddoc: $(DDOCUMENTATIONS)
$(DC) $(DDOC_FLAGS) index.d $(DF)$(DDOC_PATH)$(PATH_SEP)index.html
@echo ------------------ Building DDoc done
geany-tag:
@echo ------------------ Building geany tag
$(MKDIR) geany_config
geany -c geany_config -g $(PROJECT_NAME).d.tags $(SOURCES)
pkgfile-shared:
@echo ------------------ Building pkg-config file
@echo "# Package Information for pkg-config" > $(PKG_CONFIG_FILE)
@echo "# Author: $(AUTHOR)" >> $(PKG_CONFIG_FILE)
@echo "# Created: `date`" >> $(PKG_CONFIG_FILE)
@echo "# Licence: $(LICENSE)" >> $(PKG_CONFIG_FILE)
@echo >> $(PKG_CONFIG_FILE)
@echo prefix=$(PREFIX) >> $(PKG_CONFIG_FILE)
@echo exec_prefix=$(PREFIX) >> $(PKG_CONFIG_FILE)
@echo libdir=$(LIB_DIR) >> $(PKG_CONFIG_FILE)
@echo includedir=$(INCLUDE_DIR)sqlite >> $(PKG_CONFIG_FILE)
@echo >> $(PKG_CONFIG_FILE)
@echo Name: "$(PROJECT_NAME)" >> $(PKG_CONFIG_FILE)
@echo Description: "$(DESCRIPTION)" >> $(PKG_CONFIG_FILE)
@echo Version: "$(VERSION)" >> $(PKG_CONFIG_FILE)
@echo Libs: $(LINKERFLAG)-l$(PROJECT_NAME)-$(COMPILER) >> $(PKG_CONFIG_FILE)
@echo Cflags: -I$(INCLUDE_DIR)sqlite $(LDCFLAGS) >> $(PKG_CONFIG_FILE)
@echo >> $(PKG_CONFIG_FILE)
pkgfile-static:
@echo ------------------ Building pkg-config file
@echo "# Package Information for pkg-config" > $(PKG_CONFIG_FILE)
@echo "# Author: $(AUTHOR)" >> $(PKG_CONFIG_FILE)
@echo "# Created: `date`" >> $(PKG_CONFIG_FILE)
@echo "# Licence: $(LICENSE)" >> $(PKG_CONFIG_FILE)
@echo >> $(PKG_CONFIG_FILE)
@echo prefix=$(PREFIX) >> $(PKG_CONFIG_FILE)
@echo exec_prefix=$(PREFIX) >> $(PKG_CONFIG_FILE)
@echo libdir=$(LIB_DIR) >> $(PKG_CONFIG_FILE)
@echo includedir=$(INCLUDE_DIR)sqlite >> $(PKG_CONFIG_FILE)
@echo >> $(PKG_CONFIG_FILE)
@echo Name: "$(PROJECT_NAME)" >> $(PKG_CONFIG_FILE)
@echo Description: "$(DESCRIPTION)" >> $(PKG_CONFIG_FILE)
@echo Version: "$(VERSION)" >> $(PKG_CONFIG_FILE)
@echo Libs: $(LIB_DIR)$(PATH_SEP)$(LIBNAME) >> $(PKG_CONFIG_FILE)
@echo Cflags: -I$(INCLUDE_DIR)sqlite $(LDCFLAGS) >> $(PKG_CONFIG_FILE)
@echo >> $(PKG_CONFIG_FILE)
# For build lib need create object files and after run make-lib
$(LIBNAME): $(OBJECTS)
@echo ------------------ Building static library
$(make-lib)
# For build shared lib need create shared object files
$(SONAME): $(PICOBJECTS)
@echo ------------------ Building shared library
$(MKDIR) $(DLIB_PATH)
$(DC) -shared $(OUTPUT)$(DLIB_PATH)$(PATH_SEP)$@.$(VERSION) $^
# create object files
$(BUILD_PATH)$(PATH_SEP)%.o : %.d
$(DC) $(DCFLAGS) $(DCFLAGS_LINK) $(DCFLAGS_IMPORT) -c $< $(OUTPUT)$@
# create shared object files
$(BUILD_PATH)$(PATH_SEP)%.pic.o : %.d
$(DC) $(DCFLAGS) $(DCFLAGS_LINK) $(FPIC) $(DCFLAGS_IMPORT) -c $< $(OUTPUT)$@
# Generate Header files
$(IMPORT_PATH)$(PATH_SEP)%.di : %.d
$(DC) $(DCFLAGS) $(DCFLAGS_LINK) $(DCFLAGS_IMPORT) -c $(NO_OBJ) $< $(HF)$@
# Generate Documentation
$(DOC_PATH)$(PATH_SEP)%.html : %.d
$(DC) $(DCFLAGS) $(DCFLAGS_LINK) $(DCFLAGS_IMPORT) -c $(NO_OBJ) $< $(DF)$@
# Generate ddoc Documentation
$(DDOC_PATH)$(PATH_SEP)%.html : %.d
$(DC) $(DCFLAGS) $(DCFLAGS_LINK) $(DCFLAGS_IMPORT) -c $(NO_OBJ) $(DDOC_FLAGS) $< $(DF)$@
############# CLEAN #############
clean: clean-objects clean-static-lib clean-doc clean-header clean-pkgfile
@echo ------------------ Cleaning $^ done
clean-shared: clean-shared-objects clean-shared-lib
@echo ------------------ Cleaning $^ done
clean-objects:
$(RM) $(OBJECTS)
@echo ------------------ Cleaning objects done
clean-shared-objects:
$(RM) $(PICOBJECTS)
@echo ------------------ Cleaning shared-object done
clean-static-lib:
$(RM) $(DLIB_PATH)$(PATH_SEP)$(LIBNAME)
@echo ------------------ Cleaning static-lib done
clean-shared-lib:
$(RM) $(DLIB_PATH)$(PATH_SEP)$(SONAME).$(VERSION)
@echo ------------------ Cleaning shared-lib done
clean-header:
$(RM) $(HEADERS)
@echo ------------------ Cleaning header done
clean-doc:
$(RM) $(DOCUMENTATIONS)
$(RM) $(DOC_PATH)
@echo ------------------ Cleaning doc done
clean-ddoc:
$(RM) $(DDOC_PATH)$(PATH_SEP)index.html
$(RM) $(DDOC_PATH)
@echo ------------------ Cleaning ddoc done
clean-geany-tag:
$(RM) geany_config $(PROJECT_NAME).d.tags
@echo ------------------ Cleaning geany tag done
clean-pkgfile:
$(RM) $(PKG_CONFIG_FILE)
@echo ------------------ Cleaning pkgfile done
############# INSTALL #############
install: install-static-lib install-doc install-header install-pkgfile
@echo ------------------ Installing $^ done
install-shared: install-shared-lib install-doc install-header install-pkgfile
@echo ------------------ Installing $^ done
install-static-lib:
$(MKDIR) $(LIB_DIR)
$(CP) $(DLIB_PATH)$(PATH_SEP)$(LIBNAME) $(DESTDIR)$(LIB_DIR)
@echo ------------------ Installing static-lib done
install-shared-lib:
$(MKDIR) $(LIB_DIR)
$(CP) $(DLIB_PATH)$(PATH_SEP)$(SONAME) $(DESTDIR)$(LIB_DIR)
ln -s $(DESTDIR)$(LIB_DIR)$(SONAME).$(SO_VERSION) $(DESTDIR)$(LIB_DIR)$(PATH_SEP)$(SONAME)
@echo ------------------ Installing shared-lib done
install-header:
$(MKDIR) $(INCLUDE_DIR)
$(CP) $(IMPORT_PATH)$(PATH_SEP)$(PROJECT_NAME) $(DESTDIR)$(INCLUDE_DIR)
@echo ------------------ Installing header done
install-doc:
$(MKDIR) $(DATA_DIR)$(PATH_SEP)doc$(PATH_SEP)$(PROJECT_NAME)$(PATH_SEP)normal_doc$(PATH_SEP)
$(CP) $(DOC_PATH)$(PATH_SEP)* $(DESTDIR)$(DATA_DIR)$(PATH_SEP)doc$(PATH_SEP)$(PROJECT_NAME)$(PATH_SEP)normal_doc$(PATH_SEP)
@echo ------------------ Installing doc done
install-ddoc:
$(MKDIR) $(DATA_DIR)$(PATH_SEP)doc$(PATH_SEP)$(PROJECT_NAME)$(PATH_SEP)cute_doc$(PATH_SEP)
$(CP) $(DDOC_PATH)$(PATH_SEP)* $(DESTDIR)$(DATA_DIR)$(PATH_SEP)doc$(PATH_SEP)$(PROJECT_NAME)$(PATH_SEP)cute_doc$(PATH_SEP)
@echo ------------------ Installing ddoc done
install-geany-tag:
$(MKDIR) $(DATA_DIR)$(PATH_SEP)geany$(PATH_SEP)tags$(PATH_SEP)
$(CP) $(PROJECT_NAME).d.tags $(DESTDIR)$(DATA_DIR)$(PATH_SEP)geany$(PATH_SEP)tags$(PATH_SEP)
@echo ------------------ Installing geany tag done
install-pkgfile:
$(MKDIR) $(PKGCONFIG_DIR)
$(CP) $(PKG_CONFIG_FILE) $(DESTDIR)$(PKGCONFIG_DIR)
@echo ------------------ Installing pkgfile done