configure.in and pie

Stefan (metze) Metzmacher metze at samba.org
Sat Jun 25 06:57:01 GMT 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Lars Müller schrieb:
> Hi,
> 
> at the moment we don't compile and link with pie options and also don't
> have the ability to do.
> 
> As it must be possible to build Samba even with non pie aware tool
> chains, I've changes configure.in to add a test for pie.
> 
> It's also possible to call configure with --disable-pie.  But the
> default would be with enabled pie.
> 
> Lars
> 
> 
> ------------------------------------------------------------------------
> 
> Index: source/configure.in
> ===================================================================
> --- source/configure.in	(revision 7875)
> +++ source/configure.in	(working copy)
> @@ -210,6 +210,9 @@
>  AC_SUBST(HOST_OS)
>  AC_SUBST(PICFLAGS)
>  AC_SUBST(PICSUFFIX)
> +AC_SUBST(libc_cv_fpie)
> +AC_SUBST(PIE_CFLAGS)
> +AC_SUBST(PIE_LDFLAGS)
>  AC_SUBST(SHLIBEXT)
>  AC_SUBST(INSTALLCLIENT)
>  AC_SUBST(INSTALLCLIENTCMD_SH)
> @@ -231,6 +234,28 @@
>  AC_SUBST(EXTRA_SBIN_PROGS)
>  AC_SUBST(EXTRA_ALL_TARGETS)
>  
> +# Set defaults
> +libc_cv_fpie=no
> +PIE_CFLAGS=""
> +PIE_LDFLAGS=""
> +AC_ARG_ENABLE(pie, [  --enable-pie            Turn on pie support if available (default=yes)])
> +
> +if test "x$enable_pie" != xno
> +then
> +	AC_CACHE_CHECK(for -fpie, libc_cv_fpie, [dnl
> +		cat > conftest.c <<EOF
> +int foo;
> +main () { return 0;}
> +EOF
> +		if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -pie -fpie -o conftest conftest.c 1>&AS_MESSAGE_LOG_FD])
> +		then
> +			libc_cv_fpie=yes
> +			PIE_CFLAGS="-fpie"
> +			PIE_LDFLAGS="-pie"
> +		fi
> +		rm -f conftest*])
> +fi
> +
>  AC_ARG_ENABLE(debug, 
>  [  --enable-debug          Turn on compiler debugging information (default=no)],
>      [if eval "test x$enable_debug = xyes"; then
> Index: source/Makefile.in
> ===================================================================
> --- source/Makefile.in	(revision 7875)
> +++ source/Makefile.in	(working copy)
> @@ -746,6 +746,8 @@
>  	@echo "      LIBS = $(LIBS)"
>  	@echo "      LDSHFLAGS = $(LDSHFLAGS)"
>  	@echo "      LDFLAGS = $(LDFLAGS)"
> +	@echo "      PIE_CFLAGS = @PIE_CFLAGS@"
> +	@echo "      PIE_LDFLAGS = @PIE_LDFLAGS@"
>  
>  MAKEDIR = || exec false; \
>  	  if test -d "$$dir"; then :; else \
> @@ -759,7 +761,7 @@
>  	@if (: >> $@ || : > $@) >/dev/null 2>&1; then rm -f $@; else \
>  	 dir=`echo $@ | sed 's,/[^/]*$$,,;s,^$$,.,'` $(MAKEDIR); fi
>  	@echo Compiling $*.c
> -	@$(CC) -I. -I$(srcdir) $(FLAGS) -c $< \
> +	@$(CC) -I. -I$(srcdir) $(FLAGS) @PIE_CFLAGS@ -c $< \
>  	  -o $@ 
>  @BROKEN_CC@	-mv `echo $@ | sed 's%^.*/%%g'` $@
>  
> @@ -777,7 +779,7 @@
>  
>  dynconfig.o: dynconfig.c Makefile
>  	@echo Compiling $*.c
> -	@$(CC) $(FLAGS) $(PATH_FLAGS) -c dynconfig.c -o $@ 
> +	@$(CC) $(FLAGS) $(PATH_FLAGS) @PIE_CFLAGS@ -c dynconfig.c -o $@ 
>  
>  dynconfig. at PICSUFFIX@: dynconfig.c Makefile
>  	@if (: >> $@ || : > $@) >/dev/null 2>&1; then rm -f $@; else \
> @@ -788,7 +790,7 @@
>  
>  lib/version.o: lib/version.c include/version.h
>  	@echo Compiling $*.c
> -	@$(CC) -I. -I$(srcdir) $(FLAGS) $(PATH_FLAGS) -c lib/version.c -o $@ 
> +	@$(CC) -I. -I$(srcdir) $(FLAGS) $(PATH_FLAGS) @PIE_CFLAGS@ -c lib/version.c -o $@ 
>  
>  lib/version. at PICSUFFIX@: lib/version.c include/version.h
>  	@if (: >> $@ || : > $@) >/dev/null 2>&1; then rm -f $@; else \
> @@ -799,7 +801,7 @@
>  
>  smbd/build_options.o: smbd/build_options.c Makefile include/config.h include/build_env.h include/proto.h
>  	@echo Compiling $*.c
> -	@$(CC) $(FLAGS) $(PATH_FLAGS) -c smbd/build_options.c -o $@
> +	@$(CC) $(FLAGS) $(PATH_FLAGS) @PIE_CFLAGS@ -c smbd/build_options.c -o $@
>  
>  smbd/build_options.c: include/config.h.in script/mkbuildoptions.awk
>  	@echo Generating $@
> @@ -808,7 +810,7 @@
>  .c. at PICSUFFIX@: 
>  	@if (: >> $@ || : > $@) >/dev/null 2>&1; then rm -f $@; else \
>  	  dir=`echo $@ | sed 's,/[^/]*$$,,;s,^$$,.,'` $(MAKEDIR); fi
> -	@echo Compiling $*.c with @PICFLAGS@
> +	@echo Compiling $*.c
>  	@$(CC) -I. -I$(srcdir) $(FLAGS) @PICFLAGS@ -c $< -o $*. at PICSUFFIX@
>  @BROKEN_CC@	-mv `echo $@ | sed -e 's%^.*/%%g' -e 's%\. at PICSUFFIX@$$%.o%'` $@
>  

why did you change the @echo output here? @PICFLAGS@ is actually used here?
and we the notice to the user that it is used was intended

- --
metze

Stefan Metzmacher <metze at samba.org> www.samba.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3-nr1 (Windows XP)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCvQA5m70gjA5TCD8RAs8AAJ9epnBLoBKElJYWfivm3x886xDLrACgtQbE
vzW4INNre38pKmgItXzwFJw=
=ZDXK
-----END PGP SIGNATURE-----


More information about the samba-technical mailing list