summaryrefslogtreecommitdiff
path: root/Makefile.in
blob: 76e0e1a3c0e4d7e8a64bee6b7b575b0fb927691a (plain)
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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
PACKAGE 		= @package@
NICKNAME 		= @nickname@
PROJECT_DIR 		= @project_dir@
GIT_REFERENCE_DIR	= @git_reference_dir@

BUILD 			= @build@
HOST 			= @host@
TARGET 			= @target@
ARCH 			= @arch@
COMPILER 		= @compiler@
TOOLCHAIN		= @toolchain@
SYSROOT 		= @sysroot@
CROSS_COMPILE 		= @cross_compile@
SHELL 			= @shell@

CFLAGS_DEBUG 		= @cflags_debug@
CFLAGS_COMMON 		= @cflags_common@
CFLAGS_CMDLINE 		= @cflags_cmdline@
CFLAGS_CONFIG 		= @cflags_config@
CFLAGS_SYSROOT 		= @cflags_sysroot@
CFLAGS_OS		= @cflags_os@
CFLAGS_SITE		= @cflags_site@
CFLAGS_PATH 		= @cflags_path@

LDFLAGS_DEBUG 		= @ldflags_debug@
LDFLAGS_COMMON 		= @ldflags_common@
LDFLAGS_CMDLINE 	= @ldflags_cmdline@
LDFLAGS_CONFIG 		= @ldflags_config@
LDFLAGS_SYSROOT 	= @ldflags_sysroot@
LDFLAGS_PATH 		= @ldflags_path@

PE_SUBSYSTEM 		= @pe_subsystem@
PE_IMAGE_BASE 		= @pe_image_base@
PE_CONFIG_DEFS  	= @pe_config_defs@

ELF_EH_FRAME 		= @elf_eh_frame@
ELF_HASH_STYLE 		= @elf_hash_style@
ELF_CONFIG_DEFS 	= @elf_config_defs@

PREFIX 			= @prefix@
EXEC_PREFIX 		= @exec_prefix@
BINDIR 			= @bindir@
LIBDIR 			= @libdir@
INCLUDEDIR 		= @includedir@
MANDIR 			= @mandir@
DOCDIR 			= @docdir@
LIBEXECDIR 		= @libexecdir@

NATIVE_CC 		= @native_cc@
NATIVE_OS 		= @native_os@
NATIVE_OS_BITS 		= @native_os_bits@
NATIVE_OS_UNDERSCORE	= @native_os_underscore@

USER_CC                 = @user_cc@
USER_CPP                = @user_cpp@
USER_CXX                = @user_cxx@


all:
install:
shared:
static:

install-extras:
install-app-extras:
install-libs-extras:

include $(PROJECT_DIR)/sysinfo/host/$(HOST).mk
include $(PROJECT_DIR)/sysinfo/compiler/$(COMPILER).mk
include $(PROJECT_DIR)/sysinfo/toolchain/$(TOOLCHAIN).mk

include $(PROJECT_DIR)/project/defs.mk
include $(PROJECT_DIR)/project/tree.mk
include $(PROJECT_DIR)/project/depends.mk
include $(PROJECT_DIR)/project/headers.mk
include $(PROJECT_DIR)/project/common.mk
include $(PROJECT_DIR)/project/arch.mk
include $(PROJECT_DIR)/project/extras.mk
include $(PROJECT_DIR)/project/overrides.mk



$(APP_SRCS:%.c=%.o): version.tag
$(APP_SRCS:%.c=%.o): CFLAGS_STATIC = $(CFLAGS_APP)

src/%.lo: 	$(PROJECT_DIR)/src/%.c $(ALL_HEADERS) host.tag dirs.tag
		$(CC) -c -o $@ $< $(CFLAGS_SHARED)

src/%.o: 	$(PROJECT_DIR)/src/%.c $(ALL_HEADERS) host.tag dirs.tag
		$(CC) -c -o $@ $< $(CFLAGS_STATIC)

lib/%$(OS_LIB_SUFFIX):
		$(CC) -shared -o $@ $^ $(LDFLAGS_SHARED)

lib/%$(OS_ARCHIVE_EXT):
		rm -f $@
		$(AR) rcs $@ $^



all:		shared static app

install:	install-libs install-headers install-app install-extras

app:		default-app


install-libs:	install-shared install-static install-implib install-libs-extras

install-headers:shared static
		mkdir -p $(DESTDIR)$(INCLUDEDIR)/$(PACKAGE)
		cp $(API_HEADERS) $(DESTDIR)$(INCLUDEDIR)/$(PACKAGE)

install-shared:	shared install-implib
		mkdir -p $(DESTDIR)$(LIBDIR)
		cp $(SHARED_LIB) $(DESTDIR)$(LIBDIR)

install-static:	static
		mkdir -p $(DESTDIR)$(LIBDIR)
		cp $(STATIC_LIB) $(DESTDIR)$(LIBDIR)

install-app:	app install-app-extras
		mkdir -p $(DESTDIR)$(BINDIR)
		cp $(APP) $(DESTDIR)$(BINDIR)



shared:		shared-lib shared-implib

static:		static-lib

shared-lib:	shared-objs $(SHARED_LIB)

static-lib:	static-objs $(STATIC_LIB)

shared-implib:	shared-lib



default-app:	version.tag static $(DEFAULT_APP) $(APP)

shared-app:	version.tag shared $(SHARED_APP)

static-app:	version.tag static $(STATIC_APP)



shared-objs:	dirs $(SHARED_OBJS)

static-objs:	dirs $(STATIC_OBJS)

app-objs:	dirs $(APP_OBJS)



$(SHARED_LIB):	$(SHARED_OBJS)

$(STATIC_LIB):	$(STATIC_OBJS)

$(APP):		$(DEFAULT_APP)
		cp $^ $@

$(DEFAULT_APP):	$(STATIC_OBJS) $(APP_OBJS)
		$(CC) -o $@ $^ $(LDFLAGS_APP)

$(SHARED_APP):	$(SHARED_LIB) $(APP_OBJS)
		$(CC) -o $@ $(APP_OBJS) -l$(PACKAGE) $(LDFLAGS_SHARED)

$(STATIC_APP):	$(STATIC_OBJS) $(APP_OBJS)
		$(CC) -static -o $@ $^ -l$(PACKAGE) $(LDFLAGS_STATIC)


dirs: 		dirs.tag tree.tag

dirs.tag:
		mkdir -p bin
		mkdir -p lib
		touch dirs.tag

host.tag:	Makefile
		$(PROJECT_DIR)/sysinfo/host/host.sh --compiler="$(CC)" --cflags="$(CFLAGS)"
		touch host.tag

version.tag:	$(GIT_REFERENCE_DIR)
		$(PROJECT_DIR)/sysinfo/version.sh	\
			-s $(PROJECT_DIR)		\
			-o build/$(PACKAGE)_version.h	\
			-p $(PACKAGE)
		touch version.tag

distclean:	clean
		rm -f Makefile

clean:
		rm -f tree.tag
		rm -f dirs.tag
		rm -f host.tag
		rm -f version.tag
		rm -f $(SHARED_OBJS)
		rm -f $(STATIC_OBJS)
		rm -f $(APP_OBJS)
		rm -f $(SHARED_LIB)
		rm -f $(STATIC_LIB)
		rm -f $(SHARED_IMPLIB)
		rm -f $(APP)
		rm -f $(DEFAULT_APP)
		rm -f $(SHARED_APP)
		rm -f $(STATIC_APP)


.display:	.display-project .display-env .display-tools .display-flags \
		.display-pe .display-elf .display-dirs .display-build

.display-project:
		@echo PROJECT_DIR:'            '$(PROJECT_DIR)
		@echo BUILD_DIR:'              '$(CURDIR)
		@echo

.display-env:
		@echo BUILD:'                  '$(BUILD)
		@echo HOST:'                   '$(HOST)
		@echo TARGET:'                 '$(TARGET)
		@echo ARCH:'                   '$(ARCH)
		@echo COMPILER:'               '$(COMPILER)
		@echo TOOLCHAIN:'              '$(TOOLCHAIN)
		@echo SYSROOT:'                '$(SYSROOT)
		@echo CROSS_COMPILE:'          '$(CROSS_COMPILE)
		@echo SHELL:'                  '$(SHELL)
		@echo

.display-tools:
		@echo CC:'                     '$(CC)
		@echo CPP:'                    '$(CPP)
		@echo CXX:'                    '$(CXX)
		@echo
		@echo AS:'                     '$(AS)
		@echo AR:'                     '$(AR)
		@echo LD:'                     '$(LD)
		@echo NM:'                     '$(NM)
		@echo OBJDUMP:'                '$(OBJDUMP)
		@echo RANLIB:'                 '$(RANLIB)
		@echo SIZE:'                   '$(SIZE)
		@echo STRIP:'                  '$(STRIP)
		@echo STRINGS:'                '$(STRINGS)
		@echo
		@echo ADDR2LINE:'              '$(ADDR2LINE)
		@echo COV:'                    '$(COV)
		@echo CXXFILT'                 '$(CXXFILT)
		@echo ELFEDIT:'                '$(ELFEDIT)
		@echo OBJCOPY:'                '$(OBJCOPY)
		@echo READELF:'                '$(READELF)
		@echo

.display-flags:
		@echo CFLAGS_DEBUG:'           '$(CFLAGS_DEBUG)
		@echo CFLAGS_COMMON:'          '$(CFLAGS_COMMON)
		@echo CFLAGS_CMDLINE:'         '$(CFLAGS_CMDLINE)
		@echo CFLAGS_CONFIG:'          '$(CFLAGS_CONFIG)
		@echo CFLAGS_SYSROOT:'         '$(CFLAGS_SYSROOT)
		@echo CFLAGS_OS:'              '$(CFLAGS_OS)
		@echo CFLAGS_SITE:'            '$(CFLAGS_SITE)
		@echo CFLAGS_PATH:'            '$(CFLAGS_PATH)
		@echo
		@echo LDFLAGS_DEBUG:'           '$(LDFLAGS_DEBUG)
		@echo LDFLAGS_COMMON:'          '$(LDFLAGS_COMMON)
		@echo LDFLAGS_CMDLINE:'         '$(LDFLAGS_CMDLINE)
		@echo LDFLAGS_CONFIG:'          '$(LDFLAGS_CONFIG)
		@echo LDFLAGS_SYSROOT:'         '$(LDFLAGS_SYSROOT)
		@echo LDFLAGS_PATH:'            '$(LDFLAGS_PATH)
		@echo

.display-pe:
		@echo PE_SUBSYSTEM:'           '$(PE_SUBSYSTEM)
		@echo PE_IMAGE_BASE:'          '$(PE_IMAGE_BASE)
		@echo PE_CONFIG_DEFS:'         '$(PE_CONFIG_DEFS)
		@echo

.display-elf:
		@echo ELF_EH_FRAME:'           '$(ELF_EH_FRAME)
		@echo ELF_HASH_STYLE:'         '$(ELF_HASH_STYLE)
		@echo ELF_CONFIG_DEFS:'        '$(ELF_CONFIG_DEFS)
		@echo

.display-dirs:
		@echo PREFIX:'                 '$(PREFIX)
		@echo EXEC_PREFIX:'            '$(EXEC_PREFIX)
		@echo BINDIR:'                 '$(BINDIR)
		@echo LIBDIR:'                 '$(LIBDIR)
		@echo INCLUDEDIR:'             '$(INCLUDEDIR)
		@echo MANDIR:'                 '$(MANDIR)
		@echo DOCDIR:'                 '$(DOCDIR)
		@echo LIBEXECDIR:'             '$(LIBEXECDIR)
		@echo

.display-build:
		@echo NATIVE_CC:'              '$(NATIVE_CC)
		@echo NATIVE_OS:'              '$(NATIVE_OS)
		@echo NATIVE_OS_BITS:'         '$(NATIVE_OS_BITS)
		@echo NATIVE_OS_UNDERSCORE:'   '$(NATIVE_OS_UNDERSCORE)
		@echo
		@echo USER_CC:'                '$(USER_CC)
		@echo USER_CPP:'               '$(USER_CPP)
		@echo USER_CXX:'               '$(USER_CXX)
		@echo

.display-host:
		@$(CC) $(CFLAGS) -dumpmachine


.PHONY:		all install shared static app .display \
		shared-objs shared-lib shared-implib \
		static-objs static-lib \
		default-app shared-app static-app \
		install-shared install-static install-implib \
		install-headers install-app \
		clean distclean version \
		.display-project .display-env .display-tools .display-flags \
		.display-pe .display-elf .display-dirs .display-build