tcl.m4 97 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246
  1. #------------------------------------------------------------------------
  2. # SC_PATH_TCLCONFIG --
  3. #
  4. # Locate the tclConfig.sh file and perform a sanity check on
  5. # the Tcl compile flags
  6. #
  7. # Arguments:
  8. # none
  9. #
  10. # Results:
  11. #
  12. # Adds the following arguments to configure:
  13. # --with-tcl=...
  14. #
  15. # Defines the following vars:
  16. # TCL_BIN_DIR Full path to the directory containing
  17. # the tclConfig.sh file
  18. #------------------------------------------------------------------------
  19. AC_DEFUN([SC_PATH_TCLCONFIG], [
  20. #
  21. # Ok, lets find the tcl configuration
  22. # First, look for one uninstalled.
  23. # the alternative search directory is invoked by --with-tcl
  24. #
  25. if test x"${no_tcl}" = x ; then
  26. # we reset no_tcl in case something fails here
  27. no_tcl=true
  28. AC_ARG_WITH(tcl, [ --with-tcl directory containing tcl configuration (tclConfig.sh)], with_tclconfig=${withval})
  29. AC_MSG_CHECKING([for Tcl configuration])
  30. AC_CACHE_VAL(ac_cv_c_tclconfig,[
  31. # First check to see if --with-tcl was specified.
  32. case "${host}" in
  33. *-*-cygwin*) platDir="win" ;;
  34. *) platDir="unix" ;;
  35. esac
  36. if test x"${with_tclconfig}" != x ; then
  37. if test -f "${with_tclconfig}/tclConfig.sh" ; then
  38. ac_cv_c_tclconfig=`(cd ${with_tclconfig}; pwd)`
  39. else
  40. AC_MSG_ERROR([${with_tclconfig} directory doesn't contain tclConfig.sh])
  41. fi
  42. fi
  43. # then check for a private Tcl installation
  44. if test x"${ac_cv_c_tclconfig}" = x ; then
  45. for i in \
  46. ../tcl \
  47. `ls -dr ../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
  48. `ls -dr ../tcl[[8-9]].[[0-9]] 2>/dev/null` \
  49. `ls -dr ../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
  50. ../../tcl \
  51. `ls -dr ../../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
  52. `ls -dr ../../tcl[[8-9]].[[0-9]] 2>/dev/null` \
  53. `ls -dr ../../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
  54. ../../../tcl \
  55. `ls -dr ../../../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
  56. `ls -dr ../../../tcl[[8-9]].[[0-9]] 2>/dev/null` \
  57. `ls -dr ../../../tcl[[8-9]].[[0-9]]* 2>/dev/null` ; do
  58. if test -f "$i/$platDir/tclConfig.sh" ; then
  59. ac_cv_c_tclconfig=`(cd $i/$platDir; pwd)`
  60. break
  61. fi
  62. done
  63. fi
  64. # on Darwin, check in Framework installation locations
  65. if test "`uname -s`" = "Darwin" -a x"${ac_cv_c_tclconfig}" = x ; then
  66. for i in `ls -d ~/Library/Frameworks 2>/dev/null` \
  67. `ls -d /Library/Frameworks 2>/dev/null` \
  68. `ls -d /Network/Library/Frameworks 2>/dev/null` \
  69. `ls -d /System/Library/Frameworks 2>/dev/null` \
  70. ; do
  71. if test -f "$i/Tcl.framework/tclConfig.sh" ; then
  72. ac_cv_c_tclconfig=`(cd $i/Tcl.framework; pwd)`
  73. break
  74. fi
  75. done
  76. fi
  77. # check in a few common install locations
  78. if test x"${ac_cv_c_tclconfig}" = x ; then
  79. for i in `ls -d ${libdir} 2>/dev/null` \
  80. `ls -d ${exec_prefix}/lib 2>/dev/null` \
  81. `ls -d ${prefix}/lib 2>/dev/null` \
  82. `ls -d /usr/local/lib 2>/dev/null` \
  83. `ls -d /usr/contrib/lib 2>/dev/null` \
  84. `ls -d /usr/lib 2>/dev/null` \
  85. ; do
  86. if test -f "$i/tclConfig.sh" ; then
  87. ac_cv_c_tclconfig=`(cd $i; pwd)`
  88. break
  89. fi
  90. done
  91. fi
  92. # check in a few other private locations
  93. if test x"${ac_cv_c_tclconfig}" = x ; then
  94. for i in \
  95. ${srcdir}/../tcl \
  96. `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
  97. `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]] 2>/dev/null` \
  98. `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]]* 2>/dev/null` ; do
  99. if test -f "$i/$platDir/tclConfig.sh" ; then
  100. ac_cv_c_tclconfig=`(cd $i/$platDir; pwd)`
  101. break
  102. fi
  103. done
  104. fi
  105. ])
  106. if test x"${ac_cv_c_tclconfig}" = x ; then
  107. TCL_BIN_DIR="# no Tcl configs found"
  108. AC_MSG_WARN([Can't find Tcl configuration definitions])
  109. else
  110. no_tcl=
  111. TCL_BIN_DIR=${ac_cv_c_tclconfig}
  112. AC_MSG_RESULT([found ${TCL_BIN_DIR}/tclConfig.sh])
  113. fi
  114. fi
  115. ])
  116. #------------------------------------------------------------------------
  117. # SC_PATH_TKCONFIG --
  118. #
  119. # Locate the tkConfig.sh file
  120. #
  121. # Arguments:
  122. # none
  123. #
  124. # Results:
  125. #
  126. # Adds the following arguments to configure:
  127. # --with-tk=...
  128. #
  129. # Defines the following vars:
  130. # TK_BIN_DIR Full path to the directory containing
  131. # the tkConfig.sh file
  132. #------------------------------------------------------------------------
  133. AC_DEFUN([SC_PATH_TKCONFIG], [
  134. #
  135. # Ok, lets find the tk configuration
  136. # First, look for one uninstalled.
  137. # the alternative search directory is invoked by --with-tk
  138. #
  139. if test x"${no_tk}" = x ; then
  140. # we reset no_tk in case something fails here
  141. no_tk=true
  142. AC_ARG_WITH(tk, [ --with-tk directory containing tk configuration (tkConfig.sh)], with_tkconfig=${withval})
  143. AC_MSG_CHECKING([for Tk configuration])
  144. AC_CACHE_VAL(ac_cv_c_tkconfig,[
  145. # First check to see if --with-tkconfig was specified.
  146. if test x"${with_tkconfig}" != x ; then
  147. if test -f "${with_tkconfig}/tkConfig.sh" ; then
  148. ac_cv_c_tkconfig=`(cd ${with_tkconfig}; pwd)`
  149. else
  150. AC_MSG_ERROR([${with_tkconfig} directory doesn't contain tkConfig.sh])
  151. fi
  152. fi
  153. # then check for a private Tk library
  154. case "${host}" in
  155. *-*-cygwin*) platDir="win" ;;
  156. *) platDir="unix" ;;
  157. esac
  158. if test x"${ac_cv_c_tkconfig}" = x ; then
  159. for i in \
  160. ../tk \
  161. `ls -dr ../tk[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
  162. `ls -dr ../tk[[8-9]].[[0-9]] 2>/dev/null` \
  163. `ls -dr ../tk[[8-9]].[[0-9]]* 2>/dev/null` \
  164. ../../tk \
  165. `ls -dr ../../tk[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
  166. `ls -dr ../../tk[[8-9]].[[0-9]] 2>/dev/null` \
  167. `ls -dr ../../tk[[8-9]].[[0-9]]* 2>/dev/null` \
  168. ../../../tk \
  169. `ls -dr ../../../tk[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
  170. `ls -dr ../../../tk[[8-9]].[[0-9]] 2>/dev/null` \
  171. `ls -dr ../../../tk[[8-9]].[[0-9]]* 2>/dev/null` ; do
  172. if test -f "$i/$platDir/tkConfig.sh" ; then
  173. ac_cv_c_tkconfig=`(cd $i/$platDir; pwd)`
  174. break
  175. fi
  176. done
  177. fi
  178. # on Darwin, check in Framework installation locations
  179. if test "`uname -s`" = "Darwin" -a x"${ac_cv_c_tkconfig}" = x ; then
  180. for i in `ls -d ~/Library/Frameworks 2>/dev/null` \
  181. `ls -d /Library/Frameworks 2>/dev/null` \
  182. `ls -d /Network/Library/Frameworks 2>/dev/null` \
  183. `ls -d /System/Library/Frameworks 2>/dev/null` \
  184. ; do
  185. if test -f "$i/Tk.framework/tkConfig.sh" ; then
  186. ac_cv_c_tkconfig=`(cd $i/Tk.framework; pwd)`
  187. break
  188. fi
  189. done
  190. fi
  191. # check in a few common install locations
  192. if test x"${ac_cv_c_tkconfig}" = x ; then
  193. for i in `ls -d ${libdir} 2>/dev/null` \
  194. `ls -d ${exec_prefix}/lib 2>/dev/null` \
  195. `ls -d ${prefix}/lib 2>/dev/null` \
  196. `ls -d /usr/local/lib 2>/dev/null` \
  197. `ls -d /usr/contrib/lib 2>/dev/null` \
  198. `ls -d /usr/lib 2>/dev/null` \
  199. ; do
  200. if test -f "$i/tkConfig.sh" ; then
  201. ac_cv_c_tkconfig=`(cd $i; pwd)`
  202. break
  203. fi
  204. done
  205. fi
  206. # check in a few other private locations
  207. if test x"${ac_cv_c_tkconfig}" = x ; then
  208. for i in \
  209. ${srcdir}/../tk \
  210. `ls -dr ${srcdir}/../tk[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
  211. `ls -dr ${srcdir}/../tk[[8-9]].[[0-9]] 2>/dev/null` \
  212. `ls -dr ${srcdir}/../tk[[8-9]].[[0-9]]* 2>/dev/null` ; do
  213. if test -f "$i/$platDir/tkConfig.sh" ; then
  214. ac_cv_c_tkconfig=`(cd $i/$platDir; pwd)`
  215. break
  216. fi
  217. done
  218. fi
  219. ])
  220. if test x"${ac_cv_c_tkconfig}" = x ; then
  221. TK_BIN_DIR="# no Tk configs found"
  222. AC_MSG_WARN([Can't find Tk configuration definitions])
  223. else
  224. no_tk=
  225. TK_BIN_DIR=${ac_cv_c_tkconfig}
  226. AC_MSG_RESULT([found ${TK_BIN_DIR}/tkConfig.sh])
  227. fi
  228. fi
  229. ])
  230. #------------------------------------------------------------------------
  231. # SC_LOAD_TCLCONFIG --
  232. #
  233. # Load the tclConfig.sh file
  234. #
  235. # Arguments:
  236. #
  237. # Requires the following vars to be set:
  238. # TCL_BIN_DIR
  239. #
  240. # Results:
  241. #
  242. # Subst the following vars:
  243. # TCL_BIN_DIR
  244. # TCL_SRC_DIR
  245. # TCL_LIB_FILE
  246. #
  247. #------------------------------------------------------------------------
  248. AC_DEFUN([SC_LOAD_TCLCONFIG], [
  249. AC_MSG_CHECKING([for existence of ${TCL_BIN_DIR}/tclConfig.sh])
  250. if test -f "${TCL_BIN_DIR}/tclConfig.sh" ; then
  251. AC_MSG_RESULT([loading])
  252. . ${TCL_BIN_DIR}/tclConfig.sh
  253. else
  254. AC_MSG_RESULT([could not find ${TCL_BIN_DIR}/tclConfig.sh])
  255. fi
  256. # eval is required to do the TCL_DBGX substitution
  257. eval "TCL_LIB_FILE=\"${TCL_LIB_FILE}\""
  258. eval "TCL_STUB_LIB_FILE=\"${TCL_STUB_LIB_FILE}\""
  259. # If the TCL_BIN_DIR is the build directory (not the install directory),
  260. # then set the common variable name to the value of the build variables.
  261. # For example, the variable TCL_LIB_SPEC will be set to the value
  262. # of TCL_BUILD_LIB_SPEC. An extension should make use of TCL_LIB_SPEC
  263. # instead of TCL_BUILD_LIB_SPEC since it will work with both an
  264. # installed and uninstalled version of Tcl.
  265. if test -f "${TCL_BIN_DIR}/Makefile" ; then
  266. TCL_LIB_SPEC=${TCL_BUILD_LIB_SPEC}
  267. TCL_STUB_LIB_SPEC=${TCL_BUILD_STUB_LIB_SPEC}
  268. TCL_STUB_LIB_PATH=${TCL_BUILD_STUB_LIB_PATH}
  269. elif test "`uname -s`" = "Darwin"; then
  270. # If Tcl was built as a framework, attempt to use the libraries
  271. # from the framework at the given location so that linking works
  272. # against Tcl.framework installed in an arbitrary location.
  273. case ${TCL_DEFS} in
  274. *TCL_FRAMEWORK*)
  275. if test -f "${TCL_BIN_DIR}/${TCL_LIB_FILE}"; then
  276. for i in "`cd ${TCL_BIN_DIR}; pwd`" \
  277. "`cd ${TCL_BIN_DIR}/../..; pwd`"; do
  278. if test "`basename "$i"`" = "${TCL_LIB_FILE}.framework"; then
  279. TCL_LIB_SPEC="-F`dirname "$i"` -framework ${TCL_LIB_FILE}"
  280. break
  281. fi
  282. done
  283. fi
  284. if test -f "${TCL_BIN_DIR}/${TCL_STUB_LIB_FILE}"; then
  285. TCL_STUB_LIB_SPEC="-L${TCL_BIN_DIR} ${TCL_STUB_LIB_FLAG}"
  286. TCL_STUB_LIB_PATH="${TCL_BIN_DIR}/${TCL_STUB_LIB_FILE}"
  287. fi
  288. ;;
  289. esac
  290. fi
  291. # eval is required to do the TCL_DBGX substitution
  292. eval "TCL_LIB_FLAG=\"${TCL_LIB_FLAG}\""
  293. eval "TCL_LIB_SPEC=\"${TCL_LIB_SPEC}\""
  294. eval "TCL_STUB_LIB_FLAG=\"${TCL_STUB_LIB_FLAG}\""
  295. eval "TCL_STUB_LIB_SPEC=\"${TCL_STUB_LIB_SPEC}\""
  296. AC_SUBST(TCL_VERSION)
  297. AC_SUBST(TCL_PATCH_LEVEL)
  298. AC_SUBST(TCL_BIN_DIR)
  299. AC_SUBST(TCL_SRC_DIR)
  300. AC_SUBST(TCL_LIB_FILE)
  301. AC_SUBST(TCL_LIB_FLAG)
  302. AC_SUBST(TCL_LIB_SPEC)
  303. AC_SUBST(TCL_STUB_LIB_FILE)
  304. AC_SUBST(TCL_STUB_LIB_FLAG)
  305. AC_SUBST(TCL_STUB_LIB_SPEC)
  306. ])
  307. #------------------------------------------------------------------------
  308. # SC_LOAD_TKCONFIG --
  309. #
  310. # Load the tkConfig.sh file
  311. #
  312. # Arguments:
  313. #
  314. # Requires the following vars to be set:
  315. # TK_BIN_DIR
  316. #
  317. # Results:
  318. #
  319. # Sets the following vars that should be in tkConfig.sh:
  320. # TK_BIN_DIR
  321. #------------------------------------------------------------------------
  322. AC_DEFUN([SC_LOAD_TKCONFIG], [
  323. AC_MSG_CHECKING([for existence of ${TK_BIN_DIR}/tkConfig.sh])
  324. if test -f "${TK_BIN_DIR}/tkConfig.sh" ; then
  325. AC_MSG_RESULT([loading])
  326. . ${TK_BIN_DIR}/tkConfig.sh
  327. else
  328. AC_MSG_RESULT([could not find ${TK_BIN_DIR}/tkConfig.sh])
  329. fi
  330. # eval is required to do the TK_DBGX substitution
  331. eval "TK_LIB_FILE=\"${TK_LIB_FILE}\""
  332. eval "TK_STUB_LIB_FILE=\"${TK_STUB_LIB_FILE}\""
  333. # If the TK_BIN_DIR is the build directory (not the install directory),
  334. # then set the common variable name to the value of the build variables.
  335. # For example, the variable TK_LIB_SPEC will be set to the value
  336. # of TK_BUILD_LIB_SPEC. An extension should make use of TK_LIB_SPEC
  337. # instead of TK_BUILD_LIB_SPEC since it will work with both an
  338. # installed and uninstalled version of Tcl.
  339. if test -f "${TK_BIN_DIR}/Makefile" ; then
  340. TK_LIB_SPEC=${TK_BUILD_LIB_SPEC}
  341. TK_STUB_LIB_SPEC=${TK_BUILD_STUB_LIB_SPEC}
  342. TK_STUB_LIB_PATH=${TK_BUILD_STUB_LIB_PATH}
  343. elif test "`uname -s`" = "Darwin"; then
  344. # If Tk was built as a framework, attempt to use the libraries
  345. # from the framework at the given location so that linking works
  346. # against Tk.framework installed in an arbitrary location.
  347. case ${TK_DEFS} in
  348. *TK_FRAMEWORK*)
  349. if test -f "${TK_BIN_DIR}/${TK_LIB_FILE}"; then
  350. for i in "`cd ${TK_BIN_DIR}; pwd`" \
  351. "`cd ${TK_BIN_DIR}/../..; pwd`"; do
  352. if test "`basename "$i"`" = "${TK_LIB_FILE}.framework"; then
  353. TK_LIB_SPEC="-F`dirname "$i"` -framework ${TK_LIB_FILE}"
  354. break
  355. fi
  356. done
  357. fi
  358. if test -f "${TK_BIN_DIR}/${TK_STUB_LIB_FILE}"; then
  359. TK_STUB_LIB_SPEC="-L${TK_BIN_DIR} ${TK_STUB_LIB_FLAG}"
  360. TK_STUB_LIB_PATH="${TK_BIN_DIR}/${TK_STUB_LIB_FILE}"
  361. fi
  362. ;;
  363. esac
  364. fi
  365. # eval is required to do the TK_DBGX substitution
  366. eval "TK_LIB_FLAG=\"${TK_LIB_FLAG}\""
  367. eval "TK_LIB_SPEC=\"${TK_LIB_SPEC}\""
  368. eval "TK_STUB_LIB_FLAG=\"${TK_STUB_LIB_FLAG}\""
  369. eval "TK_STUB_LIB_SPEC=\"${TK_STUB_LIB_SPEC}\""
  370. AC_SUBST(TK_VERSION)
  371. AC_SUBST(TK_BIN_DIR)
  372. AC_SUBST(TK_SRC_DIR)
  373. AC_SUBST(TK_LIB_FILE)
  374. AC_SUBST(TK_LIB_FLAG)
  375. AC_SUBST(TK_LIB_SPEC)
  376. AC_SUBST(TK_STUB_LIB_FILE)
  377. AC_SUBST(TK_STUB_LIB_FLAG)
  378. AC_SUBST(TK_STUB_LIB_SPEC)
  379. ])
  380. #------------------------------------------------------------------------
  381. # SC_PROG_TCLSH
  382. # Locate a tclsh shell installed on the system path. This macro
  383. # will only find a Tcl shell that already exists on the system.
  384. # It will not find a Tcl shell in the Tcl build directory or
  385. # a Tcl shell that has been installed from the Tcl build directory.
  386. # If a Tcl shell can't be located on the PATH, then TCLSH_PROG will
  387. # be set to "". Extensions should take care not to create Makefile
  388. # rules that are run by default and depend on TCLSH_PROG. An
  389. # extension can't assume that an executable Tcl shell exists at
  390. # build time.
  391. #
  392. # Arguments
  393. # none
  394. #
  395. # Results
  396. # Subst's the following values:
  397. # TCLSH_PROG
  398. #------------------------------------------------------------------------
  399. AC_DEFUN([SC_PROG_TCLSH], [
  400. AC_MSG_CHECKING([for tclsh])
  401. AC_CACHE_VAL(ac_cv_path_tclsh, [
  402. search_path=`echo ${PATH} | sed -e 's/:/ /g'`
  403. for dir in $search_path ; do
  404. for j in `ls -r $dir/tclsh[[8-9]]* 2> /dev/null` \
  405. `ls -r $dir/tclsh* 2> /dev/null` ; do
  406. if test x"$ac_cv_path_tclsh" = x ; then
  407. if test -f "$j" ; then
  408. ac_cv_path_tclsh=$j
  409. break
  410. fi
  411. fi
  412. done
  413. done
  414. ])
  415. if test -f "$ac_cv_path_tclsh" ; then
  416. TCLSH_PROG="$ac_cv_path_tclsh"
  417. AC_MSG_RESULT([$TCLSH_PROG])
  418. else
  419. # It is not an error if an installed version of Tcl can't be located.
  420. TCLSH_PROG=""
  421. AC_MSG_RESULT([No tclsh found on PATH])
  422. fi
  423. AC_SUBST(TCLSH_PROG)
  424. ])
  425. #------------------------------------------------------------------------
  426. # SC_BUILD_TCLSH
  427. # Determine the fully qualified path name of the tclsh executable
  428. # in the Tcl build directory. This macro will correctly determine
  429. # the name of the tclsh executable even if tclsh has not yet
  430. # been built in the build directory. The build tclsh must be used
  431. # when running tests from an extension build directory. It is not
  432. # correct to use the TCLSH_PROG in cases like this.
  433. #
  434. # Arguments
  435. # none
  436. #
  437. # Results
  438. # Subst's the following values:
  439. # BUILD_TCLSH
  440. #------------------------------------------------------------------------
  441. AC_DEFUN([SC_BUILD_TCLSH], [
  442. AC_MSG_CHECKING([for tclsh in Tcl build directory])
  443. BUILD_TCLSH=${TCL_BIN_DIR}/tclsh
  444. AC_MSG_RESULT([$BUILD_TCLSH])
  445. AC_SUBST(BUILD_TCLSH)
  446. ])
  447. #------------------------------------------------------------------------
  448. # SC_ENABLE_SHARED --
  449. #
  450. # Allows the building of shared libraries
  451. #
  452. # Arguments:
  453. # none
  454. #
  455. # Results:
  456. #
  457. # Adds the following arguments to configure:
  458. # --enable-shared=yes|no
  459. #
  460. # Defines the following vars:
  461. # STATIC_BUILD Used for building import/export libraries
  462. # on Windows.
  463. #
  464. # Sets the following vars:
  465. # SHARED_BUILD Value of 1 or 0
  466. #------------------------------------------------------------------------
  467. AC_DEFUN([SC_ENABLE_SHARED], [
  468. AC_MSG_CHECKING([how to build libraries])
  469. AC_ARG_ENABLE(shared,
  470. [ --enable-shared build and link with shared libraries [--enable-shared]],
  471. [tcl_ok=$enableval], [tcl_ok=yes])
  472. if test "${enable_shared+set}" = set; then
  473. enableval="$enable_shared"
  474. tcl_ok=$enableval
  475. else
  476. tcl_ok=yes
  477. fi
  478. if test "$tcl_ok" = "yes" ; then
  479. AC_MSG_RESULT([shared])
  480. SHARED_BUILD=1
  481. else
  482. AC_MSG_RESULT([static])
  483. SHARED_BUILD=0
  484. AC_DEFINE(STATIC_BUILD)
  485. fi
  486. ])
  487. #------------------------------------------------------------------------
  488. # SC_ENABLE_FRAMEWORK --
  489. #
  490. # Allows the building of shared libraries into frameworks
  491. #
  492. # Arguments:
  493. # none
  494. #
  495. # Results:
  496. #
  497. # Adds the following arguments to configure:
  498. # --enable-framework=yes|no
  499. #
  500. # Sets the following vars:
  501. # FRAMEWORK_BUILD Value of 1 or 0
  502. #------------------------------------------------------------------------
  503. AC_DEFUN([SC_ENABLE_FRAMEWORK], [
  504. if test "`uname -s`" = "Darwin" ; then
  505. AC_MSG_CHECKING([how to package libraries])
  506. AC_ARG_ENABLE(framework,
  507. [ --enable-framework package shared libraries in MacOSX frameworks [--disable-framework]],
  508. [enable_framework=$enableval], [enable_framework=no])
  509. if test $enable_framework = yes; then
  510. if test $SHARED_BUILD = 0; then
  511. AC_MSG_WARN([Frameworks can only be built if --enable-shared is yes])
  512. enable_framework=no
  513. fi
  514. if test $tcl_corefoundation = no; then
  515. AC_MSG_WARN([Frameworks can only be used when CoreFoundation is available])
  516. enable_framework=no
  517. fi
  518. fi
  519. if test $enable_framework = yes; then
  520. AC_MSG_RESULT([framework])
  521. FRAMEWORK_BUILD=1
  522. else
  523. if test $SHARED_BUILD = 1; then
  524. AC_MSG_RESULT([shared library])
  525. else
  526. AC_MSG_RESULT([static library])
  527. fi
  528. FRAMEWORK_BUILD=0
  529. fi
  530. fi
  531. ])
  532. #------------------------------------------------------------------------
  533. # SC_ENABLE_THREADS --
  534. #
  535. # Specify if thread support should be enabled. TCL_THREADS is
  536. # checked so that if you are compiling an extension against a
  537. # threaded core, your extension must be compiled threaded as well.
  538. #
  539. # Arguments:
  540. # none
  541. #
  542. # Results:
  543. #
  544. # Adds the following arguments to configure:
  545. # --enable-threads
  546. #
  547. # Sets the following vars:
  548. # THREADS_LIBS Thread library(s)
  549. #
  550. # Defines the following vars:
  551. # TCL_THREADS
  552. # _REENTRANT
  553. # _THREAD_SAFE
  554. #
  555. #------------------------------------------------------------------------
  556. AC_DEFUN([SC_ENABLE_THREADS], [
  557. AC_ARG_ENABLE(threads, [ --enable-threads build with threads],
  558. [tcl_ok=$enableval], [tcl_ok=no])
  559. if test "${TCL_THREADS}" = 1; then
  560. tcl_threaded_core=1;
  561. fi
  562. if test "$tcl_ok" = "yes" -o "${TCL_THREADS}" = 1; then
  563. TCL_THREADS=1
  564. # USE_THREAD_ALLOC tells us to try the special thread-based
  565. # allocator that significantly reduces lock contention
  566. AC_DEFINE(USE_THREAD_ALLOC)
  567. AC_DEFINE(_REENTRANT)
  568. if test "`uname -s`" = "SunOS" ; then
  569. AC_DEFINE(_POSIX_PTHREAD_SEMANTICS)
  570. fi
  571. AC_DEFINE(_THREAD_SAFE)
  572. AC_CHECK_LIB(pthread,pthread_mutex_init,tcl_ok=yes,tcl_ok=no)
  573. if test "$tcl_ok" = "no"; then
  574. # Check a little harder for __pthread_mutex_init in the same
  575. # library, as some systems hide it there until pthread.h is
  576. # defined. We could alternatively do an AC_TRY_COMPILE with
  577. # pthread.h, but that will work with libpthread really doesn't
  578. # exist, like AIX 4.2. [Bug: 4359]
  579. AC_CHECK_LIB(pthread, __pthread_mutex_init,
  580. tcl_ok=yes, tcl_ok=no)
  581. fi
  582. if test "$tcl_ok" = "yes"; then
  583. # The space is needed
  584. THREADS_LIBS=" -lpthread"
  585. else
  586. AC_CHECK_LIB(pthreads, pthread_mutex_init,
  587. tcl_ok=yes, tcl_ok=no)
  588. if test "$tcl_ok" = "yes"; then
  589. # The space is needed
  590. THREADS_LIBS=" -lpthreads"
  591. else
  592. AC_CHECK_LIB(c, pthread_mutex_init,
  593. tcl_ok=yes, tcl_ok=no)
  594. if test "$tcl_ok" = "no"; then
  595. AC_CHECK_LIB(c_r, pthread_mutex_init,
  596. tcl_ok=yes, tcl_ok=no)
  597. if test "$tcl_ok" = "yes"; then
  598. # The space is needed
  599. THREADS_LIBS=" -pthread"
  600. else
  601. TCL_THREADS=0
  602. AC_MSG_WARN([Don't know how to find pthread lib on your system - you must disable thread support or edit the LIBS in the Makefile...])
  603. fi
  604. fi
  605. fi
  606. fi
  607. # Does the pthread-implementation provide
  608. # 'pthread_attr_setstacksize' ?
  609. ac_saved_libs=$LIBS
  610. LIBS="$LIBS $THREADS_LIBS"
  611. AC_CHECK_FUNCS(pthread_attr_setstacksize)
  612. AC_CHECK_FUNCS(pthread_atfork)
  613. LIBS=$ac_saved_libs
  614. else
  615. TCL_THREADS=0
  616. fi
  617. # Do checking message here to not mess up interleaved configure output
  618. AC_MSG_CHECKING([for building with threads])
  619. if test "${TCL_THREADS}" = 1; then
  620. AC_DEFINE(TCL_THREADS, 1, [Are we building with threads enabled?])
  621. if test "${tcl_threaded_core}" = 1; then
  622. AC_MSG_RESULT([yes (threaded core)])
  623. else
  624. AC_MSG_RESULT([yes])
  625. fi
  626. else
  627. AC_MSG_RESULT([no (default)])
  628. fi
  629. AC_SUBST(TCL_THREADS)
  630. ])
  631. #------------------------------------------------------------------------
  632. # SC_ENABLE_SYMBOLS --
  633. #
  634. # Specify if debugging symbols should be used.
  635. # Memory (TCL_MEM_DEBUG) and compile (TCL_COMPILE_DEBUG) debugging
  636. # can also be enabled.
  637. #
  638. # Arguments:
  639. # none
  640. #
  641. # Requires the following vars to be set in the Makefile:
  642. # CFLAGS_DEBUG
  643. # CFLAGS_OPTIMIZE
  644. # LDFLAGS_DEBUG
  645. # LDFLAGS_OPTIMIZE
  646. #
  647. # Results:
  648. #
  649. # Adds the following arguments to configure:
  650. # --enable-symbols
  651. #
  652. # Defines the following vars:
  653. # CFLAGS_DEFAULT Sets to $(CFLAGS_DEBUG) if true
  654. # Sets to $(CFLAGS_OPTIMIZE) if false
  655. # LDFLAGS_DEFAULT Sets to $(LDFLAGS_DEBUG) if true
  656. # Sets to $(LDFLAGS_OPTIMIZE) if false
  657. # DBGX Debug library extension
  658. #
  659. #------------------------------------------------------------------------
  660. AC_DEFUN([SC_ENABLE_SYMBOLS], [
  661. AC_MSG_CHECKING([for build with symbols])
  662. AC_ARG_ENABLE(symbols, [ --enable-symbols build with debugging symbols [--disable-symbols]], [tcl_ok=$enableval], [tcl_ok=no])
  663. # FIXME: Currently, LDFLAGS_DEFAULT is not used, it should work like CFLAGS_DEFAULT.
  664. if test "$tcl_ok" = "no"; then
  665. CFLAGS_DEFAULT='$(CFLAGS_OPTIMIZE)'
  666. LDFLAGS_DEFAULT='$(LDFLAGS_OPTIMIZE)'
  667. DBGX=""
  668. AC_MSG_RESULT([no])
  669. else
  670. CFLAGS_DEFAULT='$(CFLAGS_DEBUG)'
  671. LDFLAGS_DEFAULT='$(LDFLAGS_DEBUG)'
  672. DBGX=g
  673. if test "$tcl_ok" = "yes"; then
  674. AC_MSG_RESULT([yes (standard debugging)])
  675. fi
  676. fi
  677. AC_SUBST(CFLAGS_DEFAULT)
  678. AC_SUBST(LDFLAGS_DEFAULT)
  679. if test "$tcl_ok" = "mem" -o "$tcl_ok" = "all"; then
  680. AC_DEFINE(TCL_MEM_DEBUG)
  681. fi
  682. if test "$tcl_ok" = "compile" -o "$tcl_ok" = "all"; then
  683. AC_DEFINE(TCL_COMPILE_DEBUG)
  684. AC_DEFINE(TCL_COMPILE_STATS)
  685. fi
  686. if test "$tcl_ok" != "yes" -a "$tcl_ok" != "no"; then
  687. if test "$tcl_ok" = "all"; then
  688. AC_MSG_RESULT([enabled symbols mem compile debugging])
  689. else
  690. AC_MSG_RESULT([enabled $tcl_ok debugging])
  691. fi
  692. fi
  693. ])
  694. #------------------------------------------------------------------------
  695. # SC_ENABLE_LANGINFO --
  696. #
  697. # Allows use of modern nl_langinfo check for better l10n.
  698. # This is only relevant for Unix.
  699. #
  700. # Arguments:
  701. # none
  702. #
  703. # Results:
  704. #
  705. # Adds the following arguments to configure:
  706. # --enable-langinfo=yes|no (default is yes)
  707. #
  708. # Defines the following vars:
  709. # HAVE_LANGINFO Triggers use of nl_langinfo if defined.
  710. #
  711. #------------------------------------------------------------------------
  712. AC_DEFUN([SC_ENABLE_LANGINFO], [
  713. AC_ARG_ENABLE(langinfo,
  714. [ --enable-langinfo use nl_langinfo if possible to determine
  715. encoding at startup, otherwise use old heuristic],
  716. [langinfo_ok=$enableval], [langinfo_ok=yes])
  717. HAVE_LANGINFO=0
  718. if test "$langinfo_ok" = "yes"; then
  719. AC_CHECK_HEADER(langinfo.h,[langinfo_ok=yes],[langinfo_ok=no])
  720. fi
  721. AC_MSG_CHECKING([whether to use nl_langinfo])
  722. if test "$langinfo_ok" = "yes"; then
  723. AC_CACHE_VAL(tcl_cv_langinfo_h, [
  724. AC_TRY_COMPILE([#include <langinfo.h>], [nl_langinfo(CODESET);],
  725. [tcl_cv_langinfo_h=yes],[tcl_cv_langinfo_h=no])])
  726. AC_MSG_RESULT([$tcl_cv_langinfo_h])
  727. if test $tcl_cv_langinfo_h = yes; then
  728. AC_DEFINE(HAVE_LANGINFO)
  729. fi
  730. else
  731. AC_MSG_RESULT([$langinfo_ok])
  732. fi
  733. ])
  734. #--------------------------------------------------------------------
  735. # SC_CONFIG_MANPAGES
  736. #
  737. # Decide whether to use symlinks for linking the manpages,
  738. # whether to compress the manpages after installation, and
  739. # whether to add a package name suffix to the installed
  740. # manpages to avoidfile name clashes.
  741. # If compression is enabled also find out what file name suffix
  742. # the given compression program is using.
  743. #
  744. # Arguments:
  745. # none
  746. #
  747. # Results:
  748. #
  749. # Adds the following arguments to configure:
  750. # --enable-man-symlinks
  751. # --enable-man-compression=PROG
  752. # --enable-man-suffix[=STRING]
  753. #
  754. # Defines the following variable:
  755. #
  756. # MAN_FLAGS - The appropriate flags for installManPage
  757. # according to the user's selection.
  758. #
  759. #--------------------------------------------------------------------
  760. AC_DEFUN([SC_CONFIG_MANPAGES], [
  761. AC_MSG_CHECKING([whether to use symlinks for manpages])
  762. AC_ARG_ENABLE(man-symlinks,
  763. [ --enable-man-symlinks use symlinks for the manpages],
  764. test "$enableval" != "no" && MAN_FLAGS="$MAN_FLAGS --symlinks",
  765. enableval="no")
  766. AC_MSG_RESULT([$enableval])
  767. AC_MSG_CHECKING([whether to compress the manpages])
  768. AC_ARG_ENABLE(man-compression,
  769. [ --enable-man-compression=PROG
  770. compress the manpages with PROG],
  771. [case $enableval in
  772. yes) AC_MSG_ERROR([missing argument to --enable-man-compression]);;
  773. no) ;;
  774. *) MAN_FLAGS="$MAN_FLAGS --compress $enableval";;
  775. esac],
  776. enableval="no")
  777. AC_MSG_RESULT([$enableval])
  778. if test "$enableval" != "no"; then
  779. AC_MSG_CHECKING([for compressed file suffix])
  780. touch TeST
  781. $enableval TeST
  782. Z=`ls TeST* | sed 's/^....//'`
  783. rm -f TeST*
  784. MAN_FLAGS="$MAN_FLAGS --extension $Z"
  785. AC_MSG_RESULT([$Z])
  786. fi
  787. AC_MSG_CHECKING([whether to add a package name suffix for the manpages])
  788. AC_ARG_ENABLE(man-suffix,
  789. [ --enable-man-suffix=STRING
  790. use STRING as a suffix to manpage file names
  791. (default: $1)],
  792. [case $enableval in
  793. yes) enableval="$1" MAN_FLAGS="$MAN_FLAGS --suffix $enableval";;
  794. no) ;;
  795. *) MAN_FLAGS="$MAN_FLAGS --suffix $enableval";;
  796. esac],
  797. enableval="no")
  798. AC_MSG_RESULT([$enableval])
  799. AC_SUBST(MAN_FLAGS)
  800. ])
  801. #--------------------------------------------------------------------
  802. # SC_CONFIG_SYSTEM
  803. #
  804. # Determine what the system is (some things cannot be easily checked
  805. # on a feature-driven basis, alas). This can usually be done via the
  806. # "uname" command, but there are a few systems, like Next, where
  807. # this doesn't work.
  808. #
  809. # Arguments:
  810. # none
  811. #
  812. # Results:
  813. # Defines the following var:
  814. #
  815. # system - System/platform/version identification code.
  816. #
  817. #--------------------------------------------------------------------
  818. AC_DEFUN([SC_CONFIG_SYSTEM], [
  819. AC_CACHE_CHECK([system version], tcl_cv_sys_version, [
  820. if test -f /usr/lib/NextStep/software_version; then
  821. tcl_cv_sys_version=NEXTSTEP-`awk '/3/,/3/' /usr/lib/NextStep/software_version`
  822. else
  823. tcl_cv_sys_version=`uname -s`-`uname -r`
  824. if test "$?" -ne 0 ; then
  825. AC_MSG_WARN([can't find uname command])
  826. tcl_cv_sys_version=unknown
  827. else
  828. # Special check for weird MP-RAS system (uname returns weird
  829. # results, and the version is kept in special file).
  830. if test -r /etc/.relid -a "X`uname -n`" = "X`uname -s`" ; then
  831. tcl_cv_sys_version=MP-RAS-`awk '{print $[3]}' /etc/.relid`
  832. fi
  833. if test "`uname -s`" = "AIX" ; then
  834. tcl_cv_sys_version=AIX-`uname -v`.`uname -r`
  835. fi
  836. fi
  837. fi
  838. ])
  839. system=$tcl_cv_sys_version
  840. ])
  841. #--------------------------------------------------------------------
  842. # SC_CONFIG_CFLAGS
  843. #
  844. # Try to determine the proper flags to pass to the compiler
  845. # for building shared libraries and other such nonsense.
  846. #
  847. # Arguments:
  848. # none
  849. #
  850. # Results:
  851. #
  852. # Defines and substitutes the following vars:
  853. #
  854. # DL_OBJS - Name of the object file that implements dynamic
  855. # loading for Tcl on this system.
  856. # DL_LIBS - Library file(s) to include in tclsh and other base
  857. # applications in order for the "load" command to work.
  858. # LDFLAGS - Flags to pass to the compiler when linking object
  859. # files into an executable application binary such
  860. # as tclsh.
  861. # LD_SEARCH_FLAGS-Flags to pass to ld, such as "-R /usr/local/tcl/lib",
  862. # that tell the run-time dynamic linker where to look
  863. # for shared libraries such as libtcl.so. Depends on
  864. # the variable LIB_RUNTIME_DIR in the Makefile. Could
  865. # be the same as CC_SEARCH_FLAGS if ${CC} is used to link.
  866. # CC_SEARCH_FLAGS-Flags to pass to ${CC}, such as "-Wl,-rpath,/usr/local/tcl/lib",
  867. # that tell the run-time dynamic linker where to look
  868. # for shared libraries such as libtcl.so. Depends on
  869. # the variable LIB_RUNTIME_DIR in the Makefile.
  870. # MAKE_LIB - Command to execute to build the a library;
  871. # differs when building shared or static.
  872. # MAKE_STUB_LIB -
  873. # Command to execute to build a stub library.
  874. # INSTALL_LIB - Command to execute to install a library;
  875. # differs when building shared or static.
  876. # INSTALL_STUB_LIB -
  877. # Command to execute to install a stub library.
  878. # STLIB_LD - Base command to use for combining object files
  879. # into a static library.
  880. # SHLIB_CFLAGS - Flags to pass to cc when compiling the components
  881. # of a shared library (may request position-independent
  882. # code, among other things).
  883. # SHLIB_LD - Base command to use for combining object files
  884. # into a shared library.
  885. # SHLIB_LD_LIBS - Dependent libraries for the linker to scan when
  886. # creating shared libraries. This symbol typically
  887. # goes at the end of the "ld" commands that build
  888. # shared libraries. The value of the symbol is
  889. # "${LIBS}" if all of the dependent libraries should
  890. # be specified when creating a shared library. If
  891. # dependent libraries should not be specified (as on
  892. # SunOS 4.x, where they cause the link to fail, or in
  893. # general if Tcl and Tk aren't themselves shared
  894. # libraries), then this symbol has an empty string
  895. # as its value.
  896. # SHLIB_SUFFIX - Suffix to use for the names of dynamically loadable
  897. # extensions. An empty string means we don't know how
  898. # to use shared libraries on this platform.
  899. # TCL_SHLIB_LD_EXTRAS - Additional element which are added to SHLIB_LD_LIBS
  900. # TK_SHLIB_LD_EXTRAS for the build of Tcl and Tk, but not recorded in the
  901. # tclConfig.sh, since they are only used for the build
  902. # of Tcl and Tk.
  903. # Examples: MacOS X records the library version and
  904. # compatibility version in the shared library. But
  905. # of course the Tcl version of this is only used for Tcl.
  906. # LIB_SUFFIX - Specifies everything that comes after the "libfoo"
  907. # in a static or shared library name, using the $VERSION variable
  908. # to put the version in the right place. This is used
  909. # by platforms that need non-standard library names.
  910. # Examples: ${VERSION}.so.1.1 on NetBSD, since it needs
  911. # to have a version after the .so, and ${VERSION}.a
  912. # on AIX, since a shared library needs to have
  913. # a .a extension whereas shared objects for loadable
  914. # extensions have a .so extension. Defaults to
  915. # ${VERSION}${SHLIB_SUFFIX}.
  916. # TCL_NEEDS_EXP_FILE -
  917. # 1 means that an export file is needed to link to a
  918. # shared library.
  919. # TCL_EXP_FILE - The name of the installed export / import file which
  920. # should be used to link to the Tcl shared library.
  921. # Empty if Tcl is unshared.
  922. # TCL_BUILD_EXP_FILE -
  923. # The name of the built export / import file which
  924. # should be used to link to the Tcl shared library.
  925. # Empty if Tcl is unshared.
  926. # CFLAGS_DEBUG -
  927. # Flags used when running the compiler in debug mode
  928. # CFLAGS_OPTIMIZE -
  929. # Flags used when running the compiler in optimize mode
  930. # CFLAGS - Additional CFLAGS added as necessary (usually 64-bit)
  931. #
  932. #--------------------------------------------------------------------
  933. AC_DEFUN([SC_CONFIG_CFLAGS], [
  934. # Step 0.a: Enable 64 bit support?
  935. AC_MSG_CHECKING([if 64bit support is requested])
  936. AC_ARG_ENABLE(64bit,[ --enable-64bit enable 64bit support (where applicable)],
  937. [do64bit=$enableval], [do64bit=no])
  938. AC_MSG_RESULT([$do64bit])
  939. # Step 0.b: Enable Solaris 64 bit VIS support?
  940. AC_MSG_CHECKING([if 64bit Sparc VIS support is requested])
  941. AC_ARG_ENABLE(64bit-vis,[ --enable-64bit-vis enable 64bit Sparc VIS support],
  942. [do64bitVIS=$enableval], [do64bitVIS=no])
  943. AC_MSG_RESULT([$do64bitVIS])
  944. if test "$do64bitVIS" = "yes"; then
  945. # Force 64bit on with VIS
  946. do64bit=yes
  947. fi
  948. # Step 1: set the variable "system" to hold the name and version number
  949. # for the system.
  950. SC_CONFIG_SYSTEM
  951. # Step 2: check for existence of -ldl library. This is needed because
  952. # Linux can use either -ldl or -ldld for dynamic loading.
  953. AC_CHECK_LIB(dl, dlopen, have_dl=yes, have_dl=no)
  954. # Require ranlib early so we can override it in special cases below.
  955. AC_REQUIRE([AC_PROG_RANLIB])
  956. # Step 3: set configuration options based on system name and version.
  957. do64bit_ok=no
  958. LDFLAGS_ORIG="$LDFLAGS"
  959. TCL_EXPORT_FILE_SUFFIX=""
  960. UNSHARED_LIB_SUFFIX=""
  961. TCL_TRIM_DOTS='`echo ${VERSION} | tr -d .`'
  962. ECHO_VERSION='`echo ${VERSION}`'
  963. TCL_LIB_VERSIONS_OK=ok
  964. CFLAGS_DEBUG=-g
  965. CFLAGS_OPTIMIZE=-O
  966. if test "$GCC" = "yes" ; then
  967. CFLAGS_WARNING="-Wall -Wno-implicit-int -fno-strict-aliasing"
  968. else
  969. CFLAGS_WARNING=""
  970. fi
  971. TCL_NEEDS_EXP_FILE=0
  972. TCL_BUILD_EXP_FILE=""
  973. TCL_EXP_FILE=""
  974. dnl FIXME: Replace AC_CHECK_PROG with AC_CHECK_TOOL once cross compiling is fixed.
  975. dnl AC_CHECK_TOOL(AR, ar)
  976. AC_CHECK_PROG(AR, ar, ar)
  977. if test "${AR}" = "" ; then
  978. AC_MSG_ERROR([Required archive tool 'ar' not found on PATH.])
  979. fi
  980. STLIB_LD='${AR} cr'
  981. LD_LIBRARY_PATH_VAR="LD_LIBRARY_PATH"
  982. PLAT_OBJS=""
  983. PLAT_SRCS=""
  984. case $system in
  985. AIX-*)
  986. if test "${TCL_THREADS}" = "1" -a "$GCC" != "yes" ; then
  987. # AIX requires the _r compiler when gcc isn't being used
  988. case "${CC}" in
  989. *_r)
  990. # ok ...
  991. ;;
  992. *)
  993. CC=${CC}_r
  994. ;;
  995. esac
  996. AC_MSG_RESULT([Using $CC for compiling with threads])
  997. fi
  998. LIBS="$LIBS -lc"
  999. SHLIB_CFLAGS=""
  1000. # Note: need the LIBS below, otherwise Tk won't find Tcl's
  1001. # symbols when dynamically loaded into tclsh.
  1002. SHLIB_LD_LIBS='${LIBS}'
  1003. SHLIB_SUFFIX=".so"
  1004. DL_OBJS="tclLoadDl.o"
  1005. LD_LIBRARY_PATH_VAR="LIBPATH"
  1006. # Check to enable 64-bit flags for compiler/linker on AIX 4+
  1007. if test "$do64bit" = "yes" -a "`uname -v`" -gt "3" ; then
  1008. if test "$GCC" = "yes" ; then
  1009. AC_MSG_WARN([64bit mode not supported with GCC on $system])
  1010. else
  1011. do64bit_ok=yes
  1012. CFLAGS="$CFLAGS -q64"
  1013. LDFLAGS="$LDFLAGS -q64"
  1014. RANLIB="${RANLIB} -X64"
  1015. AR="${AR} -X64"
  1016. SHLIB_LD_FLAGS="-b64"
  1017. fi
  1018. fi
  1019. if test "`uname -m`" = "ia64" ; then
  1020. # AIX-5 uses ELF style dynamic libraries on IA-64, but not PPC
  1021. SHLIB_LD="/usr/ccs/bin/ld -G -z text"
  1022. # AIX-5 has dl* in libc.so
  1023. DL_LIBS=""
  1024. if test "$GCC" = "yes" ; then
  1025. CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
  1026. else
  1027. CC_SEARCH_FLAGS='-R${LIB_RUNTIME_DIR}'
  1028. fi
  1029. LD_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}'
  1030. else
  1031. if test "$GCC" = "yes" ; then
  1032. SHLIB_LD="gcc -shared"
  1033. else
  1034. SHLIB_LD="/bin/ld -bhalt:4 -bM:SRE -bE:lib.exp -H512 -T512 -bnoentry"
  1035. fi
  1036. SHLIB_LD="${TCL_SRC_DIR}/unix/ldAix ${SHLIB_LD} ${SHLIB_LD_FLAGS}"
  1037. DL_LIBS="-ldl"
  1038. CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
  1039. LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
  1040. TCL_NEEDS_EXP_FILE=1
  1041. TCL_EXPORT_FILE_SUFFIX='${VERSION}\$\{DBGX\}.exp'
  1042. fi
  1043. # AIX v<=4.1 has some different flags than 4.2+
  1044. if test "$system" = "AIX-4.1" -o "`uname -v`" -lt "4" ; then
  1045. LIBOBJS="$LIBOBJS tclLoadAix.o"
  1046. DL_LIBS="-lld"
  1047. fi
  1048. # On AIX <=v4 systems, libbsd.a has to be linked in to support
  1049. # non-blocking file IO. This library has to be linked in after
  1050. # the MATH_LIBS or it breaks the pow() function. The way to
  1051. # insure proper sequencing, is to add it to the tail of MATH_LIBS.
  1052. # This library also supplies gettimeofday.
  1053. #
  1054. # AIX does not have a timezone field in struct tm. When the AIX
  1055. # bsd library is used, the timezone global and the gettimeofday
  1056. # methods are to be avoided for timezone deduction instead, we
  1057. # deduce the timezone by comparing the localtime result on a
  1058. # known GMT value.
  1059. AC_CHECK_LIB(bsd, gettimeofday, libbsd=yes, libbsd=no)
  1060. if test $libbsd = yes; then
  1061. MATH_LIBS="$MATH_LIBS -lbsd"
  1062. AC_DEFINE(USE_DELTA_FOR_TZ)
  1063. fi
  1064. ;;
  1065. BeOS*)
  1066. SHLIB_CFLAGS="-fPIC"
  1067. SHLIB_LD="${CC} -nostart"
  1068. SHLIB_LD_LIBS='${LIBS}'
  1069. SHLIB_SUFFIX=".so"
  1070. DL_OBJS="tclLoadDl.o"
  1071. DL_LIBS="-ldl"
  1072. #-----------------------------------------------------------
  1073. # Check for inet_ntoa in -lbind, for BeOS (which also needs
  1074. # -lsocket, even if the network functions are in -lnet which
  1075. # is always linked to, for compatibility.
  1076. #-----------------------------------------------------------
  1077. AC_CHECK_LIB(bind, inet_ntoa, [LIBS="$LIBS -lbind -lsocket"])
  1078. ;;
  1079. BSD/OS-2.1*|BSD/OS-3*)
  1080. SHLIB_CFLAGS=""
  1081. SHLIB_LD="shlicc -r"
  1082. SHLIB_LD_LIBS='${LIBS}'
  1083. SHLIB_SUFFIX=".so"
  1084. DL_OBJS="tclLoadDl.o"
  1085. DL_LIBS="-ldl"
  1086. CC_SEARCH_FLAGS=""
  1087. LD_SEARCH_FLAGS=""
  1088. ;;
  1089. BSD/OS-4.*)
  1090. SHLIB_CFLAGS="-export-dynamic -fPIC"
  1091. SHLIB_LD="cc -shared"
  1092. SHLIB_LD_LIBS='${LIBS}'
  1093. SHLIB_SUFFIX=".so"
  1094. DL_OBJS="tclLoadDl.o"
  1095. DL_LIBS="-ldl"
  1096. LDFLAGS="$LDFLAGS -export-dynamic"
  1097. CC_SEARCH_FLAGS=""
  1098. LD_SEARCH_FLAGS=""
  1099. ;;
  1100. dgux*)
  1101. SHLIB_CFLAGS="-K PIC"
  1102. SHLIB_LD="cc -G"
  1103. SHLIB_LD_LIBS=""
  1104. SHLIB_SUFFIX=".so"
  1105. DL_OBJS="tclLoadDl.o"
  1106. DL_LIBS="-ldl"
  1107. CC_SEARCH_FLAGS=""
  1108. LD_SEARCH_FLAGS=""
  1109. ;;
  1110. HP-UX-*.11.*)
  1111. # Use updated header definitions where possible
  1112. AC_DEFINE(_XOPEN_SOURCE) # Use the XOPEN network library
  1113. AC_DEFINE(_XOPEN_SOURCE_EXTENDED) # Use the XOPEN network library
  1114. LIBS="$LIBS -lxnet" # Use the XOPEN network library
  1115. if test "`uname -m`" = "ia64" ; then
  1116. SHLIB_SUFFIX=".so"
  1117. else
  1118. SHLIB_SUFFIX=".sl"
  1119. fi
  1120. AC_CHECK_LIB(dld, shl_load, tcl_ok=yes, tcl_ok=no)
  1121. if test "$tcl_ok" = yes; then
  1122. SHLIB_CFLAGS="+z"
  1123. SHLIB_LD="ld -b"
  1124. SHLIB_LD_LIBS='${LIBS}'
  1125. DL_OBJS="tclLoadShl.o"
  1126. DL_LIBS="-ldld"
  1127. LDFLAGS="$LDFLAGS -Wl,-E"
  1128. CC_SEARCH_FLAGS='-Wl,+s,+b,${LIB_RUNTIME_DIR}:.'
  1129. LD_SEARCH_FLAGS='+s +b ${LIB_RUNTIME_DIR}:.'
  1130. LD_LIBRARY_PATH_VAR="SHLIB_PATH"
  1131. fi
  1132. if test "$GCC" = "yes" ; then
  1133. SHLIB_LD="gcc -shared"
  1134. SHLIB_LD_LIBS='${LIBS}'
  1135. LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
  1136. fi
  1137. # Users may want PA-RISC 1.1/2.0 portable code - needs HP cc
  1138. #CFLAGS="$CFLAGS +DAportable"
  1139. # Check to enable 64-bit flags for compiler/linker
  1140. if test "$do64bit" = "yes" ; then
  1141. if test "$GCC" = "yes" ; then
  1142. hpux_arch=`${CC} -dumpmachine`
  1143. case $hpux_arch in
  1144. hppa64*)
  1145. # 64-bit gcc in use. Fix flags for GNU ld.
  1146. do64bit_ok=yes
  1147. SHLIB_LD="${CC} -shared"
  1148. SHLIB_LD_LIBS='${LIBS}'
  1149. CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
  1150. LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
  1151. ;;
  1152. *)
  1153. AC_MSG_WARN([64bit mode not supported with GCC on $system])
  1154. ;;
  1155. esac
  1156. else
  1157. do64bit_ok=yes
  1158. CFLAGS="$CFLAGS +DD64"
  1159. LDFLAGS="$LDFLAGS +DD64"
  1160. fi
  1161. fi
  1162. ;;
  1163. HP-UX-*.08.*|HP-UX-*.09.*|HP-UX-*.10.*)
  1164. SHLIB_SUFFIX=".sl"
  1165. AC_CHECK_LIB(dld, shl_load, tcl_ok=yes, tcl_ok=no)
  1166. if test "$tcl_ok" = yes; then
  1167. SHLIB_CFLAGS="+z"
  1168. SHLIB_LD="ld -b"
  1169. SHLIB_LD_LIBS=""
  1170. DL_OBJS="tclLoadShl.o"
  1171. DL_LIBS="-ldld"
  1172. LDFLAGS="$LDFLAGS -Wl,-E"
  1173. CC_SEARCH_FLAGS='-Wl,+s,+b,${LIB_RUNTIME_DIR}:.'
  1174. LD_SEARCH_FLAGS='+s +b ${LIB_RUNTIME_DIR}:.'
  1175. LD_LIBRARY_PATH_VAR="SHLIB_PATH"
  1176. fi
  1177. ;;
  1178. IRIX-4.*)
  1179. SHLIB_CFLAGS="-G 0"
  1180. SHLIB_SUFFIX=".a"
  1181. SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r -G 0"
  1182. SHLIB_LD_LIBS='${LIBS}'
  1183. DL_OBJS="tclLoadAout.o"
  1184. DL_LIBS=""
  1185. LDFLAGS="$LDFLAGS -Wl,-D,08000000"
  1186. CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
  1187. LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
  1188. SHARED_LIB_SUFFIX='${VERSION}\$\{DBGX\}.a'
  1189. ;;
  1190. IRIX-5.*)
  1191. SHLIB_CFLAGS=""
  1192. SHLIB_LD="ld -shared -rdata_shared"
  1193. SHLIB_LD_LIBS='${LIBS}'
  1194. SHLIB_SUFFIX=".so"
  1195. DL_OBJS="tclLoadDl.o"
  1196. DL_LIBS=""
  1197. CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
  1198. LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
  1199. ;;
  1200. IRIX-6.*)
  1201. SHLIB_CFLAGS=""
  1202. SHLIB_LD="ld -n32 -shared -rdata_shared"
  1203. SHLIB_LD_LIBS='${LIBS}'
  1204. SHLIB_SUFFIX=".so"
  1205. DL_OBJS="tclLoadDl.o"
  1206. DL_LIBS=""
  1207. CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
  1208. LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
  1209. if test "$GCC" = "yes" ; then
  1210. CFLAGS="$CFLAGS -mabi=n32"
  1211. LDFLAGS="$LDFLAGS -mabi=n32"
  1212. else
  1213. case $system in
  1214. IRIX-6.3)
  1215. # Use to build 6.2 compatible binaries on 6.3.
  1216. CFLAGS="$CFLAGS -n32 -D_OLD_TERMIOS"
  1217. ;;
  1218. *)
  1219. CFLAGS="$CFLAGS -n32"
  1220. ;;
  1221. esac
  1222. LDFLAGS="$LDFLAGS -n32"
  1223. fi
  1224. ;;
  1225. IRIX64-6.*)
  1226. SHLIB_CFLAGS=""
  1227. SHLIB_LD="ld -n32 -shared -rdata_shared"
  1228. SHLIB_LD_LIBS='${LIBS}'
  1229. SHLIB_SUFFIX=".so"
  1230. DL_OBJS="tclLoadDl.o"
  1231. DL_LIBS=""
  1232. CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
  1233. LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
  1234. # Check to enable 64-bit flags for compiler/linker
  1235. if test "$do64bit" = "yes" ; then
  1236. if test "$GCC" = "yes" ; then
  1237. AC_MSG_WARN([64bit mode not supported by gcc])
  1238. else
  1239. do64bit_ok=yes
  1240. SHLIB_LD="ld -64 -shared -rdata_shared"
  1241. CFLAGS="$CFLAGS -64"
  1242. LDFLAGS="$LDFLAGS -64"
  1243. fi
  1244. fi
  1245. ;;
  1246. Linux*)
  1247. SHLIB_CFLAGS="-fPIC"
  1248. SHLIB_LD_LIBS='${LIBS}'
  1249. SHLIB_SUFFIX=".so"
  1250. CFLAGS_OPTIMIZE=-O2
  1251. # egcs-2.91.66 on Redhat Linux 6.0 generates lots of warnings
  1252. # when you inline the string and math operations. Turn this off to
  1253. # get rid of the warnings.
  1254. #CFLAGS_OPTIMIZE="${CFLAGS_OPTIMIZE} -D__NO_STRING_INLINES -D__NO_MATH_INLINES"
  1255. if test "$have_dl" = yes; then
  1256. SHLIB_LD='${CC} -shared ${CFLAGS} ${LDFLAGS}'
  1257. DL_OBJS="tclLoadDl.o"
  1258. DL_LIBS="-ldl"
  1259. LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
  1260. CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
  1261. LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
  1262. else
  1263. AC_CHECK_HEADER(dld.h, [
  1264. SHLIB_LD="ld -shared"
  1265. DL_OBJS="tclLoadDld.o"
  1266. DL_LIBS="-ldld"
  1267. CC_SEARCH_FLAGS=""
  1268. LD_SEARCH_FLAGS=""])
  1269. fi
  1270. if test "`uname -m`" = "alpha" ; then
  1271. CFLAGS="$CFLAGS -mieee"
  1272. fi
  1273. if test $do64bit = yes; then
  1274. AC_CACHE_CHECK([if compiler accepts -m64 flag], tcl_cv_cc_m64, [
  1275. hold_cflags=$CFLAGS
  1276. CFLAGS="$CFLAGS -m64"
  1277. AC_TRY_LINK(,, tcl_cv_cc_m64=yes, tcl_cv_cc_m64=no)
  1278. CFLAGS=$hold_cflags])
  1279. if test $tcl_cv_cc_m64 = yes; then
  1280. CFLAGS="$CFLAGS -m64"
  1281. do64bit_ok=yes
  1282. fi
  1283. fi
  1284. # The combo of gcc + glibc has a bug related
  1285. # to inlining of functions like strtod(). The
  1286. # -fno-builtin flag should address this problem
  1287. # but it does not work. The -fno-inline flag
  1288. # is kind of overkill but it works.
  1289. # Disable inlining only when one of the
  1290. # files in compat/*.c is being linked in.
  1291. if test x"${LIBOBJS}" != x ; then
  1292. CFLAGS="$CFLAGS -fno-inline"
  1293. fi
  1294. # XIM peeking works under XFree86.
  1295. AC_DEFINE(PEEK_XCLOSEIM)
  1296. ;;
  1297. GNU*)
  1298. SHLIB_CFLAGS="-fPIC"
  1299. SHLIB_LD_LIBS='${LIBS}'
  1300. SHLIB_SUFFIX=".so"
  1301. if test "$have_dl" = yes; then
  1302. SHLIB_LD="${CC} -shared"
  1303. DL_OBJS=""
  1304. DL_LIBS="-ldl"
  1305. LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
  1306. CC_SEARCH_FLAGS=""
  1307. LD_SEARCH_FLAGS=""
  1308. else
  1309. AC_CHECK_HEADER(dld.h, [
  1310. SHLIB_LD="ld -shared"
  1311. DL_OBJS=""
  1312. DL_LIBS="-ldld"
  1313. CC_SEARCH_FLAGS=""
  1314. LD_SEARCH_FLAGS=""])
  1315. fi
  1316. if test "`uname -m`" = "alpha" ; then
  1317. CFLAGS="$CFLAGS -mieee"
  1318. fi
  1319. ;;
  1320. Lynx*)
  1321. SHLIB_CFLAGS="-fPIC"
  1322. SHLIB_LD_LIBS='${LIBS}'
  1323. SHLIB_SUFFIX=".so"
  1324. CFLAGS_OPTIMIZE=-02
  1325. SHLIB_LD="${CC} -shared "
  1326. DL_OBJS="tclLoadDl.o"
  1327. DL_LIBS="-mshared -ldl"
  1328. LD_FLAGS="-Wl,--export-dynamic"
  1329. CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
  1330. LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
  1331. ;;
  1332. MP-RAS-02*)
  1333. SHLIB_CFLAGS="-K PIC"
  1334. SHLIB_LD="cc -G"
  1335. SHLIB_LD_LIBS=""
  1336. SHLIB_SUFFIX=".so"
  1337. DL_OBJS="tclLoadDl.o"
  1338. DL_LIBS="-ldl"
  1339. CC_SEARCH_FLAGS=""
  1340. LD_SEARCH_FLAGS=""
  1341. ;;
  1342. MP-RAS-*)
  1343. SHLIB_CFLAGS="-K PIC"
  1344. SHLIB_LD="cc -G"
  1345. SHLIB_LD_LIBS=""
  1346. SHLIB_SUFFIX=".so"
  1347. DL_OBJS="tclLoadDl.o"
  1348. DL_LIBS="-ldl"
  1349. LDFLAGS="$LDFLAGS -Wl,-Bexport"
  1350. CC_SEARCH_FLAGS=""
  1351. LD_SEARCH_FLAGS=""
  1352. ;;
  1353. NetBSD-*|FreeBSD-[[1-2]].*)
  1354. # Not available on all versions: check for include file.
  1355. AC_CHECK_HEADER(dlfcn.h, [
  1356. # NetBSD/SPARC needs -fPIC, -fpic will not do.
  1357. SHLIB_CFLAGS="-fPIC"
  1358. SHLIB_LD="ld -Bshareable -x"
  1359. SHLIB_LD_LIBS='${LIBS}'
  1360. SHLIB_SUFFIX=".so"
  1361. DL_OBJS="tclLoadDl.o"
  1362. DL_LIBS=""
  1363. CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
  1364. LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
  1365. AC_CACHE_CHECK([for ELF], tcl_cv_ld_elf, [
  1366. AC_EGREP_CPP(yes, [
  1367. #ifdef __ELF__
  1368. yes
  1369. #endif
  1370. ], tcl_cv_ld_elf=yes, tcl_cv_ld_elf=no)])
  1371. if test $tcl_cv_ld_elf = yes; then
  1372. SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so'
  1373. else
  1374. SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so.1.0'
  1375. fi
  1376. ], [
  1377. SHLIB_CFLAGS=""
  1378. SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r"
  1379. SHLIB_LD_LIBS='${LIBS}'
  1380. SHLIB_SUFFIX=".a"
  1381. DL_OBJS="tclLoadAout.o"
  1382. DL_LIBS=""
  1383. CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
  1384. LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
  1385. SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
  1386. ])
  1387. # FreeBSD doesn't handle version numbers with dots.
  1388. UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
  1389. TCL_LIB_VERSIONS_OK=nodots
  1390. ;;
  1391. OpenBSD-*)
  1392. case `arch -s` in
  1393. m88k|vax)
  1394. SHLIB_CFLAGS=""
  1395. SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r"
  1396. SHLIB_LD_LIBS='${LIBS}'
  1397. SHLIB_SUFFIX=".a"
  1398. DL_OBJS="tclLoadAout.o"
  1399. DL_LIBS=""
  1400. LDFLAGS=""
  1401. CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
  1402. LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
  1403. SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
  1404. ;;
  1405. *)
  1406. # OpenBSD/SPARC[64] needs -fPIC, -fpic will not do.
  1407. case `machine` in
  1408. sparc|sparc64)
  1409. SHLIB_CFLAGS="-fPIC";;
  1410. *)
  1411. SHLIB_CFLAGS="-fpic";;
  1412. esac
  1413. SHLIB_LD="${CC} -shared ${SHLIB_CFLAGS}"
  1414. SHLIB_LD_LIBS='${LIBS}'
  1415. SHLIB_SUFFIX=".so"
  1416. DL_OBJS="tclLoadDl.o"
  1417. DL_LIBS=""
  1418. CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
  1419. LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
  1420. SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so.1.0'
  1421. AC_CACHE_CHECK([for ELF], tcl_cv_ld_elf, [
  1422. AC_EGREP_CPP(yes, [
  1423. #ifdef __ELF__
  1424. yes
  1425. #endif
  1426. ], tcl_cv_ld_elf=yes, tcl_cv_ld_elf=no)])
  1427. if test $tcl_cv_ld_elf = yes; then
  1428. LDFLAGS=-Wl,-export-dynamic
  1429. else
  1430. LDFLAGS=""
  1431. fi
  1432. ;;
  1433. esac
  1434. # OpenBSD doesn't do version numbers with dots.
  1435. UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
  1436. TCL_LIB_VERSIONS_OK=nodots
  1437. ;;
  1438. FreeBSD-*)
  1439. # FreeBSD 3.* and greater have ELF.
  1440. SHLIB_CFLAGS="-fPIC"
  1441. SHLIB_LD="ld -Bshareable -x"
  1442. SHLIB_LD_LIBS='${LIBS}'
  1443. SHLIB_SUFFIX=".so"
  1444. DL_OBJS="tclLoadDl.o"
  1445. DL_LIBS=""
  1446. LDFLAGS="$LDFLAGS -export-dynamic"
  1447. CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
  1448. LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
  1449. if test "${TCL_THREADS}" = "1" ; then
  1450. # The -pthread needs to go in the CFLAGS, not LIBS
  1451. LIBS=`echo $LIBS | sed s/-pthread//`
  1452. CFLAGS="$CFLAGS -pthread"
  1453. LDFLAGS="$LDFLAGS -pthread"
  1454. fi
  1455. case $system in
  1456. FreeBSD-3.*)
  1457. # FreeBSD-3 doesn't handle version numbers with dots.
  1458. UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
  1459. SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so'
  1460. TCL_LIB_VERSIONS_OK=nodots
  1461. ;;
  1462. esac
  1463. ;;
  1464. Darwin-*)
  1465. CFLAGS_OPTIMIZE="-Os"
  1466. SHLIB_CFLAGS="-fno-common"
  1467. # To avoid discrepancies between what headers configure sees during
  1468. # preprocessing tests and compiling tests, move any -isysroot and
  1469. # -mmacosx-version-min flags from CFLAGS to CPPFLAGS:
  1470. CPPFLAGS="${CPPFLAGS} `echo " ${CFLAGS}" | \
  1471. awk 'BEGIN {FS=" +-";ORS=" "}; {for (i=2;i<=NF;i++) \
  1472. if ([$]i~/^(isysroot|mmacosx-version-min)/) print "-"[$]i}'`"
  1473. CFLAGS="`echo " ${CFLAGS}" | \
  1474. awk 'BEGIN {FS=" +-";ORS=" "}; {for (i=2;i<=NF;i++) \
  1475. if (!([$]i~/^(isysroot|mmacosx-version-min)/)) print "-"[$]i}'`"
  1476. if test $do64bit = yes; then
  1477. case `arch` in
  1478. ppc)
  1479. AC_CACHE_CHECK([if compiler accepts -arch ppc64 flag],
  1480. tcl_cv_cc_arch_ppc64, [
  1481. hold_cflags=$CFLAGS
  1482. CFLAGS="$CFLAGS -arch ppc64 -mpowerpc64 -mcpu=G5"
  1483. AC_TRY_LINK(,, tcl_cv_cc_arch_ppc64=yes,
  1484. tcl_cv_cc_arch_ppc64=no)
  1485. CFLAGS=$hold_cflags])
  1486. if test $tcl_cv_cc_arch_ppc64 = yes; then
  1487. CFLAGS="$CFLAGS -arch ppc64 -mpowerpc64 -mcpu=G5"
  1488. do64bit_ok=yes
  1489. fi;;
  1490. i386)
  1491. AC_CACHE_CHECK([if compiler accepts -arch x86_64 flag],
  1492. tcl_cv_cc_arch_x86_64, [
  1493. hold_cflags=$CFLAGS
  1494. CFLAGS="$CFLAGS -arch x86_64"
  1495. AC_TRY_LINK(,, tcl_cv_cc_arch_x86_64=yes,
  1496. tcl_cv_cc_arch_x86_64=no)
  1497. CFLAGS=$hold_cflags])
  1498. if test $tcl_cv_cc_arch_x86_64 = yes; then
  1499. CFLAGS="$CFLAGS -arch x86_64"
  1500. do64bit_ok=yes
  1501. fi;;
  1502. *)
  1503. AC_MSG_WARN([Don't know how enable 64-bit on architecture `arch`]);;
  1504. esac
  1505. else
  1506. # Check for combined 32-bit and 64-bit fat build
  1507. echo "$CFLAGS " | grep -E -q -- '-arch (ppc64|x86_64) ' && \
  1508. echo "$CFLAGS " | grep -E -q -- '-arch (ppc|i386) ' && \
  1509. fat_32_64=yes
  1510. fi
  1511. SHLIB_LD='${CC} -dynamiclib ${CFLAGS} ${LDFLAGS}'
  1512. AC_CACHE_CHECK([if ld accepts -single_module flag], tcl_cv_ld_single_module, [
  1513. hold_ldflags=$LDFLAGS
  1514. LDFLAGS="$LDFLAGS -dynamiclib -Wl,-single_module"
  1515. AC_TRY_LINK(, [int i;], tcl_cv_ld_single_module=yes, tcl_cv_ld_single_module=no)
  1516. LDFLAGS=$hold_ldflags])
  1517. if test $tcl_cv_ld_single_module = yes; then
  1518. SHLIB_LD="${SHLIB_LD} -Wl,-single_module"
  1519. fi
  1520. SHLIB_LD_LIBS='${LIBS}'
  1521. SHLIB_SUFFIX=".dylib"
  1522. DL_OBJS="tclLoadDyld.o"
  1523. DL_LIBS=""
  1524. # Don't use -prebind when building for Mac OS X 10.4 or later only:
  1525. test "`echo "${MACOSX_DEPLOYMENT_TARGET}" | awk -F '10\\.' '{print int([$]2)}'`" -lt 4 -a \
  1526. "`echo "${CPPFLAGS}" | awk -F '-mmacosx-version-min=10\\.' '{print int([$]2)}'`" -lt 4 && \
  1527. LDFLAGS="$LDFLAGS -prebind"
  1528. LDFLAGS="$LDFLAGS -headerpad_max_install_names"
  1529. AC_CACHE_CHECK([if ld accepts -search_paths_first flag], tcl_cv_ld_search_paths_first, [
  1530. hold_ldflags=$LDFLAGS
  1531. LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
  1532. AC_TRY_LINK(, [int i;], tcl_cv_ld_search_paths_first=yes, tcl_cv_ld_search_paths_first=no)
  1533. LDFLAGS=$hold_ldflags])
  1534. if test $tcl_cv_ld_search_paths_first = yes; then
  1535. LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
  1536. fi
  1537. CC_SEARCH_FLAGS=""
  1538. LD_SEARCH_FLAGS=""
  1539. LD_LIBRARY_PATH_VAR="DYLD_LIBRARY_PATH"
  1540. PLAT_OBJS=\$\(MAC\_OSX_OBJS\)
  1541. PLAT_SRCS=\$\(MAC\_OSX_SRCS\)
  1542. AC_MSG_CHECKING([whether to use CoreFoundation])
  1543. AC_ARG_ENABLE(corefoundation, [ --enable-corefoundation use CoreFoundation API [--enable-corefoundation]],
  1544. [tcl_corefoundation=$enableval], [tcl_corefoundation=yes])
  1545. AC_MSG_RESULT([$tcl_corefoundation])
  1546. if test $tcl_corefoundation = yes; then
  1547. AC_CACHE_CHECK([for CoreFoundation.framework], tcl_cv_lib_corefoundation, [
  1548. hold_libs=$LIBS
  1549. if test "$fat_32_64" = yes; then for v in CFLAGS CPPFLAGS LDFLAGS; do
  1550. # On Tiger there is no 64-bit CF, so remove 64-bit archs
  1551. # from CFLAGS et al. while testing for presence of CF.
  1552. # 64-bit CF is disabled in tclUnixPort.h if necessary.
  1553. eval 'hold_'$v'="$'$v'";'$v'="`echo "$'$v' "|sed -e "s/-arch ppc64 / /g" -e "s/-arch x86_64 / /g"`"'
  1554. done; fi
  1555. LIBS="$LIBS -framework CoreFoundation"
  1556. AC_TRY_LINK([#include <CoreFoundation/CoreFoundation.h>],
  1557. [CFBundleRef b = CFBundleGetMainBundle();],
  1558. tcl_cv_lib_corefoundation=yes, tcl_cv_lib_corefoundation=no)
  1559. if test "$fat_32_64" = yes; then for v in CFLAGS CPPFLAGS LDFLAGS; do
  1560. eval $v'="$hold_'$v'"'
  1561. done; fi; LIBS=$hold_libs])
  1562. if test $tcl_cv_lib_corefoundation = yes; then
  1563. LIBS="$LIBS -framework CoreFoundation"
  1564. AC_DEFINE(HAVE_COREFOUNDATION)
  1565. else
  1566. tcl_corefoundation=no
  1567. fi
  1568. if test "$fat_32_64" = yes -a $tcl_corefoundation = yes; then
  1569. AC_CACHE_CHECK([for 64-bit CoreFoundation], tcl_cv_lib_corefoundation_64, [
  1570. for v in CFLAGS CPPFLAGS LDFLAGS; do
  1571. eval 'hold_'$v'="$'$v'";'$v'="`echo "$'$v' "|sed -e "s/-arch ppc / /g" -e "s/-arch i386 / /g"`"'
  1572. done
  1573. AC_TRY_LINK([#include <CoreFoundation/CoreFoundation.h>],
  1574. [CFBundleRef b = CFBundleGetMainBundle();],
  1575. tcl_cv_lib_corefoundation_64=yes, tcl_cv_lib_corefoundation_64=no)
  1576. for v in CFLAGS CPPFLAGS LDFLAGS; do
  1577. eval $v'="$hold_'$v'"'
  1578. done])
  1579. if test $tcl_cv_lib_corefoundation_64 = no; then
  1580. AC_DEFINE(NO_COREFOUNDATION_64)
  1581. fi
  1582. fi
  1583. fi
  1584. AC_DEFINE(MAC_OSX_TCL)
  1585. ;;
  1586. NEXTSTEP-*)
  1587. SHLIB_CFLAGS=""
  1588. SHLIB_LD="cc -nostdlib -r"
  1589. SHLIB_LD_LIBS=""
  1590. SHLIB_SUFFIX=".so"
  1591. DL_OBJS="tclLoadNext.o"
  1592. DL_LIBS=""
  1593. CC_SEARCH_FLAGS=""
  1594. LD_SEARCH_FLAGS=""
  1595. ;;
  1596. OS/390-*)
  1597. CFLAGS_OPTIMIZE="" # Optimizer is buggy
  1598. AC_DEFINE(_OE_SOCKETS) # needed in sys/socket.h
  1599. ;;
  1600. OSF1-1.0|OSF1-1.1|OSF1-1.2)
  1601. # OSF/1 1.[012] from OSF, and derivatives, including Paragon OSF/1
  1602. SHLIB_CFLAGS=""
  1603. # Hack: make package name same as library name
  1604. SHLIB_LD='ld -R -export $@:'
  1605. SHLIB_LD_LIBS=""
  1606. SHLIB_SUFFIX=".so"
  1607. DL_OBJS="tclLoadOSF.o"
  1608. DL_LIBS=""
  1609. CC_SEARCH_FLAGS=""
  1610. LD_SEARCH_FLAGS=""
  1611. ;;
  1612. OSF1-1.*)
  1613. # OSF/1 1.3 from OSF using ELF, and derivatives, including AD2
  1614. SHLIB_CFLAGS="-fPIC"
  1615. if test "$SHARED_BUILD" = "1" ; then
  1616. SHLIB_LD="ld -shared"
  1617. else
  1618. SHLIB_LD="ld -non_shared"
  1619. fi
  1620. SHLIB_LD_LIBS=""
  1621. SHLIB_SUFFIX=".so"
  1622. DL_OBJS="tclLoadDl.o"
  1623. DL_LIBS=""
  1624. CC_SEARCH_FLAGS=""
  1625. LD_SEARCH_FLAGS=""
  1626. ;;
  1627. OSF1-V*)
  1628. # Digital OSF/1
  1629. SHLIB_CFLAGS=""
  1630. if test "$SHARED_BUILD" = "1" ; then
  1631. SHLIB_LD='ld -shared -expect_unresolved "*"'
  1632. else
  1633. SHLIB_LD='ld -non_shared -expect_unresolved "*"'
  1634. fi
  1635. SHLIB_LD_LIBS=""
  1636. SHLIB_SUFFIX=".so"
  1637. DL_OBJS="tclLoadDl.o"
  1638. DL_LIBS=""
  1639. CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
  1640. LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
  1641. if test "$GCC" = "yes" ; then
  1642. CFLAGS="$CFLAGS -mieee"
  1643. else
  1644. CFLAGS="$CFLAGS -DHAVE_TZSET -std1 -ieee"
  1645. fi
  1646. # see pthread_intro(3) for pthread support on osf1, k.furukawa
  1647. if test "${TCL_THREADS}" = "1" ; then
  1648. CFLAGS="$CFLAGS -DHAVE_PTHREAD_ATTR_SETSTACKSIZE"
  1649. CFLAGS="$CFLAGS -DTCL_THREAD_STACK_MIN=PTHREAD_STACK_MIN*64"
  1650. LIBS=`echo $LIBS | sed s/-lpthreads//`
  1651. if test "$GCC" = "yes" ; then
  1652. LIBS="$LIBS -lpthread -lmach -lexc"
  1653. else
  1654. CFLAGS="$CFLAGS -pthread"
  1655. LDFLAGS="$LDFLAGS -pthread"
  1656. fi
  1657. fi
  1658. ;;
  1659. QNX-6*)
  1660. # QNX RTP
  1661. # This may work for all QNX, but it was only reported for v6.
  1662. SHLIB_CFLAGS="-fPIC"
  1663. SHLIB_LD="ld -Bshareable -x"
  1664. SHLIB_LD_LIBS=""
  1665. SHLIB_SUFFIX=".so"
  1666. DL_OBJS="tclLoadDl.o"
  1667. # dlopen is in -lc on QNX
  1668. DL_LIBS=""
  1669. CC_SEARCH_FLAGS=""
  1670. LD_SEARCH_FLAGS=""
  1671. ;;
  1672. RISCos-*)
  1673. SHLIB_CFLAGS="-G 0"
  1674. SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r -G 0"
  1675. SHLIB_LD_LIBS='${LIBS}'
  1676. SHLIB_SUFFIX=".a"
  1677. DL_OBJS="tclLoadAout.o"
  1678. DL_LIBS=""
  1679. LDFLAGS="$LDFLAGS -Wl,-D,08000000"
  1680. CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
  1681. LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
  1682. ;;
  1683. SCO_SV-3.2*)
  1684. # Note, dlopen is available only on SCO 3.2.5 and greater. However,
  1685. # this test works, since "uname -s" was non-standard in 3.2.4 and
  1686. # below.
  1687. if test "$GCC" = "yes" ; then
  1688. SHLIB_CFLAGS="-fPIC -melf"
  1689. LDFLAGS="$LDFLAGS -melf -Wl,-Bexport"
  1690. else
  1691. SHLIB_CFLAGS="-Kpic -belf"
  1692. LDFLAGS="$LDFLAGS -belf -Wl,-Bexport"
  1693. fi
  1694. SHLIB_LD="ld -G"
  1695. SHLIB_LD_LIBS=""
  1696. SHLIB_SUFFIX=".so"
  1697. DL_OBJS="tclLoadDl.o"
  1698. DL_LIBS=""
  1699. CC_SEARCH_FLAGS=""
  1700. LD_SEARCH_FLAGS=""
  1701. ;;
  1702. SINIX*5.4*)
  1703. SHLIB_CFLAGS="-K PIC"
  1704. SHLIB_LD="cc -G"
  1705. SHLIB_LD_LIBS=""
  1706. SHLIB_SUFFIX=".so"
  1707. DL_OBJS="tclLoadDl.o"
  1708. DL_LIBS="-ldl"
  1709. CC_SEARCH_FLAGS=""
  1710. LD_SEARCH_FLAGS=""
  1711. ;;
  1712. SunOS-4*)
  1713. SHLIB_CFLAGS="-PIC"
  1714. SHLIB_LD="ld"
  1715. SHLIB_LD_LIBS=""
  1716. SHLIB_SUFFIX=".so"
  1717. DL_OBJS="tclLoadDl.o"
  1718. DL_LIBS="-ldl"
  1719. CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
  1720. LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
  1721. # SunOS can't handle version numbers with dots in them in library
  1722. # specs, like -ltcl7.5, so use -ltcl75 instead. Also, it
  1723. # requires an extra version number at the end of .so file names.
  1724. # So, the library has to have a name like libtcl75.so.1.0
  1725. SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so.1.0'
  1726. UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.a'
  1727. TCL_LIB_VERSIONS_OK=nodots
  1728. ;;
  1729. SunOS-5.[[0-6]])
  1730. # Careful to not let 5.10+ fall into this case
  1731. # Note: If _REENTRANT isn't defined, then Solaris
  1732. # won't define thread-safe library routines.
  1733. AC_DEFINE(_REENTRANT)
  1734. AC_DEFINE(_POSIX_PTHREAD_SEMANTICS)
  1735. SHLIB_CFLAGS="-KPIC"
  1736. # Note: need the LIBS below, otherwise Tk won't find Tcl's
  1737. # symbols when dynamically loaded into tclsh.
  1738. SHLIB_LD_LIBS='${LIBS}'
  1739. SHLIB_SUFFIX=".so"
  1740. DL_OBJS="tclLoadDl.o"
  1741. DL_LIBS="-ldl"
  1742. if test "$GCC" = "yes" ; then
  1743. SHLIB_LD="$CC -shared"
  1744. CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
  1745. LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
  1746. else
  1747. SHLIB_LD="/usr/ccs/bin/ld -G -z text"
  1748. CC_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}'
  1749. LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
  1750. fi
  1751. ;;
  1752. SunOS-5*)
  1753. # Note: If _REENTRANT isn't defined, then Solaris
  1754. # won't define thread-safe library routines.
  1755. AC_DEFINE(_REENTRANT)
  1756. AC_DEFINE(_POSIX_PTHREAD_SEMANTICS)
  1757. SHLIB_CFLAGS="-KPIC"
  1758. # Check to enable 64-bit flags for compiler/linker
  1759. if test "$do64bit" = "yes" ; then
  1760. arch=`isainfo`
  1761. if test "$arch" = "sparcv9 sparc" ; then
  1762. if test "$GCC" = "yes" ; then
  1763. if test "`gcc -dumpversion | awk -F. '{print [$]1}'`" -lt "3" ; then
  1764. AC_MSG_WARN([64bit mode not supported with GCC < 3.2 on $system])
  1765. else
  1766. do64bit_ok=yes
  1767. CFLAGS="$CFLAGS -m64 -mcpu=v9"
  1768. LDFLAGS="$LDFLAGS -m64 -mcpu=v9"
  1769. SHLIB_CFLAGS="-fPIC"
  1770. fi
  1771. else
  1772. do64bit_ok=yes
  1773. if test "$do64bitVIS" = "yes" ; then
  1774. CFLAGS="$CFLAGS -xarch=v9a"
  1775. LDFLAGS="$LDFLAGS -xarch=v9a"
  1776. else
  1777. CFLAGS="$CFLAGS -xarch=v9"
  1778. LDFLAGS="$LDFLAGS -xarch=v9"
  1779. fi
  1780. # Solaris 64 uses this as well
  1781. #LD_LIBRARY_PATH_VAR="LD_LIBRARY_PATH_64"
  1782. fi
  1783. elif test "$arch" = "amd64 i386" ; then
  1784. if test "$GCC" = "yes" ; then
  1785. AC_MSG_WARN([64bit mode not supported with GCC on $system])
  1786. else
  1787. do64bit_ok=yes
  1788. CFLAGS="$CFLAGS -xarch=amd64"
  1789. LDFLAGS="$LDFLAGS -xarch=amd64"
  1790. fi
  1791. else
  1792. AC_MSG_WARN([64bit mode not supported for $arch])
  1793. fi
  1794. fi
  1795. # Note: need the LIBS below, otherwise Tk won't find Tcl's
  1796. # symbols when dynamically loaded into tclsh.
  1797. SHLIB_LD_LIBS='${LIBS}'
  1798. SHLIB_SUFFIX=".so"
  1799. DL_OBJS="tclLoadDl.o"
  1800. DL_LIBS="-ldl"
  1801. if test "$GCC" = "yes" ; then
  1802. SHLIB_LD="$CC -shared"
  1803. CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
  1804. LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
  1805. if test "$do64bit_ok" = "yes" ; then
  1806. # We need to specify -static-libgcc or we need to
  1807. # add the path to the sparv9 libgcc.
  1808. SHLIB_LD="$SHLIB_LD -m64 -mcpu=v9 -static-libgcc"
  1809. # for finding sparcv9 libgcc, get the regular libgcc
  1810. # path, remove so name and append 'sparcv9'
  1811. #v9gcclibdir="`gcc -print-file-name=libgcc_s.so` | ..."
  1812. #CC_SEARCH_FLAGS="${CC_SEARCH_FLAGS},-R,$v9gcclibdir"
  1813. fi
  1814. else
  1815. case $system in
  1816. SunOS-5.[[1-9]][[0-9]]*)
  1817. SHLIB_LD='${CC} -G -z text';;
  1818. *)
  1819. SHLIB_LD="/usr/ccs/bin/ld -G -z text";;
  1820. esac
  1821. CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
  1822. LD_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}'
  1823. fi
  1824. ;;
  1825. ULTRIX-4.*)
  1826. SHLIB_CFLAGS="-G 0"
  1827. SHLIB_SUFFIX=".a"
  1828. SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r -G 0"
  1829. SHLIB_LD_LIBS='${LIBS}'
  1830. DL_OBJS="tclLoadAout.o"
  1831. DL_LIBS=""
  1832. LDFLAGS="$LDFLAGS -Wl,-D,08000000"
  1833. CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
  1834. LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
  1835. if test "$GCC" != "yes" ; then
  1836. CFLAGS="$CFLAGS -DHAVE_TZSET -std1"
  1837. fi
  1838. ;;
  1839. UNIX_SV* | UnixWare-5*)
  1840. SHLIB_CFLAGS="-KPIC"
  1841. SHLIB_LD="cc -G"
  1842. SHLIB_LD_LIBS=""
  1843. SHLIB_SUFFIX=".so"
  1844. DL_OBJS="tclLoadDl.o"
  1845. DL_LIBS="-ldl"
  1846. # Some UNIX_SV* systems (unixware 1.1.2 for example) have linkers
  1847. # that don't grok the -Bexport option. Test that it does.
  1848. AC_CACHE_CHECK([for ld accepts -Bexport flag], tcl_cv_ld_Bexport, [
  1849. hold_ldflags=$LDFLAGS
  1850. LDFLAGS="$LDFLAGS -Wl,-Bexport"
  1851. AC_TRY_LINK(, [int i;], tcl_cv_ld_Bexport=yes, tcl_cv_ld_Bexport=no)
  1852. LDFLAGS=$hold_ldflags])
  1853. if test $tcl_cv_ld_Bexport = yes; then
  1854. LDFLAGS="$LDFLAGS -Wl,-Bexport"
  1855. fi
  1856. CC_SEARCH_FLAGS=""
  1857. LD_SEARCH_FLAGS=""
  1858. ;;
  1859. esac
  1860. if test "$do64bit" = "yes" -a "$do64bit_ok" = "no" ; then
  1861. AC_MSG_WARN([64bit support being disabled -- don't know magic for this platform])
  1862. fi
  1863. dnl # Add any CPPFLAGS set in the environment to our CFLAGS, but delay doing so
  1864. dnl # until the end of configure, as configure's compile and link tests use
  1865. dnl # both CPPFLAGS and CFLAGS (unlike our compile and link) but configure's
  1866. dnl # preprocessing tests use only CPPFLAGS.
  1867. SC_CONFIG_COMMANDS_PRE([CFLAGS="${CFLAGS} ${CPPFLAGS}"; CPPFLAGS=""])
  1868. # Step 4: If pseudo-static linking is in use (see K. B. Kenny, "Dynamic
  1869. # Loading for Tcl -- What Became of It?". Proc. 2nd Tcl/Tk Workshop,
  1870. # New Orleans, LA, Computerized Processes Unlimited, 1994), then we need
  1871. # to determine which of several header files defines the a.out file
  1872. # format (a.out.h, sys/exec.h, or sys/exec_aout.h). At present, we
  1873. # support only a file format that is more or less version-7-compatible.
  1874. # In particular,
  1875. # - a.out files must begin with `struct exec'.
  1876. # - the N_TXTOFF on the `struct exec' must compute the seek address
  1877. # of the text segment
  1878. # - The `struct exec' must contain a_magic, a_text, a_data, a_bss
  1879. # and a_entry fields.
  1880. # The following compilation should succeed if and only if either sys/exec.h
  1881. # or a.out.h is usable for the purpose.
  1882. #
  1883. # Note that the modified COFF format used on MIPS Ultrix 4.x is usable; the
  1884. # `struct exec' includes a second header that contains information that
  1885. # duplicates the v7 fields that are needed.
  1886. if test "x$DL_OBJS" = "xtclLoadAout.o" ; then
  1887. AC_CACHE_CHECK([sys/exec.h], tcl_cv_sysexec_h, [
  1888. AC_TRY_COMPILE([#include <sys/exec.h>],[
  1889. struct exec foo;
  1890. unsigned long seek;
  1891. int flag;
  1892. #if defined(__mips) || defined(mips)
  1893. seek = N_TXTOFF (foo.ex_f, foo.ex_o);
  1894. #else
  1895. seek = N_TXTOFF (foo);
  1896. #endif
  1897. flag = (foo.a_magic == OMAGIC);
  1898. return foo.a_text + foo.a_data + foo.a_bss + foo.a_entry;
  1899. ], tcl_cv_sysexec_h=usable, tcl_cv_sysexec_h=unusable)])
  1900. if test $tcl_cv_sysexec_h = usable; then
  1901. AC_DEFINE(USE_SYS_EXEC_H)
  1902. else
  1903. AC_CACHE_CHECK([a.out.h], tcl_cv_aout_h, [
  1904. AC_TRY_COMPILE([#include <a.out.h>],[
  1905. struct exec foo;
  1906. unsigned long seek;
  1907. int flag;
  1908. #if defined(__mips) || defined(mips)
  1909. seek = N_TXTOFF (foo.ex_f, foo.ex_o);
  1910. #else
  1911. seek = N_TXTOFF (foo);
  1912. #endif
  1913. flag = (foo.a_magic == OMAGIC);
  1914. return foo.a_text + foo.a_data + foo.a_bss + foo.a_entry;
  1915. ], tcl_cv_aout_h=usable, tcl_cv_aout_h=unusable)])
  1916. if test $tcl_cv_aout_h = usable; then
  1917. AC_DEFINE(USE_A_OUT_H)
  1918. else
  1919. AC_CACHE_CHECK([sys/exec_aout.h], tcl_cv_sysexecaout_h, [
  1920. AC_TRY_COMPILE([#include <sys/exec_aout.h>],[
  1921. struct exec foo;
  1922. unsigned long seek;
  1923. int flag;
  1924. #if defined(__mips) || defined(mips)
  1925. seek = N_TXTOFF (foo.ex_f, foo.ex_o);
  1926. #else
  1927. seek = N_TXTOFF (foo);
  1928. #endif
  1929. flag = (foo.a_midmag == OMAGIC);
  1930. return foo.a_text + foo.a_data + foo.a_bss + foo.a_entry;
  1931. ], tcl_cv_sysexecaout_h=usable, tcl_cv_sysexecaout_h=unusable)])
  1932. if test $tcl_cv_sysexecaout_h = usable; then
  1933. AC_DEFINE(USE_SYS_EXEC_AOUT_H)
  1934. else
  1935. DL_OBJS=""
  1936. fi
  1937. fi
  1938. fi
  1939. fi
  1940. # Step 5: disable dynamic loading if requested via a command-line switch.
  1941. AC_ARG_ENABLE(load, [ --disable-load disallow dynamic loading and "load" command],
  1942. [tcl_ok=$enableval], [tcl_ok=yes])
  1943. if test "$tcl_ok" = "no"; then
  1944. DL_OBJS=""
  1945. fi
  1946. if test "x$DL_OBJS" != "x" ; then
  1947. BUILD_DLTEST="\$(DLTEST_TARGETS)"
  1948. else
  1949. echo "Can't figure out how to do dynamic loading or shared libraries"
  1950. echo "on this system."
  1951. SHLIB_CFLAGS=""
  1952. SHLIB_LD=""
  1953. SHLIB_SUFFIX=""
  1954. DL_OBJS="tclLoadNone.o"
  1955. DL_LIBS=""
  1956. LDFLAGS="$LDFLAGS_ORIG"
  1957. CC_SEARCH_FLAGS=""
  1958. LD_SEARCH_FLAGS=""
  1959. BUILD_DLTEST=""
  1960. fi
  1961. # If we're running gcc, then change the C flags for compiling shared
  1962. # libraries to the right flags for gcc, instead of those for the
  1963. # standard manufacturer compiler.
  1964. if test "$DL_OBJS" != "tclLoadNone.o" ; then
  1965. if test "$GCC" = "yes" ; then
  1966. case $system in
  1967. AIX-*)
  1968. ;;
  1969. BSD/OS*)
  1970. ;;
  1971. IRIX*)
  1972. ;;
  1973. NetBSD-*|FreeBSD-*|OpenBSD-*)
  1974. ;;
  1975. Darwin-*)
  1976. ;;
  1977. RISCos-*)
  1978. ;;
  1979. SCO_SV-3.2*)
  1980. ;;
  1981. ULTRIX-4.*)
  1982. ;;
  1983. *)
  1984. SHLIB_CFLAGS="-fPIC"
  1985. ;;
  1986. esac
  1987. fi
  1988. fi
  1989. if test "$SHARED_LIB_SUFFIX" = "" ; then
  1990. SHARED_LIB_SUFFIX='${VERSION}\$\{DBGX\}${SHLIB_SUFFIX}'
  1991. fi
  1992. if test "$UNSHARED_LIB_SUFFIX" = "" ; then
  1993. UNSHARED_LIB_SUFFIX='${VERSION}\$\{DBGX\}.a'
  1994. fi
  1995. if test "${SHARED_BUILD}" = "1" && test "${SHLIB_SUFFIX}" != "" ; then
  1996. LIB_SUFFIX=${SHARED_LIB_SUFFIX}
  1997. MAKE_LIB='${SHLIB_LD} -o [$]@ ${OBJS} ${SHLIB_LD_LIBS} ${TCL_SHLIB_LD_EXTRAS} ${TK_SHLIB_LD_EXTRAS} ${LD_SEARCH_FLAGS}'
  1998. INSTALL_LIB='$(INSTALL_LIBRARY) $(LIB_FILE) $(LIB_INSTALL_DIR)/$(LIB_FILE)'
  1999. else
  2000. LIB_SUFFIX=${UNSHARED_LIB_SUFFIX}
  2001. if test "$RANLIB" = "" ; then
  2002. MAKE_LIB='$(STLIB_LD) [$]@ ${OBJS}'
  2003. INSTALL_LIB='$(INSTALL_LIBRARY) $(LIB_FILE) $(LIB_INSTALL_DIR)/$(LIB_FILE)'
  2004. else
  2005. MAKE_LIB='${STLIB_LD} [$]@ ${OBJS} ; ${RANLIB} [$]@'
  2006. INSTALL_LIB='$(INSTALL_LIBRARY) $(LIB_FILE) $(LIB_INSTALL_DIR)/$(LIB_FILE) ; (cd $(LIB_INSTALL_DIR) ; $(RANLIB) $(LIB_FILE))'
  2007. fi
  2008. dnl Not at all clear what this was doing in Tcl's configure.ac
  2009. dnl or why it was needed was needed. In any event, this sort of
  2010. dnl things needs to be done in the big loop above.
  2011. dnl REMOVE THIS BLOCK LATER! (mdejong)
  2012. dnl case $system in
  2013. dnl BSD/OS*)
  2014. dnl ;;
  2015. dnl AIX-[[1-4]].*)
  2016. dnl ;;
  2017. dnl *)
  2018. dnl SHLIB_LD_LIBS=""
  2019. dnl ;;
  2020. dnl esac
  2021. fi
  2022. # Stub lib does not depend on shared/static configuration
  2023. if test "$RANLIB" = "" ; then
  2024. MAKE_STUB_LIB='${STLIB_LD} [$]@ ${STUB_LIB_OBJS}'
  2025. INSTALL_STUB_LIB='$(INSTALL_LIBRARY) $(STUB_LIB_FILE) $(LIB_INSTALL_DIR)/$(STUB_LIB_FILE)'
  2026. else
  2027. MAKE_STUB_LIB='${STLIB_LD} [$]@ ${STUB_LIB_OBJS} ; ${RANLIB} [$]@'
  2028. INSTALL_STUB_LIB='$(INSTALL_LIBRARY) $(STUB_LIB_FILE) $(LIB_INSTALL_DIR)/$(STUB_LIB_FILE) ; (cd $(LIB_INSTALL_DIR) ; $(RANLIB) $(STUB_LIB_FILE))'
  2029. fi
  2030. AC_SUBST(DL_LIBS)
  2031. AC_SUBST(DL_OBJS)
  2032. AC_SUBST(PLAT_OBJS)
  2033. AC_SUBST(PLAT_SRCS)
  2034. AC_SUBST(CFLAGS)
  2035. AC_SUBST(CFLAGS_DEBUG)
  2036. AC_SUBST(CFLAGS_OPTIMIZE)
  2037. AC_SUBST(CFLAGS_WARNING)
  2038. AC_SUBST(LDFLAGS)
  2039. AC_SUBST(LDFLAGS_DEBUG)
  2040. AC_SUBST(LDFLAGS_OPTIMIZE)
  2041. AC_SUBST(CC_SEARCH_FLAGS)
  2042. AC_SUBST(LD_SEARCH_FLAGS)
  2043. AC_SUBST(STLIB_LD)
  2044. AC_SUBST(SHLIB_LD)
  2045. AC_SUBST(TCL_SHLIB_LD_EXTRAS)
  2046. AC_SUBST(TK_SHLIB_LD_EXTRAS)
  2047. AC_SUBST(SHLIB_LD_LIBS)
  2048. AC_SUBST(SHLIB_CFLAGS)
  2049. AC_SUBST(SHLIB_SUFFIX)
  2050. AC_SUBST(MAKE_LIB)
  2051. AC_SUBST(MAKE_STUB_LIB)
  2052. AC_SUBST(INSTALL_LIB)
  2053. AC_SUBST(INSTALL_STUB_LIB)
  2054. AC_SUBST(RANLIB)
  2055. ])
  2056. #--------------------------------------------------------------------
  2057. # SC_SERIAL_PORT
  2058. #
  2059. # Determine which interface to use to talk to the serial port.
  2060. # Note that #include lines must begin in leftmost column for
  2061. # some compilers to recognize them as preprocessor directives,
  2062. # and some build environments have stdin not pointing at a
  2063. # pseudo-terminal (usually /dev/null instead.)
  2064. #
  2065. # Arguments:
  2066. # none
  2067. #
  2068. # Results:
  2069. #
  2070. # Defines only one of the following vars:
  2071. # HAVE_SYS_MODEM_H
  2072. # USE_TERMIOS
  2073. # USE_TERMIO
  2074. # USE_SGTTY
  2075. #
  2076. #--------------------------------------------------------------------
  2077. AC_DEFUN([SC_SERIAL_PORT], [
  2078. AC_CHECK_HEADERS(sys/modem.h)
  2079. AC_CACHE_CHECK([termios vs. termio vs. sgtty], tcl_cv_api_serial, [
  2080. AC_TRY_RUN([
  2081. #include <termios.h>
  2082. int main() {
  2083. struct termios t;
  2084. if (tcgetattr(0, &t) == 0) {
  2085. cfsetospeed(&t, 0);
  2086. t.c_cflag |= PARENB | PARODD | CSIZE | CSTOPB;
  2087. return 0;
  2088. }
  2089. return 1;
  2090. }], tcl_cv_api_serial=termios, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
  2091. if test $tcl_cv_api_serial = no ; then
  2092. AC_TRY_RUN([
  2093. #include <termio.h>
  2094. int main() {
  2095. struct termio t;
  2096. if (ioctl(0, TCGETA, &t) == 0) {
  2097. t.c_cflag |= CBAUD | PARENB | PARODD | CSIZE | CSTOPB;
  2098. return 0;
  2099. }
  2100. return 1;
  2101. }], tcl_cv_api_serial=termio, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
  2102. fi
  2103. if test $tcl_cv_api_serial = no ; then
  2104. AC_TRY_RUN([
  2105. #include <sgtty.h>
  2106. int main() {
  2107. struct sgttyb t;
  2108. if (ioctl(0, TIOCGETP, &t) == 0) {
  2109. t.sg_ospeed = 0;
  2110. t.sg_flags |= ODDP | EVENP | RAW;
  2111. return 0;
  2112. }
  2113. return 1;
  2114. }], tcl_cv_api_serial=sgtty, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
  2115. fi
  2116. if test $tcl_cv_api_serial = no ; then
  2117. AC_TRY_RUN([
  2118. #include <termios.h>
  2119. #include <errno.h>
  2120. int main() {
  2121. struct termios t;
  2122. if (tcgetattr(0, &t) == 0
  2123. || errno == ENOTTY || errno == ENXIO || errno == EINVAL) {
  2124. cfsetospeed(&t, 0);
  2125. t.c_cflag |= PARENB | PARODD | CSIZE | CSTOPB;
  2126. return 0;
  2127. }
  2128. return 1;
  2129. }], tcl_cv_api_serial=termios, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
  2130. fi
  2131. if test $tcl_cv_api_serial = no; then
  2132. AC_TRY_RUN([
  2133. #include <termio.h>
  2134. #include <errno.h>
  2135. int main() {
  2136. struct termio t;
  2137. if (ioctl(0, TCGETA, &t) == 0
  2138. || errno == ENOTTY || errno == ENXIO || errno == EINVAL) {
  2139. t.c_cflag |= CBAUD | PARENB | PARODD | CSIZE | CSTOPB;
  2140. return 0;
  2141. }
  2142. return 1;
  2143. }], tcl_cv_api_serial=termio, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
  2144. fi
  2145. if test $tcl_cv_api_serial = no; then
  2146. AC_TRY_RUN([
  2147. #include <sgtty.h>
  2148. #include <errno.h>
  2149. int main() {
  2150. struct sgttyb t;
  2151. if (ioctl(0, TIOCGETP, &t) == 0
  2152. || errno == ENOTTY || errno == ENXIO || errno == EINVAL) {
  2153. t.sg_ospeed = 0;
  2154. t.sg_flags |= ODDP | EVENP | RAW;
  2155. return 0;
  2156. }
  2157. return 1;
  2158. }], tcl_cv_api_serial=sgtty, tcl_cv_api_serial=none, tcl_cv_api_serial=none)
  2159. fi])
  2160. case $tcl_cv_api_serial in
  2161. termios) AC_DEFINE(USE_TERMIOS);;
  2162. termio) AC_DEFINE(USE_TERMIO);;
  2163. sgtty) AC_DEFINE(USE_SGTTY);;
  2164. esac
  2165. ])
  2166. #--------------------------------------------------------------------
  2167. # SC_MISSING_POSIX_HEADERS
  2168. #
  2169. # Supply substitutes for missing POSIX header files. Special
  2170. # notes:
  2171. # - stdlib.h doesn't define strtol, strtoul, or
  2172. # strtod insome versions of SunOS
  2173. # - some versions of string.h don't declare procedures such
  2174. # as strstr
  2175. #
  2176. # Arguments:
  2177. # none
  2178. #
  2179. # Results:
  2180. #
  2181. # Defines some of the following vars:
  2182. # NO_DIRENT_H
  2183. # NO_ERRNO_H
  2184. # NO_VALUES_H
  2185. # HAVE_LIMITS_H or NO_LIMITS_H
  2186. # NO_STDLIB_H
  2187. # NO_STRING_H
  2188. # NO_SYS_WAIT_H
  2189. # NO_DLFCN_H
  2190. # HAVE_UNISTD_H
  2191. # HAVE_SYS_PARAM_H
  2192. #
  2193. # HAVE_STRING_H ?
  2194. #
  2195. #--------------------------------------------------------------------
  2196. AC_DEFUN([SC_MISSING_POSIX_HEADERS], [
  2197. AC_CACHE_CHECK([dirent.h], tcl_cv_dirent_h, [
  2198. AC_TRY_LINK([#include <sys/types.h>
  2199. #include <dirent.h>], [
  2200. #ifndef _POSIX_SOURCE
  2201. # ifdef __Lynx__
  2202. /*
  2203. * Generate compilation error to make the test fail: Lynx headers
  2204. * are only valid if really in the POSIX environment.
  2205. */
  2206. missing_procedure();
  2207. # endif
  2208. #endif
  2209. DIR *d;
  2210. struct dirent *entryPtr;
  2211. char *p;
  2212. d = opendir("foobar");
  2213. entryPtr = readdir(d);
  2214. p = entryPtr->d_name;
  2215. closedir(d);
  2216. ], tcl_cv_dirent_h=yes, tcl_cv_dirent_h=no)])
  2217. if test $tcl_cv_dirent_h = no; then
  2218. AC_DEFINE(NO_DIRENT_H)
  2219. fi
  2220. AC_CHECK_HEADER(errno.h, , [AC_DEFINE(NO_ERRNO_H)])
  2221. AC_CHECK_HEADER(float.h, , [AC_DEFINE(NO_FLOAT_H)])
  2222. AC_CHECK_HEADER(values.h, , [AC_DEFINE(NO_VALUES_H)])
  2223. AC_CHECK_HEADER(limits.h,
  2224. [AC_DEFINE(HAVE_LIMITS_H)], [AC_DEFINE(NO_LIMITS_H)])
  2225. AC_CHECK_HEADER(stdlib.h, tcl_ok=1, tcl_ok=0)
  2226. AC_EGREP_HEADER(strtol, stdlib.h, , tcl_ok=0)
  2227. AC_EGREP_HEADER(strtoul, stdlib.h, , tcl_ok=0)
  2228. AC_EGREP_HEADER(strtod, stdlib.h, , tcl_ok=0)
  2229. if test $tcl_ok = 0; then
  2230. AC_DEFINE(NO_STDLIB_H)
  2231. fi
  2232. AC_CHECK_HEADER(string.h, tcl_ok=1, tcl_ok=0)
  2233. AC_EGREP_HEADER(strstr, string.h, , tcl_ok=0)
  2234. AC_EGREP_HEADER(strerror, string.h, , tcl_ok=0)
  2235. # See also memmove check below for a place where NO_STRING_H can be
  2236. # set and why.
  2237. if test $tcl_ok = 0; then
  2238. AC_DEFINE(NO_STRING_H)
  2239. fi
  2240. AC_CHECK_HEADER(sys/wait.h, , [AC_DEFINE(NO_SYS_WAIT_H)])
  2241. AC_CHECK_HEADER(dlfcn.h, , [AC_DEFINE(NO_DLFCN_H)])
  2242. # OS/390 lacks sys/param.h (and doesn't need it, by chance).
  2243. AC_HAVE_HEADERS(unistd.h sys/param.h)
  2244. ])
  2245. #--------------------------------------------------------------------
  2246. # SC_PATH_X
  2247. #
  2248. # Locate the X11 header files and the X11 library archive. Try
  2249. # the ac_path_x macro first, but if it doesn't find the X stuff
  2250. # (e.g. because there's no xmkmf program) then check through
  2251. # a list of possible directories. Under some conditions the
  2252. # autoconf macro will return an include directory that contains
  2253. # no include files, so double-check its result just to be safe.
  2254. #
  2255. # Arguments:
  2256. # none
  2257. #
  2258. # Results:
  2259. #
  2260. # Sets the the following vars:
  2261. # XINCLUDES
  2262. # XLIBSW
  2263. #
  2264. #--------------------------------------------------------------------
  2265. AC_DEFUN([SC_PATH_X], [
  2266. AC_PATH_X
  2267. not_really_there=""
  2268. if test "$no_x" = ""; then
  2269. if test "$x_includes" = ""; then
  2270. AC_TRY_CPP([#include <X11/XIntrinsic.h>], , not_really_there="yes")
  2271. else
  2272. if test ! -r $x_includes/X11/Intrinsic.h; then
  2273. not_really_there="yes"
  2274. fi
  2275. fi
  2276. fi
  2277. if test "$no_x" = "yes" -o "$not_really_there" = "yes"; then
  2278. AC_MSG_CHECKING([for X11 header files])
  2279. found_xincludes="no"
  2280. AC_TRY_CPP([#include <X11/Intrinsic.h>], found_xincludes="yes", found_xincludes="no")
  2281. if test "$found_xincludes" = "no"; then
  2282. dirs="/usr/unsupported/include /usr/local/include /usr/X386/include /usr/X11R6/include /usr/X11R5/include /usr/include/X11R5 /usr/include/X11R4 /usr/openwin/include /usr/X11/include /usr/sww/include"
  2283. for i in $dirs ; do
  2284. if test -r $i/X11/Intrinsic.h; then
  2285. AC_MSG_RESULT([$i])
  2286. XINCLUDES=" -I$i"
  2287. found_xincludes="yes"
  2288. break
  2289. fi
  2290. done
  2291. fi
  2292. else
  2293. if test "$x_includes" != ""; then
  2294. XINCLUDES="-I$x_includes"
  2295. found_xincludes="yes"
  2296. fi
  2297. fi
  2298. if test found_xincludes = "no"; then
  2299. AC_MSG_RESULT([couldn't find any!])
  2300. fi
  2301. if test "$no_x" = yes; then
  2302. AC_MSG_CHECKING([for X11 libraries])
  2303. XLIBSW=nope
  2304. dirs="/usr/unsupported/lib /usr/local/lib /usr/X386/lib /usr/X11R6/lib /usr/X11R5/lib /usr/lib/X11R5 /usr/lib/X11R4 /usr/openwin/lib /usr/X11/lib /usr/sww/X11/lib"
  2305. for i in $dirs ; do
  2306. if test -r $i/libX11.a -o -r $i/libX11.so -o -r $i/libX11.sl; then
  2307. AC_MSG_RESULT([$i])
  2308. XLIBSW="-L$i -lX11"
  2309. x_libraries="$i"
  2310. break
  2311. fi
  2312. done
  2313. else
  2314. if test "$x_libraries" = ""; then
  2315. XLIBSW=-lX11
  2316. else
  2317. XLIBSW="-L$x_libraries -lX11"
  2318. fi
  2319. fi
  2320. if test "$XLIBSW" = nope ; then
  2321. AC_CHECK_LIB(Xwindow, XCreateWindow, XLIBSW=-lXwindow)
  2322. fi
  2323. if test "$XLIBSW" = nope ; then
  2324. AC_MSG_RESULT([could not find any! Using -lX11.])
  2325. XLIBSW=-lX11
  2326. fi
  2327. ])
  2328. #--------------------------------------------------------------------
  2329. # SC_BLOCKING_STYLE
  2330. #
  2331. # The statements below check for systems where POSIX-style
  2332. # non-blocking I/O (O_NONBLOCK) doesn't work or is unimplemented.
  2333. # On these systems (mostly older ones), use the old BSD-style
  2334. # FIONBIO approach instead.
  2335. #
  2336. # Arguments:
  2337. # none
  2338. #
  2339. # Results:
  2340. #
  2341. # Defines some of the following vars:
  2342. # HAVE_SYS_IOCTL_H
  2343. # HAVE_SYS_FILIO_H
  2344. # USE_FIONBIO
  2345. # O_NONBLOCK
  2346. #
  2347. #--------------------------------------------------------------------
  2348. AC_DEFUN([SC_BLOCKING_STYLE], [
  2349. AC_CHECK_HEADERS(sys/ioctl.h)
  2350. AC_CHECK_HEADERS(sys/filio.h)
  2351. SC_CONFIG_SYSTEM
  2352. AC_MSG_CHECKING([FIONBIO vs. O_NONBLOCK for nonblocking I/O])
  2353. case $system in
  2354. # There used to be code here to use FIONBIO under AIX. However, it
  2355. # was reported that FIONBIO doesn't work under AIX 3.2.5. Since
  2356. # using O_NONBLOCK seems fine under AIX 4.*, I removed the FIONBIO
  2357. # code (JO, 5/31/97).
  2358. OSF*)
  2359. AC_DEFINE(USE_FIONBIO)
  2360. AC_MSG_RESULT([FIONBIO])
  2361. ;;
  2362. SunOS-4*)
  2363. AC_DEFINE(USE_FIONBIO)
  2364. AC_MSG_RESULT([FIONBIO])
  2365. ;;
  2366. ULTRIX-4.*)
  2367. AC_DEFINE(USE_FIONBIO)
  2368. AC_MSG_RESULT([FIONBIO])
  2369. ;;
  2370. *)
  2371. AC_MSG_RESULT([O_NONBLOCK])
  2372. ;;
  2373. esac
  2374. ])
  2375. #--------------------------------------------------------------------
  2376. # SC_TIME_HANLDER
  2377. #
  2378. # Checks how the system deals with time.h, what time structures
  2379. # are used on the system, and what fields the structures have.
  2380. #
  2381. # Arguments:
  2382. # none
  2383. #
  2384. # Results:
  2385. #
  2386. # Defines some of the following vars:
  2387. # USE_DELTA_FOR_TZ
  2388. # HAVE_TM_GMTOFF
  2389. # HAVE_TM_TZADJ
  2390. # HAVE_TIMEZONE_VAR
  2391. #
  2392. #--------------------------------------------------------------------
  2393. AC_DEFUN([SC_TIME_HANDLER], [
  2394. AC_CHECK_HEADERS(sys/time.h)
  2395. AC_HEADER_TIME
  2396. AC_STRUCT_TIMEZONE
  2397. AC_CHECK_FUNCS(gmtime_r localtime_r)
  2398. AC_CACHE_CHECK([tm_tzadj in struct tm], tcl_cv_member_tm_tzadj, [
  2399. AC_TRY_COMPILE([#include <time.h>], [struct tm tm; tm.tm_tzadj;],
  2400. tcl_cv_member_tm_tzadj=yes, tcl_cv_member_tm_tzadj=no)])
  2401. if test $tcl_cv_member_tm_tzadj = yes ; then
  2402. AC_DEFINE(HAVE_TM_TZADJ)
  2403. fi
  2404. AC_CACHE_CHECK([tm_gmtoff in struct tm], tcl_cv_member_tm_gmtoff, [
  2405. AC_TRY_COMPILE([#include <time.h>], [struct tm tm; tm.tm_gmtoff;],
  2406. tcl_cv_member_tm_gmtoff=yes, tcl_cv_member_tm_gmtoff=no)])
  2407. if test $tcl_cv_member_tm_gmtoff = yes ; then
  2408. AC_DEFINE(HAVE_TM_GMTOFF)
  2409. fi
  2410. #
  2411. # Its important to include time.h in this check, as some systems
  2412. # (like convex) have timezone functions, etc.
  2413. #
  2414. AC_CACHE_CHECK([long timezone variable], tcl_cv_timezone_long, [
  2415. AC_TRY_COMPILE([#include <time.h>],
  2416. [extern long timezone;
  2417. timezone += 1;
  2418. exit (0);],
  2419. tcl_cv_timezone_long=yes, tcl_cv_timezone_long=no)])
  2420. if test $tcl_cv_timezone_long = yes ; then
  2421. AC_DEFINE(HAVE_TIMEZONE_VAR)
  2422. else
  2423. #
  2424. # On some systems (eg IRIX 6.2), timezone is a time_t and not a long.
  2425. #
  2426. AC_CACHE_CHECK([time_t timezone variable], tcl_cv_timezone_time, [
  2427. AC_TRY_COMPILE([#include <time.h>],
  2428. [extern time_t timezone;
  2429. timezone += 1;
  2430. exit (0);],
  2431. tcl_cv_timezone_time=yes, tcl_cv_timezone_time=no)])
  2432. if test $tcl_cv_timezone_time = yes ; then
  2433. AC_DEFINE(HAVE_TIMEZONE_VAR)
  2434. fi
  2435. fi
  2436. ])
  2437. #--------------------------------------------------------------------
  2438. # SC_BUGGY_STRTOD
  2439. #
  2440. # Under Solaris 2.4, strtod returns the wrong value for the
  2441. # terminating character under some conditions. Check for this
  2442. # and if the problem exists use a substitute procedure
  2443. # "fixstrtod" (provided by Tcl) that corrects the error.
  2444. # Also, on Compaq's Tru64 Unix 5.0,
  2445. # strtod(" ") returns 0.0 instead of a failure to convert.
  2446. #
  2447. # Arguments:
  2448. # none
  2449. #
  2450. # Results:
  2451. #
  2452. # Might defines some of the following vars:
  2453. # strtod (=fixstrtod)
  2454. #
  2455. #--------------------------------------------------------------------
  2456. AC_DEFUN([SC_BUGGY_STRTOD], [
  2457. AC_CHECK_FUNC(strtod, tcl_strtod=1, tcl_strtod=0)
  2458. if test "$tcl_strtod" = 1; then
  2459. AC_CACHE_CHECK([for Solaris2.4/Tru64 strtod bugs], tcl_cv_strtod_buggy,[
  2460. AC_TRY_RUN([
  2461. extern double strtod();
  2462. int main() {
  2463. char *infString="Inf", *nanString="NaN", *spaceString=" ";
  2464. char *term;
  2465. double value;
  2466. value = strtod(infString, &term);
  2467. if ((term != infString) && (term[-1] == 0)) {
  2468. exit(1);
  2469. }
  2470. value = strtod(nanString, &term);
  2471. if ((term != nanString) && (term[-1] == 0)) {
  2472. exit(1);
  2473. }
  2474. value = strtod(spaceString, &term);
  2475. if (term == (spaceString+1)) {
  2476. exit(1);
  2477. }
  2478. exit(0);
  2479. }], tcl_cv_strtod_buggy=ok, tcl_cv_strtod_buggy=buggy,
  2480. tcl_cv_strtod_buggy=buggy)])
  2481. if test "$tcl_cv_strtod_buggy" = buggy; then
  2482. LIBOBJS="$LIBOBJS fixstrtod.o"
  2483. AC_DEFINE(strtod, fixstrtod)
  2484. fi
  2485. fi
  2486. ])
  2487. #--------------------------------------------------------------------
  2488. # SC_TCL_LINK_LIBS
  2489. #
  2490. # Search for the libraries needed to link the Tcl shell.
  2491. # Things like the math library (-lm) and socket stuff (-lsocket vs.
  2492. # -lnsl) are dealt with here.
  2493. #
  2494. # Arguments:
  2495. # Requires the following vars to be set in the Makefile:
  2496. # DL_LIBS
  2497. # LIBS
  2498. # MATH_LIBS
  2499. #
  2500. # Results:
  2501. #
  2502. # Subst's the following var:
  2503. # TCL_LIBS
  2504. # MATH_LIBS
  2505. #
  2506. # Might append to the following vars:
  2507. # LIBS
  2508. #
  2509. # Might define the following vars:
  2510. # HAVE_NET_ERRNO_H
  2511. #
  2512. #--------------------------------------------------------------------
  2513. AC_DEFUN([SC_TCL_LINK_LIBS], [
  2514. #--------------------------------------------------------------------
  2515. # On a few very rare systems, all of the libm.a stuff is
  2516. # already in libc.a. Set compiler flags accordingly.
  2517. # Also, Linux requires the "ieee" library for math to work
  2518. # right (and it must appear before "-lm").
  2519. #--------------------------------------------------------------------
  2520. AC_CHECK_FUNC(sin, MATH_LIBS="", MATH_LIBS="-lm")
  2521. AC_CHECK_LIB(ieee, main, [MATH_LIBS="-lieee $MATH_LIBS"])
  2522. #--------------------------------------------------------------------
  2523. # Interactive UNIX requires -linet instead of -lsocket, plus it
  2524. # needs net/errno.h to define the socket-related error codes.
  2525. #--------------------------------------------------------------------
  2526. AC_CHECK_LIB(inet, main, [LIBS="$LIBS -linet"])
  2527. AC_CHECK_HEADER(net/errno.h, [AC_DEFINE(HAVE_NET_ERRNO_H)])
  2528. #--------------------------------------------------------------------
  2529. # Check for the existence of the -lsocket and -lnsl libraries.
  2530. # The order here is important, so that they end up in the right
  2531. # order in the command line generated by make. Here are some
  2532. # special considerations:
  2533. # 1. Use "connect" and "accept" to check for -lsocket, and
  2534. # "gethostbyname" to check for -lnsl.
  2535. # 2. Use each function name only once: can't redo a check because
  2536. # autoconf caches the results of the last check and won't redo it.
  2537. # 3. Use -lnsl and -lsocket only if they supply procedures that
  2538. # aren't already present in the normal libraries. This is because
  2539. # IRIX 5.2 has libraries, but they aren't needed and they're
  2540. # bogus: they goof up name resolution if used.
  2541. # 4. On some SVR4 systems, can't use -lsocket without -lnsl too.
  2542. # To get around this problem, check for both libraries together
  2543. # if -lsocket doesn't work by itself.
  2544. #--------------------------------------------------------------------
  2545. tcl_checkBoth=0
  2546. AC_CHECK_FUNC(connect, tcl_checkSocket=0, tcl_checkSocket=1)
  2547. if test "$tcl_checkSocket" = 1; then
  2548. AC_CHECK_FUNC(setsockopt, , [AC_CHECK_LIB(socket, setsockopt,
  2549. LIBS="$LIBS -lsocket", tcl_checkBoth=1)])
  2550. fi
  2551. if test "$tcl_checkBoth" = 1; then
  2552. tk_oldLibs=$LIBS
  2553. LIBS="$LIBS -lsocket -lnsl"
  2554. AC_CHECK_FUNC(accept, tcl_checkNsl=0, [LIBS=$tk_oldLibs])
  2555. fi
  2556. AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(nsl, gethostbyname,
  2557. [LIBS="$LIBS -lnsl"])])
  2558. # Don't perform the eval of the libraries here because DL_LIBS
  2559. # won't be set until we call SC_CONFIG_CFLAGS
  2560. TCL_LIBS='${DL_LIBS} ${LIBS} ${MATH_LIBS}'
  2561. AC_SUBST(TCL_LIBS)
  2562. AC_SUBST(MATH_LIBS)
  2563. ])
  2564. #--------------------------------------------------------------------
  2565. # SC_TCL_EARLY_FLAGS
  2566. #
  2567. # Check for what flags are needed to be passed so the correct OS
  2568. # features are available.
  2569. #
  2570. # Arguments:
  2571. # None
  2572. #
  2573. # Results:
  2574. #
  2575. # Might define the following vars:
  2576. # _ISOC99_SOURCE
  2577. # _LARGEFILE64_SOURCE
  2578. # _LARGEFILE_SOURCE64
  2579. #
  2580. #--------------------------------------------------------------------
  2581. AC_DEFUN([SC_TCL_EARLY_FLAG],[
  2582. AC_CACHE_VAL([tcl_cv_flag_]translit($1,[A-Z],[a-z]),
  2583. AC_TRY_COMPILE([$2], $3, [tcl_cv_flag_]translit($1,[A-Z],[a-z])=no,
  2584. AC_TRY_COMPILE([[#define ]$1[ 1
  2585. ]$2], $3,
  2586. [tcl_cv_flag_]translit($1,[A-Z],[a-z])=yes,
  2587. [tcl_cv_flag_]translit($1,[A-Z],[a-z])=no)))
  2588. if test ["x${tcl_cv_flag_]translit($1,[A-Z],[a-z])[}" = "xyes"] ; then
  2589. AC_DEFINE($1)
  2590. tcl_flags="$tcl_flags $1"
  2591. fi
  2592. ])
  2593. AC_DEFUN([SC_TCL_EARLY_FLAGS],[
  2594. AC_MSG_CHECKING([for required early compiler flags])
  2595. tcl_flags=""
  2596. SC_TCL_EARLY_FLAG(_ISOC99_SOURCE,[#include <stdlib.h>],
  2597. [char *p = (char *)strtoll; char *q = (char *)strtoull;])
  2598. SC_TCL_EARLY_FLAG(_LARGEFILE64_SOURCE,[#include <sys/stat.h>],
  2599. [struct stat64 buf; int i = stat64("/", &buf);])
  2600. SC_TCL_EARLY_FLAG(_LARGEFILE_SOURCE64,[#include <sys/stat.h>],
  2601. [char *p = (char *)open64;])
  2602. if test "x${tcl_flags}" = "x" ; then
  2603. AC_MSG_RESULT([none])
  2604. else
  2605. AC_MSG_RESULT([${tcl_flags}])
  2606. fi
  2607. ])
  2608. #--------------------------------------------------------------------
  2609. # SC_TCL_64BIT_FLAGS
  2610. #
  2611. # Check for what is defined in the way of 64-bit features.
  2612. #
  2613. # Arguments:
  2614. # None
  2615. #
  2616. # Results:
  2617. #
  2618. # Might define the following vars:
  2619. # TCL_WIDE_INT_IS_LONG
  2620. # TCL_WIDE_INT_TYPE
  2621. # HAVE_STRUCT_DIRENT64
  2622. # HAVE_STRUCT_STAT64
  2623. # HAVE_TYPE_OFF64_T
  2624. #
  2625. #--------------------------------------------------------------------
  2626. AC_DEFUN([SC_TCL_64BIT_FLAGS], [
  2627. AC_MSG_CHECKING([for 64-bit integer type])
  2628. AC_CACHE_VAL(tcl_cv_type_64bit,[
  2629. tcl_cv_type_64bit=none
  2630. # See if the compiler knows natively about __int64
  2631. AC_TRY_COMPILE(,[__int64 value = (__int64) 0;],
  2632. tcl_type_64bit=__int64, tcl_type_64bit="long long")
  2633. # See if we should use long anyway Note that we substitute in the
  2634. # type that is our current guess for a 64-bit type inside this check
  2635. # program, so it should be modified only carefully...
  2636. AC_TRY_COMPILE(,[switch (0) {
  2637. case 1: case (sizeof(]${tcl_type_64bit}[)==sizeof(long)): ;
  2638. }],tcl_cv_type_64bit=${tcl_type_64bit})])
  2639. if test "${tcl_cv_type_64bit}" = none ; then
  2640. AC_DEFINE(TCL_WIDE_INT_IS_LONG)
  2641. AC_MSG_RESULT([using long])
  2642. else
  2643. AC_DEFINE_UNQUOTED(TCL_WIDE_INT_TYPE,${tcl_cv_type_64bit})
  2644. AC_MSG_RESULT([${tcl_cv_type_64bit}])
  2645. # Now check for auxiliary declarations
  2646. AC_CACHE_CHECK([for struct dirent64], tcl_cv_struct_dirent64,[
  2647. AC_TRY_COMPILE([#include <sys/types.h>
  2648. #include <sys/dirent.h>],[struct dirent64 p;],
  2649. tcl_cv_struct_dirent64=yes,tcl_cv_struct_dirent64=no)])
  2650. if test "x${tcl_cv_struct_dirent64}" = "xyes" ; then
  2651. AC_DEFINE(HAVE_STRUCT_DIRENT64)
  2652. fi
  2653. AC_CACHE_CHECK([for struct stat64], tcl_cv_struct_stat64,[
  2654. AC_TRY_COMPILE([#include <sys/stat.h>],[struct stat64 p;
  2655. ],
  2656. tcl_cv_struct_stat64=yes,tcl_cv_struct_stat64=no)])
  2657. if test "x${tcl_cv_struct_stat64}" = "xyes" ; then
  2658. AC_DEFINE(HAVE_STRUCT_STAT64)
  2659. fi
  2660. AC_CHECK_FUNCS(open64 lseek64)
  2661. AC_MSG_CHECKING([for off64_t])
  2662. AC_CACHE_VAL(tcl_cv_type_off64_t,[
  2663. AC_TRY_COMPILE([#include <sys/types.h>],[off64_t offset;
  2664. ],
  2665. tcl_cv_type_off64_t=yes,tcl_cv_type_off64_t=no)])
  2666. dnl Define HAVE_TYPE_OFF64_T only when the off64_t type and the
  2667. dnl functions lseek64 and open64 are defined.
  2668. if test "x${tcl_cv_type_off64_t}" = "xyes" && \
  2669. test "x${ac_cv_func_lseek64}" = "xyes" && \
  2670. test "x${ac_cv_func_open64}" = "xyes" ; then
  2671. AC_DEFINE(HAVE_TYPE_OFF64_T)
  2672. AC_MSG_RESULT([yes])
  2673. else
  2674. AC_MSG_RESULT([no])
  2675. fi
  2676. fi
  2677. ])
  2678. #--------------------------------------------------------------------
  2679. # SC_TCL_GETHOSTBYADDR_R
  2680. #
  2681. # Check if we have MT-safe variant of gethostbyaddr().
  2682. #
  2683. # Arguments:
  2684. # None
  2685. #
  2686. # Results:
  2687. #
  2688. # Might define the following vars:
  2689. # HAVE_GETHOSTBYADDR_R
  2690. # HAVE_GETHOSTBYADDR_R_7
  2691. # HAVE_GETHOSTBYADDR_R_8
  2692. #
  2693. #--------------------------------------------------------------------
  2694. AC_DEFUN([SC_TCL_GETHOSTBYADDR_R], [AC_CHECK_FUNC(gethostbyaddr_r, [
  2695. AC_CACHE_CHECK([for gethostbyaddr_r with 7 args], tcl_cv_api_gethostbyaddr_r_7, [
  2696. AC_TRY_COMPILE([
  2697. #include <netdb.h>
  2698. ], [
  2699. char *addr;
  2700. int length;
  2701. int type;
  2702. struct hostent *result;
  2703. char buffer[2048];
  2704. int buflen = 2048;
  2705. int h_errnop;
  2706. (void) gethostbyaddr_r(addr, length, type, result, buffer, buflen,
  2707. &h_errnop);
  2708. ], tcl_cv_api_gethostbyaddr_r_7=yes, tcl_cv_api_gethostbyaddr_r_7=no)])
  2709. tcl_ok=$tcl_cv_api_gethostbyaddr_r_7
  2710. if test "$tcl_ok" = yes; then
  2711. AC_DEFINE(HAVE_GETHOSTBYADDR_R_7)
  2712. else
  2713. AC_CACHE_CHECK([for gethostbyaddr_r with 8 args], tcl_cv_api_gethostbyaddr_r_8, [
  2714. AC_TRY_COMPILE([
  2715. #include <netdb.h>
  2716. ], [
  2717. char *addr;
  2718. int length;
  2719. int type;
  2720. struct hostent *result, *resultp;
  2721. char buffer[2048];
  2722. int buflen = 2048;
  2723. int h_errnop;
  2724. (void) gethostbyaddr_r(addr, length, type, result, buffer, buflen,
  2725. &resultp, &h_errnop);
  2726. ], tcl_cv_api_gethostbyaddr_r_8=yes, tcl_cv_api_gethostbyaddr_r_8=no)])
  2727. tcl_ok=$tcl_cv_api_gethostbyaddr_r_8
  2728. if test "$tcl_ok" = yes; then
  2729. AC_DEFINE(HAVE_GETHOSTBYADDR_R_8)
  2730. fi
  2731. fi
  2732. if test "$tcl_ok" = yes; then
  2733. AC_DEFINE(HAVE_GETHOSTBYADDR_R)
  2734. fi
  2735. ])])
  2736. #--------------------------------------------------------------------
  2737. # SC_TCL_GETHOSTBYNAME_R
  2738. #
  2739. # Check to see what variant of gethostbyname_r() we have.
  2740. # Based on David Arnold's example from the comp.programming.threads
  2741. # FAQ Q213
  2742. #
  2743. # Arguments:
  2744. # None
  2745. #
  2746. # Results:
  2747. #
  2748. # Might define the following vars:
  2749. # HAVE_GETHOSTBYADDR_R
  2750. # HAVE_GETHOSTBYADDR_R_3
  2751. # HAVE_GETHOSTBYADDR_R_5
  2752. # HAVE_GETHOSTBYADDR_R_6
  2753. #
  2754. #--------------------------------------------------------------------
  2755. AC_DEFUN([SC_TCL_GETHOSTBYNAME_R], [AC_CHECK_FUNC(gethostbyname_r, [
  2756. AC_CACHE_CHECK([for gethostbyname_r with 6 args], tcl_cv_api_gethostbyname_r_6, [
  2757. AC_TRY_COMPILE([
  2758. #include <netdb.h>
  2759. ], [
  2760. char *name;
  2761. struct hostent *he, *res;
  2762. char buffer[2048];
  2763. int buflen = 2048;
  2764. int h_errnop;
  2765. (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop);
  2766. ], tcl_cv_api_gethostbyname_r_6=yes, tcl_cv_api_gethostbyname_r_6=no)])
  2767. tcl_ok=$tcl_cv_api_gethostbyname_r_6
  2768. if test "$tcl_ok" = yes; then
  2769. AC_DEFINE(HAVE_GETHOSTBYNAME_R_6)
  2770. else
  2771. AC_CACHE_CHECK([for gethostbyname_r with 5 args], tcl_cv_api_gethostbyname_r_5, [
  2772. AC_TRY_COMPILE([
  2773. #include <netdb.h>
  2774. ], [
  2775. char *name;
  2776. struct hostent *he;
  2777. char buffer[2048];
  2778. int buflen = 2048;
  2779. int h_errnop;
  2780. (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop);
  2781. ], tcl_cv_api_gethostbyname_r_5=yes, tcl_cv_api_gethostbyname_r_5=no)])
  2782. tcl_ok=$tcl_cv_api_gethostbyname_r_5
  2783. if test "$tcl_ok" = yes; then
  2784. AC_DEFINE(HAVE_GETHOSTBYNAME_R_5)
  2785. else
  2786. AC_CACHE_CHECK([for gethostbyname_r with 3 args], tcl_cv_api_gethostbyname_r_3, [
  2787. AC_TRY_COMPILE([
  2788. #include <netdb.h>
  2789. ], [
  2790. char *name;
  2791. struct hostent *he;
  2792. struct hostent_data data;
  2793. (void) gethostbyname_r(name, he, &data);
  2794. ], tcl_cv_api_gethostbyname_r_3=yes, tcl_cv_api_gethostbyname_r_3=no)])
  2795. tcl_ok=$tcl_cv_api_gethostbyname_r_3
  2796. if test "$tcl_ok" = yes; then
  2797. AC_DEFINE(HAVE_GETHOSTBYNAME_R_3)
  2798. fi
  2799. fi
  2800. fi
  2801. if test "$tcl_ok" = yes; then
  2802. AC_DEFINE(HAVE_GETHOSTBYNAME_R)
  2803. fi
  2804. ])])
  2805. #--------------------------------------------------------------------
  2806. # SC_TCL_GETPWUID_R
  2807. #
  2808. # Check if we have MT-safe variant of getpwuid() and if yes,
  2809. # which one exactly.
  2810. #
  2811. # Arguments:
  2812. # None
  2813. #
  2814. # Results:
  2815. #
  2816. # Might define the following vars:
  2817. # HAVE_GETPWUID_R
  2818. # HAVE_GETPWUID_R_4
  2819. # HAVE_GETPWUID_R_5
  2820. #
  2821. #--------------------------------------------------------------------
  2822. AC_DEFUN([SC_TCL_GETPWUID_R], [AC_CHECK_FUNC(getpwuid_r, [
  2823. AC_CACHE_CHECK([for getpwuid_r with 5 args], tcl_cv_api_getpwuid_r_5, [
  2824. AC_TRY_COMPILE([
  2825. #include <sys/types.h>
  2826. #include <pwd.h>
  2827. ], [
  2828. uid_t uid;
  2829. struct passwd pw, *pwp;
  2830. char buf[512];
  2831. int buflen = 512;
  2832. (void) getpwuid_r(uid, &pw, buf, buflen, &pwp);
  2833. ], tcl_cv_api_getpwuid_r_5=yes, tcl_cv_api_getpwuid_r_5=no)])
  2834. tcl_ok=$tcl_cv_api_getpwuid_r_5
  2835. if test "$tcl_ok" = yes; then
  2836. AC_DEFINE(HAVE_GETPWUID_R_5)
  2837. else
  2838. AC_CACHE_CHECK([for getpwuid_r with 4 args], tcl_cv_api_getpwuid_r_4, [
  2839. AC_TRY_COMPILE([
  2840. #include <sys/types.h>
  2841. #include <pwd.h>
  2842. ], [
  2843. uid_t uid;
  2844. struct passwd pw;
  2845. char buf[512];
  2846. int buflen = 512;
  2847. (void)getpwnam_r(uid, &pw, buf, buflen);
  2848. ], tcl_cv_api_getpwuid_r_4=yes, tcl_cv_api_getpwuid_r_4=no)])
  2849. tcl_ok=$tcl_cv_api_getpwuid_r_4
  2850. if test "$tcl_ok" = yes; then
  2851. AC_DEFINE(HAVE_GETPWUID_R_4)
  2852. fi
  2853. fi
  2854. if test "$tcl_ok" = yes; then
  2855. AC_DEFINE(HAVE_GETPWUID_R)
  2856. fi
  2857. ])])
  2858. #--------------------------------------------------------------------
  2859. # SC_TCL_GETPWNAM_R
  2860. #
  2861. # Check if we have MT-safe variant of getpwnam() and if yes,
  2862. # which one exactly.
  2863. #
  2864. # Arguments:
  2865. # None
  2866. #
  2867. # Results:
  2868. #
  2869. # Might define the following vars:
  2870. # HAVE_GETPWNAM_R
  2871. # HAVE_GETPWNAM_R_4
  2872. # HAVE_GETPWNAM_R_5
  2873. #
  2874. #--------------------------------------------------------------------
  2875. AC_DEFUN([SC_TCL_GETPWNAM_R], [AC_CHECK_FUNC(getpwnam_r, [
  2876. AC_CACHE_CHECK([for getpwnam_r with 5 args], tcl_cv_api_getpwnam_r_5, [
  2877. AC_TRY_COMPILE([
  2878. #include <sys/types.h>
  2879. #include <pwd.h>
  2880. ], [
  2881. char *name;
  2882. struct passwd pw, *pwp;
  2883. char buf[512];
  2884. int buflen = 512;
  2885. (void) getpwnam_r(name, &pw, buf, buflen, &pwp);
  2886. ], tcl_cv_api_getpwnam_r_5=yes, tcl_cv_api_getpwnam_r_5=no)])
  2887. tcl_ok=$tcl_cv_api_getpwnam_r_5
  2888. if test "$tcl_ok" = yes; then
  2889. AC_DEFINE(HAVE_GETPWNAM_R_5)
  2890. else
  2891. AC_CACHE_CHECK([for getpwnam_r with 4 args], tcl_cv_api_getpwnam_r_4, [
  2892. AC_TRY_COMPILE([
  2893. #include <sys/types.h>
  2894. #include <pwd.h>
  2895. ], [
  2896. char *name;
  2897. struct passwd pw;
  2898. char buf[512];
  2899. int buflen = 512;
  2900. (void)getpwnam_r(name, &pw, buf, buflen);
  2901. ], tcl_cv_api_getpwnam_r_4=yes, tcl_cv_api_getpwnam_r_4=no)])
  2902. tcl_ok=$tcl_cv_api_getpwnam_r_4
  2903. if test "$tcl_ok" = yes; then
  2904. AC_DEFINE(HAVE_GETPWNAM_R_4)
  2905. fi
  2906. fi
  2907. if test "$tcl_ok" = yes; then
  2908. AC_DEFINE(HAVE_GETPWNAM_R)
  2909. fi
  2910. ])])
  2911. #--------------------------------------------------------------------
  2912. # SC_TCL_GETGRGID_R
  2913. #
  2914. # Check if we have MT-safe variant of getgrgid() and if yes,
  2915. # which one exactly.
  2916. #
  2917. # Arguments:
  2918. # None
  2919. #
  2920. # Results:
  2921. #
  2922. # Might define the following vars:
  2923. # HAVE_GETGRGID_R
  2924. # HAVE_GETGRGID_R_4
  2925. # HAVE_GETGRGID_R_5
  2926. #
  2927. #--------------------------------------------------------------------
  2928. AC_DEFUN([SC_TCL_GETGRGID_R], [AC_CHECK_FUNC(getgrgid_r, [
  2929. AC_CACHE_CHECK([for getgrgid_r with 5 args], tcl_cv_api_getgrgid_r_5, [
  2930. AC_TRY_COMPILE([
  2931. #include <sys/types.h>
  2932. #include <grp.h>
  2933. ], [
  2934. gid_t gid;
  2935. struct group gr, *grp;
  2936. char buf[512];
  2937. int buflen = 512;
  2938. (void) getgrgid_r(gid, &gr, buf, buflen, &grp);
  2939. ], tcl_cv_api_getgrgid_r_5=yes, tcl_cv_api_getgrgid_r_5=no)])
  2940. tcl_ok=$tcl_cv_api_getgrgid_r_5
  2941. if test "$tcl_ok" = yes; then
  2942. AC_DEFINE(HAVE_GETGRGID_R_5)
  2943. else
  2944. AC_CACHE_CHECK([for getgrgid_r with 4 args], tcl_cv_api_getgrgid_r_4, [
  2945. AC_TRY_COMPILE([
  2946. #include <sys/types.h>
  2947. #include <grp.h>
  2948. ], [
  2949. gid_t gid;
  2950. struct group gr;
  2951. char buf[512];
  2952. int buflen = 512;
  2953. (void)getgrgid_r(gid, &gr, buf, buflen);
  2954. ], tcl_cv_api_getgrgid_r_4=yes, tcl_cv_api_getgrgid_r_4=no)])
  2955. tcl_ok=$tcl_cv_api_getgrgid_r_4
  2956. if test "$tcl_ok" = yes; then
  2957. AC_DEFINE(HAVE_GETGRGID_R_4)
  2958. fi
  2959. fi
  2960. if test "$tcl_ok" = yes; then
  2961. AC_DEFINE(HAVE_GETGRGID_R)
  2962. fi
  2963. ])])
  2964. #--------------------------------------------------------------------
  2965. # SC_TCL_GETGRNAM_R
  2966. #
  2967. # Check if we have MT-safe variant of getgrnam() and if yes,
  2968. # which one exactly.
  2969. #
  2970. # Arguments:
  2971. # None
  2972. #
  2973. # Results:
  2974. #
  2975. # Might define the following vars:
  2976. # HAVE_GETGRNAM_R
  2977. # HAVE_GETGRNAM_R_4
  2978. # HAVE_GETGRNAM_R_5
  2979. #
  2980. #--------------------------------------------------------------------
  2981. AC_DEFUN([SC_TCL_GETGRNAM_R], [AC_CHECK_FUNC(getgrnam_r, [
  2982. AC_CACHE_CHECK([for getgrnam_r with 5 args], tcl_cv_api_getgrnam_r_5, [
  2983. AC_TRY_COMPILE([
  2984. #include <sys/types.h>
  2985. #include <grp.h>
  2986. ], [
  2987. char *name;
  2988. struct group gr, *grp;
  2989. char buf[512];
  2990. int buflen = 512;
  2991. (void) getgrnam_r(name, &gr, buf, buflen, &grp);
  2992. ], tcl_cv_api_getgrnam_r_5=yes, tcl_cv_api_getgrnam_r_5=no)])
  2993. tcl_ok=$tcl_cv_api_getgrnam_r_5
  2994. if test "$tcl_ok" = yes; then
  2995. AC_DEFINE(HAVE_GETGRNAM_R_5)
  2996. else
  2997. AC_CACHE_CHECK([for getgrnam_r with 4 args], tcl_cv_api_getgrnam_r_4, [
  2998. AC_TRY_COMPILE([
  2999. #include <sys/types.h>
  3000. #include <grp.h>
  3001. ], [
  3002. char *name;
  3003. struct group gr;
  3004. char buf[512];
  3005. int buflen = 512;
  3006. (void)getgrnam_r(name, &gr, buf, buflen);
  3007. ], tcl_cv_api_getgrnam_r_4=yes, tcl_cv_api_getgrnam_r_4=no)])
  3008. tcl_ok=$tcl_cv_api_getgrnam_r_4
  3009. if test "$tcl_ok" = yes; then
  3010. AC_DEFINE(HAVE_GETGRNAM_R_4)
  3011. fi
  3012. fi
  3013. if test "$tcl_ok" = yes; then
  3014. AC_DEFINE(HAVE_GETGRNAM_R)
  3015. fi
  3016. ])])
  3017. #--------------------------------------------------------------------
  3018. # SC_CONFIG_COMMANDS_PRE(CMDS)
  3019. #
  3020. # Replacement for autoconf 2.5x AC_COMMANDS_PRE:
  3021. # Commands to run right before config.status is
  3022. # created. Accumulates.
  3023. #
  3024. # Requires presence of SC_OUTPUT_COMMANDS_PRE at the end
  3025. # of configure.ac (right before AC_OUTPUT).
  3026. #
  3027. #--------------------------------------------------------------------
  3028. AC_DEFUN([SC_CONFIG_COMMANDS_PRE], [
  3029. define([SC_OUTPUT_COMMANDS_PRE], defn([SC_OUTPUT_COMMANDS_PRE])[$1
  3030. ])])
  3031. AC_DEFUN([SC_OUTPUT_COMMANDS_PRE])