File: configure

package info (click to toggle)
doris 5.0.3~beta%2Bdfsg-14
  • links: PTS, VCS
  • area: contrib
  • in suites: bullseye
  • size: 6,668 kB
  • sloc: cpp: 43,593; python: 8,213; csh: 3,636; sh: 2,527; ansic: 649; makefile: 346; xml: 208
file content (828 lines) | stat: -rwxr-xr-x 26,797 bytes parent folder | download | duplicates (2)
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
#!/bin/csh -f
########################################################################
# This is a "makefile generator" for the doris software.  It creates
# a makefile for compilation of the Doris source code.  Follow the 
# on the screen please.
#
# For CYGWIN: change the first line to "tcsh -f". (Download tcsh from 
#     ------  redhat site, together with the develop package.)
#
#########################################################################
# based on interactive questions, and ls commands.
#%// BK 24-Aug-2000
# Added check for strptime
#%// BK 08-Mar-2001
# Changed name of script to "configure".
# Added big endian check.
#%// BK 19-Apr-2001
# Added large file support and -Wno-deprecated warnings
#%// PM 18-Aug-2004
# Added more path options for fftw.higher versions and different compilers
#%// PM 01-Sep-2004
# baseline.doris.sh and baseline.doris.csh
#%// PM 15-Feb-2007
# Added compilation and linking of Triangulate
#%// FvL 02-OKT-2007
# Added check .so for fftw and libsearch dir as /usr/lib64
#%// MA 02-Mar-2009
# Update testorbit build
#%// MA 22-May-2009
#

if ( -x /bin/clear ) /bin/clear
#set PRG    = `basename "$0"`
set PRG    = "configure"
set VER    = "v1.7, DEOS software"
set AUT    = "TUDelft, 19-May-2009"
set MAKEFILE = "Makefile"


echo "$PRG $VER, $AUT"
echo " "
echo " Welcome to the Makefile generator for the Doris insar software."
echo " I will ask you some questions on compilers, etc."
echo " The output of this program is a makefile named: $MAKEFILE"
echo " that you can use to compile Doris."
echo " More instructions will follow afterwards. (Please read them.)"
echo " "
echo "===> Press enter to continue."
set key = $<


# Declare variables.
set CXX         = ""
set GppCOMPILER = n
set FFTW        = n
set VECLIB      = n
set LAPACK      = n
set X86         = n
set DEBUG       = n
set FFTWLIBDIR  = ""
set FFTWINCLDIR = ""
set VECLIBDIR   = ""
set LAPACKDIR   = ""
set LIBDIRS     = "../fftw-3.2.1/lib ../../fftw-3.2.1/lib /lib /lib64 /usr/lib /usr/lib64 /usr/lib32 /usr/local/lib /usr/lib/`dpkg-architecture -qDEB_BUILD_MULTIARCH`"
### for fftw include dirs, assume they installed it with doris distributed.
### by doing what we said in install.
set INCLDIRS    = "../fftw-3.2.1/include ../../fftw-3.2.1/include /include /usr/include /usr/local/include"
set DEFINSTALLDIR  = "/home/dummy/bin"
if ( ! -d $DEFINSTALLDIR ) set DEFINSTALLDIR = "/usr/local/bin"
if ( ! -d $DEFINSTALLDIR ) set DEFINSTALLDIR = "../bin"

#
set TMPDIR = "/tmp"
if ( ! -w $TMPDIR ) set TMPDIR = .
echo "   Using temp dir: $TMPDIR"


# Get most likely compiler, first check g++
foreach TMPCC ( g++ g++-3.4 g++-4.0 g++-4.1 g++-4.2 g++-4.3 CXX CC aCC icpc )
  echo Checking compiler: \"$TMPCC\"...
  $TMPCC -v > & /dev/null
  if ( ! $status ) then
    echo "   I found a working(?) compiler: $TMPCC"
    set CXX = "$TMPCC"
    break
  endif
end


#
# Set flag for g++, this define enables some functions like sqr(int)
# that are not standard C++, but were provided with, e.g., HP aCC compiler.
#
if ( "$CXX" == "g++" ) set GppCOMPILER = "y"


#
# Check little Endian integers:
# Compile this program and run it.
#
set TSTPRG = "$TMPDIR/Doris_endian"
echo "Checking endianness for integers..."
echo "Creating test program: $TSTPRG.cc"
cat << __EOFDH > $TSTPRG.cc
/* *** Test program to find out if little endian           *** */
/* *   Generated by Doris software install script            * */
/* *   Exits with 0 if big, 1 if little endian integer.      * */
/* *** Bert Kampes, 19-Apr-2001                            *** */
// #include <ctime>
int main()
  {
  int i;
  int littleendian=0;// thus big assumed
  char test[64]={0};
  for (i=0;i<32;i++) test[i]=0;
  test[0]=0x01;
  if (0x0001==*(int *)(&test[0])) littleendian=1;
  return littleendian;
  }
__EOFDH
echo "Compiling test program: $TSTPRG"
$CXX $TSTPRG.cc -o $TSTPRG > & /dev/null
if ( $status != 0 ) then
  echo "   ---------------------------------------------------------------"
  echo "   Sorry, could not compile test program, continuing."
  echo "   THIS WILL LIKELY CAUSE TROUBLE IF YOUR COMPILER DOESN'T WORK"
  echo "   Please change endianness interactively in a moment if required."
  echo "   ---------------------------------------------------------------"
  echo " "
  set X86 = "n"
endif
echo "Running test program: $TSTPRG"
if ( -x $TSTPRG ) then
  $TSTPRG > & /dev/null
  if ( $status != 0 ) then
    set X86 = "y"
    echo "   Your system seems Little Endian, using -D__X86PROCESSOR__"
    echo "   (or program failed to execute for another reason)"
  else
    echo "   Your system is Big Endian (not using a define)."
  endif
  rm -f $TSTPRG.cc $TSTPRG.o $TSTPRG
endif
echo " "


#
# Check library function strptime works:
#
echo "Checking whether library function strptime works ok..."
set STRPTIME = "1"
set TSTPRG = "$TMPDIR/Doris_strptime"
echo "Creating test program: $TSTPRG.cc"
cat << __EOFDH > $TSTPRG.cc
/* *** Test program to find out if function strptime works *** */
/* *   Generated by Doris software install script            * */
/* *** Bert Kampes, 14-Mar-2001                            *** */
//#include <iostream>
// #include <time.h>
#include <ctime>
int main()
  {
  struct tm tm_ref;
  char utc_ref[100] = "05-JAN-1985 01:02:03.000";
  strptime(utc_ref,"%d-%b-%Y %T",&tm_ref);
  int status = 0;
  if (tm_ref.tm_mday != 5) status=1;
  if (tm_ref.tm_mon  != 0) status=1;
  if (tm_ref.tm_year != 85) status=1;
  if (tm_ref.tm_hour != 1) status=1;
  if (tm_ref.tm_min  != 2) status=1;
  if (tm_ref.tm_sec  != 3) status=1;
  //cerr << "tm_ref.tm_mday: " << tm_ref.tm_mday << endl;
  return status;
  }
__EOFDH
echo "Compiling test program: $TSTPRG"
$CXX $TSTPRG.cc -o $TSTPRG > & /dev/null
if ( $status != 0 ) then
  echo "   function strptime not found in library, using internal definition."
  echo "   by define -D__NO_STRPTIME (change by editing DEF8 in $MAKEFILE)"
  set STRPTIME = "0"
endif
echo "Running test program: $TSTPRG"
if ( -x $TSTPRG ) then
  $TSTPRG > & /dev/null
  if ( $status != 0 ) then
    echo "   strptime does not work properly, using internal definition."
    echo "   by define -D__NO_STRPTIME (change by editing DEF8 in $MAKEFILE)"
    echo "   (or program failed to execute for another reason)"
    set STRPTIME = "0"
  else
    rm -f $TSTPRG.cc $TSTPRG.o $TSTPRG
  endif
endif
if ( "$STRPTIME" == "1" ) then
  echo "   Library function strptime works fine, using it."
endif
echo " "




#
# Try to find veclib library
#
foreach DIR ( $LIBDIRS )
 echo Checking directory: \"$DIR\" for Veclib...
 if ( -e $DIR/libveclib.a ) then
   echo "   I found libveclib.a in $DIR"
   set VECLIBDIR = "$DIR"
   set VECLIB = "y"
   break
 endif
end
#
# Try to find lapack library (careful, most people have fortran version)
#
foreach DIR ( $LIBDIRS )
 echo Checking directory: \"$DIR\" for Lapack...
 if ( -e $DIR/liblapack.a ) then
   echo "   I found liblapack.a in $DIR"
   set LAPACKDIR = "$DIR"
   set LAPACK = "y"
   break
 endif
end
if ( "$VECLIB" == "n" ) echo "   I could not find libveclib.a"
if ( "$LAPACK" == "n" ) echo "   I could not find liblapack.a"
echo " "
#
# Try to find fftw library
#
foreach DIR ( $INCLDIRS )
 echo Checking directory: \"$DIR\" for fftw3.h...
 if ( -e $DIR/fftw3.h ) then
   echo "   I found fftw3.h in $DIR"
   set FFTWINCLDIR = "$DIR"
   #set FFTW = "y"
   break
 endif
end
foreach DIR ( $LIBDIRS )
 echo "Checking directory: $DIR for libfftw3f.[a|so]..."
 if ( -e $DIR/libfftw3f.a ) then
   echo "   I found libfftw3f.a in $DIR"
   set FFTWLIBDIR = "$DIR"
   set FFTW = "y"
   break
 else if ( -e $DIR/libfftw3f.so ) then
   echo "   I found libfftw3f.so in $DIR"
   set FFTWLIBDIR = "$DIR"
   set FFTW = "y"
   break
 endif
end
if ( "$FFTW" == "n" ) echo "   I could not find libfftw3f.a or libfftw3f.so"
if ( "$FFTW" == "y" ) if ( "$VECLIB" == "y" ) echo "   NOT POSSIBLE TO USE VECLIB AND FFTW"
echo " "



##########################################################################
#
# Interactive questions/check by user:
#
echo "===> What is your C++ compiler? [$CXX] "
set key = $<
if ( "X$key" != "X" ) set CXX = "$key"
if ( "$CXX" == "g++" ) set GppCOMPILER = y

echo "===> Do you have the FFTW library (y/n)? [$FFTW] "
set key = $<
if ( "$key" == "y" || "$key" == "Y" ) then 
  set FFTW = "y"
else if ( "$key" == "n" || "$key" == "N" ) then
  set FFTW = "n"
else
  echo "     Using default: [$FFTW]"
endif
if ( "$FFTW" == "y" ) then
  echo "===> What is the path to the FFTW library (libfftw3f.a or libfftw3f.so)? [$FFTWLIBDIR] "
  set key = $<
  if ( "X$key" != "X" ) set FFTWLIBDIR = "$key"
  if ( "X$FFTWLIBDIR" == "X" || ! -d $FFTWLIBDIR ) then
    echo " you entered a non existing directory: $FFTWLIBDIR"
    echo "===> What is the path to the FFTW library? [$FFTWLIBDIR] "
    set key = $<
    if ( "X$key" != "X" ) set FFTWLIBDIR = "$key"
  endif
  echo "===> What is the path to the FFTW include file (fftw3.h)? [$FFTWINCLDIR] "
  set key = $<
  if ( "X$key" != "X" ) set FFTWINCLDIR = "$key"
  if ( "X$FFTWINCLDIR" == "X" || ! -d $FFTWINCLDIR ) then
    echo " you entered a non existing directory: $FFTWINCLDIR"
    echo "===> What is the path to the FFTW library? [$FFTWINCLDIR] "
    set key = $<
    if ( "X$key" != "X" ) set FFTWINCLDIR = "$key"
  endif
endif


echo "===> Do you have the VECLIB library (y/n)? [$VECLIB] "
set key = $<
if ( "$key" == "y" || "$key" == "Y" ) then 
  set VECLIB = "y"
else if ( "$key" == "n" || "$key" == "N" ) then
  set VECLIB = "n"
else
  echo "     Using default: [$VECLIB]"
endif
if ( "$VECLIB" == "y" ) then
  echo "===> What is the path to the VECLIB library? [$VECLIBDIR] "
  set key = $<
  if ( "X$key" != "X" ) set VECLIBDIR = "$key"
  if ( "X$VECLIBDIR" == "X" || ! -d $VECLIBDIR ) then
    echo " you entered a non existing directory: $VECLIBDIR"
    echo "===> What is the path to the VECLIB library? [$VECLIBDIR] "
    set key = $<
    if ( "X$key" != "X" ) set VECLIBDIR = "$key"
  endif
endif


echo "===> Do you have the LAPACK library (y/n)? [$LAPACK] "
set key = $<
if ( "$key" == "y" || "$key" == "Y" ) then
  set LAPACK = "y"
else if ( "$key" == "n" || "$key" == "N" ) then
  set LAPACK = "n"
else
  echo "     Using default: [$LAPACK]"
endif
if ( "$LAPACK" == "y" ) then
  echo "===> What is the path to the LAPACK library liblapack.a? [$LAPACKDIR] "
  set key = $<
  if ( "X$key" != "X" ) set LAPACKDIR = "$key"
  if ( ! -d $LAPACKDIR ) then
    echo " you entered a non existing directory: $LAPACKDIR"
    echo "===> What is the path to the LAPACK library? [$LAPACKDIR] "
    set key = $<
    if ( "X$key" != "X" ) set LAPACKDIR = "$key"
  endif
  ### Check LAPACK dir fortran version (underscore appended)
  echo " Checking whether you have FORTRAN LAPACK library:"
  nm $LAPACKDIR/liblapack.a | grep spotrf_ >& /dev/null
  if ( $status == 0 ) then
    echo "     FORTRAN"
  else
    echo "     C (or nm failed?)"
    echo "     If compilation fails, please do not use LAPACK"
    echo "     or change in the source code file matrixspecs.cc"
  endif
endif


echo "===> Are you working on a Little Endian (X86 PC, Intel) machine (y/n)? [$X86] "
set key = $<
if ( "$key" == "y" || "$key" == "Y" ) set X86 = "y"
if ( "$key" == "n" || "$key" == "N" ) set X86 = "n"


echo "===> Do you want to compile a more verbose DEBUG version (y/n)? [$DEBUG] "
echo "     (You can first compile an optimal version, then perform a make clean,"
echo "      and then compile a debug version, which you can use in case doris "
echo "      does not produce expected results)"
set key = $<
if ( "$key" == "y" || "$key" == "Y" ) set DEBUG = "y"


set INSTALLDIR = "dummy.$$.$$.$$"
while ( ! -d $INSTALLDIR )
  set INSTALLDIR = "$DEFINSTALLDIR"
  echo "===> Installation of Doris in directory: $INSTALLDIR (y/n)? [y]"
  set key = $<
  if ( "$key" == "n" || "$key" == "N" ) then
    echo "===> Enter installation directory (use absolute path): "
    set INSTALLDIR = $<
    if ( ! -d $INSTALLDIR ) then
      echo "===> Installation directory: $INSTALLDIR does not exist."
      echo "===> Should I create it (y/n)? [y]"
      set key = $<
      if ( "$key" != "n" && "$key" != "N" ) mkdir $INSTALLDIR
    endif
  endif
end



###################################################
echo " "
echo " Creating Makefile for:"
echo " compiler:       $CXX"
echo " fftw:           $FFTW"
if ( "$FFTW" == "y" ) echo " FFTW LIB DIR:     $FFTWLIBDIR"
if ( "$FFTW" == "y" ) echo " FFTW INCLUDE DIR: $FFTWINCLDIR"
echo " veclib:         $VECLIB"
if ( "$VECLIB" == "y" ) echo " VECLIB dir:     $VECLIBDIR"
echo " lapack:         $LAPACK"
if ( "$LAPACK" == "y" ) echo " LAPACK dir:     $LAPACKDIR"
echo " Little endian:  $X86"
echo " DEBUG version:  $DEBUG"
echo " Install in dir: $INSTALLDIR"
echo " "
if ( -e $MAKEFILE ) then
  echo " file: $MAKEFILE will be OVERWRITTEN."
else
  echo " file: $MAKEFILE will be created."
endif
echo "===> Press enter to continue (CTRL-C to exit)."
set key = $<



#
# Set variable for LFLAGS, IFLAGS, DEFINES
#
# +++ At 17:49, August 29th, Robert J. Mellors wrote:
#<RJM:   I had a few minor problems compiling v3.16 with gcc on my intel linux
#<RJM:  redhat system -
#<RJM: [...]
#<RJM:  Next, the linker complained about a variety of missing functions,
#<RJM:  c_sqrt and a plethora of others; I added
#<RJM:  -lg2c   (before -lm) to LFLAGS in the Makefile (being too lazy to do it
#<RJM:  right and change configure).
#<RJM:  This seemed to fix that.

set CFLAGS = " "
set LFLAGS = " "
#set LFLAGS = "-lg2c"
set IFLAGS = " "
if ( "$FFTW" == "y" ) then                           # MA moved back to top due to searchpath issues: ../fftw/lib vs /usr/lib
  set CFLAGS = "$CFLAGS -D__USE_FFTW_LIBRARY__"
  ### last one must be fftw lib and math lib         # to be tested again
  ### for Cygwin, the slash after "-L$FFTWLIBDIR/" is maybe required?!
  echo "Adding extra lib flag for fftw: -lm (must be at end)"
  set LFLAGS = "$LFLAGS -L$FFTWLIBDIR -lfftw3f -lm"
  set IFLAGS = "$IFLAGS -I$FFTWINCLDIR"
endif
###########################
if ( "$LAPACK" == "y" ) then 
  set CFLAGS = "$CFLAGS -D__USE_LAPACK_LIBRARY__"
  # Set the location of liblapack.a (DEF4)
  echo "Adding lib for lapack"
  set LFLAGS = "$LFLAGS -L$LAPACKDIR -llapack"
endif
###########################
if ( "$VECLIB" == "y" ) then 
  set CFLAGS = "$CFLAGS -D__USE_VECLIB_LIBRARY__"
  # Set the location of libveclib.a (DEF4)
  echo "Adding extra flag for veclib: -lcl"
  set LFLAGS = "$LFLAGS -L$VECLIBDIR -lveclib -lcl"
endif
###########################
if ( "$X86" == "y" ) then
  set CFLAGS = "$CFLAGS -D__X86PROCESSOR__"
endif
###########################
if ( "$STRPTIME" == "0" ) then
  set CFLAGS = "$CFLAGS -D__NO_STRPTIME"
endif
###########################
#DEF9     = -D__NO_IOS_BINARY__ # -9- comment out if you ios::binary (most will)
### include dir for fftw
set CFLAGS = "$CFLAGS $IFLAGS"




#
# Create the Makefile:
#

cat << __EOFHD > $MAKEFILE
#########################################################################
# Makefile for the Doris software.					#
# Created by: $PRG						#
# 04-Dec-1998                                                           #
#                                                                       #
# Delft University of Technology                                        #
# Delft Institute of Earth Observation and Space Systems                #
# http://doris.tudelft.nl               				#
# See also the user manual, annex installation.				#
#									#
### Usage ### 								#
# The command: "make" creates and optimized version of doris.		#
# The command: "make install" installs it andcleans up.			#
# If this does not work, try a more controlled approach by:		#
#									#
# 0. inspect set up of this Makefile					#
# 1. set CXX DEFS LIBS etc., first set these to debug values		#
#    (read NOTE there if problems)					#
# 2. compile software sources to *.o:     "make swobjs"			#
# 3. link object together to executable:  "make doris"			#
# 4. install executable:                  "make install"		#
# 5. remove object files:                 "make clean"			#
#									#
# BTW. "make" does "swobjs doris" by default.				#
#									#
###        								#
# Successfully tested for compilers/platforms:				#
#  GNU g++ version 2.7.2.2 on HP-UX B.10.20 A 9000/785			#
#  GNU g++ version 2.95.2  on HP-UX B.10.20 A 9000/785			#
#  HP  aCC version A.01.07 on HP-UX B.10.20 A 9000/785			#
#  GNU g++ version ?       on Linux X86					#
#  SGI ?								#
#  Sun Studion 9,10,11     on Solaris Sparc and X86/AMD64		#
#  GNU g++ versions v3.4, v4.0, v4.1, v4.2, v4.3 on Linux X86 and AMD64 # 
#  Sun Sudion v11          on Linux AMD64				#
#  Intel Compilers v9, v10, v11 on Linux AMD64				#
#########################################################################
###################################################################
###################################################################
# Please change if required: DEF[1-6], CXX, CFLAGS, LIBDIR,     ###
###################################################################
### The shell used by this makefile ###
SHELL   = /bin/sh

### Specify compiler/installation directory ###
INSTALLDIR = $INSTALLDIR
CXX	   = $CXX
SCRIPTSDIR = ../bin

### Define statements controlling compilation ###
# Comment out DEF[1-8] statements when appropriate.
DEF1    = -D__DEBUGMAT1	# 		-1- range checking in matrix class
DEF2    = -D__DEBUGMAT2	# 		-2- info matrix class (debug only)
DEF3    = -D__DEBUG #			-3- debug for other files
DEF4    = -Wno-deprecated            #  -4- do not display warnings due to depricated entries 
DEF5    = -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE #  -5- support for large files
#DEF6    = -DNO_FASTTRIG              #  -6-  extra functional switches
#DEF9     = -D__NO_IOS_BINARY__ # -9- comment out if you ios::binary (most will)
#
### Do not change following 2, simply comment DEF1-8 above
DEFSDEBUG 	= \$(DEF1) \$(DEF2) \$(DEF3)
DEFS		= \$(DEF4) \$(DEF5) \$(DEF6) $CFLAGS

### NOTE ###
# If you get warnings like the following (I got them with g++, not with aCC)
# then use define __GNUC__ to define these functions
#%// BK 15-Aug-2000
#In file included from matrixbk.h:38,
#		 from processor.cc:23:
#constants.h: In method \`real8 cn::dist(cn) const':
#constants.h:106: implicit declaration of function \`int sqr(...)'
### END NOTE ###


# LOCAL dir
LOCAL_INSTALLDIR = ../bin

### CFLAGS ###
# Compiler options flag ###
# Specify compiler flags (I selected these for g++)
CFLAGSDEBUG 	= -g -O \$(DEFS) \$(DEFSDEBUG)
CFLAGSOPT 	= -O \$(DEFS)
#CFLAGSOPT 	= -O2 \$(DEFS)   # this crashed doris! (?)
#CFLAGSOPT 	= -O3 \$(DEFS)   # this crashed doris! (?)

__EOFHD



#
# See if you want a DEBUG version
#
if ( "$DEBUG" == "n" ) then
cat << __EOFHD >> $MAKEFILE
### CCNOTE ###
### Change here ###
### set CFLAGS depending on if you compile debug version or working version ###
#CFLAGS 	= \$(CFLAGSDEBUG)
CFLAGS 	= \$(CFLAGSOPT)
### END CCNOTE ###
__EOFHD
else
cat << __EOFHD >> $MAKEFILE
### CCNOTE ###
### Change here ###
### set CFLAGS depending on if you compile debug version or working version ###
CFLAGS 	= \$(CFLAGSDEBUG)
#CFLAGS 	= \$(CFLAGSOPT)
### END CCNOTE ###
__EOFHD
endif



#
# Add LFLAGS to Makefile 
#
cat << __EOFHD >> $MAKEFILE

### Library locations flag ###
### -lcl : used for veclib 
### -lm  : used for fftw
LFLAGS  = $LFLAGS \$(LDFLAGS)


#####################################################
### No need to change anything below here... ####
#####################################################
EXECUTABLE = 	doris

SWSRCS	=	processor.cc \
		utilities.cc \
		ioroutines.cc \
		readinput.cc \
		readdata.cc \
		coregistration.cc \
		filtering.cc \
		referencephase.cc \
		products.cc \
		geocode.cc \
		unwrap.cc \
		matrixspecs.cc \
		exceptions.cc \
		estorbit.cc
SWOBJS	=	\$(SWSRCS:.cc=.o)

### scripts of doris.tar in SCRIPTSDIR, used at make install
SCRIPTS	=	helpdoris \
		baseline.doris.sh \
		baseline.doris.csh \
                construct_dem.sh \
		coregpm.doris \
		doris* \
		heightamb \
		phasefilt.doris \
		plotcpm* \
		plotoffsets* \
		run \
		viewanddel \
		cpx2ps \
		lonlathei2ascii \
		ascii2ascii_UTM \
		ascii2ps* \
                tsx* \
                rs2* \
                csk* \
                gammaReadfiles.csh \
                hhmmss2sec.py \
                sec2hhmmss.py




#####################################################
### And no need to change anything below here... ####
#####################################################
### what to do if make w/o arguments ###
# first make all object files, then link them together
default:        \$(EXECUTABLE)


### how to compile object code .o from C++ source files .cc (general rule) ###
# space between -o and filename for SUN make (BK 7 july 2000)
.cc.o:		
		\$(CXX) \$(CPPFLAGS) \$(CFLAGS) -c -o \$(@) \$<

#####################################################
### Make object code from source ###
swobjs:		\$(SWOBJS)


### Load objects to executable ###
### The added .cc files contain class definitions
### matrixclass is explicitly included
### in the source code since we had some problems finding out how to do that
### here, since compilers treat the template class differently than normal classes.
### BK 07-Feb-2002
\$(EXECUTABLE):	\$(SWOBJS) tmp_strptime.cc slcimage.cc productinfo.cc orbitbk.cc
		\$(CXX) \$(CPPFLAGS) \$(CFLAGS)\
		tmp_strptime.cc \$(SWOBJS) -ltriangle\
		slcimage.cc productinfo.cc orbitbk.cc\
		\$(LFLAGS) -o \$@
		@echo " "
		@echo "*******************************"
		@echo "* ...Compilation finished...  *"
		@echo "*******************************"
		@echo " "


### Install executable in installdir ###
install:	\$(EXECUTABLE)
		@echo "* Installing \$(EXECUTABLE) in: \$(INSTALLDIR)"
		mkdir -p \$(INSTALLDIR)
		@cp -f \$(EXECUTABLE) \$(INSTALLDIR)/.
		( cd \$(SCRIPTSDIR); cp -f \$(SCRIPTS) \$(INSTALLDIR)/. )
		\$(MAKE) cleaner
		@echo " "
		@echo "*******************************"
		@echo "* ...Installation finished... *"
		@echo "*******************************"
		@echo " "
		@echo "* Check that \$(INSTALLDIR) is in your path search: echo \\\$\$PATH ."
		@echo " "


installcb:	\$(EXECUTABLE)
		@echo "* Installing \$(EXECUTABLE) in: \$(LOCAL_INSTALLDIR)"
		@cp -f \$(EXECUTABLE) \$(LOCAL_INSTALLDIR)/.
		\$(MAKE) cleaner
		@echo " "
		@echo "*******************************"
		@echo "* ...Installation finished... *"
		@echo "*******************************"
		@echo " "
		@echo "* Check that \$(LOCAL_INSTALLDIR) is in your path search: echo \\\$\$PATH ."
		@echo " "


#####################################################
### Testers ###
test:		testdoris
testdoris:	\$(EXECUTABLE)
		@echo " "
		@echo "* Executing command: \$(EXECUTABLE) -v"
		\$(EXECUTABLE) -v
		@echo " "

### Orbit test program for debugging ###
test-orbit:	ioroutines.o matrixspecs.o utilities.o exceptions.cc slcimage.cc orbitbk.cc matrixbk.cc bk_messages.hh
		\$(CXX) \$(CPPFLAGS) \$(CFLAGS) -D__TESTMAIN__ \
		ioroutines.o matrixspecs.o utilities.o exceptions.cc slcimage.cc orbitbk.cc \
		\$(LFLAGS) \
		-o \$@
### Matrix test program for debugging ###
### fast_sin defined in utilities.cc, which requires ioroutines, which, etc.
test-matrix:  matrix_test.cc matrixspecs.o utilities.o utilities.o ioroutines.o matrixbk.cc
		\$(CXX) \$(CPPFLAGS) \$(CFLAGS) matrix_test.cc matrixspecs.o \
		utilities.o ioroutines.o exceptions.cc orbitbk.cc \
		\$(LFLAGS) \
		-o \$@
		@echo " "


#####################################################
### Cleaners ###
clean:		cleanswobjs 

cleaner:	clean cleanprog
cleanest:	clean cleanprog uninstall
cleanprog:
		@rm -f \$(EXECUTABLE) \$(EXECUTABLE.debug) \
		matrixbk_test testorbit
		@echo "* Removed executables in current dir."
cleanswobjs:
		@rm -f \$(SWOBJS) matrixbk_test.o orbitbk.o slcimage.o triangle.o
		@echo "* Removed object files."
uninstall:	
		@rm -f \$(INSTALLDIR)/\$(EXECUTABLE)
		@echo "* Removed executables in install dir: \$(INSTALLDIR)."

### BK 12-Dec-2000 ###

__EOFHD




### Finish with some hints.
set LINE = `grep -n CFLAGSOPT $MAKEFILE | cut -f1 -d":"`
cat << __EOFHD

  $PRG has finished creating: $MAKEFILE
  -------------------------------------------------
  To compile the Doris software do the following:
   1. Inspect the created Makefile named: $MAKEFILE
       *TIP* If you like to use other compiler flags (CFLAGS),
             change them in file: $MAKEFILE
             change them at line: $LINE[1] in file: $MAKEFILE
       *TIP* the command: make -f $MAKEFILE -n 
             will show what happens without executing.

   2. At the prompt, enter the command:
        make -f $MAKEFILE
      to compile an version of Doris.
       *TIP* if compilation FAILS due to strptime, try uncommenting DEF8
       *TIP* if compilation FAILS due to something else, please report the
             problem to the mailing list, after checking the user manual
	     and the FAQ.

   3. Enter the command: make -f $MAKEFILE install
      to install the executable in directory: $INSTALLDIR
      This will also install the scripts residing in directory ../bin
      and it will clean up this directory (remove the object files).

   4. After installation, the command:
        doris -v         [should now give the version number]
        doris -h         [should give help]
        doris -c         [should give the copyright notice]
        doris -q         [should give help also]

       *TIP* Make sure the installation directory is in your path.
             (do a rehash or login again)
 
   5. You are adviced to create a (slower, much more verbose) debug 
      version of Doris.  If you get an error during running the normal 
      version of Doris, you can repeat the processing with this debug
      executable.  In order to compile a debug version, make sure the
      normal version is installed.  next, run the configure script again
      (or set appropriate CFLAGS in file $MAKEFILE at line $LINE[2]),
      and indicate that you do want a debug version.  Then give the commands:
        make clean
	make -f $MAKEFILE 
      This compiles a debug version, named "doris".  Do not use make install,
      instead move this executable to "doris.debug" in the installation
      directory by hand.

  ----------------------------------------------------------------------
  DO NOT FORGET to go to directory SARtools and do a make install,
  and also in directory ENVISAT_TOOLS.  The programs in these directories
  are used in doris.
  Before compiling doris, create the fftw library if you want to use it.
  ----------------------------------------------------------------------
  
  
  MORE INFORMATION
  ----------------
   - See the README file, the $MAKEFILE, or the users manual
     (at: http://doris.tudelft.nl/)
   - Consider installing the Matlab InSAR toolbox.

__EOFHD

### EOF.