-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile.in
1251 lines (1129 loc) · 41.7 KB
/
Makefile.in
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
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# ----------------------------------------------------------------------------
#
# Contents: Makefile for bar
# Systems: all
#
# ----------------------------------------------------------------------------
#----------------------------- external variables ----------------------------
#
# DESTDIR=<path> install destination directory
# DIST=1 install for creating distribution packages
#---------------------------------- settings ---------------------------------
ENABLE_DEBUG = @ENABLE_DEBUG@
ENABLE_GUI = @ENABLE_GUI@
PLATFORM = @PLATFORM@
#------------------------------------ paths ----------------------------------
ROOT_DIR = $(abspath @srcdir@)
SOURCE_DIR = $(abspath @srcdir@)
BUILD_DIR = $(CURDIR)
ETC_DIR = /etc
ifeq ($(DESTDIR),)
INSTALL_DIR = $(if $(prefix),$(prefix),@INSTALL_DIR@)
INSTALL_BIN_DIR = $(if $(bindir),$(bindir),@INSTALL_BIN_DIR@)
INSTALL_LIB_DIR = $(if $(libdir),$(libdir),/usr/lib)
INSTALL_LOCALE_DIR = $(if $(datadir),$(datadir)/locale,@LOCALE_DIR@)
INSTALL_ETC_DIR = $(if $(sysconfdir),$(sysconfdir),$(ETC_DIR))
#INSTALL_INITD_DIR = $(INSTALL_ETC_DIR)/$(if $(wildcard $(ETC_DIR)/rc.d),rc.d/init.d,init.d)
INSTALL_INITD_DIR = $(INSTALL_ETC_DIR)/init.d
INSTALL_LOGROTATED_DIR = $(INSTALL_ETC_DIR)/logrotate.d
INSTALL_CONFIG_DIR = $(if $(sysconfdir),$(sysconfdir)/bar,@CONFIG_DIR@)
INSTALL_MAN_DIR = $(if $(mandir),$(mandir),@MAN_DIR@)
else
INSTALL_DIR = @INSTALL_DIR@
INSTALL_BIN_DIR = @INSTALL_BIN_DIR@
INSTALL_LIB_DIR = /usr/lib
INSTALL_LOCALE_DIR = @LOCALE_DIR@
INSTALL_ETC_DIR = $(ETC_DIR)
#INSTALL_INITD_DIR = $(INSTALL_ETC_DIR)/$(if $(wildcard $(ETC_DIR)/rc.d),rc.d/init.d,init.d)
INSTALL_INITD_DIR = $(INSTALL_ETC_DIR)/init.d
INSTALL_LOGROTATED_DIR = $(INSTALL_ETC_DIR)/logrotate.d
INSTALL_CONFIG_DIR = @CONFIG_DIR@
INSTALL_MAN_DIR = @MAN_DIR@
endif
INSTALL_TLS_DIR = @TLS_DIR@
#--------------------------------- tool chain --------------------------------
CERTTOOL = @CERTTOOL@
OPENSSL = @OPENSSL@
KEYTOOL = @KEYTOOL@
DOCKER_RUN_FLAGS = run -i -t
DOCKER_PROMPT = '\[\e[0;38;5;39m\]\u\[\e[0;38;5;39m\]@\[\e[0;38;5;39m\]\H\[\e[0;38;5;39m\]:\[\e[0;38;5;39m\]\w \[\e[0;38;5;39m\]$$ \[\e[0m\]'
TXT2MAN = @TXT2MAN@
UNOCONV = @UNOCONV@
LAUNCH4JC = @LAUNCH4JC@
#---------------------------------- commands----------------------------------
CAT = cat
CD = cd
CHMOD = chmod
CP = cp
CUT = cut
DIFF = diff
DOCKER = @DOCKER@
ECHO = echo
ECHO_NO_LF = echo -n
GIT = @GIT@
GREP = grep
INSTALL = @INSTALL@
LN = ln
MD5SUM = @MD5SUM@
MKDIR = mkdir
MV = mv
NROFF = nroff
PERL = @PERL@
PRINTF = printf
RMDIR = rmdir
RMF = rm -f
RMRF = rm -rf
SED = sed
TAR = tar
TAIL = tail
TR = tr
WINE = @WINE@
WINE_C_DRIVE = @WINE_C_DRIVE@
ZIP = zip
#------------------------ specific variables/settings ------------------------
# special constants
EMPTY :=
SPACE := $(EMPTY) $(EMPTY)
COMMA := ,
# shell in Makefile must be bash with pipe-fail handling
SHELL = bash -o pipefail
VERSION_MAJOR := $(shell $(CAT) $(SOURCE_DIR)/version|$(GREP) MAJOR|$(SED) 's/MAJOR=//g')
VERSION_MINOR := $(shell $(CAT) $(SOURCE_DIR)/version|$(GREP) MINOR|$(SED) 's/MINOR=//g')
VERSION_PATCH := $(shell $(CAT) $(SOURCE_DIR)/version|$(GREP) PATCH|$(SED) 's/PATCH=//g')
VERSION := $(VERSION_MAJOR)$(if $(VERSION_MINOR),$(if $(VERSION_MAJOR),.)$(VERSION_MINOR))$(VERSION_PATCH)
PACKAGE_NAME = backup-archiver
PACKAGE_NAME_GUI = backup-archiver-gui
DISTRIBUTION_NAME = $(PACKAGE_NAME)-$(VERSION)
DISTRIBUTION_NAME_ORIG = $(PACKAGE_NAME)_$(VERSION).orig
DISTRIBUTION_NAME_GUI = $(PACKAGE_NAME_GUI)-$(VERSION)
TEST_PACKAGES_CENTOS := 8
TEST_PACKAGES_FEDORA := 37 38 39 40
TEST_PACKAGES_OPENSUSE_LEAP := 15.1 15.2 15.3 15.4 15.5
TEST_PACKAGES_DEBIAN := 10 11 12
TEST_PACKAGES_UBUNTU := 20.04 22.04 23.04 23.10
#-------------------------------- functions ----------------------------------
# print info line
# $(call functionPrintInfo,text)
functionPrintInfo = \
$(if $(QUIET), \
$(ECHO_NO_LF) "$1...",\
$(PRINTF) -vl "%$${COLUMNS:-`tput cols 2>&-||$(ECHO) 80`}s\n" && $(PRINTF) -vl -- "--- $1 $${l// /-}\n" && $(ECHO) $${l:0:`tput cols 2>&-||$(ECHO) 80`}\
)
# print result
# $(call functionPrintResult,text)
functionPrintResult = \
$(if $(QUIET), \
$(ECHO) "$1",\
$(PRINTF) -vl "%$${COLUMNS:-`tput cols 2>&-||$(ECHO) 80`}s\n" && $(PRINTF) -vl -- "--- $1 $${l// /-}\n" && $(ECHO) $${l:0:`tput cols 2>&-||$(ECHO) 80`}\
)
#---------------------------------- rules ------------------------------------
#--------------------------------- objects -----------------------------------
TARGETS = bar/bar@EXEEXT@ \
bar/bar-debug@EXEEXT@ \
bar/bar-gcov@EXEEXT@ \
bar/bar-gprof@EXEEXT@ \
bar/bar-valgrind@EXEEXT@ \
bar/destroyer@EXEEXT@ \
bar/bar-keygen@SHELLEXT@ \
$(if $(findstring $(ENABLE_GUI),yes),\
$(if $(findstring $(PLATFORM),LINUX),\
barcontrol/barcontrol \
) \
$(if $(findstring $(PLATFORM),WINDOWS),\
barcontrol/barcontrol.cmd \
$(if $(LAUNCH4JC),barcontrol/barcontrol@EXEEXT@) \
) \
) \
OTHER_SOURCES = $(SOURCE_DIR)/errors.pl \
$(SOURCE_DIR)/errors.def \
KEY_FILES = bar-key.pem \
bar-ca.pem \
bar-server-key.pem \
bar-server-cert.pem \
SCRIPTS = $(SOURCE_DIR)/scripts/barserver-SuSE \
$(SOURCE_DIR)/scripts/barserver-Fedora \
$(SOURCE_DIR)/scripts/barserver-RedHat \
$(SOURCE_DIR)/scripts/barserver-Mandrake \
$(SOURCE_DIR)/scripts/barserver-debian \
$(SOURCE_DIR)/scripts/barserver-CentOS \
$(SOURCE_DIR)/scripts/barserver.service \
$(SOURCE_DIR)/scripts/logrotate.conf \
#------------------------------ dependencies ---------------------------------
.PHONY: all clean distclean
all: \
$(TARGETS) \
clean: \
clean_keys \
clean_doc \
clean_rpm \
clean_deb \
clean_win32
-$(MAKE) -C bar clean
ifeq ($(ENABLE_GUI),yes)
-$(MAKE) -C barcontrol clean
endif
$(RMRF) $(DISTRIBUTION_NAME)
$(RMF) $(DISTRIBUTION_NAME).tar.bz2 $(DISTRIBUTION_NAME).orig.tar.gz
$(RMRF) tmp
distclean: clean
-$(MAKE) -C bar distclean
ifeq ($(ENABLE_GUI),yes)
-$(MAKE) -C barcontrol distclean
endif
$(ROOT_DIR)/download-third-party-packages.sh --clean
$(RMRF) extern
$(RMF) Makefile
$(RMF) src/Config.java
$(RMF) config.status
$(RMF) config.log
$(RMRF) build
# help
.PHONY: help
help:
@$(ECHO) "Help targets:"
@$(ECHO) ""
@$(ECHO) " all "
@$(ECHO) " clean "
@$(ECHO) " distclean"
@$(ECHO) ""
@$(ECHO) " bar"
@$(ECHO) " bar-keygen"
@$(ECHO) " barcontrol"
@$(ECHO) ""
@$(ECHO) " keys"
@$(ECHO) ""
@$(ECHO) " doc"
@$(ECHO) " clean_doc"
@$(ECHO) " man"
@$(ECHO) " showman"
@$(ECHO) " pdf"
@$(ECHO) ""
@$(ECHO) " install"
@$(ECHO) ""
@$(ECHO) " tests"
@$(ECHO) " tests1[-debug|-valgrind], test_basic"
@$(ECHO) " tests2[-debug|-valgrind], test_compress"
@$(ECHO) " tests3[-debug|-valgrind], test_crypt"
@$(ECHO) " tests4[-debug|-valgrind], test_asymmetric_crypt"
@$(ECHO) " tests5[-debug|-valgrind], test_signatures"
@$(ECHO) " tests6[-debug|-valgrind], test_split"
@$(ECHO) " tests7[-debug|-valgrind], test_convert"
@$(ECHO) " tests8[-debug|-valgrind], test_image"
@$(ECHO) " tests9[-debug|-valgrind], test_storage"
@$(ECHO) " tests10[-debug|-valgrind], test_huge"
@$(ECHO) " tests11[-debug|-valgrind], test_index"
@$(ECHO) " tests12[-debug|-valgrind], test_server"
@$(ECHO) " tests13[-debug|-valgrind], test_master_slave"
@$(ECHO) " tests_combined"
@$(ECHO) " tests_arguments"
@$(ECHO) " tests_config"
@$(ECHO) " tests_miscellaneous"
@$(ECHO) " tests_smoke"
@$(ECHO) ""
@$(ECHO) " memcheck"
@$(ECHO) " memcheck_extended"
@$(ECHO) ""
@$(ECHO) " dist"
@$(ECHO) " clean_dist"
@$(ECHO) " debian_dist"
@$(ECHO) " clean_debian_dist"
@$(ECHO) ""
@$(ECHO) " rpm[d]"
@$(ECHO) " rpm32[d]"
@$(ECHO) " rpm64[d]"
@$(ECHO) " clean_rpm"
@$(ECHO) ""
@$(ECHO) " deb[d]"
@$(ECHO) " deb32[d]"
@$(ECHO) " deb64[d]"
@$(ECHO) " clean_deb"
@$(ECHO) ""
@$(ECHO) " win32"
@$(ECHO) " clean_win32"
@$(ECHO) ""
@$(ECHO) " docker_update"
@$(ECHO) " docker_purge"
@$(ECHO) ""
@$(ECHO) " docker_run"
@$(ECHO) " docker_run_win32"
@$(ECHO) " docker_run_win32-x86_64"
@$(ECHO) ""
@$(ECHO) " docker_rpm"
@$(ECHO) " docker_den"
@$(ECHO) " docker_win32"
@$(ECHO) ""
@$(ECHO) " install_test[d]"
@$(ECHO) ""
@$(ECHO) " install_test_rpm[d]"
@$(ECHO) " install_test_rpm_centos8-x86_64[d]"
@$(ECHO) " install_test_rpm_fedora[$(subst $(SPACE),\|,$(TEST_PACKAGES_FEDORA))]-x86_64[d]"
@$(ECHO) " install_test_rpm_opensuse-tumbleweed-x86_64[d]"
@$(ECHO) " install_test_rpm_opensuse-leap[$(subst $(SPACE),\|,$(TEST_PACKAGES_OPENSUSE_LEAP))]-x86_64[d]"
@$(ECHO) ""
@$(ECHO) " install_test_deb[d]"
@$(ECHO) " install_test_deb_debian[$(subst $(SPACE),\|,$(TEST_PACKAGES_DEBIAN))]-x86_64[d]"
@$(ECHO) " install_test_deb_ubuntu[$(subst $(SPACE),\|,$(TEST_PACKAGES_UBUNTU))]-x86_64[d]"
@$(ECHO) ""
@$(ECHO) " install_test_win32[d]"
@$(ECHO) ""
@$(ECHO) " gui"
@$(ECHO) " clean_gui"
# create dependencies
.PHONY: depend
depend:
$(MAKE) -j1 -C bar depend
$(MAKE) -j1 -C barcontrol depend
# ----------------------------------------------------------------------------
# create bar
bar/%:
$(MAKE) -C bar $*
.PHONY: bar bar-debug bar-gcov bar-gprof bar-valgrind
bar:
$(MAKE) -C bar bar
bar-debug:
$(MAKE) -C bar bar-debug
bar-gcov:
$(MAKE) -C bar bar-gcov
bar-gprof:
$(MAKE) -C bar bar-gprof
bar-valgrind:
$(MAKE) -C bar bar-valgrind
# create bar-keygen
.PHONY: bar-keygen
bar-keygen:
$(MAKE) -C bar bar-keygen
# create barcontrol
.PHONY: barcontrol
barcontrol/barcontrol barcontrol:
ifeq ($(ENABLE_GUI),yes)
$(MAKE) -C barcontrol barcontrol
else
@$(ECHO) "ERROR: GUI components not configured - cannot be build."
endif
barcontrol/barcontrol.cmd:
ifeq ($(ENABLE_GUI),yes)
$(MAKE) -C barcontrol barcontrol.cmd
else
@$(ECHO) "ERROR: GUI components not configured - cannot be build."
endif
ifeq ($(PLATFORM),WINDOWS)
ifneq ($(LAUNCH4JC),)
barcontrol/barcontrol@EXEEXT@:
ifeq ($(ENABLE_GUI),yes)
$(MAKE) -C barcontrol barcontrol@EXEEXT@
else
@$(ECHO) "ERROR: GUI components not configured - cannot be build."
endif
endif
endif
barcontrol/barcontrol%.jar:
ifeq ($(ENABLE_GUI),yes)
$(MAKE) -C barcontrol barcontrol$*.jar
else
@$(ECHO) "ERROR: GUI components not configured - cannot be build."
endif
# ----------------------------------------------------------------------------
# create SSL keys and certificates
.PHONY: keys clean_keys
keys: \
$(KEY_FILES)
clean_keys:
$(RMF) $(KEY_FILES)
$(KEY_FILES):
$(MAKE) -C bar bar-keygen@SHELLEXT@
($(CD) bar; \
./bar-keygen@SHELLEXT@ \
--tls-directory=.. \
--private-directory=.. \
--certs-directory=.. \
$(if $(CERTTOOL),--certtool) \
$(if $(OPENSSL),--openssl) \
--force \
)
# ----------------------------------------------------------------------------
# create documentation
.PHONY: doc clean_doc showman pdf
doc:
@$(MAKE) -C doc
clean_doc:
@$(MAKE) -C doc clean
# create man-page
.PHONY: man clean_man showman
man:
@$(MAKE) -C doc man
clean_man:
@$(MAKE) -C doc clean_man
showman:
@$(MAKE) -C doc showman
# create manual
pdf doc/backup-archiver.pdf:
@$(MAKE) -C doc backup-archiver.pdf
# ----------------------------------------------------------------------------
# install/uninstall
# Note: prefix DESTDIR is used for temporary installations
.PHONY: install install_bar install_barcontrol install_scripts install_man install_keys uninstall install_dist
install: \
install_bar \
install_barcontrol \
install_scripts \
install_man \
$(if $(DIST),,install_keys)
install_bar:
$(MAKE) -C bar install \
prefix=$(prefix) \
bindir=$(bindir) \
libdir=$(libdir) \
datadir=$(datadir) \
sysconfdir=$(sysconfdir) \
mandir=$(mandir) \
DESTDIR=$(DESTDIR)
install_barcontrol:
$(MAKE) -C barcontrol install \
prefix=$(prefix) \
bindir=$(bindir) \
libdir=$(libdir) \
datadir=$(datadir) \
sysconfdir=$(sysconfdir) \
mandir=$(mandir) \
DESTDIR=$(DESTDIR)
# install script files
install_scripts: \
$(SCRIPTS)
$(INSTALL) -d "$(DESTDIR)$(INSTALL_LOGROTATED_DIR)"; \
$(INSTALL) -m 644 scripts/logrotate.conf "$(DESTDIR)$(INSTALL_LOGROTATED_DIR)/bar"; \
$(INSTALL) -d "$(DESTDIR)/var/lib/bar/install"; \
$(INSTALL) -t "$(DESTDIR)/var/lib/bar/install" \
scripts/barserver-SuSE \
scripts/barserver-Fedora \
scripts/barserver-RedHat \
scripts/barserver-CentOS \
scripts/barserver-Mandrake \
scripts/barserver-debian \
scripts/barserver.service
# install man-page
install_man:
$(MAKE) -C doc install_man
# install keys
# Note: prefix is used for temporary installations
install_keys: \
$(KEY_FILES)
$(INSTALL) -d "$(DESTDIR)$(INSTALL_TLS_DIR)"
$(INSTALL) -d "$(DESTDIR)$(INSTALL_TLS_DIR)/certs"
$(INSTALL) -m 644 bar-ca.pem "$(DESTDIR)$(INSTALL_TLS_DIR)/certs"
$(INSTALL) -m 644 bar-server-cert.pem "$(DESTDIR)$(INSTALL_TLS_DIR)/certs"
$(INSTALL) -d -m 700 "$(DESTDIR)$(INSTALL_TLS_DIR)/private"
$(INSTALL) -m 600 bar-server-key.pem "$(DESTDIR)$(INSTALL_TLS_DIR)/private"
$(INSTALL) -m 600 bar-key.pem "$(DESTDIR)$(INSTALL_TLS_DIR)/private"
# uninstall all
uninstall:
@read -n 1 -p "Really uninstall? [y/N] " s; \
if test "$s" = "y" -o "$s" = "Y"; then \
$(RMF) "$(DESTDIR)$(INSTALL_BIN_DIR)/bar@EXEEXT@"; \
$(RMF) "$(DESTDIR)$(INSTALL_BIN_DIR)/bar-keygen@SHELLEXT@"; \
$(if $(findstring $(ENABLE_GUI),yes),$(RMF) "$(DESTDIR)$(INSTALL_BIN_DIR)/barcontrol" \
"$(DESTDIR)$(INSTALL_BIN_DIR)/barcontrol.jar" \
"$(DESTDIR)$(INSTALL_BIN_DIR)/barcontrol@EXEEXT@"; \
) \
$(RMF) "$(DESTDIR)$(INSTALL_CONFIG_DIR)/bar.cfg"; \
$(RMF) "$(DESTDIR)$(INSTALL_TLS_DIR)/certs/bar-ca.pem"; \
$(RMF) "$(DESTDIR)$(INSTALL_TLS_DIR)/certs/bar-server-cert.pem"; \
$(RMF) "$(DESTDIR)$(INSTALL_TLS_DIR)/private/bar-server-key.pem"; \
$(if $(findstring $(ENABLE_GUI),yes),$(RMF) "$(DESTDIR)$(INSTALL_CONFIG_DIR)"; \
) \
$(RMF) "$(DESTDIR)$(INSTALL_INITD_DIR)/barserver"; \
$(RMF) "$(DESTDIR)$(INSTALL_LOGROTATED_DIR)/bar"; \
$(RMF) "$(DESTDIR)$(INSTALL_MAN_DIR)/man7"; \
fi
# ----------------------------------------------------------------------------
# tests
# run server
.PHONY: barserver barserver_ssl
barserver:
@$(MAKE) -C bar barserver
barserver_ssl:
@$(MAKE) -C bar barserver_ssl
# do tests
.PHONY: tests test test% test%-debug test%-gcov test%-gprof test%-valgrind
tests test:
@$(MAKE) -C bar $@
test%:
@$(MAKE) -C bar $@
test%-debug:
@$(MAKE) -C bar $@
test%-gcov:
@$(MAKE) -C bar $@
test%-gprof:
@$(MAKE) -C bar $@
test%-valgrind:
@$(MAKE) -C bar $@
# memory checks
.PHONY: memcheck memcheck1 memcheck_extended
memcheck:
@$(MAKE) -C bar memcheck
memcheck_extended:
@$(MAKE) -C bar memcheck_extended
# ----------------------------------------------------------------------------
# distribution
.PHONY: distribution dist clean_distribution clean_dist
distribution dist:
$(RMF) $(DISTRIBUTION_NAME).tar.bz2
$(MAKE) $(DISTRIBUTION_NAME).tar.bz2
clean_distribution clean_dist:
$(RMF) $(DISTRIBUTION_NAME).tar.bz2
# create distribution
$(DISTRIBUTION_NAME).tar.bz2: \
$(SOURCE_DIR)/configure \
$(SOURCE_DIR)/configure.ac \
$(SOURCE_DIR)/Makefile.in \
$(SOURCE_DIR)/version \
$(SOURCE_DIR)/ToDo \
$(SOURCE_DIR)/ChangeLog \
\
$(SOURCE_DIR)/download-third-party-packages.sh \
$(OTHER_SOURCES) \
\
$(SOURCE_DIR)/bin/config.guess \
$(SOURCE_DIR)/bin/config.sub \
$(SOURCE_DIR)/bin/install-sh \
$(SOURCE_DIR)/bin/config.guess \
\
$(SOURCE_DIR)/bar/Makefile.in \
$(SOURCE_DIR)/bar/tests/Makefile.in \
$(SOURCE_DIR)/barcontrol/Makefile.in \
\
$(SOURCE_DIR)/ssl/certtool/*.tmpl \
$(SOURCE_DIR)/ssl/openssl/*.tmpl \
\
$(SCRIPTS) \
\
$(SOURCE_DIR)/misc/*.patch \
\
$(SOURCE_DIR)/packages/*
$(INSTALL) -d tmp/$(DISTRIBUTION_NAME)
$(INSTALL) -m 775 \
-t tmp/$(DISTRIBUTION_NAME) \
$(SOURCE_DIR)/configure \
$(SOURCE_DIR)/download-third-party-packages.sh \
$(OTHER_SOURCES)
$(INSTALL) -m 664 \
-t tmp/$(DISTRIBUTION_NAME) \
$(SOURCE_DIR)/configure.ac \
$(SOURCE_DIR)/Makefile.in \
$(SOURCE_DIR)/ToDo \
$(SOURCE_DIR)/ChangeLog
( \
$(GREP) MAJOR $(SOURCE_DIR)/version; \
$(GREP) MINOR $(SOURCE_DIR)/version; \
$(GREP) PATCH $(SOURCE_DIR)/version; \
$(ECHO) "RELEASE=$(shell $(GIT) rev-parse HEAD)"; \
) > tmp/$(DISTRIBUTION_NAME)/version
$(INSTALL) -d tmp/$(DISTRIBUTION_NAME)/bin
$(INSTALL) -m 664 \
-t tmp/$(DISTRIBUTION_NAME)/bin \
$(SOURCE_DIR)/bin/config.guess \
$(SOURCE_DIR)/bin/config.sub \
$(SOURCE_DIR)/bin/install-sh
$(MAKE) -C bar dist DIRECTORY="../tmp/$(DISTRIBUTION_NAME)"
$(MAKE) -C barcontrol dist DIRECTORY="../tmp/$(DISTRIBUTION_NAME)"
$(MAKE) -C doc dist DIRECTORY="../tmp/$(DISTRIBUTION_NAME)"
#
$(INSTALL) -d tmp/$(DISTRIBUTION_NAME)/ssl
$(INSTALL) -d tmp/$(DISTRIBUTION_NAME)/ssl/certtool
$(INSTALL) -m 664 \
-t tmp/$(DISTRIBUTION_NAME)/ssl/certtool \
$(SOURCE_DIR)/ssl/certtool/*.tmpl
$(INSTALL) -d tmp/$(DISTRIBUTION_NAME)/ssl/openssl
$(INSTALL) -m 664 \
-t tmp/$(DISTRIBUTION_NAME)/ssl/openssl \
$(SOURCE_DIR)/ssl/openssl/*.tmpl
#
$(INSTALL) -d tmp/$(DISTRIBUTION_NAME)/scripts
$(INSTALL) -m 664 \
-t tmp/$(DISTRIBUTION_NAME)/scripts \
$(SCRIPTS)
#
$(INSTALL) -d tmp/$(DISTRIBUTION_NAME)/misc
$(INSTALL) -m 664 \
-t tmp/$(DISTRIBUTION_NAME)/misc \
$(SOURCE_DIR)/misc/*.patch
#
$(INSTALL) -d tmp/$(DISTRIBUTION_NAME)/packages
$(INSTALL) -m 664 \
-t tmp/$(DISTRIBUTION_NAME)/packages \
$(SOURCE_DIR)/packages/*.dockerfile \
$(SOURCE_DIR)/packages/*.spec \
$(SOURCE_DIR)/packages/*.iss \
$(SOURCE_DIR)/packages/*.sh
$(INSTALL) -m 775 \
-t tmp/$(DISTRIBUTION_NAME)/packages \
$(SOURCE_DIR)/packages/changelog.pl
$(INSTALL) -d tmp/$(DISTRIBUTION_NAME)/packages/debian
$(INSTALL) -m 664 \
-t tmp/$(DISTRIBUTION_NAME)/packages/debian \
$(SOURCE_DIR)/packages/debian/compat \
$(SOURCE_DIR)/packages/debian/conffiles \
$(SOURCE_DIR)/packages/debian/control \
$(SOURCE_DIR)/packages/debian/copyright \
$(SOURCE_DIR)/packages/debian/postinst \
$(SOURCE_DIR)/packages/debian/postrm \
$(SOURCE_DIR)/packages/debian/preinst \
$(SOURCE_DIR)/packages/debian/prerm \
$(SOURCE_DIR)/packages/debian/rules
$(INSTALL) -d tmp/$(DISTRIBUTION_NAME)/packages/debian/source
$(INSTALL) -m 664 \
-t tmp/$(DISTRIBUTION_NAME)/packages/debian/source \
$(SOURCE_DIR)/packages/debian/source/format
#
($(CD) tmp; $(TAR) cjf ../$@ $(DISTRIBUTION_NAME))
$(RMRF) tmp
#
ifneq ($(MD5SUM),)
$(MD5SUM) $@
endif
# --- Debian distribution
.PHONY: debian_dist clean_debian_dist $(DISTRIBUTION_NAME).orig.tar.gz
debian_dist: \
$(DISTRIBUTION_NAME).orig.tar.gz
clean_debian_dist:
$(RMF) $(DISTRIBUTION_NAME).orig.tar.gz
# create Debian distribution
$(DISTRIBUTION_NAME).orig.tar.gz: \
$(DISTRIBUTION_NAME).tar.bz2 \
download-third-party-packages.sh
$(INSTALL) -d tmp/$(DISTRIBUTION_NAME).orig
($(CD) tmp/$(DISTRIBUTION_NAME).orig; $(TAR) --strip-components=1 -xjf ../../$(DISTRIBUTION_NAME).tar.bz2)
$(INSTALL) -d tmp/$(DISTRIBUTION_NAME).orig/extern
# copy existing packages to avoid download (which may fail because of an instable Internet)
$(INSTALL) \
extern/binutils-*.tar.bz2 \
extern/bzip2-*.tar.gz \
extern/c-ares-*.tar.gz \
extern/curl-*.tar.bz2 \
extern/gmp-*.tar.xz \
extern/gnutls-*.tar.xz \
extern/icu*.tgz \
extern/libiconv-*.tar.gz \
extern/libcdio-*.tar.gz \
extern/libgcrypt-*.tar.bz2 \
extern/libgpg-error-*.tar.bz2 \
extern/libssh2-*.tar.gz \
extern/lz4-*.tar.gz \
extern/lzo-*.tar.gz \
extern/mtx-*.tar.gz \
extern/mxml-*.tar.gz \
extern/nettle-*.tar.gz \
extern/openssl-*.tar.gz \
extern/pcre-*.tar.bz2 \
extern/sqlite-src-*.zip \
extern/pthreads-w32-*.tar.gz \
extern/xdelta*.tar.gz \
extern/xz-*.tar.gz \
extern/zlib-*.tar.gz \
extern/zstd-*.zip \
tmp/$(DISTRIBUTION_NAME).orig/extern
$(INSTALL) \
third-party/breakpad-r1430.tar.bz2 \
tmp/$(DISTRIBUTION_NAME).orig/extern/breakpad.tar.bz2
if test -n "`ls extern/ftplib-*.tar.gz 2>/dev/null`"; then \
$(INSTALL) \
extern/ftplib-*.tar.gz \
tmp/$(DISTRIBUTION_NAME).orig/extern; \
fi
if test -n "`ls extern/launch4j-*.tgz 2>/dev/null`"; then \
$(INSTALL) \
extern/launch4j-*.tgz \
tmp/$(DISTRIBUTION_NAME).orig/extern; \
fi
# download not existing packages
./download-third-party-packages.sh --local-directory extern -d tmp/$(DISTRIBUTION_NAME).orig -n
./download-third-party-packages.sh -d tmp/$(DISTRIBUTION_NAME).orig -n
($(CD) tmp; $(TAR) czf ../$@ $(DISTRIBUTION_NAME).orig)
$(RMRF) tmp/$(DISTRIBUTION_NAME).orig
# ----------------------------------------------------------------------------
# packages
.PHONY: packages
packages: \
rpm \
deb \
gui
.PHONY: docker_update update_docker
docker_update update_docker:
# base images
$(DOCKER) pull centos:7
$(DOCKER) pull debian:10
$(DOCKER) pull ubuntu:22.04
#
$(INSTALL) download-third-party-packages.sh packages
#
(cd packages; $(DOCKER) build -f bar-centos7-x86_64.dockerfile -t bar-centos-x86_64:7 --build-arg uid=$(shell id -u jenkins) --build-arg gid=$(shell id -g jenkins) .)
(cd packages; $(DOCKER) build -f bar-debian10-x86_64.dockerfile -t bar-debian-x86_64:10 --build-arg uid=$(shell id -u jenkins) --build-arg gid=$(shell id -g jenkins) .)
(cd packages; $(DOCKER) build -f bar-ubuntu-mingw32.dockerfile -t bar-mingw32 --build-arg uid=$(shell id -u jenkins) --build-arg gid=$(shell id -g jenkins) .)
#
$(RMF) packages/download-third-party-packages.sh
#
# build image
$(INSTALL) download-third-party-packages.sh ci
$(INSTALL) bar/tests/bar-sudoers ci
#
(cd ci; $(DOCKER) build -f build.dockerfile -t bar --build-arg uid=$(shell id -u jenkins) --build-arg gid=$(shell id -g jenkins) .)
#
# test packages images
$(foreach i,$(TEST_PACKAGES_CENTOS),$(DOCKER) pull centos:$i;)
#
$(foreach i,$(TEST_PACKAGES_FEDORA),$(DOCKER) pull fedora:$i;)
#
$(DOCKER) pull opensuse/tumbleweed
$(foreach i,$(TEST_PACKAGES_OPENSUSE_LEAP),$(DOCKER) pull opensuse/leap:$i;)
#
$(foreach i,$(TEST_PACKAGES_DEBIAN),$(DOCKER) pull debian:$i;)
#
$(foreach i,$(TEST_PACKAGES_UBUNTU),$(DOCKER) pull ubuntu:$i;)
#
$(RMF) ci/bar-sudoers
$(RMF) ci/download-third-party-packages.sh
.PHONY: docker_purge purge_docker
docker_purge purge_docker:
$(DOCKER) rm $$($(DOCKER) ps -a -q)
functionGetCDEmuDevice=$(shell cdemu device-mapping |$(TAIL) -n +3|$(GREP) 0|$(TR) -s ' '|$(CUT) -d ' ' -f 2)
.PHONY: docker_run docker_run_win32 docker_run_win32-x86_64
docker_run:
# Notes: - no image operations in docker, because /dev/loop* and mount only
# work with --privileges=true which may cause dangerous/instable
# behaviour
# - do not enable host network, because of sftp/ssh/apache instances
# in container; just map ssh port
# - need root privileges in container to start services
if test -z "`cdemu device-mapping |$(TAIL) -n +3`"; then \
cdemu add-device; \
cdemu create-blank --writer-id=WRITER-ISO --medium-type=dvd+r 0 /tmp/bar-optical; \
fi
$(DOCKER) $(DOCKER_RUN_FLAGS) \
--rm \
-p 2222:22 \
-e TERM=xterm-256color \
-e COLUMNS="`tput cols`" -e LINES="`tput lines`" \
-e TEST_BASE_DIR=/home/test \
-e TEST_LOGIN_NAME=test \
-e TEST_PASSWORD=test \
-e TEST_PUBLIC_KEY_SSH=/home/test/.ssh/id_rsa.pub \
-e TEST_PRIVATE_KEY_SSH=/home/test/.ssh/id_rsa \
-e TEST_MOUNT_OPERATIONS=no \
-v $(HOME):$(HOME) \
-v $(PWD):/media/home \
--device `cdemu device-mapping |$(TAIL) -n +3|$(GREP) 0|$(TR) -s ' '|$(CUT) -d ' ' -f 2` \
-v `cdemu device-mapping |$(TAIL) -n +3|$(GREP) 0|$(TR) -s ' '|$(CUT) -d ' ' -f 2`:/dev/sr0 \
-w $(PWD) \
--name=bar \
bar \
/bin/bash -c "echo export PS1=\'$(DOCKER_PROMPT)\' >> ~/.bashrc && /bin/bash"
docker_run_win32-x86_64:
( \
$(DOCKER) $(DOCKER_RUN_FLAGS) \
--rm \
--net=host \
-e COLUMNS="`tput cols`" -e LINES="`tput lines`" \
-v $(PWD):/media/home \
-v $(WINE_C_DRIVE):/media/wine \
--name=bar-win32-x86_64 \
bar-mingw32 setarch x86_64 -- /media/home/packages/build_win32.sh \
-s \
$(PACKAGE_NAME) \
$(DISTRIBUTION_NAME).tar.bz2 \
$(VERSION) \
$(shell id -u):$(shell id -g) \
$(WINE) \
$(PACKAGE_NAME)-setup-$(VERSION); \
)
# RPM
.PHONY: rpm rpmd clean_rpm
rpm: \
rpm32 \
rpm64
rpmd: \
rpm32d \
rpm64d
.PHONY: rpm32 rpm32d rpm64 rpm64d
rpm32: \
$(DISTRIBUTION_NAME).rpm
rpm32d:
$(MAKE) $(DISTRIBUTION_NAME).rpm DEBUG=1
rpm64: \
$(DISTRIBUTION_NAME)-x86_64.rpm
rpm64d:
$(MAKE) $(DISTRIBUTION_NAME)-x86_64.rpm DEBUG=1
clean_rpm:
$(RMF) build/rpm/$(DISTRIBUTION_NAME).rpm
$(RMF) build/rpm/$(DISTRIBUTION_NAME).rpm.log
$(RMF) build/rpm/$(DISTRIBUTION_NAME)-x86_64.rpm
$(RMF) build/rpm/$(DISTRIBUTION_NAME)-x86_64.rpm.log
$(DISTRIBUTION_NAME)-x86_64.rpm: \
$(DISTRIBUTION_NAME).tar.bz2
@$(call functionPrintInfo,Build RPM on CentOS 6 64bit)
@( \
$(DOCKER) $(DOCKER_RUN_FLAGS) \
--rm \
--net=host \
--user $(shell id -u):$(shell id -g) \
-e COLUMNS="`tput cols`" -e LINES="`tput lines`" \
-v $(PWD)/extern:/media/extern \
-v $(PWD):/media/home \
bar-centos-x86_64:7 setarch x86_64 -- /bin/bash -c "make -C /media/home build_rpm DEBUG=$(DEBUG)" \
) | tee [email protected]
@$(call functionPrintResult,OK)
.PHONY: build_rpm
build_rpm:
install -d build/rpm
# Note: scl_source to enable gcc 7
(cd build/rpm; \
source scl_source enable devtoolset-7; \
../../packages/build_rpm.sh \
../.. \
$(PACKAGE_NAME) \
../../$(DISTRIBUTION_NAME).tar.bz2 \
$(VERSION) \
$(shell id -u):$(shell id -g) \
$(DISTRIBUTION_NAME)-x86_64.rpm \
$(if $(DEBUG),--debug) \
; \
)
# DEB
.PHONY: deb debd clean_deb
deb: \
deb32 \
deb64
debd: \
deb32d \
deb64d
.PHONY: deb32 deb32d deb-gui32 deb-gui32d deb64 deb64d deb-gui64 deb-gui64d
deb32: \
$(DISTRIBUTION_NAME).deb
deb32d:
$(MAKE) $(DISTRIBUTION_NAME).deb DEBUG=1
deb-gui32: \
$(DISTRIBUTION_NAME_GUI).deb
deb-gui32d:
$(MAKE) $(DISTRIBUTION_NAME_GUI).deb DEBUG=1
deb64: \
$(DISTRIBUTION_NAME)-x86_64.deb
deb64d:
$(MAKE) $(DISTRIBUTION_NAME)-x86_64.deb DEBUG=1
deb-gui64: \
$(DISTRIBUTION_NAME_GUI)-x86_64.deb
deb-gui64d:
$(MAKE) $(DISTRIBUTION_NAME_GUI)-x86_64.deb DEBUG=1
clean_deb:
$(RMF) build/rpm/$(DISTRIBUTION_NAME).deb
$(RMF) build/rpm/$(DISTRIBUTION_NAME_GUI).deb
$(RMF) build/rpm/$(DISTRIBUTION_NAME).deb.log
$(RMF) build/rpm/$(DISTRIBUTION_NAME)-x86_64.deb
$(RMF) build/rpm/$(DISTRIBUTION_NAME_GUI)-x86_64.deb
$(RMF) build/rpm/$(DISTRIBUTION_NAME)-x86_64.deb.log
$(DISTRIBUTION_NAME)-x86_64.deb $(DISTRIBUTION_NAME_GUI)-x86_64.deb: \
$(DISTRIBUTION_NAME).tar.bz2
@$(call functionPrintInfo,Build DEB on Debian 7 (wheezy) 64bit)
( \
$(DOCKER) $(DOCKER_RUN_FLAGS) \
--rm \
--net=host \
--user $(shell id -u):$(shell id -g) \
-e COLUMNS="`tput cols`" -e LINES="`tput lines`" \
-v $(PWD)/extern:/media/extern \
-v $(PWD):/media/home \
bar-debian-x86_64:10 setarch x86_64 -- /bin/bash -c "make -C /media/home build_deb DEBUG=$(DEBUG)" \
) | tee [email protected]
@$(call functionPrintResult,OK)
# TODO: out-of-source build, distribution file
.PHONY: build_deb
build_deb:
install -d build/deb
(cd build/deb; \
../../packages/build_deb.sh \
../.. \
$(PACKAGE_NAME) \
../../$(DISTRIBUTION_NAME).tar.bz2 \
$(VERSION) \
$(shell id -u):$(shell id -g) \
$(DISTRIBUTION_NAME)-x86_64.deb \
$(DISTRIBUTION_NAME_GUI)-x86_64.deb \
$(if $(DEBUG),--debug); \
)
# Windows setup
.PHONY: win32 win32d clean_win32
win32:
$(MAKE) $(PACKAGE_NAME)-setup-$(VERSION)@EXEEXT@
win32d:
$(MAKE) $(PACKAGE_NAME)-setup-$(VERSION)@EXEEXT@ DEBUG=1
clean_win32:
$(RMF) build/rpm/$(DISTRIBUTION_NAME).rpm
$(RMF) build/rpm/$(DISTRIBUTION_NAME).rpm.log
$(RMF) build/rpm/$(DISTRIBUTION_NAME)-x86_64.rpm
$(RMF) build/rpm/$(DISTRIBUTION_NAME)-x86_64.rpm.log
#TODO: remove /media/wine and move to build_win32.sh
$(PACKAGE_NAME)-setup-$(VERSION)@EXEEXT@: \
$(DISTRIBUTION_NAME).tar.bz2
@$(call functionPrintInfo,Build Win32 on mingw32)
( \
$(DOCKER) $(DOCKER_RUN_FLAGS) \
--rm \
--net=host \
--user $(shell id -u):$(shell id -g) \
-e COLUMNS="`tput cols`" -e LINES="`tput lines`" \
-v $(PWD)/extern:/media/extern \
-v $(PWD):/media/home \
-v $(WINE_C_DRIVE):/media/wine \
bar-mingw32 setarch x86_64 -- /bin/bash -c "make -C /media/home build_win32 DEBUG=$(DEBUG)" \
) | tee [email protected]
@$(call functionPrintResult,OK)
.PHONY: build_win32
build_win32:
install -d build/win32
(cd build/win32; \
../../packages/build_win32.sh \
../.. \
$(PACKAGE_NAME) \
../../$(DISTRIBUTION_NAME).tar.bz2 \
$(VERSION) \
$(shell id -u):$(shell id -g) \
$(PACKAGE_NAME)-setup-$(VERSION) \
$(if $(DEBUG),--debug); \
)
# install test
# call functionInstallTestRPM,<docker image>,<architecture>,<RPM files>,<options>
functionInstallTestRPM = \
if test -f /.dockerenv; then \
packages/install_test_rpm.sh \
$3 $4; \
else \
if test -n "$(DOCKER)"; then \
$(DOCKER) $(DOCKER_RUN_FLAGS) \
--rm \
-e COLUMNS="`tput cols`" -e LINES="`tput lines`" \
-v $(PWD):/media/home \