-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_init
executable file
·4495 lines (4112 loc) · 113 KB
/
build_init
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
#!/usr/bin/perl
# the Getopt::Long package provides some nice command line processing options
# http://search.cpan.org/~jv/Getopt-Long-2.34/lib/Getopt/Long.pm
use Getopt::Long;
# the Inline::Files package allows you to append multiple virtual
# files to the end of your perl program.
# http://search.cpan.org/~dconway/Inline-Files-0.62/lib/Inline/Files.pm
use Inline::Files;
#build_init --package <packagename> \
# --version <version> \
# --rootdir <root dir> \
# --subdirs <list of subdirs separated by whitespace>
#
# e.g., build_init --package hello --version 1.0 --rootdir hello \
# --subdirs hello/goodbye hello/goodbye/leave hello/goodlib
#
# build script and makefile templates are stored in this script
# using the Inline::Files package.
#
# The following file handles are available:
#
# __CONFIGURE__AC__ configure.ac
# __MAKEFILE_IN__ makefile.in
# __LOCAL_MAK__ local.mak
# __CONFIG_GUESS__ config.guess
# __CONFIG_SUB__ config.sub
# __EXCLUDE_TXT__ exclude.txt
# __INSTALL_SH__ install-sh
#
#
# creates a file that stores the project's subdirectories
# this makes it easier to add subdirectories after initially
# establishing the build environment
# parameter: list of subdirectories from the command line
# returns: list of unique subdirectories for the project or false
sub create_subdir_file {
local @dirlist = @_;
local @subdir_list;
# check to see if the subdir file already exists
$config_file = "<.build_init_subdirs";
if (open config_file) {
# read the file into an array
local @subdirs = split / /, <config_file>;
# smash the two arrays together
push(@subdirs, @dirlist);
# now prune the smashed array so it only contains unique values
local %seen = ( );
foreach $item (@subdirs) {
$seen{$item}++;
}
@subdir_list = keys %seen;
close config_file;
} else { # we are creating the .subdirs file for the first time
@subdir_list = @dirlist;
}
# now open the file for writing - truncate
$config_file = ">.subdirs";
open config_file or die "Can't open $config_file";
foreach $item (@subdir_list) {
print config_file "$item ";
}
close config_file;
return @subdir_list;
}
sub create_template_files {
foreach $parm (@_) {
print "$parm ";
}
print "\n";
# first parameter is the root build directory
local $mydir = shift(@_);
# second parameter is a list of subdirectories
local @dirlist = @_;
$now = localtime;
print "creating template files - checking for dir $mydir...";
if (opendir( my $dirh, $mydir)) {
closedir($dirh);
print "directory $mydir exists\n";
#----------------- create the configure.ac autoconf template ----------------#
print "Creating $mydir/configure.ac...";
local $config_file = ">$mydir/configure.ac";
open config_file or die "Can't open $config_file";
print "created\n";
# prepend the initial autoconf macros
print config_file "# -*- Autoconf -*-\n";
print config_file "# This configuration template was created at $now\n";
print config_file "# command line: $0 $COMMAND_LINE \n";
print config_file "# Process this file with autoconf to produce a configure script.\n";
print config_file "#-------------------------- Initialization --------------------------#\n";
printf config_file "AC_PREREQ(2.57)\nAC_INIT([%s], [%s], [])\n", $src_package, $src_version;
# now copy the inline template to the output file
open CONFIGURE_AC, '<';
while(<CONFIGURE_AC>) {
print config_file $_;
}
close CONFIGURE_AC;
# now construct the AC_CONFIG_FILES macro
print config_file "AC_CONFIG_FILES([Makefile\n ";
my $subdir;
foreach $subdir (@dirlist) {
print config_file "$subdir/Makefile\n ";
}
print config_file "])\n";
print config_file "AC_OUTPUT\n";
close config_file ;
#---------- create the Makefile.in Makefile template in each subdirectory ---------#
# create Makefile.in in the build root, then copy it to subdirectories
local $makefile_in = ">$mydir/Makefile.in";
print "Creating $mydir/Makefile.in...";
open makefile_in or die "Can't open $makefile_in";
print "created\n";
print makefile_in "# -*- makefile -*-\n";
print makefile_in "# This makefile template was createdy at $now\n";
print makefile_in "# command line: $0 $COMMAND_LINE \n";
print makefile_in "# Process this file with autoconf to produce a Makefile.\n";
# now copy the inline template to the output file
open MAKEFILE_IN, '<';
while(<MAKEFILE_IN>) {
print makefile_in $_;
}
close MAKEFILE_IN;
close makefile_in;
# now copy the makefile template to each subdirectory
foreach $subdir (@dirlist) {
`cp $mydir/Makefile.in $mydir/$subdir/Makefile.in`
}
#------------ create the local Makefile template ----------------------------------#
local $local_mak = "<$mydir/local.mak";
# this is not a template file, so we need to see if it already exists
print "Checking for pre-existing instance of $mydir/local.mak...";
if (open local_mak ) {
print "already exists\n";
close local_make;
}
else {
$local_mak = ">$mydir/local.mak";
print "Creating $mydir/local.mak...";
open local_mak or die "Can't open $local_mak";
print "created\n";
print local_mak "# -*- makefile -*-\n";
print local_mak "# This makefile template was createdy at $now\n";
print local_mak "# command line: $0 $COMMAND_LINE \n";
print local_mak "# This file is included into the build by the actual Makefile.\n";
open LOCAL_MAK, '<';
while(<LOCAL_MAK>) {
print local_mak $_;
}
close LOCAL_MAK;
close local_mak;
}
# now copy the makefile template to each subdirectory
foreach $subdir(@dirlist) {
$local_mak = "<$mydir/$subdir/local.mak";
# this is not a template file, so we need to see if it already exists
print "Checking for pre-existing instance of $mydir/$subdir/local.mak...";
if (open local_mak ) {
print "already exists\n";
close local_make;
}
else {
print "creating...";
$local_mak = ">$mydir/$subdir/local.mak";
open local_mak or die "Can't open $mydir/$subdir/$local_mak ";
print "created\n";
print local_mak "# -*- makefile -*-\n";
print local_mak "# This makefile template was createdy at $now\n";
print local_mak "# command line: $0 $COMMAND_LINE \n";
print local_mak "# This file is included into the build by the actual Makefile.\n";
open LOCAL_MAK, '<';
while(<LOCAL_MAK>) {
print local_mak $_;
}
close LOCAL_MAK;
close local_mak;
}
} # for each subdir, make sure local.mak is present
#------------------------ config.guess -------------------------------------------#
# now copy the config.guess bash script to the root source directory
# after copying it, change its mode to allow execution 0755
local $config_guess = "<$mydir/config.guess";
# this is a script, so we need to see if it already exists
print "Checking for pre-existing instance of $mydir/config.guess...";
if (open config_guess ) {
print "already exists\n";
# now check the mode
my $mode = (stat("$mydir/config.guess"))[2];
$mode &= 07777;
if($mode & 0100 ) { #owner can execute the file
printf "Permissions are %04o\n", $mode;
}
else {
chmod "$mydir/config.guess", 0755;
printf "Permissions are 0755\n";
}
close config_guess;
}
else {
print "creating...";
$config_guess = ">$mydir/config.guess";
open config_guess or die "Can't open $mydir/config.guess";
print "created\n";
# config.guess is too large to read into one buffer
# split the reads into 1K chunks.
open CONFIG_GUESS, '<';
while ( read CONFIG_GUESS, my $buf, 1024) {print config_guess $buf;}
close CONFIG_GUESS;
close config_guess;
chmod 0755, "$mydir/config.guess" or die "Unable to change mode of $mydir/config.guess";
printf "Permissions are 0755\n";
}
#------------------------ config.sub -------------------------------------------#
# now copy the config.sub bash script to the root source directory
# after copying it, change its mode to allow execution 0755
local $config_sub = "<$mydir/config.sub";
# this is a script, so we need to see if it already exists
print "Checking for pre-existing instance of $mydir/config.sub...";
if (open config_sub ) {
print "already exists\n";
# now check the mode
my $mode = (stat("$mydir/config.sub"))[2];
$mode &= 07777;
if($mode & 0100 ) { #owner can execute the file
printf "Permissions are %04o\n", $mode;
}
else {
chmod "$mydir/config.sub", 0755;
printf "Permissions are 0755\n";
}
close config_sub;
}
else {
print "creating...";
$config_sub = ">$mydir/config.sub";
open config_sub or die "Can't open $mydir/config.sub";
print "created\n";
# config.sub is too large to read into one buffer
# split the reads into 1K chunks.
open CONFIG_SUB, '<';
while ( read CONFIG_SUB, my $buf, 1024) {print config_sub $buf;}
close CONFIG_SUB;
close config_sub;
chmod 0755, "$mydir/config.sub" or die "Unable to change mode of $mydir/config.sub";
printf "Permissions are 0755\n";
}
#-------------------- exclude.txt ------------------------------#
# this file tells the tar program which types of files to exclude
# from an archive of the source package. If the user is editing
# (adding, removing) patterns in the local copy, we don't want to
# overwrite it.
local $exclude_txt = "<$mydir/exclude.txt";
print "Checking for pre-existing instancy of $mydir/exclude.txt...";
if(open exclude_txt) {
print "already exists\n";
}
else {
print "creating...";
$exclude_txt = ">$mydir/exclude.txt";
open exclude_txt or die "Can't open $mydir/exclude.txt";
print "created\n";
open EXCLUDE_TXT, '<';
while(<EXCLUDE_TXT>) {
print exclude_txt $_;
}
close EXCLUDE_TXT;
close exclude_txt;
}
#------------------------------ install-sh -----------------------------#
# now copy the install-sh bash script to the root source directory
# after copying it, change its mode to allow execution 0755
local $install_sh = "<$mydir/install-sh";
# this is a script, so we need to see if it already exists
print "Checking for pre-existing instance of $mydir/install-sh...";
if (open install_sh ) {
print "already exists\n";
# now check the mode
my $mode = (stat("$mydir/install-sh"))[2];
$mode &= 07777;
if($mode & 0100 ) { #owner can execute the file
printf "Permissions are %04o\n", $mode;
}
else {
chmod "$mydir/install-sh", 0755;
printf "Permissions are 0755\n";
}
close install_sh;
}
else {
print "creating...";
$install_sh = ">$mydir/install-sh";
open install_sh or die "Can't open $mydir/install-sh";
print "created\n";
# install-sh is too large to read into one buffer
# split the reads into 1K chunks.
open INSTALL_SH, '<';
while ( read INSTALL_SH, my $buf, 1024) {print install_sh $buf;}
close INSTALL_SH;
close install_sh;
chmod 0755, "$mydir/install-sh" or die "Unable to change mode of $mydir/install-sh";
printf "Permissions are 0755\n";
}
return true;
} # if we got the root subdir opened
return false;
}
sub make_one_dir {
if (opendir(my $dirh, $_[0])) {
print "directory $_[0] already exists...\n";
closedir($dirh);
return true;
}
else {
print "creating directory $_[0]...\n";
`mkdir $_[0]`;
if(opendir(my $dirh, $_[0])) {
closedir($dirh);
return true;
}
}
return false;
}
sub make_dirs {
make_one_dir($src_rootdir) or die "Error - unable to create directory $_[0]";
chdir $src_rootdir or die "Error - unable to change to $_[0]";
foreach $subdir (@src_subdirs) {
print "making $subdir\n";
make_one_dir($subdir) or die "Error = unable to create directory $subdir";
}
chdir "..";
}
sub usage {
print "build_init - Create a multi-platform Build Environment\n";
print "\n";
print "Usage: build_init --package <packagename> --version <version> \n\t";
print "--rootdir <project directory> --subdir <subdirectory>\n\n";
print "--package: the name of the package or project\n";
print "--version: the version of the package or project\n";
print "--rootdir: the root (or top) directory of the build environment\n";
print "--subdir: a subdirectory (relative to the root) of the build environment.\n\n";
print "The --subdir option can be specified multiple times on the command line.\n";
print "For example, specifying --subdir src --subdir src/common --subdir src/util\n";
print "will create src, src/common, and src/util directories and\n";
print "populate them with Makefiles.\n\n";
}
$src_package='';
$src_version ='';
$src_rootdir='';
@src_subdir='';
$COMMAND_LINE = join($",@ARGV);
GetOptions("package=s" => \$src_package,
"version=s" => \$src_version,
"rootdir=s" => \$src_rootdir,
"subdir=s" => \@src_subdirs) or die usage;
# check options
if(0 == length $src_package ||
0 == length $src_version ||
0 == length $src_rootdir ) {usage ; exit 0};
make_dirs($src_rootdir , @src_subdirs);
chdir $src_rootdir;
@smashed_subdirs = create_subdir_file(@src_subdirs);
chdir "..";
create_template_files($src_rootdir, @smashed_subdirs) or die "failed creating template files";
print "preparing config.h.in and creating the configuration script...\n";
chdir $src_rootdir;
`autoheader`;
`autoconf`;
system "./configure ";
chdir "..";
__CONFIGURE_AC__
#-------------------------- Initialization --------------------------#
AC_PREREQ(2.57)
AC_INIT([ldap_slp], [0.1.1], [])
# get the processor, vendor, and host information
AC_CANONICAL_BUILD
# create a time-date stamp that will be available in config.h
config_time=`date`
AC_DEFINE_UNQUOTED([CONFIG_TIME], ["$config_time"], [Configuration Time])
# get the build host
config_host=$(hostname)'.'$(hostname -d)
AC_DEFINE_UNQUOTED([CONFIG_HOST], ["$config_host"], [Configuration Host])
AC_DEFINE_UNQUOTED([CONFIG_USER], ["$USER"], [Configuration User])
canonical_config="Configure/Build initiated by $USER@$config_host on $config_time"
AC_DEFINE_UNQUOTED([CANONICAL_CONFIG_STRING], ["$canonical_config"], [Canonical configuration string])
#------------- define HOST_PROCESSOR, HOST_VENDOR, HOST_OS ------------#
# see http://gcc.gnu.org/install/specific.html for a list of targets
# -----------------------------------------------------------------------
#---------------- Get the cononical build string and set host variables -#
AC_DEFINE_UNQUOTED([CANONICAL_BUILD], ["$build"], [Canonical Build])
# This next three case expressions provide conditional code blocks for
# the host processor, vendor, and operating system.
# Most of the conditional configuration code is in the operating
# system case expression.
case $build in
i?86-*-*)
AC_DEFINE([HOST_PROCESSOR], ["x86"], [Host Processor])
HOST_PROCESSOR=x86
;;
ia64-*-*)
AC_DEFINE([HOST_PROCESSOR], ["ia64"], [Host Processor])
HOST_PROCESSOR=ia64
;;
'@(x86_64-*-* | amd64-*-*)' )
AC_DEFINE([HOST_PROCESSOR], ["amd64"], [Host Processor])
HOST_PROCESSOR=amd64
;;
powerpc-*-*)
AC_DEFINE([HOST_PROCESSOR], ["power"], [Host Processor])
HOST_PROCESSOR=power
;;
powerpcle-*-*)
AC_DEFINE([HOST_PROCESSOR], ["power_le"], [Host Processor])
HOST_PROCESSOR=power_le
;;
s390-*-*)
AC_DEFINE([HOST_PROCESSOR], ["390"], [Host Processor])
HOST_PROCESSOR=390
;;
s390x-*-*)
AC_DEFINE([HOST_PROCESSOR], ["390_x"], [Host Processor])
HOST_PROCESSOR=390_x
;;
esac
case $build in
*-ibm-*)
AC_DEFINE([HOST_VENDOR], ["ibm"], [Host Vendor])
HOST_VENDOR=ibm
;;
*-redhat-*)
AC_DEFINE([HOST_VENDOR], ["redhat"], [Host Vendor])
HOST_VENDOR=redhat
;;
*-pc-*)
AC_DEFINE([HOST_VENDOR], ["MSFT"], [Host Vendor])
HOST_VENDOR=msft
;;
esac
case $build in
*-*-linux*)
AC_DEFINE([HOST_OS], ["linux"], [Host OS])
HOST_OS=linux
AC_DEFINE([OS_PORT_INCLUDE], ["lslp-linux.h"], [Portability Header])
OS_PORT_INCLUDE=lslp-linux.h
OS_PORT_SRC=lslp-linux.c
OS_PORT_OBJ=lslp-linux.o
AC_PROG_CC()
LINKER=$CC
EXE=
LIBS=
LIB_INCLUDE_FLAG=-l
THREAD_LIBS=-lpthread
REENTRANT_FLAG=-D_REENTRANT
NO_LINK_FLAG=-c
LIB_SUFFIX=.o
DLL_SUFFIX=.so
EXE_OUT=-o
OBJ_OUT=-o
INSTALL_EXE=install
INSTALL_FLAGS=--mode=install
LIBTOOL=/usr/bin/libtool
LIBTOOL_MODE_COMPILE=--mode=compile
LIBTOOL_MODE_LINK=--mode=link
LIBTOOL_MODE_CLEAN=--mode=clean
LIBTOOL_MODE_INSTALL=--mode=install
# check see if the production variable is set
if [[ -z "$PRODUCTION" ]] ; then
echo "Configuring Compiler for a debug build..."
CPPFLAGS=
CFLAGS="-fPIC -g -Wall"
CXXFLAGS=$CFLAGS
echo "Configuring Linker for a debug build..."
LDFLAGS=-g
else
echo "Configuring Compiler for a production build..."
CPPFLAGS=
CFLAGS="-fPIC -g -Wall"
CXXFLAGS=$CFLAGS
echo "Configuring Linker for a production build..."
LDFLAGS=-s
fi
AC_PROG_MAKE_SET
# Checks for libraries.
# AC_CHECK_LIB([dl], [dlopen])
prefix=/usr/local
exec_prefix=$prefix
bindir=$prefix/bin
sbindir=$prefix/sbin
libexecdir=$sbindir
libdir=$prefix/lib
includedir=$prefix/include
;;
*-*-aix*)
AC_DEFINE([HOST_OS], ["aix"], [Host OS])
HOST_OS=aix
if [[ -z "$PRODUCTION" ]] ; then
echo "remove this line and input the actual production flags"
else
echo "remove this line and input the actual debug flags"
fi
;;
*-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows*)
# force the user to have VCINSTALLDIR defined in the
# environment before running the configuration script
#
if test -z "$VCINSTALLDIR" ; then
echo "Error - VCINSTALLDIR not defined in environment"
echo "Must define VCINSTALLDIR to point to the Visual Studio root"
exit 1
else
echo "MSFT Visual Studio located at $VCINSTALLDIR"
fi
AC_DEFINE([HOST_OS], ["windows"], [Host OS])
HOST_OS=windows
AC_DEFINE([OS_PORT_INCLUDE], ["lslp-windows.h"], [Portability Header])
AC_DEFINE([OS_PORT_SRC], ["lslp-windows.c"], [Portability Source])
AC_DEFINE([OS_PORT_OBJ], ["lslp-windows.obj"], [Portability Object])
OS_PORT_INCLUDE=lslp-windows.h
OS_PORT_SRC=lslp-windows.c
OS_PORT_OBJ=lslp-windows.obj
# use the MSFT SYSTEMDRIVE environment variable to construct
# the default pathways.
prefix=$SYSTEMDRIVE
exec_prefix=$prefix
bindir=$prefix\\WINDOWS\\system32
sbindir=$bindir
libexecdir=$bindir
libdir=$bindir
includedir="$VCINSTALLDIR\\Vc7\\include;$VCINSTALLDIR\\Vc7\\PlatformSDK\\include"
echo "MSFT cl INCLUDE variable set to: $includedir"
if [[ -z "$PRODUCTION" ]] ; then
echo "Configuring Compiler for a debug build..."
CPPFLAGS=""
CFLAGS="/nologo /c /Zi"
CXXFLAGS=$CFLAGS
LDFLAGS="/nologo /DEBUG"
LINKER_OPTIONS="/link /INCREMENTAL:NO /DEBUG /MAP /MAPINFO:EXPORTS /MAPINFO:LINES"
AC_SUBST([LINKER_OPTIONS])
else
echo "Configuring Compiler for a production build..."
CPPFLAGS=""
CFLAGS="/nologo /c "
CXXFLAGS=$CFLAGS
LDFLAGS="/nologo"
LINKER_OPTIONS="/link /INCREMENTAL:NO"
AC_SUBST([LINKER_OPTIONS])
fi
INCLUDE="$includedir"
AC_SUBST([INCLUDE])
LIB="$VCINSTALLDIR\\Vc7\\lib;$VCINSTALLDIR\\Vc7\PlatformSDK\\lib;$libdir"
echo "MSFT cl LIB variable set to: $LIB"
AC_SUBST([LIB])
;;
*-*-openbsd*)
AC_DEFINE([HOST_OS], ["openBSD"], [Target Operation System])
HOST_OS=openbsd
AC_DEFINE([OS_PORT_INCLUDE], ["lslp-linux.h"], [Portability Header])
OS_PORT_INCLUDE=lslp-linux.h
OS_PORT_SRC=lslp-linux.c
OS_PORT_OBJ=lslp-linux.o
HOST_OS=openBSD
AC_PROG_CC()
LINKER=$CC
EXE=
LIBS=
LIB_INCLUDE_FLAG=-l
THREAD_LIBS=-lpthread
REENTRANT_FLAG=-D_REENTRANT
NO_LINK_FLAG=-c
LIB_SUFFIX=.o
DLL_SUFFIX=.so
EXE_OUT=-o
OBJ_OUT=-o
INSTALL_EXE=installMa
INSTALL_FLAGS=
LIBTOOL_MODE_COMPILE=
LIBTOOL_MODE_LINK=
LIBTOOL_MODE_CLEAN=
LIBTOOL_MODE_INSTALL=
if [[ -z "$PRODUCTION" ]] ; then
CFLAGS="-g -Wall -Dlinux -DBSD -DDEBUG_ALLOC"
LDFLAGS=-g
LFLAGS="-p -v -d "
YFLAGS="-v -d"
else
CFLAGS="-O -Wall -Dlinux -DBSD"
LDFLAGS=-s
LFLAGS="-f -w"
YFLAGS=-l
fi
prefix=/usr/local
exec_prefix=$prefix
bindir=$prefix/bin
sbindir=$prefix/sbin
libexecdir=$sbindir
libdir=$prefix/lib
includedir=$prefix/include
;;
esac
#------------------ special windows|notwindows initializations --------------------
# The following if/else/endif block is a convenient way to do initialization that
# is different for Windows, but the same for the other platforms.
#
# Basically this block uses home-grown checks for Windows, but uses canned Autoconf
# macros for all the other platforms.
#
# I could have equally put this block in one or more of the case expressions above
# but it is more compact to do it this way.
#-----------------------------------------------------------------------------------
if [[ $HOST_OS == "windows" ]] ; then
# Define the dll import and export directives to be active on MSFT platforms
AC_DEFINE([DLL_EXPORT], [__declspec(dllexport)], [DLL Export directive for MSFT])
AC_DEFINE([DLL_IMPORT], [__declspec(dllimport)], [DLL Import directive for MSFT])
echo "defined DLL_EXPORT: __declspec(dllexport)"
echo "defined DLL_IMPORT: __declspec(dllimport)"
AC_DEFINE([_WIN32_WINNT], [0x400], [Required for Windows Platform Headers])
echo "_WIN32_WINNT Preprocessor variable set to WINNT 4.0 and Above"
windows_save_ifs=$IFS
IFS=';'
for dir in $includedir ; do
# home-grown header checks for MSFT. Loops to check all defined include dirs
IFS=$windows_save_ifs
if [[ -e "$dir\\inttypes.h" ]] ; then
AC_DEFINE([HAVE_INTTYPES_H], [1],
[Define to 1 if you have the <inttypes.h> header file])
fi
if [[ -e "$dir\\memory.h" ]] ; then
AC_DEFINE([HAVE_MEMORY_H], [1],
[Define to 1 if you have the <memory.h> header file])
fi
if [[ -e "$dir\\stdint.h" ]] ; then
AC_DEFINE([HAVE_STDINT_H], [1],
[Define to 1 if you have the <stdint.h> header file])
fi
if [[ -e "$dir\\stdlib.h" ]] ; then
AC_DEFINE([HAVE_STDLIB_H], [1],
[Define to 1 if you have the <stdlib.h> header file])
fi
if [[ -e "$dir\\strings.h" ]] ; then
AC_DEFINE([HAVE_STRINGS_H], [1],
[Define to 1 if you have the <strings.h> header file])
fi
if [[ -e "$dir\\string.h" ]] ; then
AC_DEFINE([HAVE_STRING_H], [1],
[Define to 1 if you have the <string.h> header file])
fi
if [[ -e "$dir\\sys\\stat.h" ]] ; then
AC_DEFINE([HAVE_SYS_STAT_H], [1],
[Define to 1 if you have the <sys/stat.h> header file])
fi
if [[ -e "$dir\\sys\\types.h" ]] ; then
AC_DEFINE([HAVE_SYS_TYPES_H], [1],
[Define to 1 if you have the <sys/types.h> header file])
fi
if [[ -e "$dir\\unistd.h" ]] ; then
AC_DEFINE([HAVE_UNISTD_H], [1],
[Define to 1 if you have the <unistd.h> header file])
fi
if [[ -e "$dir\\WinVer.h" ]] ; then
AC_DEFINE([HAVE_WINVER_H], [1],
[Define to 1 if you have <WinVer.h> header file])
fi
IFS=';'
done
IFS=$windows_save_ifs
AC_DEFINE_UNQUOTED([WINSOCK_2], [1], [Using Winsock 2 interface])
else
export PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin
AC_DEFINE([DLL_EXPORT], [], [Dll Export directive for MSFT])
AC_DEFINE([DLL_IMPORT], [], [Dll Import directive for MSFT])
AC_CHECK_HEADERS([unistd.h])
AC_PATH_PROG([LDCONFIG], [ldconfig])
AC_PATH_PROG([ARCHIVE], [ar])
AC_PATH_PROG([INSTALL], [install])
fi
AC_PROG_LEX
AC_PROG_YACC
#--------------------Definitions and Substitutions--------------------------
# definitions
# each AC_SUBST will take a shell variable defined above or elsewhere
# and put it into the makefile
AC_SUBST([config_time])
AC_SUBST([config_host])
AC_SUBST([USER])
AC_SUBST([canonical_config])
AC_SUBST([build])
AC_SUBST([HOST_PROCESSOR])
AC_SUBST([HOST_OS])
AC_SUBST([HOST_VENDOR])
AC_SUBST([CPPFLAGS])
AC_SUBST([CFLAGS])
AC_SUBST([CXXFLAGS])
AC_SUBST([LDFLAGS])
AC_SUBST([YACC])
AC_SUBST([YFLAGS])
AC_SUBST([LEX])
AC_SUBST([LFLAGS])
AC_SUBST([builddir])
AC_SUBST([abs_builddir])
AC_SUBST([top_builddir])
AC_SUBST([abs_top_builddir])
AC_SUBST([srcdir])
AC_SUBST([abs_srcdir])
AC_SUBST([top_srcdir])
AC_SUBST([abs_top_srcdir])
AC_SUBST([prefix ])
AC_SUBST([exec_prefix])
AC_SUBST([bindir])
AC_SUBST([sbindir])
AC_SUBST([libexecdir]) # programs to be run by other programs (not users)
AC_SUBST([libdir ]) # $(exec_prefix)/lib
AC_SUBST([includedir])
AC_SUBST([CVS_ROOT])
AC_SUBST([PORTAL])
AC_SUBST([PORTAL_MAILTO])
AC_SUBST([EXTRACT])
AC_SUBST([INSTALL_CMD])
AC_SUBST([UNINSTALL_CMD])
AC_SUBST([OS_PORT_INCLUDE])
AC_SUBST([OS_PORT_SRC])
AC_SUBST([OS_PORT_OBJ])
AC_SUBST([LINKER])
AC_SUBST([LIB_INCLUDE_FLAG])
AC_SUBST([THREAD_LIBS])
AC_SUBST([REENTRANT_FLAG])
AC_SUBST([NO_LINK_FLAG])
AC_SUBST([LIB_SUFFIX])
AC_SUBST([DLL_SUFFIX])
AC_SUBST([EXE_OUT])
AC_SUBST([OBJ_OUT])
AC_SUBST([INSTALL_EXE])
AC_SUBST([INSTALL_FLAGS])
AC_SUBST([LIBTOOL])
AC_SUBST([LIBTOOL_MODE_COMPILE])
AC_SUBST([LIBTOOL_MODE_LINK])
AC_SUBST([LIBTOOL_MODE_CLEAN])
AC_SUBST([LIBTOOL_MODE_INSTALL])
AC_SUBST([DLL_EXPORT])
AC_SUBST([DLL_IMPORT])
AC_CONFIG_HEADER([config.h])
AC_CONFIG_FILES([Makefile
src/Makefile
src/kernel/Makefile
src/cmd-utils/Makefile
src/cmd-utils/port/Makefile
src/cmd-utils/port/aix5/Makefile
src/cmd-utils/port/linux/Makefile
src/cmd-utils/port/windows/Makefile
src/cmd-utils/slp_client/Makefile
src/cmd-utils/slp_query/Makefile
src/cmd-utils/slp_srvreg/Makefile
src/cmd-utils/slp_attrreq/Makefile
])
AC_OUTPUT
__MAKEFILE_IN__
export PACKAGE_NAME := @PACKAGE_NAME@
export PACKAGE_VERSION := @PACKAGE_VERSION@
VPATH := @srcdir@
export HOST_PROCESSOR := @HOST_PROCESSOR@
export HOST_OS := @HOST_OS@
export CONFIG_TIME := @config_time@
export CONFIG_HOST := @config_host@
export CONFIG_USER := @USER@
export CONFIG_STRING := @canonical_config@
CANONICAL_BUILD := @build@
export HOST_PROCESSOR := @HOST_PROCESSOR@
export HOST_OS := @HOST_OS@
export HOST_VENDOR := @HOST_VENDOR@
export CPPFLAGS := @CPPFLAGS@
export CFLAGS := @CFLAGS@
export CXXFLAGS := @CXXFLAGS@
export LDFLAGS:=@LDFLAGS@
export LINKER_OPTIONS:=@LINKER_OPTIONS@
LD_LIBS :=
LOAD_LIBS :=
export YACC := @YACC@
export YFLAGS := @YFLAGS@
export LEX := @LEX@
export LFLAGS := @LFLAGS@
export builddir := @builddir@
export abs_builddir := @abs_builddir@
export top_builddir := @top_builddir@
export abs_top_builddir := @abs_top_builddir@
export srcdir := @srcdir@
export top_srcdir := @top_srcdir@
export abs_top_srcdir := @abs_top_srcdir@
export prefix := @prefix@
export exec_prefix := @exec_prefix@
export bindir := @bindir@
export sbindir := @sbindir@
export libexecdir := @libexecdir@
export libdir := @libdir@
export includedir := @includedir@
ifeq ($(HOST_OS), windows)
export INCLUDE:=@INCLUDE@
export LIB:=@LIB@
endif
CVS_ROOT := @CVS_ROOT@
PORTAL := @PORTAL@
PORTAL_MAILTO := @PORTAL_MAILTO@
EXTRACT := @EXTRACT@
INSTALL_CMD := @INSTALL_CMD@
UNINSTALL_CMD := @UNINSTALL_CMD@
export OS_PORT_INCLUDE := @OS_PORT_INCLUDE@
export OS_PORT_SRC := @OS_PORT_SRC@
export OS_PORT_OBJ := @OS_PORT_OBJ@
export LINKER := @LINKER@
export LIB_INCLUDE_FLAG:= @LIB_INCLUDE_FLAG@
export THREAD_LIBS := @THREAD_LIBS@
export REENTRANT_FLAG := @REENTRANT_FLAG@
export NO_LINK_FLAG := @NO_LINK_FLAG@
export LIB_SUFFIX:= @LIB_SUFFIX@
export DLL_SUFFIX:= @DLL_SUFFIX@
export EXE_OUT := @EXE_OUT@
export OBJ_OUT := @OBJ_OUT@
export INSTALL_EXE := @INSTALL_EXE@
export INSTALL_FLAGS := @INSTALL_FLAGS@
export LIBTOOL := @LIBTOOL@
export LIBTOOL_MODE_COMPILE := @LIBTOOL_MODE_COMPILE@
export LIBTOOL_MODE_LINK := @LIBTOOL_MODE_LINK@
export LIBTOOL_MODE_CLEAN := @LIBTOOL_MODE_CLEAN@
export LIBTOOL_MODE_INSTALL := @LIBTOOL_MODE_INSTALL@
export LDCONFIG := @LDCONFIG@
export ARCHIVE := @ARCHIVE@
export INSTALL := @INSTALL@
#-------------------------Make Targets----------------------------------#
# all - everything
# bin - program files