home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Unix / Shells / zsh / Source / src / config / bz.makeprobe < prev    next >
Encoding:
Text File  |  1994-04-07  |  10.4 KB  |  498 lines

  1. # --- bz.makeprobe
  2.  
  3. # --- make groks VPATH?
  4.  
  5. test -z "$make_groks_VPATH_done" && . bz.makevpath
  6.  
  7. # -- 
  8.  
  9. if test -z "$B_justmake"
  10. then
  11.  
  12. cat <<foo
  13.     probing for Makefile...
  14.  
  15. foo
  16.  
  17. # --- cc?
  18.  
  19. test -z "$makecc_done" && . bz.makecc
  20.  
  21. # --- CFLAGS
  22.  
  23. if test -z "$C_CFLAGS"
  24. then
  25.  
  26. CFLAGS_D="$CFLAGS_D $C_CFLAGS_D"
  27.  
  28. CFLAGS_X="$CFLAGS_X $C_CFLAGS_X"
  29.  
  30. CFLAGS_W="$CFLAGS_W $C_CFLAGS_W"
  31.  
  32. if test -n "$B_debug"
  33. then
  34.   CFLAGS_g="`echo $CFLAGS_g $C_CFLAGS_g | sed 's/^ +$//'`"
  35.   test -z "$CFLAGS_g" && CFLAGS_g="$DEFAULT_C_CFLAGS_g"
  36. fi
  37.  
  38. if test -n "$B_zshdebug"
  39. then
  40.   CFLAGS_z="$CFLAGS_z $C_CFLAGS_z"
  41.   test -z "$CFLAGS_z" && CFLAGS_z="$DEFAULT_C_CFLAGS_z"
  42. fi
  43.  
  44. D_HP='-D_XOPEN_SOURCE -D_HPUX_SOURCE'
  45.  
  46. if test -n "$B_gcc" -o -n "$LINUX" -o -n "$NEXT"
  47. then
  48.   # NeXT 3.* has POSIX headers but no POSIX libs, sheesh
  49.   # LINUX has no prototypes for non-ANSI stuff, sheesh
  50.   if test -n "$LINUX" -o -n "$NEXT"
  51.   then
  52.     CFLAGS_W="$GCC_BASE0_W"    # no -ansi or -Wmissing-prototypes
  53.   else
  54.     CFLAGS_W="$GCC_BASE1_W"
  55.   fi
  56.   DEFAULT_C_CFLAGS_O=-O2
  57.   test -n "$B_mediumgcc" && CFLAGS_W="$CFLAGS_W $GCC_MEDIUM_W"
  58.   test -n "$B_strictgcc" && CFLAGS_W="$CFLAGS_W $GCC_STRICT_W"
  59.   test -n "$NEXT" -o -n "$LINUX" && CFLAGS_X="$CFLAGS_X -pipe"
  60.   test -z "$LINUX" -a -z "$NEXT" && CFLAGS_X="$CFLAGS_X -fpcc-struct-return"
  61.   test Z"$host" = Z"i486"        && CFLAGS_M="$CFLAGS_M -m486"
  62.   # if we have gcc, never mind that the native cc might be mips
  63.   CC_MIPS_STYLE=
  64. elif test -n "$APOLLO"
  65. then CFLAGS_W="$CFLAGS_W -A nansi"
  66. elif test -n "$HPUX"
  67. then
  68.   CFLAGS_D="$CFLAGS_D $D_HP -D_POSIX_SOURCE"
  69.   if test -n "$C89"
  70.   then CFLAGS_W="$CFLAGS_W +w1"
  71.   else test Z"$HPUX" = Z"7.03" && CFLAGS_X="$CFLAGS_X -Wc,-Ns5000"
  72.   fi
  73.   C_LDFLAGS="$C_LDFLAGS -z"
  74. elif test -n "$AIX"
  75. then test -n "$C89" && CFLAGS_D="$CFLAGS_D -D_ALL_SOURCE"
  76. elif test -n "$HPOSF"
  77. # HPOSF must be tested before OSF1
  78. then
  79.   CFLAGS_D="$CFLAGS_D $D_HP -D_OSF_SOURCE"
  80.   CFLAGS_W="$CFLAGS_W -q lang_level:ansi"
  81. elif test -n "$OSF1"            # NOTE: the -Olimit N 
  82. then CFLAGS_W="$CFLAGS_W -std1"    # is done later on
  83. elif test -n "$NEWS"            # as it will be useful
  84. then CFLAGS_W="$CFLAGS_W -std"    # only iff optimization
  85. elif test -n "$MIPS"            # will be used.
  86. then
  87.   CFLAGS_W="$CFLAGS_W -std1"
  88.   CFLAGS_X="$CFLAGS_X -Wf,-XNd5000 -Wf,-XNl4096"
  89. elif test -n "$CONVEX"
  90. then
  91. CFLAGS_W="$CFLAGS_W -d arg_ptr_qual=w -d arg_ptr_ref=w -d bad_escape=w -d class_ignored=w -d const_not_init=w -d division_by_zero=w -d dollar_names=w -d escape_range_sequence=w -d float_suffix=w -d function_parameter=w -d hidden_arg=w -d hidden_extern=w -d hides_outer=w -d implicit_decl=w -d integer_overflow=w -d long_long_suffix=w -d no_arg_type=w -d no_external_declaration=w -d no_newline=w -d non_int_bit_field=w -d nothing_declared=w -d pp_argcount=w -d pp_argsended=w -d pp_badstr=w -d pp_badtp=w -d pp_badtp_cmdl=w -d pp_error_directive=w -d pp_extra=w -d pp_idexpected=w -d pp_line_range=w -d pp_macro_arg=w -d pp_macro_redefinition=w -d pp_macro_redefinition_cmdl=w -d pp_malformed_directive=w -d pp_old_dir=w -d pp_parse=w -d pp_undef=w -d pp_undef_cmdl=w -d pp_unrecognized_directive=w -d pp_unrecognized_pragma=w -d ptr_cvt_truncates=w -d qualified_cast=w -d record_fn_call=w -d record_fn_defn=w -d shift_too_large=w -d short_cvt_truncates=w -d strict_syntax=w -d unsigned_suffix"
  92. elif test -n "$SOLARIS"
  93. then
  94. # -Xa would be nicer but it is strictish ANSI, while zsh
  95. # needs K&R, so -Xs (s=sun) it is
  96. # If you dream of -D_POSIX_SOURCE, quit dreaming.
  97.   DEFAULT_C_CFLAGS_O="$DEFAULT_C_CFLAGS_O -xO2"
  98.   CFLAGS_W="$CFLAGS_W -v -Xs"
  99. elif test -n "$UNICOS"
  100. then CFLAGS_W="$CFLAGS_W -h stdc"
  101. elif test -f ${headerdir}/ndir.h -a ! -f /usr/lib/libBSD.a
  102. then CFLAGS_W="$CFLAGS_W -Aa"
  103. elif test -n "$IRIX"
  104. then
  105.   CFLAGS_W="$CFLAGS_W -ansiposix -prototypes -fullwarn"
  106.   if test -n "$IRIX5"
  107.   then CFLAGS_W="$CFLAGS_W -woff 799"
  108.   else CFLAGS_W="$CFLAGS_W -woff 2,183,262,269,302,303,309"    # IRIX 4
  109.   fi
  110. fi
  111.  
  112. # optimization by default on
  113. CFLAGS_O="`echo $CFLAGS_O $C_CFLAGS_O | sed 's/^ +$//'`"
  114. test -z "$CFLAGS_O" && CFLAGS_O="$DEFAULT_C_CFLAGS_O"
  115.  
  116. if test -n "$B_noopt"
  117. then
  118.   CFLAGS_O=
  119. fi
  120.  
  121. fi
  122.  
  123. # --- do -c and -o work simultaneously?
  124.  
  125. if test -z "$F_bld_eq_src"
  126. then
  127.  
  128. cc_groks_c_o=
  129. cc_groks_c_o_done=
  130.  
  131. if test -z "$cc_groks_c_o_done"
  132. then
  133.  
  134. for co in $CC_GROK_c_o
  135. do
  136.  if test -n "`eval echo '$'$co`"
  137.  then
  138.    cc_groks_c_o=yep
  139.    cc_groks_c_o_done=yep
  140.    break
  141.  fi
  142. done
  143.  
  144. fi
  145.  
  146. if test -z "$cc_groks_c_o_done"
  147. then
  148.  
  149. for co in $CC_LOSE_c_o
  150. do
  151.  if test -n "`eval echo '$'$co`"
  152.  then
  153.    cc_groks_c_o=
  154.    cc_groks_c_o_done=yep
  155.    break
  156.  fi
  157. done
  158.  
  159. fi
  160.  
  161. if test -z "$cc_groks_c_o_done"
  162. then
  163.  
  164. # well, we must really test for it, then, mustn't we?
  165.  
  166. tmpc=/tmp/_tmp$$.c
  167. tmpo=/tmp/_tmp$$.o
  168.  
  169. trap "rm -f $tmpc $tmpo;$TRAPN" $TRAPSIGS
  170.  
  171. echo 'int foo=42;' > $tmpc
  172. # this C program *should* not elicit any other errors than just
  173. # the complaint about simultaneous -c and -o
  174. test -n "`($CC -c -o $tmpo $tmpc 2>&1)`" && cc_groks_c_o=
  175.  
  176. rm -f $tmpc $tmpo
  177.  
  178. cc_groks_c_o_done=yep
  179.  
  180. fi
  181.  
  182. if test -z "$cc_groks_c_o"
  183. then
  184.   if test -n "$F_bld_eq_src"
  185.   then
  186.     CC_JUST_C=yep
  187.   else
  188.     CC_LOSES_c_O=yep
  189.   fi
  190. fi
  191.  
  192. G_verb1_=Does
  193. G_subj_=$CC
  194. G_verb2_=understand
  195. set 'test -z "$cc_groks_c_o"' cc_groks_c_o 1 "-c and -o simultaneously"
  196. . bz.ifdef
  197.  
  198. fi
  199.  
  200. # --- do -g and -O work simultaneously?
  201.  
  202. if test -z "$B_noopt" -a -n "$B_debug" -a -n "$CFLAGS_O"
  203. then
  204.  
  205. cc_groks_g_O=
  206. cc_groks_g_O_done=
  207.  
  208. if test -z "$cc_groks_g_O_done"
  209. then
  210.  
  211. for co in $CC_LOSE_g_O
  212. do
  213.  if test -n "`eval echo '$'$co`"
  214.  then
  215.    cc_groks_g_O=
  216.    cc_groks_g_O_done=yep
  217.    break
  218.  fi
  219. done
  220.  
  221. fi
  222.  
  223. if test -z "$cc_groks_g_O_done"
  224. then
  225.  
  226. for co in $CC_GROK_g_O
  227. do
  228.  set Z `echo $co|tr -d "'" |tr ":" " "`
  229.  if test -n "`eval echo '$'$1`"
  230.  then
  231.    test -n "$3" && CFLAGS_g="$3"
  232.    test -n "$4" && CFLAGS_O="$4"
  233.    cc_groks_g_O=yep
  234.    cc_groks_g_O_done=yep
  235.    break
  236.  fi
  237. done
  238.  
  239. fi
  240.  
  241. if test -z "$cc_groks_g_O_done"
  242. then
  243.  
  244. # well, we must really test for it, then, mustn't we?
  245.  
  246. tmpc=/tmp/_tmp$$.c
  247. tmpo=/tmp/_tmp$$.o
  248.  
  249. trap "rm -f $tmpc $tmpo;$TRAPN" $TRAPSIGS
  250.  
  251. echo 'int foo=42;' > $tmpc
  252. # this C program *should* not elicit any other errors than just
  253. # the complaint about simultaneous -g and -O
  254. test -z "`($CC $CFLAGS_g $CFLAGS_O -o $tmpo -c $tmpc 2>&1)`" && cc_groks_g_O=yep
  255.  
  256. rm -f $tmpc $tmpo
  257.  
  258. cc_groks_g_O_done=yep
  259.  
  260. fi
  261.  
  262. G_verb1_=Does
  263. G_subj_=$CC
  264. G_verb2_=understand
  265. set 'test -n "$cc_groks_g_O"' cc_groks_g_O 1 "-g and -O simultaneously"
  266. . bz.ifdef
  267.  
  268. fi
  269.  
  270. # ---
  271.  
  272. if test -n "$CFLAGS_O" -a -n "$CFLAGS_g" -a -z "$cc_groks_g_O"
  273. then
  274.   echo "    ($CC cannot simultaneously optimize (-O) and debug (-g),"
  275.   if test -n "$B_debug"
  276.   then
  277.     echo "    turning off optimization...)"
  278.     CFLAGS_O=
  279.   elif test -z "$B_noopt"
  280.   then
  281.     echo "    turning off debug...)"
  282.     CFLAGS_g=
  283.   fi
  284. fi
  285.  
  286. ### Optimization complexity level
  287. # for MIPS style compilers
  288. if test -n "$CFLAGS_O" -a -n "$CC_MIPS_STYLE" -a -z "`echo $CFLAGS_O|grep Olimit`"
  289. then
  290.   CFLAGS_O="$CFLAGS_O -Olimit 1000"
  291. fi
  292.  
  293. if test -n "$B_query"
  294. then
  295.  
  296. set CFLAGS_O "$CFLAGS_O" "$CC optimizer flags (e.g. -O)"
  297. . bz.define
  298.  
  299. set CFLAGS_g "$CFLAGS_g" "$CC debug flags (e.g. -g)"
  300. . bz.define
  301.  
  302. set CFLAGS_X "$CFLAGS_X" "$CC additional flags (fancy -Defines, etc)"
  303. . bz.define
  304.  
  305. fi
  306.  
  307. # the final joining of various CFLAGS_
  308.  
  309. # non-optimizing CFLAGS
  310. CFLAGS_WO_O="`echo $CFLAGS_D $CFLAGS_W $CFLAGS_X $CFLAGS_g $CFLAGS_z $CFLAGS_M|sed 's/  */ /g'`"
  311.  
  312. CFLAGS_W_O="`echo $CFLAGS_WO_O $CFLAGS_O|sed 's/  */ /g'`"
  313.  
  314. if test -z "$CFLAGS" -a -n "$C_CFLAGS"
  315. then
  316.   CFLAGS="$C_CFLAGS"
  317. else
  318.   CFLAGS="$CFLAGS_W_O"
  319. fi
  320. set CFLAGS "$CFLAGS" "$CC flags"
  321. . bz.define
  322.  
  323. # LD
  324.  
  325. LD="$CC"
  326.  
  327. test -z "$LD" -a -n "$C_LD" && LD="$C_LD"
  328. test -z "$LD" && LD="$DEFAULT_C_LD"
  329. set LD "$LD" "linker"
  330. . bz.define
  331.  
  332. # LDFLAGS
  333.  
  334. LDFLAGS="`echo $CFLAGS_X $CFLAGS_M $CFLAGS_O $CFLAGS_g|sed 's/  */ /g'`"
  335.  
  336. test -n "$C_LDFLAGS" && LDFLAGS="$C_LDFLAGS"
  337. set LDFLAGS "$LDFLAGS" "link flags"
  338. . bz.define
  339.  
  340. # --- LIBS
  341.  
  342. if test -z "$LIBS"
  343. then
  344.  
  345.   if test -n "$IRIX"
  346.   then
  347.     if grep '^\+' /etc/passwd >/dev/null 2>&1
  348.     then LIBS='-lcurses -lmalloc -lbsd -lsun'
  349.     else LIBS='-lcurses -lmalloc -lbsd'
  350.     fi
  351.   elif test -n "$SOLARIS"
  352.   then LIBS='-ltermcap -lnsl'
  353.   elif test -n "$BBN"
  354.   then LIBS='-ltermcap -lposix'
  355.   elif test -n "$OSF1" -o -n "$TITAN" -o -n "$HPUX"
  356.   then LIBS='-ltermcap'
  357.   elif test -f /usr/lib/libcposix.a
  358.   then LIBS='-lcposix -ltermcap'
  359.   elif test -f /usr/lib/libBSD.a
  360.   then LIBS='-ltermcap -lBSD'
  361.   elif test -f /usr/lib/libtermcap.a -o -f /usr/ucblib/libtermcap.a
  362.   then
  363.     if test -n "$AIX"
  364.     then LIBS='-lcurses'    # -lbsd should not be needed
  365.     else LIBS='-ltermcap'
  366.     fi
  367.   fi
  368. fi
  369.  
  370. test -z "$LIBS" -a -n "$C_LIBS" && LIBS="$C_LIBS"
  371. test -z "$LIBS" && LIBS="$DEFAULT_C_LIBS"
  372. set LIBS "$LIBS" "libraries to link with"
  373. . bz.define
  374.  
  375. # -- modules
  376.  
  377. echo '    Working out modules (*.{[hco],pro})...'
  378.  
  379. modules="/tmp/modules$$"
  380. modules_c="${modules}.c"
  381. modules_h="${modules}.h"
  382. modules_o="${modules}.o"
  383. modules_p="${modules}.p"
  384.  
  385. trap "rm -f $modules $modules_c $modules_h $modules_o $modules_p;$TRAPN" $TRAPSIGS
  386.  
  387. (exec >$modules
  388. # C source files and header files, one file per line,
  389. # between "cat <<foo" and "foo"-lines
  390. cat <<foo
  391. builtin.c
  392. cond.c
  393. exec.c
  394. glob.c
  395. hist.c
  396. init.c
  397. jobs.c
  398. lex.c
  399. loop.c
  400. math.c
  401. mem.c
  402. params.c
  403. parse.c
  404. subst.c
  405. table.c
  406. text.c
  407. utils.c
  408. watch.c
  409. zle_bindings.c
  410. zle_hist.c
  411. zle_main.c
  412. zle_misc.c
  413. zle_move.c
  414. zle_refresh.c
  415. zle_tricky.c
  416. zle_utils.c
  417. zle_vi.c
  418. zle_word.c
  419. funcs.h
  420. zle.h
  421. zsh.h
  422. ztype.h
  423. foo
  424. )
  425.  
  426. echo '    .c....'
  427. egrep '\.c$' $modules > $modules_c
  428. SRC=`cat $modules_c|tr '\012' ' '`
  429.  
  430. # as SRC but without .c 
  431. BSRC=`cat $modules_c|sed 's/\.c$//'|tr '\012' ' '`
  432.  
  433. echo '    .h....'
  434. egrep '\.h$' $modules > $modules_h
  435. HEADER=`cat $modules_h | tr '\012' ' '`
  436.  
  437. test -n "$make_groks_VPATH" && c_blddir= || c_blddir="$C_BLDDIR"
  438.  
  439. echo '    .pro....'
  440. sed 's/\.c$/.pro/' < $modules_c | sed "s%^%$c_blddir%" > $modules_p
  441. PROTO=`cat $modules_p | tr '\012' ' '`
  442.  
  443. echo '    .o....'
  444. sed 's/\.c$/.o/' < $modules_c | sed "s%^%$c_blddir%" > $modules_o
  445. OBJS=`cat $modules_o | tr '\012' ' '`
  446.  
  447. rm -f $modules $modules_c $modules_h $modules_o $modules_p
  448.  
  449. {
  450.   echo
  451.   echo "    probed for Makefile..."
  452.   echo
  453. } >&2
  454.  
  455. fi
  456.  
  457. # -- find out how to build the .c.o rule
  458.  
  459. ccit='$(CC) $(CFLAGS) -c $(DFLAGS)'
  460. ccdotc='$<'
  461. ccseparate=
  462. makeprecd=
  463. makefflag=
  464. ccinc=
  465.  
  466. if test -z "$F_bld_eq_src"
  467. then
  468.   test -n "$C_SRCDIR" && ccinc=" -I$C_SRCDIR"
  469.   if test -z "$B_makeatbld"
  470.   then
  471.      makefflag="-f $MAKEFILE"
  472.      ccinc=" -I$C_BLDDIR"
  473.   else
  474.      makeprecmd="cd $C_BLDDIR && "
  475.      ccseparate=yep
  476.   fi
  477.   if test -n "$make_groks_VPATH"
  478.   then
  479.      if test -z "$B_makeatbld"
  480.      then
  481.        ccit="$ccit$ccinc -o ${C_BLDDIR}\$@ "
  482.      fi
  483.   else
  484.      if test -n "$B_makeatbld"
  485.      then
  486.        ccit="$ccit$ccinc"' -o `basename ${C_SRCDIR}\$@`'
  487.      else
  488.        ccseparate=yep
  489.      fi
  490.   fi
  491. fi
  492.  
  493. # all set
  494.  
  495. make_probe_done=yep
  496.  
  497. ###
  498.