File: Makefile.in

package info (click to toggle)
firebird3.0 3.0.5.33100.ds4-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 41,296 kB
  • sloc: ansic: 374,363; cpp: 318,213; sql: 14,311; pascal: 14,123; yacc: 7,541; fortran: 5,645; sh: 5,261; makefile: 1,084; perl: 138; sed: 83; awk: 75; xml: 19; csh: 15
file content (734 lines) | stat: -rw-r--r-- 21,973 bytes parent folder | download
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
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
#
#	PROGRAM:	Firebird single makefile
#	MODULE:		Makefile.in
#	DESCRIPTION:	Posix build main file
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
# You may obtain a copy of the Licence at
# http://www.gnu.org/licences/lgpl.html
# 
# As a special exception this file can also be included in modules
# with other source code as long as that source code has been 
# released under an Open Source Initiative certificed licence.  
# More information about OSI certification can be found at: 
# http://www.opensource.org 
# 
# This module is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public Licence for more details.
# 
# This module was created by members of the firebird development 
# team.  All individual contributions remain the Copyright (C) of 
# those individuals and all rights are reserved.  Contributors to 
# this file are either listed below or can be obtained from a SVN 
# history command.
#
#  Created by:  Mark O'Donohue <mark.odonohue@ludwig.edu.au>
#
#  Contributor(s):
#		Alex Peshkoff - created single makefile based on Mark's files
# 

ROOT=$(shell cd ..; pwd)

include     make.defaults
ifeq ($(CROSS_OUT), Y)
include     make.crossPlatform
else
include     make.platform
endif
include     make.rules
include     make.shared.variables

@SET_MAKE@

ifeq ($(IsDeveloper), Y)
  DefaultTarget := Debug
else
  DefaultTarget := Release
endif

ifeq ($(IsCross), Y)
  Process := cross_process
else
  Process := master_process
endif

.PHONY:	master_process cross_process firebird Debug Release extern

all:	firebird

firebird:
	$(MAKE) TARGET=$(DefaultTarget) $(Process)

Release:
	$(MAKE) TARGET=Release $(Process)

Debug:
	$(MAKE) TARGET=Debug $(Process)


#----------------------------------------------------------------------------
# jrd/build_no.h contains the version and build# fields used throughout the
# program and quoted in the tools.  This routine will update the build_no.h
# file with the auto update build# script file, writeBuildNum.sh.  The
# writeBuildNum.sh script is autoupdated by SVN checkins.
#

.PHONY: updateCloopInterfaces updateBuildNum

IDL_ROOT=$(SRC_ROOT)/include/firebird
IDL_FILE=$(IDL_ROOT)/FirebirdInterface.idl
API_H_FILE=$(IDL_ROOT)/IdlFbInterfaces.h
API_PAS_FILE=$(SRC_ROOT)/include/gen/Firebird.pas
PAS_ROOT=$(SRC_ROOT)/misc/pascal
PASCAL_SOURCES=$(wildcard $(PAS_ROOT)/*)
TMP_FUNCS=$(TMP_ROOT)/func.pas
XPB_CONSTS=$(SRC_ROOT)/include/consts_pub.h
ERR_CONSTS=$(ROOT)/lang_helpers/gds_codes.pas

updateCloopInterfaces : $(API_H_FILE) $(API_PAS_FILE)

$(API_H_FILE): $(IDL_FILE)
	$(CLOOP) $< c++ $@ IDL_FB_INTERFACES_H Firebird I

$(TMP_FUNCS): $(PASCAL_SOURCES) $(XPB_CONSTS) $(ERR_CONSTS)
	cat $(PAS_ROOT)/fb_get_master_interface.pas >$(TMP_FUNCS)
	awk -f $(PAS_ROOT)/Pascal.Constants.awk <$(XPB_CONSTS) >>$(TMP_FUNCS)
	grep '[[:space:]]isc_' $(ERR_CONSTS) >>$(TMP_FUNCS)

$(API_PAS_FILE): $(IDL_FILE) $(PASCAL_SOURCES) $(TMP_FUNCS)
	$(CLOOP) $(IDL_FILE) pascal $@ Firebird --uses SysUtils \
		--interfaceFile $(PAS_ROOT)/Pascal.interface.pas \
    	--implementationFile $(PAS_ROOT)/Pascal.implementation.pas \
    	--exceptionClass FbException \
    	--functionsFile $(TMP_FUNCS) \
    	--prefix I

updateBuildNum : $(SRC_ROOT)/jrd/build_no.h $(GEN_ROOT)/Make.Version

$(SRC_ROOT)/jrd/build_no.h : $(SRC_ROOT)/misc/writeBuildNum.sh
	(cd $(ROOT); ./src/misc/writeBuildNum.sh rebuildHeader)

$(GEN_ROOT)/Make.Version : $(SRC_ROOT)/misc/writeBuildNum.sh
	$(SRC_ROOT)/misc/writeBuildNum.sh createMakeVersion $@


#___________________________________________________________________________
# build external software
#

extern:
	$(MAKE) -C $(ROOT)/extern/btyacc
	$(MAKE) -C $(ROOT)/extern/cloop TARGET=release WITH_FPC=0 BUILD_DIR=$(TMP_ROOT)/cloop OUT_DIR=$(GEN_ROOT)/$(TARGET)/cloop

ifeq ($(TOMBUILD_FLG),Y)
	echo $(LIBTOOL)
	$(MAKE) -C $(ROOT)/extern/libtommath -f makefile.shared LIBTOOL=$(LIBTOOL)
	ln -sf $(TOMMATH_SO).$(TOMMATH_VER) $(LIB)
	ln -sf $(TOMMATH_SO) $(LIB)
endif

ifeq ($(STD_EDITLINE),false)
ifeq ($(EDITLINE_FLG),Y)
	$(MAKE) -f $(GEN_ROOT)/Makefile.extern.editline
endif
endif


#___________________________________________________________________________
# create platform-specific export lists (version scripts) in gen
#

%.vers: $(ROOT)/builds/posix/%.vers
	sh vers.sh $(firstword $@)

export_lists: $(ALLVERS)

#___________________________________________________________________________
# LibTomMath - used by cross-builds
#

.PHONY:	tommath
TOMLIB=$(LIB)/libtommath.a
TOM_Objs=$(addprefix ../extern/libtommath/,$(call doObjects,$(call dirFiles,../extern/libtommath)))

tommath:	$(TOMLIB)

$(TOMLIB):	$(TOM_Objs)
	-$(RM) $@
	$(STATICLIB_LINK) $@ $^

#___________________________________________________________________________
# main build target for both debug and release builds
#

.PHONY:	cross1 cross2 boot yvalve engine fbintl gpre utilities plugins rest codes ids examples cross_rest preliminaryCheck

master_process:
	ln -sf $(SRC_ROOT)/include/gen/autoconfig.auto $(SRC_ROOT)/include/gen/autoconfig.h
	$(MAKE) updateBuildNum
	$(MAKE) export_lists
	$(MAKE) extern
	$(MAKE) updateCloopInterfaces
	$(MAKE) preliminaryCheck
	$(MAKE) boot
	$(MAKE) yvalve
	$(MAKE) ids
	$(MAKE) engine
	$(MAKE) fbintl
	$(MAKE) utilities
# Now having ready such useful tools as gbak and isql, we may restore / create
# required databases and switch to full-featured gpre
	$(MAKE) gpre
# Pay attention - after build force gpre_current to point to gpre 
# even if gpre itself was not rebuilt
	-$(RM) $(GPRE_CURRENT)
	(cd $(BIN); $(LN) $(notdir $(GPRE)) $(notdir $(GPRE_CURRENT)))
	$(MAKE) codes
	$(MAKE) plugins
	$(MAKE) examples
	$(MAKE) rest


cross_process:
	$(MAKE) TARGET=Native cross1
	$(MAKE) CROSS_OUT=Y cross2

cross1:
	ln -sf $(SRC_ROOT)/include/gen/autoconfig.auto $(SRC_ROOT)/include/gen/autoconfig.h
	$(MAKE) updateBuildNum
	$(MAKE) export_lists
	$(MAKE) extern
	$(MAKE) updateCloopInterfaces
	$(MAKE) boot
	$(MAKE) yvalve
	$(MAKE) ids
	$(MAKE) engine
	$(MAKE) fbintl
	$(MAKE) gbak isql gfix
# Now having ready such useful tools as gbak and isql, we may restore / create
# required databases and switch to full-featured gpre
	$(MAKE) gpre
# Pay attention - after build force gpre_current to point to gpre 
# even if gpre itself was not rebuilt
	-$(RM) $(GPRE_CURRENT)
	(cd $(BIN); $(LN) $(notdir $(RUN_GPRE)) $(notdir $(GPRE_CURRENT)))
	$(MAKE) include_generic
	$(MAKE) -f Makefile.examples -C $(GEN_ROOT)/examples/

cross2:
	ln -sf $(SRC_ROOT)/include/cross/$(CROSS_CONFIG) $(SRC_ROOT)/include/gen/autoconfig.h
	$(MAKE) prerequisites
	$(MAKE) tommath
	$(MAKE) yvalve
	$(MAKE) engine
	$(MAKE) fbintl
	$(MAKE) utilities
	$(MAKE) $(GPRE)
	$(MAKE) plugins
	$(MAKE) -f Makefile.plugins_examples
	$(MAKE) cross_rest


#___________________________________________________________________________
# preliminary checks - make sure platform is OK to build FB
#

STD_SIZES:=$(SRC_ROOT)/misc/ods.txt
RUN_SIZES:=$(GEN_ROOT)/ods.txt
ODS_H:=$(SRC_ROOT)/jrd/ods.h
ODS_AWK:=$(SRC_ROOT)/misc/ods.awk
ODS_TEST_CPP:=$(GEN_ROOT)/odstest.cpp
ODS_TEST:=$(GEN_ROOT)/odstest$(EXEC_EXT)

preliminaryCheck:	$(STD_SIZES) $(RUN_SIZES)
	diff -u $^

$(RUN_SIZES): $(ODS_H) $(ODS_AWK)
	awk -f $(ODS_AWK) <$(ODS_H) >$(ODS_TEST_CPP)
	$(CXX) -o $(ODS_TEST) $(WCXXFLAGS) $(ODS_TEST_CPP)
	$(ODS_TEST) >$(RUN_SIZES)

#___________________________________________________________________________
# static library - various common code, used in different FB projects
#

$(COMMON_LIB):	$(Common_Objects)
	-$(RM) $@
	$(STATICLIB_LINK) $@ $^


#___________________________________________________________________________
# gpre_boot
#

boot: $(GPRE_BOOT)

$(GPRE_BOOT):	$(GPRE_Boot_Objects) $(COMMON_LIB)
	$(STATICEXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ -L$(LIB) $(LINK_LIBS)
	-$(RM) $(GPRE_CURRENT)
	(cd $(@D); $(LN) $(@F) $(notdir $(GPRE_CURRENT)))


#___________________________________________________________________________
# yValve
#

yvalve: $(LIBFIREBIRD_BASENAME)

ifneq ($(LibraryBaseName),$(LibrarySoName))
$(LIBFIREBIRD_BASENAME):	$(LIBFIREBIRD_SONAME)
	(cd $(LIB) && $(LN) -f $(LibrarySoName) $(LibraryBaseName) )
endif

ifneq ($(LibrarySoName),$(LibraryFullName))
$(LIBFIREBIRD_SONAME):	$(LIBFIREBIRD_FULLNAME)
	(cd $(LIB) && $(LN) -f $(LibraryFullName) $(LibrarySoName) )
endif

# remote redirector is statically linked in main FB library
$(LIBFIREBIRD_FULLNAME):	$(YValve_Objects) $(Remote_Client_Objects) $(COMMON_LIB)
	$(LINK_FIREBIRD) -o $@ $^ $(LINK_FIREBIRD_LIBS)


#___________________________________________________________________________
# core part - jrd's engine
#

engine: $(ENGINE_SONAME)

$(ENGINE_SONAME):	$(Engine_Objects) $(SVC_Objects) $(COMMON_LIB)
	$(LINK_ENGINE) -o $@ $^ $(LINK_ENGINE_LIBS)


#___________________________________________________________________________
# intl support
#

fbintl: $(LIBFBINTL_SO)

$(LIBFBINTL_SO):	$(INTL_Objects) $(COMMON_LIB)
	$(LINK_INTL) -o $@ $^ $(LINK_INTL_LIBS)


#___________________________________________________________________________
# full gpre
# when switching to it we also build databases needed later
#

.PHONY:	databases

gpre: $(GPRE) databases

$(GPRE):	$(GPRE_Objects) $(COMMON_LIB)
	$(EXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS)

HELP_FDB = $(FIREBIRD)/help/help.fdb
SECURITY_FDB = $(FIREBIRD)/security3.fdb
SECURITY_TMP = security.tmp

databases:		yachts.lnk msg.timestamp $(SECURITY_FDB)

export LD_LIBRARY_PATH := $(LD_LIBRARY_PATH):$(FIREBIRD)/lib

yachts.lnk:		metadata.fdb
	-$(RM) $@
	$(LN) $^ $@

metadata.fdb:	$(RUN_ISQL) $(SRC_ROOT)/dbs/metadata.sql
	-$(RM) $@
	$(RUN_ISQL) -q -i $(SRC_ROOT)/dbs/metadata.sql
	$(RUN_GFIX) -mode read_only $@
	$(CHMOD) 0444 $@

$(SECURITY_FDB):	security.fdb
	-$(RM) $@
	$(CP) $^ $@

security.fdb:	$(SRC_ROOT)/dbs/security.sql
	-$(RM) $@
	-$(RM) $(SECURITY_TMP)
	echo create database \'$(SECURITY_TMP)\'\; | $(RUN_ISQL)
	$(RUN_GFIX) -write async $(SECURITY_TMP)
	$(RUN_ISQL) -i $^ $(SECURITY_TMP)
	$(CHMOD) a=rw $(SECURITY_TMP)
	$(CP) $(SECURITY_TMP) $@
	$(RUN_GFIX) -write sync $@

msg.timestamp:	$(MSG_FILES)
	-$(RM) msg.fdb
	echo create database \'msg.fdb\'\; | $(RUN_ISQL)
	$(RUN_GFIX) -write async msg.fdb
	for sql in $(MSG_FILES); do (echo $$sql; $(RUN_ISQL) -i $$sql msg.fdb) || exit; done
	$(TOUCH) $@


.PHONY:	udfs ibutil ibudf fbudf udfsupport

udfsupport:
	$(MAKE) ibutil
	$(MAKE) udfs

udfs:	ibudf fbudf

UDF = $(FB_BUILD)/UDF
IBUDF_SO = $(UDF)/ib_udf.$(SHRLIB_EXT)
FBUDF_SO = $(UDF)/fbudf.$(SHRLIB_EXT)

ibudf:	$(IBUDF_SO)

$(IBUDF_SO):	$(IBUDF_Objects)
	$(call LINK_UDF,ib_udf) -o $@ $^ $(LINK_UDF_LIBS)

fbudf:	$(FBUDF_SO)

$(FBUDF_SO):	$(FBUDF_Objects) $(COMMON_LIB)
	$(call LINK_UDF,fbudf) -o $@ $^ $(LINK_UDF_LIBS) $(FIREBIRD_LIBRARY_LINK)

ibutil: $(LIBIBUTIL_SO)

$(LIBIBUTIL_SO): $(UTIL_Objects)
	$(LINK_IB_UTIL) -o $@ $^ $(LINK_IB_UTIL_LIBS)


#___________________________________________________________________________
# most of utilities, including network server and UDFs
# qli is not here cause it needs special database (help.fdb), therefore needs gbak
#

.PHONY:	firebird_server fb_lock_print fbguard fbsvcmgr fbtracemgr gbak gfix gsec gsplit gstat isql nbackup

utilities: firebird_server fb_lock_print fbguard fbsvcmgr fbtracemgr gbak gfix gsec gsplit gstat isql nbackup udfsupport

firebird_server:	$(FB_DAEMON)

$(FB_DAEMON):	$(Remote_Server_Objects) $(COMMON_LIB)
	$(EXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS)

fb_lock_print:	$(LOCKPRINT)

$(LOCKPRINT):	$(LOCKPRINT_Objects) $(COMMON_LIB)
	$(EXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS)

fbguard:		$(FBGUARD)

$(FBGUARD):		$(FBGUARD_Objects) $(COMMON_LIB)
	$(EXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS)

fbsvcmgr:		$(FBSVCMGR)

$(FBSVCMGR):	$(FBSVCMGR_Objects) $(COMMON_LIB)
	$(EXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS)

fbtracemgr:		$(FBTRACEMGR)

$(FBTRACEMGR):	$(FBTRACEMGR_Objects) $(COMMON_LIB)
	$(EXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS)

gbak:			$(GBAK)

$(GBAK):		$(GBAK_Objects) $(COMMON_LIB)
	$(EXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS)

gsplit:			$(GSPLIT)

$(GSPLIT):		$(GSPLIT_Objects) $(COMMON_LIB)
	$(EXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS)

gfix:			$(GFIX)

$(GFIX):		$(GFIX_Objects) $(COMMON_LIB)
	$(EXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS)

gsec:			$(GSEC)

$(GSEC):		$(GSEC_Objects) $(COMMON_LIB)
	$(EXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS)

gstat:			$(GSTAT)

$(GSTAT):		$(GSTAT_Objects) $(COMMON_LIB)
	$(EXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS)

isql:			$(ISQL)

$(ISQL):		$(ISQL_Objects) $(COMMON_LIB)
	$(EXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) \
	    $(LIBEDITLINE) $(LINK_LIBS) $(ICU_LIBS)

nbackup:		$(NBACKUP)

$(NBACKUP):		$(NBACKUP_Objects) $(COMMON_LIB)
	$(EXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS)


#___________________________________________________________________________
# plugins - some of them are required to build examples, use separate entry for them
#

.PHONY:	udr legacy_user_management legacy_auth_server trace auth_debug
UDR_PLUGIN = $(call makePluginName,udr_engine)
LEGACY_USER_MANAGER = $(call makePluginName,Legacy_UserManager)
LEGACY_AUTH_SERVER = $(call makePluginName,Legacy_Auth)
SRP_USER_MANAGER = $(call makePluginName,Srp)
FBTRACE = $(call makePluginName,fbtrace)
AUTH_DEBUGGER = $(call makePluginName,Auth_Debug)

BUILD_DEBUG:=
ifeq ($(TARGET),Debug)
	BUILD_DEBUG:=auth_debug
endif

plugins: udr legacy_user_management legacy_auth_server srp_user_management trace $(BUILD_DEBUG)

udr:	$(UDR_PLUGIN) $(PLUGINS)/udr_engine.conf

$(PLUGINS)/udr_engine.conf: $(ROOT)/src/plugins/udr_engine/udr_engine.conf
	cp $^ $@

$(UDR_PLUGIN):	$(UDRENG_Objects) $(COMMON_LIB)
	$(LINK_UDRENG) $(call LIB_LINK_SONAME,$(notdir $@).0) -o $@ $^ $(LINK_UDRENG_LIBS) $(FIREBIRD_LIBRARY_LINK)

legacy_user_management:	$(LEGACY_USER_MANAGER)

$(LEGACY_USER_MANAGER):	$(LEGACY_USERS_MANAGE_Objects) $(COMMON_LIB)
	$(LINK_PLUGIN) $(call LIB_LINK_SONAME,$(notdir $@).0) -o $@ $^ $(LINK_PLUG_LIBS) $(FIREBIRD_LIBRARY_LINK)

legacy_auth_server:	$(LEGACY_AUTH_SERVER)

$(LEGACY_AUTH_SERVER):	$(LEGACY_AUTH_SERVER_Objects) $(COMMON_LIB)
	$(LINK_PLUGIN) $(call LIB_LINK_SONAME,$(notdir $@).0) -o $@ $^ $(LINK_PLUG_LIBS) $(FIREBIRD_LIBRARY_LINK)

trace:	$(FBTRACE)

$(FBTRACE):	$(FBTRACE_UTIL_Objects) $(COMMON_LIB)
	$(LINK_TRACE) -o $@ $^ $(FIREBIRD_LIBRARY_LINK) $(LINK_TRACE_LIBS)

auth_debug:	$(AUTH_DEBUGGER)

$(AUTH_DEBUGGER):	$(AUTH_DEBUGGER_Objects) $(COMMON_LIB)
	$(LINK_PLUGIN) $(call LIB_LINK_SONAME,$(notdir $@).0) -o $@ $^ $(LINK_PLUG_LIBS) $(FIREBIRD_LIBRARY_LINK)

srp_user_management: $(SRP_USER_MANAGER)

$(SRP_USER_MANAGER):	$(SRP_USERS_MANAGE_Objects) $(COMMON_LIB)
	$(LINK_PLUGIN) $(call LIB_LINK_SONAME,$(notdir $@).0) -o $@ $^ $(LINK_PLUG_LIBS) $(FIREBIRD_LIBRARY_LINK)

#___________________________________________________________________________
# codes - developers change them sometimes
#

.PHONY: gen_codes
CODES = $(BIN)/codes$(EXEC_EXT)
IDS = $(SRC_ROOT)/include/gen/ids.h

codes:	gen_codes

ids:	$(IDS)

gen_codes:	$(CODES) msg.timestamp
	$(CODES) $(SRC_ROOT)/include/gen $(LNG_ROOT)

$(CODES):	$(CODES_Objects) $(COMMON_LIB)
	$(EXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS)

$(IDS):		$(SRC_ROOT)/misc/ids.m $(SRC_ROOT)/jrd/relations.h
	m4 $< > $@


#___________________________________________________________________________
# all the rest we need to build
#

.PHONY:	message_file gbak_files

FDB_FILES := $(HELP_FDB) $(ROOT)/gen/msg.fdb $(SECURITY_FDB) $(FIREBIRD)/examples/empbuild/employee.fdb
GBAK_FILES := $(FDB_FILES:.fdb=.gbak) $(FIREBIRD)/msg.gbak
GBAK_FILES := $(subst Native,$(TARGET),$(GBAK_FILES))

rest:	message_file

cross_rest:	qli gbak_files
	$(MAKE) $(BUILD_FILE)

examples: include_generic
	$(MAKE) -f Makefile.examples -C $(GEN_ROOT)/examples/
	$(MAKE) -f Makefile.plugins_examples

message_file:	$(FIREBIRD_MSG)

$(FIREBIRD_MSG):	$(BUILD_FILE) msg.timestamp
	$(BUILD_FILE) -d msg.fdb -f $@
	$(CHMOD_6) $@

$(BUILD_FILE):	$(BUILD_Objects) $(COMMON_LIB)
	$(EXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS)

gbak_files: $(GBAK_FILES)

$(GEN_ROOT)/$(TARGET)/firebird/msg.gbak:	$(ROOT)/gen/msg.gbak
	cp $^ $@

#---------------------------------------------------------------------------

# This target builds the include files for distribution with the release
# Some of the files differ from the ones used internally to compile the
# software - mainly they are just flattened out to make the view simpler
# from an external point of view.

INCLUDE_DEST=   $(FB_BUILD)/include

NEW_INCLUDES_SRC = $(shell find $(SRC_ROOT)/include/firebird -type f)
NEW_INCLUDES_DEST = $(patsubst $(SRC_ROOT)/include/firebird/%, $(INCLUDE_DEST)/firebird/%, $(NEW_INCLUDES_SRC))

include_generic: $(INCLUDE_DEST)/ib_util.h  \
                 $(INCLUDE_DEST)/ibase.h	\
                 $(NEW_INCLUDES_DEST)

# ib_util.h actually is a marker for a number of headers

# All these files are #included in ibase.h. Here we cat them all together
# and remove the embedded #includes to make it simpler for external usage.

IBASE_ExtraFiles = include/types_pub.h include/consts_pub.h dsql/sqlda_pub.h common/dsc_pub.h jrd/ibase.h jrd/inf_pub.h jrd/blr.h include/gen/iberror.h
SRC_IBASE_ExtraFiles = $(addprefix $(SRC_ROOT)/, $(IBASE_ExtraFiles))
MAKE_HEADER_Src = $(addprefix $(SRC_ROOT)/, misc/makeHeader.cpp)
MAKE_HEADER_Bin = ./makeHeader

$(INCLUDE_DEST)/ibase.h: $(SRC_IBASE_ExtraFiles)
	$(STATICEXE_LINK) $(EXE_LINK_OPTIONS) $(LINK_OPTS) $(CPPFLAGS) -o $(MAKE_HEADER_Bin) $(MAKE_HEADER_Src)
	$(CP) $^ .
	$(MAKE_HEADER_Bin) <ibase.h >$@
	$(RM) -f ibase.h

# Copy all the other headers to the distribution directory. We use
# ib_util.h as the marker for all the files.

OtherDistribHeaders = extlib/ib_util.h \
                      yvalve/perf.h  \
                      include/gen/iberror.h

SRC_OtherDistribHeaders = $(addprefix $(SRC_ROOT)/, $(OtherDistribHeaders))

$(INCLUDE_DEST)/ib_util.h : $(SRC_OtherDistribHeaders)
	mkdir -p $(INCLUDE_DEST)
	$(CP) $^ $(INCLUDE_DEST)/

$(INCLUDE_DEST)/firebird/%: $(SRC_ROOT)/include/firebird/%
	mkdir -p $(@D)
	$(CP) $< $@


#___________________________________________________________________________
# track dependencies
#

include $(ROOT)/gen/make.shared.targets

Dependencies = $(AllObjects:.o=.d) 
-include $(Dependencies)


#___________________________________________________________________________
# create binary packages
#

.PHONY: install silent_install install-embedded package packages dist
 
install install-embedded silent_install package packages dist:
	$(MAKE) -f Makefile.install $@


#___________________________________________________________________________
# various cleaning
#
.PHONY: clean clean_objects clean_dependancies clean_extern_objects clean_build \
		clean_gpre_gen clean_icu clean_dbs clean_examples clean_makefiles \
		clean_editline clean_all


clean: clean_objects clean_dependancies clean_extern_objects clean_build \
		clean_yacc_gen clean_gpre_gen clean_dbs clean_examples clean_tommath

ifeq ($(EDITLINE_FLG),Y)
ifeq ($(STD_EDITLINE),false)
clean: clean_editline
endif
endif

clean_config clean_all: clean clean_makefiles
	$(RM) $(ROOT)/configure
	$(RM) $(ROOT)/aclocal.m4
	$(RM) $(ROOT)/config.log
	$(RM) $(ROOT)/config.status
	$(RM) $(ROOT)/libtool
	$(RM_R) $(ROOT)/autom4te.cache
	-$(MAKE) -C $(ROOT)/extern/editline distclean
#	-$(MAKE) -C $(ROOT)/extern/icu/source distclean
	-$(MAKE) -C $(ROOT)/extern/btyacc distclean

clean_dbs:
	$(RM) *.fdb *.FDB msg.timestamp
	$(RM) yachts.lnk


# The examples are a bit different, since the makefile is included in the directory
# and not in the gen directory, deleting it means, make clean; make doesnt work correctly
# so the code below deletes all the other stuff but not the Makefile.examples MOD Nov-2007

clean_examples:
	$(RM) `find $(GEN_ROOT)/examples/ -type f ! -name 'Make*'`

clean_editline:
	-$(MAKE) -C $(ROOT)/extern/editline clean

#clean_icu:
#	-$(MAKE) -C $(ROOT)/extern/icu/source clean

clean_tommath:
	-$(MAKE) -C $(ROOT)/extern/libtommath clean

clean_objects:
	$(RM) `find $(TMP_ROOT)/ -type f -name '*.o' -print`
	$(RM) `find $(TMP_ROOT)/ -type f -name '*.a' -print`
	$(RM) `find $(TMP_ROOT)/ -type f -name '*.cpp' -print`
	$(RM) `find $(TMP_ROOT)/ -type f -name '*.pas' -print`

clean_extern_objects:
	$(RM) `find $(ROOT)/extern/ -type f -name '*.lo' -print`
	$(RM) `find $(ROOT)/extern/ -type f -name '*.o' -print`

# Clear out dependancies files created by the gcc compiler
# since when .o and other files are deleted the dependant
# targets need to be recalculated

clean_dependancies:
	$(RM) -f `find $(TMP_ROOT)/ -type f -name '*.d' -print`

# delete only all of the files of type regular file in $FIREBIRD
# leave the directories to make dependacies work still

clean_build:
	$(RM) `find $(GEN_ROOT)/*/firebird \( -type f -o -type l \) -print`

clean_makefiles:
	$(RM) $(GEN_ROOT)/Make*
	$(RM) $(GEN_ROOT)/make*
	$(RM) `find $(GEN_ROOT)/install \( -type f -o -type l \) -print`
	-$(RM) $(GEN_ROOT)/examples/Make*
	$(RM) $(ROOT)/Makefile
	$(RM) $(SRC_ROOT)/include/gen/autoconfig.h

clean_gpre_gen:
	-$(RM) -f `find $(TMP_ROOT)/ -type f -name '*.cpp' -print`

clean_yacc_gen:
	$(RM) $(ROOT)/src/dsql/parse.cpp $(ROOT)/src/dsql/dsql.tab.h

#___________________________________________________________________________
# Extra platform specific targets