/[gxemul]/trunk/configure
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/configure

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4 by dpavlin, Mon Oct 8 16:18:00 2007 UTC revision 22 by dpavlin, Mon Oct 8 16:19:37 2007 UTC
# Line 1  Line 1 
1  #!/bin/sh  #!/bin/sh
2  ###############################################################################  ###############################################################################
3  #  #
4  #  Copyright (C) 2003-2005  Anders Gavare.  All rights reserved.  #  Copyright (C) 2003-2006  Anders Gavare.  All rights reserved.
5  #  #
6  #  Redistribution and use in source and binary forms, with or without  #  Redistribution and use in source and binary forms, with or without
7  #  modification, are permitted provided that the following conditions are met:  #  modification, are permitted provided that the following conditions are met:
# Line 27  Line 27 
27  #  SUCH DAMAGE.  #  SUCH DAMAGE.
28  #  #
29  #  #
30  #  $Id: configure,v 1.123 2005/04/17 01:42:21 debug Exp $  #  $Id: configure,v 1.198 2006/02/18 13:15:20 debug Exp $
31  #  #
32  #  This is a minimal configure script, hardcoded for GXemul. This script  #  This is a minimal configure script, hardcoded for GXemul. This script
33  #  figures out which compiler flags will work, and creates Makefiles in  #  figures out which compiler flags will work, and creates Makefiles in
# Line 49  Line 49 
49  #    o)  which compiler flags to use  (overridden by setting CFLAGS)  #    o)  which compiler flags to use  (overridden by setting CFLAGS)
50  #    o)  X11 flags and libraries  (TODO: should be possible to override)  #    o)  X11 flags and libraries  (TODO: should be possible to override)
51  #    o)  binary translation (on supported platforms)  #    o)  binary translation (on supported platforms)
52  #    o)  prefetch capability  (TODO: this is assumed on Alpha, but not all  #
53  #                              Alphas have it...)  #  TODO:
54    #    o)  X11 libs and includes via command line options?
55  #  #
56  ###############################################################################  ###############################################################################
57    
58  ENABLEALPHA=NO  #  Figure out if this is a stable version (0.x.x).
59  ENABLEHPPA=NO  X=`basename \`pwd\`|cut -d \- -f 2-|cut -c1-2`
60  ENABLEMIPS=YES  if [ z"$X" = z0. ]; then
61  ENABLEPPC=YES          #  Stable:
62  ENABLESPARC=NO          ENABLEARM=YES
63  ENABLEURISC=YES          ENABLEMIPS=YES
64  ENABLEX86=NO          ENABLEPPC=YES
65    else
66            #  Development:
67            UNSTABLE=YES
68            DYNTRANSBACKEND=NO #YES
69            ENABLEALPHA=YES
70            ENABLEARM=YES
71            ENABLEAVR=YES
72            ENABLEHPPA=YES
73            ENABLEI960=YES
74            ENABLEIA64=YES
75            ENABLEM68K=YES
76            ENABLEMIPS=YES
77            NEWMIPS=NO
78            ENABLEPPC=YES
79            ENABLESH=YES
80            ENABLESPARC=YES
81            ENABLEX86=YES
82    fi
83    
84    if [ z"$UNSTABLE" = zYES ]; then
85            printf "###  DEVELOPMENT (UNSTABLE)\n\n"
86    fi
87    
88  if [ z"$*" != z ]; then  if [ z"$*" != z ]; then
89          #  Parse command line options:          #  Parse command line options:
# Line 69  if [ z"$*" != z ]; then Line 92  if [ z"$*" != z ]; then
92                          NOX11=YES                          NOX11=YES
93                  else if [ z$a = z--always32 ]; then                  else if [ z$a = z--always32 ]; then
94                          ALWAYS32=YES                          ALWAYS32=YES
95                    else if [ z$a = z--tracenull ]; then
96                            TRACENULL=YES
97                  else if [ z$a = z--disable-bintrans ]; then                  else if [ z$a = z--disable-bintrans ]; then
98                          NOBINTRANS=YES                          NOBINTRANS=YES
99                    else if [ z$a = z--enable-bintrans ]; then
100                            NOBINTRANS=NO
101                    else if [ z$a = z--disable-mips16 ]; then
102                            MIPS16=NO
103                  else if [ z$a = z--enable-mips16 ]; then                  else if [ z$a = z--enable-mips16 ]; then
104                          MIPS16=YES                          MIPS16=YES
105                  else if [ z$a = z--enable-alpha ]; then                  else if [ z$a = z--disable-dyntransbackend ]; then
106                          ENABLEALPHA=YES                          DYNTRANSBACKEND=NO
107                  else if [ z$a = z--enable-hppa ]; then                  else if [ z$a = z--enable-dyntransbackend ]; then
108                          ENABLEHPPA=YES                          DYNTRANSBACKEND=YES
109                  else if [ z$a = z--disable-mips ]; then                  else if [ z$a = z--disable-delays ]; then
110                          ENABLEMIPS=NO                          DELAYS=NO
                 else if [ z$a = z--disable-ppc ]; then  
                         ENABLEPPC=NO  
                 else if [ z$a = z--enable-sparc ]; then  
                         ENABLESPARC=YES  
                 else if [ z$a = z--disable-urisc ]; then  
                         ENABLEURISC=NO  
                 else if [ z$a = z--enable-x86 ]; then  
                         ENABLEX86=YES  
111                  else if [ z$a = z--enable-delays ]; then                  else if [ z$a = z--enable-delays ]; then
112                          DELAYS=YES                          DELAYS=YES
113                    else if [ z$a = z--disable-caches ]; then
114                            CACHES=NO
115                  else if [ z$a = z--enable-caches ]; then                  else if [ z$a = z--enable-caches ]; then
116                          CACHES=YES                          CACHES=YES
117                    else if [ z$a = z--disable-newmips ]; then
118                            NEWMIPS=NO
119                    else if [ z$a = z--enable-newmips ]; then
120                            NEWMIPS=YES
121                    else if [ z$a = z--disable-1k-pages ]; then
122                            ONEKPAGE=NO
123                    else if [ z$a = z--enable-1k-pages ]; then
124                            ONEKPAGE=YES
125                  else if [ z$a = z--help ]; then                  else if [ z$a = z--help ]; then
126                          echo "usage: $0 [options]"                          echo "usage: $0 [options]"
127                          printf "\nDevelopment (debug) options:\n"  
128                          echo "  --always32          enable" \                          printf "\nGeneral options:\n\n"
129                              "ALWAYS_SIGNEXTEND_32 (for hunting down"  
130                          echo "                      32/64-bit bugs)"                          echo "  --disable-bintrans  configure without the" \
131                          printf "\nGeneral options:\n"                              "old binary translation subsystem,"
132                          echo "  --disable-bintrans  configure without" \                          echo "                      even if the host" \
133                              "bintrans, even if the host supports it"                              "supports it"
                         echo "  --enable-caches     enable cache emulation" \  
                             "(experimental)"  
                         echo "  --enable-delays     enable instruction" \  
                             "latency/delay emulation"  
134                          echo "  --disable-x         don't include X11 support"                          echo "  --disable-x         don't include X11 support"
135                          printf "\nCPU selection options: (most of these"  
136                          printf " are experimental)\n"                          printf "\nDevelopment (debug) options:\n\n"
137                          echo "  --enable-alpha      enable Alpha CPU emulation"  
138                          echo "  --enable-hppa       enable HPPA CPU emulation"                          echo "  --always32         enable ALWAYS_SIGNEXTEND_32"\
139                          echo "  --disable-mips      disable MIPS CPU emulation"                              "(for hunting down 32-bit bugs)"
140                          echo "  --disable-ppc       disable PPC CPU emulation"                          printf "  --enable-caches    enable cache emulation"
141                          echo "  --enable-sparc      enable SPARC CPU emulation"                          printf " (BUGGY)\n"
142                          echo "  --disable-urisc     disable URISC CPU emulation"                          echo "  --enable-delays    enable instruction" \
143                          echo "  --enable-x86        enable x86 CPU emulation"                              "latency/delay emulation"
144                          printf "\nMIPS-specific options:\n"  
145                          echo "  --enable-mips16     enable MIPS16 instruction" \                          if [ z$DYNTRANSBACKEND = zYES ]; then
146                              "support (experimental)"                                  printf "  --disable-dyntransbackend  disable "
147                          printf "\n"                          else
148                                    printf "  --enable-dyntransbackend  enable"
149                            fi
150                            printf "dyntrans backend\n"
151    
152                            echo "  --enable-mips16    enable MIPS16 support"
153                            echo "  --enable-newmips   use new MIPS dyntrans code"
154                            #printf "  --enable-1k-pages  allow 1KB dyntrans pages"
155                            #printf " (default: 4KB)\n"
156    
157                            printf "\n(Pretty much all of these options are only"
158                            printf " meaningful during the development of\nthe"
159                            printf " emulator, and should not be used when "
160                            printf "compiling a stable version.)\n"
161                          exit                          exit
162                  else                  else
163                          echo "Invalid option: $a"                          echo "Invalid option: $a"
164                          echo "Run  $0 --help  to get a list of" \                          echo "Run  $0 --help  to get a list of" \
165                              "available options."                              "available options."
166                          exit                          exit
167                  fi; fi; fi; fi; fi; fi; fi; fi; fi; fi; fi; fi; fi; fi                  fi; fi; fi; fi; fi; fi; fi; fi; fi; fi; fi; fi; fi; fi; fi; fi
168                    fi; fi
169          done          done
170  fi  fi
171    
# Line 148  printf "/* Line 189  printf "/*
189  #  Figure out if VERSION should be defined.  #  Figure out if VERSION should be defined.
190  X=`basename \`pwd\`|cut -d \- -f 2-`  X=`basename \`pwd\`|cut -d \- -f 2-`
191  if [ z"$X" = zgxemul ]; then  if [ z"$X" = zgxemul ]; then
192          echo '#  No VERSION defined.' >> _Makefile.header          echo '/*  No VERSION defined.  */' >> config.h
193  else  else
194          printf "#define VERSION \"$X\"\n" >> config.h          printf "#define VERSION \"$X\"\n" >> config.h
195  fi  fi
# Line 167  if [ z$MIPS16 = zYES ]; then Line 208  if [ z$MIPS16 = zYES ]; then
208  fi  fi
209  if [ z$ENABLEALPHA = zYES ]; then  if [ z$ENABLEALPHA = zYES ]; then
210          printf "#define ENABLE_ALPHA\n" >> config.h          printf "#define ENABLE_ALPHA\n" >> config.h
211            CPU_ARCHS="$CPU_ARCHS cpu_alpha.o cpu_alpha_palcode.o"
212            CPU_TOOLS="$CPU_TOOLS generate_alpha_misc"
213    fi
214    if [ z$ENABLEARM = zYES ]; then
215            printf "#define ENABLE_ARM\n" >> config.h
216            CPU_ARCHS="$CPU_ARCHS cpu_arm.o cpu_arm_coproc.o memory_arm.o "
217            CPU_ARCHS="$CPU_ARCHS tmp_arm_dpi.o tmp_arm_loadstore.o tmp_arm_r.o"
218            CPU_ARCHS="$CPU_ARCHS tmp_arm_r0.o tmp_arm_r1.o"
219            CPU_ARCHS="$CPU_ARCHS tmp_arm_r2.o tmp_arm_r3.o"
220            CPU_ARCHS="$CPU_ARCHS tmp_arm_r4.o tmp_arm_r5.o"
221            CPU_ARCHS="$CPU_ARCHS tmp_arm_r6.o tmp_arm_r7.o"
222            CPU_ARCHS="$CPU_ARCHS tmp_arm_r8.o tmp_arm_r9.o"
223            CPU_ARCHS="$CPU_ARCHS tmp_arm_ra.o tmp_arm_rb.o"
224            CPU_ARCHS="$CPU_ARCHS tmp_arm_rc.o tmp_arm_rd.o"
225            CPU_ARCHS="$CPU_ARCHS tmp_arm_re.o tmp_arm_rf.o tmp_arm_multi.o"
226            CPU_TOOLS="$CPU_TOOLS generate_arm_dpi generate_arm_r"
227            CPU_TOOLS="$CPU_TOOLS generate_arm_loadstore generate_arm_multi"
228    fi
229    if [ z$ENABLEAVR = zYES ]; then
230            printf "#define ENABLE_AVR\n" >> config.h
231            CPU_ARCHS="$CPU_ARCHS cpu_avr.o"
232  fi  fi
233  if [ z$ENABLEHPPA = zYES ]; then  if [ z$ENABLEHPPA = zYES ]; then
234          printf "#define ENABLE_HPPA\n" >> config.h          printf "#define ENABLE_HPPA\n" >> config.h
235            CPU_ARCHS="$CPU_ARCHS cpu_hppa.o"
236    fi
237    if [ z$ENABLEI960 = zYES ]; then
238            printf "#define ENABLE_I960\n" >> config.h
239            CPU_ARCHS="$CPU_ARCHS cpu_i960.o"
240    fi
241    if [ z$ENABLEIA64 = zYES ]; then
242            printf "#define ENABLE_IA64\n" >> config.h
243            CPU_ARCHS="$CPU_ARCHS cpu_ia64.o"
244    fi
245    if [ z$ENABLEM68K = zYES ]; then
246            printf "#define ENABLE_M68K\n" >> config.h
247            CPU_ARCHS="$CPU_ARCHS cpu_m68k.o"
248  fi  fi
249  if [ z$ENABLEMIPS = zYES ]; then  if [ z$ENABLEMIPS = zYES ]; then
250          printf "#define ENABLE_MIPS\n" >> config.h          printf "#define ENABLE_MIPS\n" >> config.h
251            if [ z$NEWMIPS = zYES ]; then
252                    echo 'Enabling the _EXPERIMENTAL_ MIPS dyntrans code.'
253                    printf "#define EXPERIMENTAL_NEWMIPS\n" >> config.h
254            fi
255  fi  fi
256  if [ z$ENABLEPPC = zYES ]; then  if [ z$ENABLEPPC = zYES ]; then
257          printf "#define ENABLE_PPC\n" >> config.h          printf "#define ENABLE_PPC\n" >> config.h
258            CPU_ARCHS="$CPU_ARCHS cpu_ppc.o"
259            CPU_TOOLS="$CPU_TOOLS generate_ppc_loadstore"
260    fi
261    if [ z$ENABLESH = zYES ]; then
262            printf "#define ENABLE_SH\n" >> config.h
263            CPU_ARCHS="$CPU_ARCHS cpu_sh.o"
264  fi  fi
265  if [ z$ENABLESPARC = zYES ]; then  if [ z$ENABLESPARC = zYES ]; then
266          printf "#define ENABLE_SPARC\n" >> config.h          printf "#define ENABLE_SPARC\n" >> config.h
267  fi          CPU_ARCHS="$CPU_ARCHS cpu_sparc.o"
 if [ z$ENABLEURISC = zYES ]; then  
         printf "#define ENABLE_URISC\n" >> config.h  
268  fi  fi
269  if [ z$ENABLEX86 = zYES ]; then  if [ z$ENABLEX86 = zYES ]; then
270          printf "#define ENABLE_X86\n" >> config.h          printf "#define ENABLE_X86\n" >> config.h
271            CPU_ARCHS="$CPU_ARCHS cpu_x86.o"
272  fi  fi
273    
274    
# Line 195  if [ z$DELAYS = zYES ]; then Line 279  if [ z$DELAYS = zYES ]; then
279  fi  fi
280    
281    
282  #  Instruction delay/latency emulation:  #  Development option: ALWAYS_SIGNEXTEND_32
283  if [ z$ALWAYS32 = zYES ]; then  if [ z$ALWAYS32 = zYES ]; then
284          echo 'Enabling ALWAYS_SIGNEXTEND_32. (NOTE:' \          echo 'Enabling ALWAYS_SIGNEXTEND_32. (NOTE:' \
285              'This slows down everything.)'              'This slows down everything.)'
# Line 203  if [ z$ALWAYS32 = zYES ]; then Line 287  if [ z$ALWAYS32 = zYES ]; then
287  fi  fi
288    
289    
290    #  1KB page emulation:
291    if [ z$ONEKPAGE = zYES ]; then
292            echo '1 KB pages: not yet.'
293            exit
294            echo 'Enabling 1 KB page dyntrans support. (NOTE:' \
295                'This slows down everything.)'
296            printf "#define ONEKPAGE\n" >> config.h
297    fi
298    
299    
300  #  Cache emulation:  #  Cache emulation:
301  if [ z$CACHES = zYES ]; then  if [ z$CACHES = zYES ]; then
302          echo 'Enabling Cache emulation. (EXPERIMENTAL)'          echo 'Enabling Cache emulation. (EXPERIMENTAL and BUGGY)'
303          printf "#define ENABLE_CACHE_EMULATION\n" >> config.h          printf "#define ENABLE_CACHE_EMULATION\n" >> config.h
304    
305          if [ z$DELAYS != zYES ]; then          if [ z$DELAYS != zYES ]; then
# Line 214  if [ z$CACHES = zYES ]; then Line 308  if [ z$CACHES = zYES ]; then
308                  printf '         (--delays) will not produce correct '                  printf '         (--delays) will not produce correct '
309                  printf 'cache miss penalties and such.\n'                  printf 'cache miss penalties and such.\n'
310          fi          fi
311    
312            printf "\nNOTE: Cache emulation enabled, but right now it triggers "
313            printf "weird bugs in the\n      emulator. You have been warned.\n\n"
314  fi  fi
315    
316    
# Line 291  if [ z"$CC" = z ]; then Line 388  if [ z"$CC" = z ]; then
388          fi          fi
389          rm -f _testprog          rm -f _testprog
390    
391          #  Try ccc (FreeBSD/Alpha):  #       #  Try ccc (FreeBSD/Alpha):
392          printf "#!/bin/sh\nccc _testprog.c -o _testprog >" > _test.sh  #       printf "#!/bin/sh\nccc _testprog.c -o _testprog >" > _test.sh
393          printf " /dev/null 2> /dev/null\n" >> _test.sh  #       printf " /dev/null 2> /dev/null\n" >> _test.sh
394          chmod 755 _test.sh  #       chmod 755 _test.sh
395          ./_test.sh > /dev/null 2> /dev/null  #       ./_test.sh > /dev/null 2> /dev/null
396          if [ -x _testprog ]; then  #       if [ -x _testprog ]; then
397                  CC="ccc"  #               CC="ccc"
398          fi  #       fi
399          rm -f _testprog  #       rm -f _testprog
400    
401          rm -f _test.sh          rm -f _test.sh
402  fi  fi
# Line 414  if [ z$OSF1 = zYES ]; then Line 511  if [ z$OSF1 = zYES ]; then
511  fi  fi
512    
513    
514  #  Check for weird 'alpha' define.  #  Check for 'alpha' define.
515  printf "checking for weird 'alpha' define... "  printf "checking for 'alpha' define... "
516  printf "#include <stdio.h>\nint main(int argc, char *argv[]){  printf "#include <stdio.h>\nint main(int argc, char *argv[]){
517  #ifdef alpha  #ifdef alpha
518  printf(\"1\");  printf(\"1\");
# Line 445  fi Line 542  fi
542  rm -f _testm*  rm -f _testm*
543    
544    
 #  Check for weird 'hppa' define.  
 printf "checking for weird 'hppa' define... "  
 printf "#include <stdio.h>\nint main(int argc, char *argv[]){  
 #ifdef hppa  
 printf(\"1\");  
 #undef hppa  
 #ifdef hppa  
 printf(\"2\");  
 #endif  
 #endif  
 printf(\"\\\n\");return 0;}\n" > _testm.c  
 $CC $CFLAGS _testm.c -o _testm 2> /dev/null  
 if [ ! -x _testm ]; then  
         printf "\nWARNING! COULD NOT COMPILE hppa define TEST"  
         printf " PROGRAM AT ALL!\n"  
 else  
         if [ z`./_testm` = z1 ]; then  
                 printf "yes, workaround applied\n"  
                 echo "#undef hppa" >> config.h  
         else  
                 if [ z`./_testm` = z12 ]; then  
                         printf "yes, but workaround not possible\n"  
                         exit  
                 else  
                         printf "no\n"  
                 fi  
         fi  
 fi  
 rm -f _testm*  
   
   
545  #  Some OSes on MIPS seems to define 'mips' to 1. (eg OpenBSD/arc)  #  Some OSes on MIPS seems to define 'mips' to 1. (eg OpenBSD/arc)
546  printf "checking for weird 'mips' define... "  printf "checking for 'mips' define... "
547  printf "#include <stdio.h>\nint main(int argc, char *argv[]){  printf "#include <stdio.h>\nint main(int argc, char *argv[]){
548  #ifdef mips  #ifdef mips
549  printf(\"1\");  printf(\"1\");
# Line 509  rm -f _testm* Line 575  rm -f _testm*
575    
576  #  Similar to the mips define check above, although I don't know if  #  Similar to the mips define check above, although I don't know if
577  #  any OS actually defined ppc like this.  #  any OS actually defined ppc like this.
578  printf "checking for weird 'ppc' define... "  printf "checking for 'ppc' define... "
579  printf "#include <stdio.h>\nint main(int argc, char *argv[]){  printf "#include <stdio.h>\nint main(int argc, char *argv[]){
580  #ifdef ppc  #ifdef ppc
581  printf(\"1\");  printf(\"1\");
# Line 541  rm -f _testm* Line 607  rm -f _testm*
607    
608  #  Similar to the mips define check above, although I don't know if  #  Similar to the mips define check above, although I don't know if
609  #  any OS actually defined sparc like this.  #  any OS actually defined sparc like this.
610  printf "checking for weird 'sparc' define... "  printf "checking for 'sparc' define... "
611  printf "#include <stdio.h>\nint main(int argc, char *argv[]){  printf "#include <stdio.h>\nint main(int argc, char *argv[]){
612  #ifdef sparc  #ifdef sparc
613  printf(\"1\");  printf(\"1\");
# Line 584  if [ -x _testprog ]; then Line 650  if [ -x _testprog ]; then
650          if [ z"$COMPAQCC" = zYES ]; then          if [ z"$COMPAQCC" = zYES ]; then
651                  CWARNINGS="$CWARNINGS -msg_disable longlongtype,unusedtop"                  CWARNINGS="$CWARNINGS -msg_disable longlongtype,unusedtop"
652          fi          fi
653    
654            if [ z"$UNSTABLE" = zYES ]; then
655                    printf "checking whether -Werror can be used... "
656                    rm -f _testprog
657                    $CC $CFLAGS $CWARNINGS _testprog.c -o _testprog -Werror 2> /dev/null
658                    if [ -x _testprog ]; then
659                            printf "yes\n"
660                            CWARNINGS="$CWARNINGS -Werror"
661                    else
662                            printf "no\n"
663                    fi
664            fi
665  else  else
666          printf "no\n"          printf "no\n"
667  fi  fi
# Line 591  rm -f _testprog Line 669  rm -f _testprog
669    
670    
671  if [ z"$COMPAQCC" = zYES ]; then  if [ z"$COMPAQCC" = zYES ]; then
672          #  -O4 is possible, but is -O3 better?          #  -O4 is possible, but sometimes -O3 is better?
673          CFLAGS="-O4 $CFLAGS"          CFLAGS="-O4 $CFLAGS"
674  else  else
675          if [ z"`uname`" = zSunOS ]; then          if [ z"`uname`" = zSunOS ]; then
# Line 606  else Line 684  else
684                  $CC $CFLAGS _testprog.c -o _testprog -O 2> /dev/null                  $CC $CFLAGS _testprog.c -o _testprog -O 2> /dev/null
685                  if [ -x _testprog ]; then                  if [ -x _testprog ]; then
686                          rm -f _testprog                          rm -f _testprog
687                          $CC $CFLAGS _testprog.c -o _testprog -O2 2> /dev/null                          $CC $CFLAGS _testprog.c -o _testprog -O3 2> /dev/null
688                          if [ -x _testprog ]; then                          if [ -x _testprog ]; then
689                                  CFLAGS="-O2 $CFLAGS"                                  CFLAGS="-O3 $CFLAGS"
690                          else                          else
691                                  CFLAGS="-O $CFLAGS"                                  CFLAGS="-O $CFLAGS"
692                          fi                          fi
# Line 678  fi Line 756  fi
756  rm -f _testprog _testprog.error _testprog.stdout  rm -f _testprog _testprog.error _testprog.stdout
757    
758    
759  #  -fmove-all-movables  #  -fomit-frame-pointer
760  printf "checking whether -fmove-all-movables can be used... "  printf "checking whether -fomit-frame-pointer can be used... "
761  $CC $CFLAGS -fmove-all-movables _testprog.c -o \  $CC $CFLAGS -fomit-frame-pointer _testprog.c -o \
762      _testprog > _testprog.stdout 2>&1      _testprog 1> _testprog.stdout 2>&1
763  cat _testprog.stdout >> _testprog.error  cat _testprog.stdout >> _testprog.error
764  if grep movables _testprog.error > /dev/null 2>&1; then  if grep frame _testprog.error > /dev/null 2>&1; then
765          printf "no\n"          printf "no\n"
766  else  else
767          if [ -x _testprog ]; then          if [ -x _testprog ]; then
768                  CFLAGS="-fmove-all-movables $CFLAGS"                  CFLAGS="-fomit-frame-pointer $CFLAGS"
769                  printf "yes\n"                  printf "yes\n"
770          else          else
771                  printf "no\n"                  printf "no\n"
# Line 696  fi Line 774  fi
774  rm -f _testprog _testprog.error _testprog.stdout  rm -f _testprog _testprog.error _testprog.stdout
775    
776    
777  #  -fomit-frame-pointer  #  -g
778  printf "checking whether -fomit-frame-pointer can be used... "  printf "checking whether -g can be used... "
779  $CC $CFLAGS -fomit-frame-pointer _testprog.c -o \  if [ z"$COMPAQCC" = zYES ]; then
780      _testprog 1> _testprog.stdout 2>&1          printf "skipping\n"
 cat _testprog.stdout >> _testprog.error  
 if grep frame _testprog.error > /dev/null 2>&1; then  
         printf "no\n"  
781  else  else
782            $CC $CFLAGS -g _testprog.c -o _testprog > _testprog.stdout 2>&1
783            cat _testprog.stdout >> _testprog.error
784          if [ -x _testprog ]; then          if [ -x _testprog ]; then
785                  CFLAGS="-fomit-frame-pointer $CFLAGS"                  CFLAGS="-g $CFLAGS"
786                  printf "yes\n"                  printf "yes\n"
787          else          else
788                  printf "no\n"                  printf "no\n"
# Line 792  fi Line 869  fi
869  rm -f _testr.[co] _testr  rm -f _testr.[co] _testr
870    
871    
872    #  strlcpy missing?
873    printf "checking for strlcpy... "
874    printf "#include <string.h>
875    int main(int argc, char *argv[]) { char *p; char *q; size_t x;
876      x = strlcpy(p, q, 50); return 0;}\n" > _tests.c
877    $CC $CFLAGS _tests.c -o _tests 2> /dev/null
878    if [ ! -x _tests ]; then
879            printf "missing, using mystrlcpy\n"
880            printf "#define strlcpy mystrlcpy\n" >> config.h
881            printf "#define strlcat mystrlcat\n" >> config.h
882            printf "#define USE_STRLCPY_REPLACEMENTS\n" >> config.h
883    else
884            printf "found\n"
885    fi
886    rm -f _tests.[co] _tests
887    
888    
889  #  strtoull missing?  #  strtoull missing?
890  printf "checking for strtoull... "  printf "checking for strtoull... "
891  printf "#include <stdlib.h>  printf "#include <stdlib.h>
# Line 804  if [ ! -x _tests ]; then Line 898  if [ ! -x _tests ]; then
898          printf "missing, using mystrtoull\n"          printf "missing, using mystrtoull\n"
899          printf "#define strtoull mystrtoull\n" >> config.h          printf "#define strtoull mystrtoull\n" >> config.h
900  else  else
901          printf "yes\n"          printf "found\n"
902  fi  fi
903  rm -f _testlong* _tests.[co] _tests  rm -f _tests.[co] _tests
904    
905    
906    #  mkstemp missing?
907    printf "checking for mkstemp... "
908    printf "#include <unistd.h>
909    int main(int argc, char *argv[]) { int x; char *y = \"abc\";
910    x = mkstemp(y); return 0;}\n" > _tests.c
911    $CC $CFLAGS _tests.c -o _tests 2> /dev/null
912    if [ ! -x _tests ]; then
913            printf "missing, using workaround\n"
914            printf "#define mkstemp mymkstemp\n" >> config.h
915    else
916            printf "found\n"
917    fi
918    rm -f _tests.[co] _tests
919    
920    
921  #  fseeko missing?  #  fseeko missing?
# Line 818  printf "#include <stdlib.h> Line 927  printf "#include <stdlib.h>
927  int main(int argc, char *argv[]) { fseeko(NULL, 0, 0); return 0;}\n" > _tests.c  int main(int argc, char *argv[]) { fseeko(NULL, 0, 0); return 0;}\n" > _tests.c
928  $CC $CFLAGS _tests.c -o _tests 2> /dev/null  $CC $CFLAGS _tests.c -o _tests 2> /dev/null
929  if [ ! -x _tests ]; then  if [ ! -x _tests ]; then
930          printf "no\n"          printf "missing\n"
931          printf "WARNING! fseeko missing from libc. Using a hack, "          printf "WARNING! fseeko missing from libc. Using a hack, "
932          printf "which probably doesn't work.\n"          printf "which probably doesn't work.\n"
933          printf "#define HACK_FSEEKO\n" >> config.h          printf "#define HACK_FSEEKO\n" >> config.h
934  else  else
935          printf "yes\n"          printf "found\n"
936  fi  fi
937  rm -f _tests.[co] _tests  rm -f _tests.[co] _tests
938    
# Line 841  if [ ! -x _tests ]; then Line 950  if [ ! -x _tests ]; then
950          printf "no, using int\n"          printf "no, using int\n"
951          CFLAGS="$CFLAGS -Dsocklen_t=int"          CFLAGS="$CFLAGS -Dsocklen_t=int"
952  else  else
953          printf "yes\n"          printf "socklen_t\n"
954  fi  fi
955  rm -f _tests.[co] _tests  rm -f _tests.[co] _tests
956    
# Line 913  rm -f _testoff.c _testoff Line 1022  rm -f _testoff.c _testoff
1022    
1023    
1024  #  Check for u_int8_t etc:  #  Check for u_int8_t etc:
1025    #  These are needed because some header files in src/include/ use u_int*
1026    #  instead of uint*, and I don't have time to rewrite them all.
1027  printf "checking for u_int8_t... "  printf "checking for u_int8_t... "
1028  printf "#include <stdio.h>\n#include <inttypes.h>\n#include <sys/types.h>\n  printf "#include <stdio.h>\n#include <inttypes.h>\n#include <sys/types.h>\n
1029  int main(int argc, char *argv[]){printf(\"%%i\\\n\",  int main(int argc, char *argv[]){printf(\"%%i\\\n\",
# Line 934  if [ ! -x _testuint ]; then Line 1045  if [ ! -x _testuint ]; then
1045          printf "typedef uint8_t u_int8_t;\n" >> config.h          printf "typedef uint8_t u_int8_t;\n" >> config.h
1046          printf "typedef uint16_t u_int16_t;\n" >> config.h          printf "typedef uint16_t u_int16_t;\n" >> config.h
1047          printf "typedef uint32_t u_int32_t;\n" >> config.h          printf "typedef uint32_t u_int32_t;\n" >> config.h
         printf "typedef uint64_t u_int64_t;\n" >> config.h  
1048          printf "uint8_t\n"          printf "uint8_t\n"
1049  else  else
1050          printf "yes\n"          printf "yes\n"
1051  fi  fi
1052  rm -f _testuint.c _testuint  rm -f _testuint.c _testuint
1053    
1054    printf "checking for u_int64_t... "
1055    printf "#include <stdio.h>\n#include <inttypes.h>\n#include <sys/types.h>\n
1056    int main(int argc, char *argv[]){printf(\"%%i\\\n\",
1057     (int)sizeof(u_int64_t));return 0;}\n" > _testuint.c
1058    $CC $CFLAGS _testuint.c -o _testuint 2> /dev/null
1059    if [ ! -x _testuint ]; then
1060            rm -f _testuint*
1061            printf "#include <stdio.h>\n#include <inttypes.h>
1062            \n#include <sys/types.h>\nint main(int argc, char *argv[])
1063            {printf(\"%%i\\\n\", (int)sizeof(uint64_t));return 0;}\n" > _testuint.c
1064            $CC $CFLAGS _testuint.c -o _testuint 2> /dev/null
1065            if [ ! -x _testuint ]; then
1066                    printf "no\n\nERROR: No u_int64_t or uint64_t. Aborting\n"
1067                    #  TODO: Automagically detect using various combinations
1068                    #  of char, int, short, long etc.
1069                    exit
1070            fi
1071    
1072            printf "typedef uint64_t u_int64_t;\n" >> config.h
1073            printf "uint64_t\n"
1074    else
1075            printf "yes\n"
1076    fi
1077    rm -f _testuint.c _testuint
1078    
1079    
1080  ###############################################################################  ###############################################################################
1081  #  #
1082  #  Dynamic binary translation (BINTRANS):  #  OLD binary translation (BINTRANS):
1083  #  #
1084  ###############################################################################  ###############################################################################
1085    
# Line 969  else Line 1104  else
1104                  BINTRANS=YES                  BINTRANS=YES
1105          fi          fi
1106    
1107          #  x86:  (all machines ending in "86" are treated as i386)          #  x86:
1108          if [ z"`uname -m|rev|cut -c1-2`" = z68 ]; then          if `uname -m|grep -v 64|grep -q 86`; then
1109                  printf "#define I386\n" >> config.h                  printf "#define I386\n" >> config.h
1110                  printf "#define BINTRANS\n" >> config.h                  printf "#define BINTRANS\n" >> config.h
1111                  printf "i386\n"                  printf "i386\n"
# Line 1008  fi Line 1143  fi
1143    
1144    
1145  ###############################################################################  ###############################################################################
1146    #
1147  #  Prefetch support?  #  Dyntrans recompilation (native backend) support:
1148  printf "checking for asm prefetch support... "  #
 if [ z"`uname -m`" = zalpha ]; then  
         rm -f _alpha_asm_test.c _alpha_asm_test  
         printf 'int main(int argc, char *argv[])  
          { int x; int *y = &x; asm ("ldl $31,0(%%0)" : : "g" (y));  
           return 0; }\n' > _alpha_asm_test.c  
         $CC $CFLAGS -O2 _alpha_asm_test.c -o _alpha_asm_test \  
             > /dev/null 2> /dev/null  
         if [ -x _alpha_asm_test ]; then  
 #               printf "#define HAVE_PREFETCH\n" >> config.h  
                 printf "#define PREFETCH(x) asm(\"ldl" >> config.h  
                 printf " \$31,0(%%0)\" : : \"g\" (x))\n" >> config.h  
                 echo "yes"  
                 PREFSUP=YES  
         fi  
         rm -f _alpha_asm_test.c _alpha_asm_test  
 fi  
 if [ z$PREFSUP = z ]; then  
         printf "#define PREFETCH(x) { }\n" >> config.h  
         echo "no"  
 fi  
   
   
1149  ###############################################################################  ###############################################################################
1150    
1151  INCLUDE=-Iinclude/  if [ z$DYNTRANSBACKEND = zYES ]; then
1152  DINCLUDE=-I../include/          printf "Dyntrans: Not yet.\n"
1153            exit
1154    
1155  echo C compiler flags: $CFLAGS $CWARNINGS          printf "checking for dyntrans backend... "
1156  echo Linker flags: $OTHERLIBS          DBFOUND=NO
 echo "CWARNINGS=$CWARNINGS" >> _Makefile.header  
 echo "COPTIM=$CFLAGS" >> _Makefile.header  
 echo "INCLUDE=$INCLUDE" >> _Makefile.header  
 echo "DINCLUDE=$DINCLUDE" >> _Makefile.header  
 echo "CC=$CC" >> _Makefile.header  
 echo "OTHERLIBS=$OTHERLIBS" >> _Makefile.header  
 echo "" >> _Makefile.header  
1157    
1158            #  Alpha:
1159            if [ z"`uname -m`" = zalpha ]; then
1160                    printf "#define DYNTRANS_BACKEND_ALPHA\n" >> config.h
1161                    printf "Alpha\n"
1162                    CPU_BACKENDS="$CPU_BACKENDS backend_alpha.o"
1163                    DBFOUND=YES
1164            fi
1165    
1166  printf "Regression test setup: (not really needed to build gxemul)\n"          #  AMD64:
1167            #  TODO
1168    
1169  ##  64-bit HPPA cross-assembler:  #       #  UltraSPARC:
1170  #  #       if [ z"`uname -m`" = zsun4u ]; then
1171  #HPPA=''  #               printf "#define DYNTRANS_BACKEND_SPARC64\n" >> config.h
1172  #if [ z$ENABLEHPPA = zYES ]; then  #               printf "UltraSPARC\n"
1173  #       printf "Checking for a GNU cross-assembler for 64-bit HPPA... "  #               CPU_BACKENDS="$CPU_BACKENDS backend_sparc.o"
1174  #       echo 'nop' > _testprog.s  #               DBFOUND=YES
1175  #  #       fi
1176  #       for HPPA_TRY in hppa64-unknown-elf hppa64-elf; do  #       if [ z"`uname -m`" = zsparc64 ]; then
1177  #               printf '#!/bin/sh\n'$HPPA_TRY'-as _testprog.s' > _test.sh  #               printf "#define DYNTRANS_BACKEND_SPARC64\n" >> config.h
1178  #               printf ' -o _testprog.o\n' >> _test.sh  #               printf "UltraSPARC\n"
1179  #               chmod 755 _test.sh  #               CPU_BACKENDS="$CPU_BACKENDS backend_sparc.o"
1180  #               rm -f _testprog.o  #               DBFOUND=YES
 #               ./_test.sh > /dev/null 2> /dev/null  
 #               if [ -f _testprog.o ]; then  
 #                       HPPA=$HPPA_TRY  
 #                       break  
 #               fi  
 #               rm -f _testprog.o  
 #       done  
 #  
 #       if [ z$HPPA = z ]; then  
 #               echo "none"  
 #       else  
 #               echo $HPPA"-gcc"  
1181  #       fi  #       fi
 #fi  
 #rm -f _testprog* _test.sh  
 #  
 ## TODO: are these ok?  64-bit mode!  
 ##echo "HPPA_CC="$HPPA"-gcc -g -O2 -fno-builtin -fschedule-insns" \  
 ##      >> _Makefile.header  
 #echo "HPPA_AS="$HPPA"-as " >> _Makefile.header  
 #echo "HPPA_LD="$HPPA"-ld -Ttext 0xa800000000030000 -e main" \  
 #    "--oformat=elf64-bigmips" >> _Makefile.header  
 #echo "" >> _Makefile.header  
1182    
1183            #  x86:
1184            if `uname -m|grep -q -v 64|grep -q 86`; then
1185                    printf "#define DYNTRANS_BACKEND_I386\n" >> config.h
1186                    printf "i386\n"
1187                    CPU_BACKENDS="$CPU_BACKENDS backend_i386.o"
1188                    DBFOUND=YES
1189            fi
1190    
1191  #  64-bit MIPS cross-compiler:          if [ z$DBFOUND = zYES ]; then
1192                    printf "#define DYNTRANS_BACKEND\n" >> config.h
1193            else
1194                    printf "not supported yet on this arch ("
1195                    printf `uname -m`
1196                    printf ")\n"
1197            fi
1198    fi
1199    
 MIPS=''  
 if [ z$ENABLEMIPS = zYES ]; then  
         printf "Checking for a GNU cross-compiler for 64-bit MIPS... "  
         echo 'int f(int x) { return x; }' > _testprog.c  
1200    
1201          for MIPS_TRY in mips64-unknown-elf mips64-elf mips-unknown-elf64; do  ###############################################################################
                 printf '#!/bin/sh\n'$MIPS_TRY'-gcc _testprog.c -c\n' > _test.sh  
                 chmod 755 _test.sh  
                 rm -f _testprog.o  
                 ./_test.sh > /dev/null 2> /dev/null  
                 if [ -f _testprog.o ]; then  
                         MIPS=$MIPS_TRY  
                         break  
                 fi  
                 rm -f _testprog.o  
         done  
1202    
1203          if [ z$MIPS = z ]; then  #  Host byte order?
1204                  echo "none"  printf "checking host endianness... "
1205    rm -f _test_end*
1206    printf '#include <stdio.h>
1207    int main(int argc, char *argv[])
1208    {  int x = 1; void *xp = (void *)&x; char *p = (char *)xp;
1209    if (*p) printf("little\\\n"); else printf("big\\\n"); }
1210    ' > _test_end.c
1211    $CC $CFLAGS _test_end.c -o _test_end 2> /dev/null
1212    X=`./_test_end`
1213    echo $X
1214    if [ z$X = zlittle ]; then
1215            printf "#define HOST_LITTLE_ENDIAN\n" >> config.h
1216    else
1217            if [ z$X = zbig ]; then
1218                    printf "#define HOST_BIG_ENDIAN\n" >> config.h
1219          else          else
1220                  echo $MIPS"-gcc"                  echo "Error! Could not determine host's endianness."
1221                    exit
1222          fi          fi
1223  fi  fi
1224  rm -f _testprog* _test.sh  rm -f _test_end*
1225    
1226  echo "MIPS_CC="$MIPS"-gcc -g -O2 -fno-builtin -fschedule-insns" \  ###############################################################################
1227      "-mips64 -mabi=64" >> _Makefile.header  
1228  echo "MIPS_AS="$MIPS"-as -mabi=64 -mips64" >> _Makefile.header  INCLUDE=-Iinclude/
1229  echo "MIPS_LD="$MIPS"-ld -Ttext 0xa800000000030000 -e main" \  DINCLUDE=-I../include/
     "--oformat=elf64-bigmips" >> _Makefile.header  
 echo "" >> _Makefile.header  
1230    
1231    rm -f _testprog.c
1232    
1233  ##  PPC64 cross-assembler:  echo C compiler flags: $CFLAGS $CWARNINGS
1234  #  echo Linker flags: $OTHERLIBS
1235  #PPC=''  echo "CWARNINGS=$CWARNINGS" >> _Makefile.header
1236  #if [ z$ENABLEPPC = zYES ]; then  echo "COPTIM=$CFLAGS" >> _Makefile.header
1237  #       printf "Checking for a GNU cross-assembler for 64-bit PPC... "  echo "INCLUDE=$INCLUDE" >> _Makefile.header
1238  #       echo 'nop' > _testprog.s  echo "DINCLUDE=$DINCLUDE" >> _Makefile.header
1239  #  echo "CC=$CC" >> _Makefile.header
1240  #       for a in ppc64 powerpc64; do  echo "OTHERLIBS=$OTHERLIBS" >> _Makefile.header
1241  #         for b in unknown; do  echo "CPU_ARCHS=$CPU_ARCHS" >> _Makefile.header
1242  #           for c in elf elf64 linux linux64 aix aix5; do  echo "CPU_BACKENDS=$CPU_BACKENDS" >> _Makefile.header
1243  #               PPC_TRY=$a-$b-$c  echo "CPU_TOOLS=$CPU_TOOLS" >> _Makefile.header
1244  #               printf '#!/bin/sh\n'$PPC_TRY'-as _testprog.s' > _test.sh  echo "" >> _Makefile.header
 #               printf ' -o _testprog.o\n' >> _test.sh  
 #               chmod 755 _test.sh  
 #               rm -f _testprog.o  
 #               ./_test.sh > /dev/null 2> /dev/null  
 #               if [ -f _testprog.o ]; then  
 #                       PPC=$PPC_TRY  
 #                       break  
 #               fi  
 #               rm -f _testprog.o  
 #           done  
 #         done  
 #       done  
 #  
 #       if [ z$PPC = z ]; then  
 #               echo "none"  
 #       else  
 #               echo $PPC"-as"  
 #       fi  
 #fi  
 #rm -f _testprog* _test.sh  
 #  
 ##echo "PPC_CC="$PPC"-gcc -g -O2 -fno-builtin" >> _Makefile.header  
 #echo "PPC_AS="$PPC"-as" >> _Makefile.header  
 #echo "PPC_LD="$PPC"-ld -e main" >> _Makefile.header  
 #echo "" >> _Makefile.header  
   
   
 ##  SPARC64 cross-compiler:  
 #  
 #SPARC=''  
 #if [ z$ENABLESPARC = zYES ]; then  
 #       printf "Checking for a GNU cross-compiler for 64-bit SPARC... "  
 #       echo 'int f(int x) { return x; }' > _testprog.c  
 #  
 #       for a in sparc64; do  
 #         for b in unknown; do  
 #           for c in elf elf64; do  
 #               SPARC_TRY=$a-$b-$c  
 #               printf '#!/bin/sh\n'$SPARC_TRY'-gcc _testprog.c -c' > _test.sh  
 #               printf ' -o _testprog.o\n' >> _test.sh  
 #               chmod 755 _test.sh  
 #               rm -f _testprog.o  
 #               ./_test.sh > /dev/null 2> /dev/null  
 #               if [ -f _testprog.o ]; then  
 #                       SPARC=$SPARC_TRY  
 #                       break  
 #               fi  
 #               rm -f _testprog.o  
 #           done  
 #         done  
 #       done  
 #  
 #       if [ z$SPARC = z ]; then  
 #               echo "none"  
 #       else  
 #               echo $SPARC"-gcc"  
 #       fi  
 #fi  
 #rm -f _testprog* _test.sh  
 #  
 #echo "SPARC_CC="$SPARC"-gcc -g -O2 -fno-builtin" >> _Makefile.header  
 #echo "SPARC_AS="$SPARC"-as" >> _Makefile.header  
 #echo "SPARC_LD="$SPARC"-ld -e main" >> _Makefile.header  
 #echo "" >> _Makefile.header  
1245    
1246    
1247  #  Create the Makefiles:  #  Create the Makefiles:
1248    D=". src src/include src/cpus src/devices src/devices/fonts"
1249  for a in . src src/devices src/devices/fonts tests; do  D="$D src/machines src/promemul"
1250    for a in $D; do
1251          echo "creating $a/Makefile"          echo "creating $a/Makefile"
1252          touch $a/Makefile          touch $a/Makefile
1253          cat _Makefile.header > $a/Makefile          cat _Makefile.header > $a/Makefile

Legend:
Removed from v.4  
changed lines
  Added in v.22

  ViewVC Help
Powered by ViewVC 1.1.26