home *** CD-ROM | disk | FTP | other *** search
/ PC Open 48 / pcopen48.iso / Internet / HtTrack / DATA1.CAB / Sources / src / configure next >
Encoding:
Text File  |  2001-01-21  |  7.0 KB  |  280 lines

  1. #!/bin/sh
  2. # No, this isn't generated by autoconf
  3. # Some parts are inspired by autoconf (Free Software Foundation), however
  4. # And the idea is slightly the same
  5.  
  6. # Usage:
  7. # './configure' and then 'make' and 'make install', or
  8. # './configure --make --install'
  9.  
  10. SHELL=/bin/sh
  11.  
  12. ac_prev=
  13. for ac_option
  14. do
  15.   # If the previous option needs an argument, assign it.
  16.   if test -n "$ac_prev"; then
  17.     eval "$ac_prev=\$ac_option"
  18.     ac_prev=
  19.     continue
  20.   fi
  21.  
  22.   case "$ac_option" in
  23.     -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
  24.     *) ac_optarg= ;;
  25.   esac
  26.  
  27.   case "$ac_option" in
  28.  
  29.   --nopthread | --nothread) THREADS=0   ;;
  30.   --pthread | --thread)     THREADS=1   ;;
  31.  
  32.   --nolonglong)             LONGLONG=0  ;;
  33.   --longlong)               LONGLONG=1  ;;
  34.  
  35.   --inaddrt)                NODECLINADDRT=0 ;;
  36.   --noinaddrt)              NODECLINADDRT=1 ;;
  37.  
  38.   --nouseuid)               NOUID=0     ;;
  39.   --useuid)                 NOUID=1     ;;
  40.  
  41.   --system=*)               SYSTEMTYPE="$ac_optarg" ;;
  42.   --system)                 ac_prev=SYSTEMTYPE ;;
  43.  
  44.   --debug)                  OTYPE="-O0 -g3" ;;
  45.  
  46.   --make)                   DOMAKE=1    ;;
  47.   --install)                DOINSTALL=1 ;;
  48.   --cls)
  49.     strip_cr *.c *.h
  50.     rm -f httrack 2>/dev/null
  51.     chmod 644 *.h *.c
  52.     chmod u+w *
  53.     exit    
  54.     ;;
  55.   -bindir | --bindir | --bindi | --bind | --bin | --bi)
  56.     ac_prev=bindir ;;
  57.   -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
  58.     bindir="$ac_optarg" ;;
  59.  
  60.   --help)
  61.     cat <<EOF
  62. --nopthread  : do not use threads (pthread.h)
  63. --pthread    : do     use threads (pthread.h)
  64. --nolonglong : do not use 64-bit int
  65. --longlong   : do     use 64-bit int
  66. --noinaddrt  : do not redeclare in_addr_t
  67. --inaddrt    : do     redeclare in_addr_t
  68. --nouseuid   : do not use setuid()/setgid()
  69. --useuid     : do     use setuid()/setgid()
  70. --system=<type> : override system type (uname) (types: 'Default','Linux','SunOS','AIX')
  71. --make       : 'make' after configure
  72. --install    : 'make install' after configure
  73. --debug      : add debug information (for gdb)
  74. EOF
  75.   exit
  76.   ;;
  77.  
  78.   *) echo "Unrecognized option: $ac_option" 
  79.      exit 
  80.      ;;
  81.  
  82.   esac
  83.  
  84. done
  85.  
  86. echo "Welcome to HTTrack Website Copier!"
  87. echo "Type in ./configure --help for more details"
  88. echo "If this script fails, you can enter supplemental options thtough '--option=value'"
  89. echo "or enter in manual make, through 'make help'"
  90. echo ""
  91.  
  92. if cp -f Makefile.in Makefile; then
  93.  
  94. SEDEXEC=
  95.  
  96. # System (OS) type?
  97. printf "Checking for OS type.. "
  98. if test -z "$SYSTEMTYPE"; then
  99.     SYSTEMTYPE="`uname`"
  100. fi
  101. case "$SYSTEMTYPE" in 
  102.     SunOS) printf "SunOS/Solaris\n"; 
  103.                PLATFORM=0
  104.                SOLSOCK=1
  105.                ;;
  106.     AIX)   printf "AIX\n";           PLATFORM=2 ;;
  107.     *)     printf "Linux type\n";    PLATFORM=3 ;;
  108. esac
  109.  
  110. WTYPE="-Wall -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wnested-externs"
  111.  
  112. if test -z "$OTYPE"; then
  113.     OTYPE="-O3"
  114. fi
  115.  
  116. # Binaries location
  117. if test -z "$BINPATH"; then
  118. printf "Checking for bin directory.. "
  119. if test -d "/usr/bin"; then
  120.     BINPATH="/usr/bin"
  121. else
  122.     BINPATH="/bin"
  123. fi
  124. printf "$BINPATH\n"
  125. else
  126.     echo "Overriding BINPATH=$BINPATH"
  127. fi
  128.  
  129. # 64-bit (long long) cause some troubles to some processors
  130. # because some alignements aren't properly defined
  131. # we only accept 64-bit on tested processors here
  132. if test -z "$LONGLONG"; then
  133. printf "Checking for long long.. "
  134. LONGLONG=
  135. if grep "long long" /usr/include/sys/types.h >/dev/null; then
  136. if uname -a|grep -E ' i[3-9]86 ' >/dev/null; then
  137.     LONGLONG=1
  138. fi
  139. fi
  140. if test -n "$LONGLONG"; then
  141.     printf "supported\n"
  142. else
  143.     printf "not tested/supported. Use --LONGLONG=1 to override\n"
  144. fi
  145. else
  146.     echo "Overriding LONGLONG=$LONGLONG"
  147. fi
  148.  
  149. # Do we not have to redeclare in_addr_t ?
  150. # Sometimes this type is defined, or not..
  151. if test -z "$NODECLINADDRT"; then
  152. printf "Checking for in_addr_t declaration in /usr/include/arpa/inet.h.. "
  153. if grep "in_addr_t" /usr/include/arpa/inet.h >/dev/null; then
  154.     printf "found, do not redeclare\n"
  155.     NODECLINADDRT=1
  156. else
  157.     printf "not found, declaring\n"
  158.     NODECLINADDRT=
  159. fi
  160. else
  161.     echo "Overriding NODECLINADDRT=$NODECLINADDRT"
  162. fi
  163.  
  164. # Sometimes, pthread.h doesn't exists on some systems
  165. # This is sad, because it speeds up some useful things, like DNS or ftp
  166. if test -z "$THREADS"; then
  167. printf "Checking for /usr/include/pthread.h.. "
  168. if test -f "/usr/include/pthread.h"; then
  169. if test -f "/usr/lib/libpthread.so"; then
  170.     printf "found\n"
  171.     THREADS=1
  172. else
  173.     printf "library not found, no threads will be available\n"
  174.     THREADS=
  175. fi
  176. else
  177.     printf "not found, no threads will be available\n"
  178.     THREADS=
  179. fi
  180. else
  181.     echo "Overriding THREADS=$THREADS"
  182. fi
  183.  
  184. # Sometimes, setuid and setgid can't be used (missing pwd.h and unistd.h ?!)
  185. if test -z "$NOUID"; then
  186. NOUID=1
  187. printf "Checking for /usr/include/pwd.h and /usr/include/unistd.h.. "
  188. if test -f "/usr/include/pwd.h"; then
  189. if test -f "/usr/include/unistd.h"; then
  190.     NOUID=
  191. fi
  192. fi
  193. if test -z "$NOUID"; then
  194.     printf "found\n"
  195. else
  196.     printf "not found, not using setuid() and setgid()\n"
  197. fi
  198. else
  199.     echo "Overriding NOUID=$NOUID"
  200. fi
  201.  
  202.  
  203. # Test variables
  204. if test "$NOUID" = 1; then
  205.     SEDEXEC="$SEDEXEC | sed -e 's/__DEFINEUID__/HTS_DO_NOT_USE_UID/'"
  206. fi
  207. if test "$NODECLINADDRT" = 1; then
  208.     SEDEXEC="$SEDEXEC | sed -e 's/__DEFINEINA__/HTS_DO_NOT_REDEFINE_in_addr_t/'"
  209. fi
  210. if test "$THREADS" = 1; then
  211.     SEDEXEC="$SEDEXEC | sed -e \"s/__CFLAGS__/$OTYPE $WTYPE -D_REENTRANT/g\""
  212.     SEDEXEC="$SEDEXEC | sed -e 's/__LFLAGS__/-lpthread/g'"
  213. else
  214.     SEDEXEC="$SEDEXEC | sed -e 's/__DEFINEPTH__/HTS_DO_NOT_USE_PTHREAD/'"
  215.     SEDEXEC="$SEDEXEC | sed -e \"s/__CFLAGS__/$OTYPE $WTYPE/g\""
  216.     SEDEXEC="$SEDEXEC | sed -e 's/__LFLAGS__//g'"
  217. fi
  218. if test "$SOLSOCK" = 1; then
  219.     SEDEXEC="$SEDEXEC | sed -e 's/__LFLAGS2__/-lnsl -lsocket/g'"
  220. else
  221.     SEDEXEC="$SEDEXEC | sed -e 's/__LFLAGS2__/-lpthread/g'"
  222. fi
  223. if test "$LONGLONG" = 0; then
  224.     SEDEXEC="$SEDEXEC | sed -e 's/__DEFINE64B__/HTS_NO_64_BIT/'"
  225. fi
  226. SEDEXEC="$SEDEXEC | sed -e \"s/__PLATFORM__/$PLATFORM/g\""
  227. SEDEXEC="$SEDEXEC | sed -e 's/#__AUTONAME__/AUTONAME  = auto/'"
  228. SEDEXEC="$SEDEXEC | sed -e 's/#define __DEFINE.*__//g'"
  229. TMP=`echo $BINPATH | sed -e 's/\\//\\\\\\//g'` 
  230. SEDEXEC="$SEDEXEC | sed -e \"s/#__BINPATH__/BINPATH = $TMP/g\""
  231.  
  232.  
  233. # Sed strip_cr
  234. printf "Checking for perl.. "
  235. PERLPATH=
  236. cp -f strip_cr.in strip_cr
  237. if test -f "/usr/bin/perl"; then
  238. PERLPATH=/usr/bin/perl
  239. else
  240. if test -f "/bin/perl"; then
  241. PERLPATH=/bin/perl
  242. fi
  243. fi
  244. if test -n "$PERLPATH"; then
  245. printf "found $PERLPATH\nEnsuring that *.c/*.h source files don't contains CR (^M).. "
  246. TMP=`echo $PERLPATH | sed -e 's/\\//\\\\\\//g'` 
  247. cat strip_cr | sed -e "s/__PERL__/$TMP/" >  __tmp; mv __tmp strip_cr
  248. chmod 700 strip_cr
  249. ./strip_cr *.c *.h
  250. printf "done\n"
  251. fi
  252.  
  253. # Sed all __VARS__
  254. CMD="cat Makefile $SEDEXEC > __tmp; mv __tmp Makefile"
  255. echo "Command: $CMD"
  256. if eval $CMD; then
  257.  
  258. echo ""
  259. echo "Makefile created!"
  260. echo "Type in 'make' to build and 'make install' to install"
  261.  
  262. if test -n "$DOMAKE"; then
  263.     echo "Making.."
  264.     make clean
  265.     make
  266. fi
  267. if test -n "$DOINSTALL"; then
  268.     echo "Installing.."
  269.     make install
  270. fi
  271.  
  272. else
  273.     echo "Error while seding Makefile.."
  274. fi
  275.  
  276. else
  277.     echo "Error copying Makefile.in -> Makefile.. giving up"
  278. fi
  279.  
  280.