* How to cache $CFLAGS, $LIBS etc. @ 2000-08-11 11:28 Peter Stephenson 2000-08-11 11:32 ` Ollivier Robert ` (2 more replies) 0 siblings, 3 replies; 8+ messages in thread From: Peter Stephenson @ 2000-08-11 11:28 UTC (permalink / raw) To: Zsh hackers list The only way supported by configure of passing in special values of compiler flags and libraries etc. is by setting the environment variables CFLAGS and LIBS. That's fine the first time you run configure, but they aren't remembered so (1) if you run it again, you have to specify them again from memory or by digging around deep inside the configuration files (2) rather worse, if changes to the configuration force `configure --recheck' they are automatically stomped on. This has been regularly getting my goat for several years. So I tried to think up a way of doing it better. Here are the possibilities. 1. Simply cache any value for a specified set of environment variables, and re-use them any time no explicit value was passed. Unfortunately, caching doesn't really work that way. Either you have to cache something the first time and use it ever after, or you don't cache it at all, which isn't quite what I want. 2. Use `--enable-cflags', `--enable-libs', `--enable-ldflags' or whatever. This probably ought to work because the arguments are remembered for use with --recheck. But the guide for how configure is used is pretty fascistic about not allowing anything RMS wouldn't like, so I don't know if there are drawbacks to this. Plus we need to be careful if people supply environment variables in the standard way. Does anyone know how to do this properly? -- Peter Stephenson <pws@csr.com> Cambridge Silicon Radio, Unit 300, Science Park, Milton Road, Cambridge, CB4 0XL, UK Tel: +44 (0)1223 392070 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to cache $CFLAGS, $LIBS etc. 2000-08-11 11:28 How to cache $CFLAGS, $LIBS etc Peter Stephenson @ 2000-08-11 11:32 ` Ollivier Robert 2000-08-11 13:48 ` Trond Eivind Glomsrød 2000-08-11 16:16 ` Bart Schaefer 2000-08-16 7:25 ` Andrej Borsenkow 2 siblings, 1 reply; 8+ messages in thread From: Ollivier Robert @ 2000-08-11 11:32 UTC (permalink / raw) To: Peter Stephenson; +Cc: Zsh hackers list According to Peter Stephenson: > Does anyone know how to do this properly? Look at Xemacs' configure.in. They have a --cflags and --libs that is cached in config.status. -- Ollivier ROBERT -=- Eurocontrol EEC/ITM -=- roberto@eurocontrol.fr The Postman hits! The Postman hits! You have new mail. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to cache $CFLAGS, $LIBS etc. 2000-08-11 11:32 ` Ollivier Robert @ 2000-08-11 13:48 ` Trond Eivind Glomsrød 0 siblings, 0 replies; 8+ messages in thread From: Trond Eivind Glomsrød @ 2000-08-11 13:48 UTC (permalink / raw) To: Zsh hackers list Ollivier Robert <roberto@eurocontrol.fr> writes: > According to Peter Stephenson: > > Does anyone know how to do this properly? > > Look at Xemacs' configure.in. They have a --cflags and --libs that is > cached in config.status. I would be very wary of looking at XEmacs for autoconf advice - their setup suck. Also, I like being able to set CFLAGS and LDFLAGS at compile time. -- Trond Eivind Glomsrød Red Hat, Inc. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to cache $CFLAGS, $LIBS etc. 2000-08-11 11:28 How to cache $CFLAGS, $LIBS etc Peter Stephenson 2000-08-11 11:32 ` Ollivier Robert @ 2000-08-11 16:16 ` Bart Schaefer 2000-08-11 16:37 ` Bart Schaefer 2000-08-11 18:08 ` Peter Stephenson 2000-08-16 7:25 ` Andrej Borsenkow 2 siblings, 2 replies; 8+ messages in thread From: Bart Schaefer @ 2000-08-11 16:16 UTC (permalink / raw) To: Peter Stephenson, Zsh hackers list On Aug 11, 12:28pm, Peter Stephenson wrote: } Subject: How to cache $CFLAGS, $LIBS etc. } } 2. Use `--enable-cflags', `--enable-libs', `--enable-ldflags' or whatever. } This probably ought to work because the arguments are remembered for use } with --recheck. I've done this with configure in other packages; it works fine. } But the guide for how configure is used is pretty fascistic about not } allowing anything RMS wouldn't like, so I don't know if there are } drawbacks to this. Zsh isn't a GNU package, so I'm not especially concerned about RMS's blood pressure. } Plus we need to be careful if people supply } environment variables in the standard way. It actually all works pretty well as long as you don't try to use both the environment variables and the --enable flags in the same configure (with different values). The --enable flags always win. If you use environment variables or make-command-line variables to change the CFLAGS at make time, they'll correctly override the --enable settings for the actual build, but not for any tests run within an automatic re- configure. If that's a problem we can most likely rewrite the Makefile.in to force the appropriate --enable options to be passed to config.status; e.g. config.status --recheck --enable-cflags='$(CFLAGS)' ... However, I've never yet found this to be an issue. If the new value of, say, LIBS would result in a different configuration output, chances are you should have run configure directly in the first place. } Does anyone know how to do this properly? This is lifted (and edited to change the name) from another acinclude.m4 that I wrote: AC_DEFUN([zsh_compile_flags], [AC_ARG_ENABLE(cflags, [ --enable-cflags=... specify C compiler flags], if test "$enableval" = "yes" then CFLAGS="$1" else CFLAGS="$enable_cflags" fi) [AC_ARG_ENABLE(ldflags, [ --enable-ldflags=... specify linker flags], if test "$enableval" = "yes" then LDFLAGS="$1" else LDFLAGS="$enable_ldflags" fi)]) Add any others that you want, stick it in aczsh.m4, etc., you know the drill. -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to cache $CFLAGS, $LIBS etc. 2000-08-11 16:16 ` Bart Schaefer @ 2000-08-11 16:37 ` Bart Schaefer 2000-08-11 18:08 ` Peter Stephenson 1 sibling, 0 replies; 8+ messages in thread From: Bart Schaefer @ 2000-08-11 16:37 UTC (permalink / raw) To: Peter Stephenson, Zsh hackers list On Aug 11, 4:16pm, Bart Schaefer wrote: } Subject: Re: How to cache $CFLAGS, $LIBS etc. } } This is lifted (and edited to change the name) from another acinclude.m4 } that I wrote: } } AC_DEFUN([zsh_compile_flags], } [AC_ARG_ENABLE(cflags, } [ --enable-cflags=... specify C compiler flags], } if test "$enableval" = "yes" } then CFLAGS="$1" } else CFLAGS="$enable_cflags" } fi) } [AC_ARG_ENABLE(ldflags, } [ --enable-ldflags=... specify linker flags], } if test "$enableval" = "yes" } then LDFLAGS="$1" ^^ That should be "$2". Sorry about that. } else LDFLAGS="$enable_ldflags" } fi)]) The references to "$1" and "$2" are of course the argument of the m4 macro when called from configure, not shell positional parameters. E.g. you can put in configure.in zsh_compile_flags(-g3 -O0, -ltermcap) to cause those to be the defaults for --enable-cflags and --enable-ldflags. -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to cache $CFLAGS, $LIBS etc. 2000-08-11 16:16 ` Bart Schaefer 2000-08-11 16:37 ` Bart Schaefer @ 2000-08-11 18:08 ` Peter Stephenson 1 sibling, 0 replies; 8+ messages in thread From: Peter Stephenson @ 2000-08-11 18:08 UTC (permalink / raw) To: Zsh hackers list Bart wrote: > On Aug 11, 12:28pm, Peter Stephenson wrote: > } Subject: How to cache $CFLAGS, $LIBS etc. > } > } 2. Use `--enable-cflags', `--enable-libs', `--enable-ldflags' or whatever. > } This probably ought to work because the arguments are remembered for use > } with --recheck. > > I've done this with configure in other packages; it works fine. Seems OK. I've only tried it with the CFLAGS and LIBS values. Index: INSTALL =================================================================== RCS file: /cvsroot/zsh/zsh/INSTALL,v retrieving revision 1.1.1.21 diff -u -r1.1.1.21 INSTALL --- INSTALL 2000/03/01 18:31:21 1.1.1.21 +++ INSTALL 2000/08/11 18:06:38 @@ -127,6 +127,15 @@ Or on systems that have the "env" program, you can do it like this: env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure +The flags CFLAGS, CPPFLAGS, LDFLAGS and LIBS can also be set as flags to +configure, where the name appears in lower case: + configure --enable-cflags=-O2 --enable-libs=-lposix + +The advantage of this form is that `config.status --recheck' will remember +the flags you originally specified. You can still override the flags when +running `make' (although these will not be passed down via `config.status +--recheck'). + Check Generated Files --------------------- Index: aczsh.m4 =================================================================== RCS file: /cvsroot/zsh/zsh/aczsh.m4,v retrieving revision 1.1.1.9 diff -u -r1.1.1.9 aczsh.m4 --- aczsh.m4 1999/12/06 19:01:52 1.1.1.9 +++ aczsh.m4 2000/08/11 18:06:38 @@ -620,3 +620,29 @@ rm -f conftestsed AC_SUBST(tzsh)dnl ]) + +AC_DEFUN(zsh_COMPILE_FLAGS, + [AC_ARG_ENABLE(cppflags, + [ --enable-cppflags=... specify C preprocessor flags], + if test "$enableval" = "yes" + then CPPFLAGS="$1" + else CPPFLAGS="$enable_cppflags" + fi) + AC_ARG_ENABLE(cflags, + [ --enable-cflags=... specify C compiler flags], + if test "$enableval" = "yes" + then CFLAGS="$1" + else CFLAGS="$enable_cflags" + fi) + AC_ARG_ENABLE(ldflags, + [ --enable-ldflags=... specify linker flags], + if test "$enableval" = "yes" + then LDFLAGS="$2" + else LDFLAGS="$enable_ldflags" + fi) + AC_ARG_ENABLE(libs, + [ --enable-libs=... specify link libraries], + if test "$enableval" = "yes" + then LIBS="$3" + else LIBS="$enable_libs" + fi)]) Index: configure.in =================================================================== RCS file: /cvsroot/zsh/zsh/configure.in,v retrieving revision 1.20 diff -u -r1.20 configure.in --- configure.in 2000/08/08 14:57:02 1.20 +++ configure.in 2000/08/11 18:06:39 @@ -48,6 +48,9 @@ dnl Handle --program-prefix, --program-suffix, etc. zsh_ARG_PROGRAM +dnl Handle setting of compile flags (CPPFLAGS, CFLAGS, LDFLAGS, LIBS). +zsh_COMPILE_FLAGS + dnl Do you want to debug zsh? undefine([zsh-debug])dnl AC_ARG_ENABLE(zsh-debug, -- Peter Stephenson <pws@csr.com> Cambridge Silicon Radio, Unit 300, Science Park, Milton Road, Cambridge, CB4 0XL, UK Tel: +44 (0)1223 392070 ^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: How to cache $CFLAGS, $LIBS etc. 2000-08-11 11:28 How to cache $CFLAGS, $LIBS etc Peter Stephenson 2000-08-11 11:32 ` Ollivier Robert 2000-08-11 16:16 ` Bart Schaefer @ 2000-08-16 7:25 ` Andrej Borsenkow 2000-08-16 12:56 ` Bart Schaefer 2 siblings, 1 reply; 8+ messages in thread From: Andrej Borsenkow @ 2000-08-16 7:25 UTC (permalink / raw) To: Zsh hackers list > > 2. Use `--enable-cflags', `--enable-libs', `--enable-ldflags' or whatever. > This probably ought to work because the arguments are remembered for use > with --recheck. But the guide for how configure is used is pretty > fascistic about not allowing anything RMS wouldn't like, so I don't know if > there are drawbacks to this. Plus we need to be careful if people supply > environment variables in the standard way. > > Does anyone know how to do this properly? > May be it is too late, but NEWS for current CVS autoconf says: - Remembers environment variables when reconfiguring. The previous scheme to set envvar before running configure was ENV=VAL ./configure what prevented configure from remembering the environment in which it was run, therefore --recheck was run in an inconsistent environment. Now, one should run ./configure ENV=VAR and then --recheck will work properly. Variables declared with AC_ARG_VAR are also preserved. It also has the whole bunch of new tests (64 bit, LFS, check for proper function prototypes etc etc). The CVS version was recently stamped with version number that probably indicates it's relative "stableness" :-) If we commit to using it ... some packages do (NTP being one). It also gives a chance to test autoconf before release (at least, I'd be very interested to see if tests for 64bit/LFS really work here). -andrej ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to cache $CFLAGS, $LIBS etc. 2000-08-16 7:25 ` Andrej Borsenkow @ 2000-08-16 12:56 ` Bart Schaefer 0 siblings, 0 replies; 8+ messages in thread From: Bart Schaefer @ 2000-08-16 12:56 UTC (permalink / raw) To: Andrej Borsenkow, Zsh hackers list On Aug 16, 11:25am, Andrej Borsenkow wrote: } Subject: RE: How to cache $CFLAGS, $LIBS etc. } } May be it is too late, but NEWS for current CVS autoconf says: } } - Remembers environment variables when reconfiguring. We can't rely on unreleased versions of autoconf unless we're going to put the generated configure into our cvs repository and designate someone to keep it up to date. We can copy tests from the latest autoconf into aclocal.m4, though, if we think they're better than the ones we already do. -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2000-08-16 12:57 UTC | newest] Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2000-08-11 11:28 How to cache $CFLAGS, $LIBS etc Peter Stephenson 2000-08-11 11:32 ` Ollivier Robert 2000-08-11 13:48 ` Trond Eivind Glomsrød 2000-08-11 16:16 ` Bart Schaefer 2000-08-11 16:37 ` Bart Schaefer 2000-08-11 18:08 ` Peter Stephenson 2000-08-16 7:25 ` Andrej Borsenkow 2000-08-16 12:56 ` Bart Schaefer
Code repositories for project(s) associated with this public inbox https://git.vuxu.org/mirror/zsh/ This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).