From 464f652ea4d36fd866bd9621f02e0a41c0ecb5c9 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Thu, 22 Dec 2011 21:21:20 +0000 Subject: [PATCH] Eliminate a bunch of weird bogusness with various environment variables Originally committed to SVN as r6076. --- aegisub/Makefile.inc.in | 8 +-- aegisub/Makefile.target | 4 +- aegisub/configure.in | 111 ++++++++++-------------------------- aegisub/libaegisub/Makefile | 2 +- aegisub/src/Makefile | 18 +++--- 5 files changed, 43 insertions(+), 100 deletions(-) diff --git a/aegisub/Makefile.inc.in b/aegisub/Makefile.inc.in index 089e9b579..1ebd764f0 100644 --- a/aegisub/Makefile.inc.in +++ b/aegisub/Makefile.inc.in @@ -80,9 +80,10 @@ P_DOC =$(P_DATAROOT)/doc/aegisub/$(AEGISUB_VERSION_DATA) ############### # LIBRARY FLAGS ############### +CFLAGS_WX = @WX_CFLAGS@ CXXFLAGS_WX = @WX_CXXFLAGS@ - CPPFLAGS_WX = @WX_CPPFLAGS@ +LDFLAGS_WX = @WX_LIBS@ CFLAGS_FONTCONFIG = @FONTCONFIG_CFLAGS@ CFLAGS_FREETYPE = @FREETYPE_CFLAGS@ @@ -99,7 +100,6 @@ CFLAGS_OPENAL = @OPENAL_CFLAGS@ CFLAGS_PORTAUDIO = @PORTAUDIO_CFLAGS@ CFLAGS_PTHREAD = @PTHREAD_CFLAGS@ CFLAGS_UCHARDET = -I../universalchardet -CFLAGS_WX = @WX_CFLAGS@ LDFLAGS_ALSA = @ALSA_LDFLAGS@ LDFLAGS_FONTCONFIG = @FONTCONFIG_LIBS@ @@ -117,8 +117,6 @@ LDFLAGS_OPENAL = @OPENAL_LIBS@ LDFLAGS_PTHREAD = @PTHREAD_LIBS@ LDFLAGS_PORTAUDIO = @PORTAUDIO_LIBS@ LDFLAGS_UCHARDET ?= ../universalchardet/libuniversalchardet.a -LDFLAGS_WX = @WX_LIBS@ - ##################### # DEBUG / DEVELOPMENT @@ -126,11 +124,9 @@ LDFLAGS_WX = @WX_LIBS@ PRECOMPILED_HEADER = @enable_gcc_prec@ CCACHE_ENABLE = @enable_ccache@ LDFLAGS_CCMALLOC = @CCMALLOC_LDFLAGS@ -LDFLAGS_DEBUG = @DEBUG_FLAGS@ LDFLAGS_EFENCE = @EFENCE_LDFLAGS@ LDFLAGS_GCOV = @GCOV_LDFLAGS@ -CFLAGS_DEBUG = @DEBUG_FLAGS@ CFLAGS_EFENCE = @EFENCE_LDFLAGS@ CFLAGS_GCOV = @GCOV_CFLAGS@ diff --git a/aegisub/Makefile.target b/aegisub/Makefile.target index 906a64964..f5ff66d5e 100644 --- a/aegisub/Makefile.target +++ b/aegisub/Makefile.target @@ -160,7 +160,7 @@ endif .SUFFIXES: .o .c .cpp .cxx %.o: %.c - $(CXX_ENV) $(BIN_CC) $(CFLAGS_DEP) $(CFLAGS) -c -o $@ $< + $(CXX_ENV) $(BIN_CC) $(CFLAGS_DEP) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< %.o: %.cpp $(CXX_ENV) $(BIN_CXX) $(CFLAGS_DEP) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $< @@ -169,7 +169,7 @@ endif $(CXX_ENV) $(BIN_CXX) $(CFLAGS_DEP) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $< $(PRECOMPILED_HEADER_NAME).gch: $(PRECOMPILED_HEADER_NAME) - $(CXX_ENV) $(BIN_CXX) $(CXXFLAGS) $(DEBUG_FLAGS) $< + $(CXX_ENV) $(BIN_CXX) $(CPPFLAGS) $(CXXFLAGS) $< diff --git a/aegisub/configure.in b/aegisub/configure.in index 808453315..eff8ddccf 100644 --- a/aegisub/configure.in +++ b/aegisub/configure.in @@ -33,6 +33,8 @@ m4_define([fftw_required_version], [3.3]) # Setup ####### AC_INIT([Aegisub], [aegisub_version],, [aegisub]) +: ${CFLAGS=""} +: ${CXXFLAGS=""} AC_CONFIG_SRCDIR([src/main.cpp]) AC_CONFIG_HEADER([acconf.h]) AC_GNU_SOURCE @@ -42,7 +44,6 @@ AC_CANONICAL_HOST ########################### # Check target architecture ########################### - AC_MSG_CHECKING([for target architecture]) case x"$target" in xNONE | x) @@ -123,11 +124,9 @@ AC_C_BIGENDIAN( AC_DEFINE([HAVE_UNIVERSAL_ENDIAN], [1], [Universal Endian (MAC Universal PPC/Intel Binaries, uses HAVE_DYNAMIC_ENDIAN)]) ) - ######################## # Configurable variables ######################## - # These cannot be set before AC_INIT() AEGISUB_VERSION_MAJOR=aegisub_version_major AEGISUB_VERSION_MINOR=aegisub_version_minor @@ -149,23 +148,14 @@ AC_SUBST(AEGISUB_COMMAND) AC_ARG_WITH(desktop-dir, AS_HELP_STRING([--with-desktop-dir=PATH],[desktop file locations [PREFIX/share/applications]])) -if test -z "$with_desktop_dir"; then - P_DESKTOP="$datarootdir/applications" -else - P_DESKTOP=$with_desktop_dir -fi +P_DESKTOP=${with_desktop_dir:-$datarootdir/applications} AC_SUBST(P_DESKTOP) - # Handle location of icons: http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html AC_ARG_WITH(icon-dir, AS_HELP_STRING([--with-icon-dir=PATH],[icon locations [PREFIX/share/icons]])) -if test -z "$with_icon_dir"; then - P_ICON="$datarootdir/icons" -else - P_ICON=$with_icon_dir -fi +P_ICON=${with_icon_dir:-$datarootdir/icons} AC_SUBST(P_ICON) @@ -196,7 +186,6 @@ else AC_MSG_RESULT([no]) fi - #################### # Check for programs #################### @@ -281,7 +270,6 @@ if test "$agi_cv_with_pthread_rwlock" = "yes"; then AC_DEFINE(HAVE_RWLOCK,1,[define if the compiler implements pthread_rwlock_*]) fi - ###################### # Check compiler flags ###################### @@ -393,19 +381,15 @@ PKG_CHECK_MODULES(FONTCONFIG, fontconfig >= fontconfig_required_version, ######## ## iconv ######## -AC_ARG_VAR([ICONV_CFLAGS], [CFLAGS to use for iconv [CPPFLAGS]]) -AC_ARG_VAR([ICONV_LDFLAGS], [LDFLAGS to use for iconv [LDFLAGS -liconv]]) +AC_ARG_VAR([ICONV_CFLAGS], [CFLAGS to use for iconv []]) +AC_ARG_VAR([ICONV_LDFLAGS], [LDFLAGS to use for iconv [-liconv]]) if test -z "$ICONV_LDFLAGS"; then - if test "$build_linux" = "yes"; then - ICONV_LDFLAGS="$LDFLAGS" - else - ICONV_LDFLAGS="$LDFLAGS -liconv"; - fi -fi - -if test -z "$ICONV_CFLAGS"; then - ICONV_CFLAGS="$CPPFLAGS"; + OLD_LIBS="$LIBS" + LIBS="" + AC_SEARCH_LIBS([iconv_open], [iconv]) + ICONV_LDFLAGS="$LIBS" + LIBS="$OLD_LIBS" fi AC_AGI_COMPILE([iconv], [iconv], [$ICONV_CFLAGS], [$ICONV_LDFLAGS],[ @@ -439,8 +423,6 @@ if test "$agi_cv_with_iconv_const" = "yes"; then AC_DEFINE(AGI_ICONV_CONST, 1, [Enable if iconv expects the in argument to be const]) fi - - ############### # Audio Players ############### @@ -451,31 +433,23 @@ AC_ARG_WITH(alsa, AS_HELP_STRING([--without-alsa],[build without ALSA audio provider [auto]]), alsa_disabled="(disabled)") -AC_ARG_VAR([ALSA_CFLAGS], [CFLAGS to use for ALSA [CPPFLAGS]]) +AC_ARG_VAR([ALSA_CFLAGS], [CFLAGS to use for ALSA []]) AC_ARG_VAR([ALSA_LDFLAGS], [LDFLAGS to use for ALSA [-lasound -lrt]]) -if test -z "$ALSA_LDFLAGS"; then - ALSA_LDFLAGS="-lasound -lrt"; -fi - -if test -z "$ALSA_CFLAGS"; then - ALSA_CFLAGS="$CPPFLAGS"; -fi +ALSA_LDFLAGS=${ALSA_LDFLAGS:--lasound -lrt} if test "$with_alsa" != "no"; then - aegisub_save_LDFLAGS="$LDFLAGS" - LDFLAGS="$ALSA_LDFLAGS" - AC_CHECK_LIB([asound], [snd_pcm_open], [ALSA_LDFLAGS="-lasound -lrt"; with_alsa="yes"], [with_alsa="no"]) - LDFLAGS="$aegisub_save_LDFLAGS" + AC_CHECK_LIB([asound], [snd_pcm_open], [with_alsa="yes"], [with_alsa="no"], $ALSA_LDFLAGS) fi if test "$with_alsa" != "no"; then AC_DEFINE(WITH_ALSA, 1, [Enable ALSA Support]) found_audio_player="yes" fi -AC_SUBST(with_alsa) -AC_SUBST(ALSA_LDFLAGS) +AC_SUBST(ALSA_CFLAGS) +AC_SUBST(ALSA_LDFLAGS) +AC_SUBST(with_alsa) ############ ## PortAudio @@ -495,7 +469,6 @@ fi AC_SUBST(with_portaudio) - ############# ## PulseAudio ############# @@ -514,7 +487,6 @@ fi AC_SUBST(with_pulseaudio) - ######### ## OpenAL ######### @@ -562,7 +534,6 @@ fi AC_SUBST(with_openal) - ###### ## OSS ###### @@ -764,13 +735,11 @@ AC_ARG_VAR([DEBUG_FLAGS], [Debug flag to use with --enable-debug [-g]]) AC_MSG_CHECKING([whether to turn on debugging]) AC_ARG_ENABLE(debug, AS_HELP_STRING([--enable-debug],[enable debugging [no]])) + if test "$enable_debug" = "yes"; then - if test -z "$DEBUG_FLAGS"; then - DEBUG_FLAGS="-g"; - fi + DEBUG_FLAGS=${DEBUG_FLAGS:--g} AC_MSG_RESULT([yes ($DEBUG_FLAGS)]) - CPPFLAGS="$DEBUG_FLAGS $CPPFLAGS" msg_debug="($DEBUG_FLAGS)" # This turns on some internal (to aegisub) debugging features. @@ -779,6 +748,7 @@ if test "$enable_debug" = "yes"; then AC_CXX_FLAG([-D_DEBUG]) fi else + DEBUG_FLAGS="" enable_debug="no" AC_MSG_RESULT([no]) fi @@ -807,11 +777,9 @@ AC_ARG_VAR([PROFILE_FLAGS], [Profile flag(s) to use with --enable-profile [-pg]] AC_MSG_CHECKING([whether to turn on profiling]) AC_ARG_ENABLE(profile, AS_HELP_STRING([--enable-profile],[enable profiling [no]])) if test "$enable_profile" = "yes"; then - if test -z "$PROFILE_FLAGS"; then - PROFILE_FLAGS="-pg"; - fi + PROFILE_FLAGS=${PROFILE_FLAGS:--pg} AC_MSG_RESULT([yes ($PROFILE_FLAGS)]) - CPPFLAGS="$PROFILE_FLAGS $CPPFLAGS" + CFLAGS="$PROFILE_FLAGS $CFLAGS" else enable_profile="no" AC_MSG_RESULT([no]) @@ -828,24 +796,17 @@ AC_MSG_CHECKING([whether to turn on gcov]) AC_ARG_ENABLE(gcov, AS_HELP_STRING([--enable-gcov],[enable gcov [no]])) if test "$enable_gcov" = "yes"; then - if test -z "$GCOV_CFLAGS"; then - GCOV_CFLAGS="-fprofile-arcs -ftest-coverage"; - fi - - if test -z "$GCOV_LDFLAGS"; then - GCOV_LDFLAGS="-lgcov"; - fi + GCOV_CFLAGS=${GCOV_CLFAGS:--fprofile-arcs -ftest-coverage} + GCOV_LDFLAGS=${GCOV_LDFLAGS:--lgcov} AC_MSG_RESULT([yes ($GCOV_FLAGS)]) CFLAGS="$CFLAGS $GCOV_CFLAGS" LDFLAGS="$LDFLAGS $GCOV_LDFLAGS" - CPPFLAGS="$CPPFLAGS $GCOV_CFLAGS" else enable_gcov="no" AC_MSG_RESULT([no]) fi - ################ # Electric Fence ################ @@ -854,9 +815,7 @@ AC_ARG_VAR([EFENCE_LDFLAGS], [Electric Fence ldflag(s) to use with --enable-prof AC_MSG_CHECKING([whether to turn on Electric Fence]) AC_ARG_ENABLE(efence, AS_HELP_STRING([--enable-efence],[enable Electric Fence [no]])) if test "$enable_efence" = "yes"; then - if test -z "$EFENCE_LDFLAGS"; then - EFENCE_LDFLAGS="-lefence"; - fi + EFENCE_LDFLAGS=${EFENCE_LDFLAGS:--lefence} AC_MSG_RESULT([yes ($EFENCE_LDFLAGS)]) else enable_efence="no" @@ -873,13 +832,8 @@ AC_ARG_VAR([CCMALLOC_LDFLAGS], [ccmalloc ldflag(s) to use with --enable-ccmalloc AC_MSG_CHECKING([whether to turn on ccmalloc]) AC_ARG_ENABLE(ccmalloc, AS_HELP_STRING([--enable-ccmalloc],[enable ccmalloc [no]])) if test "$enable_ccmalloc" = "yes"; then - if test -z "$CCMALLOC_LIBS"; then - CCMALLOC_LIBS="$prefix/lib/ccmalloc-c++.o"; - fi - - if test -z "$CCMALLOC_LDFLAGS"; then - CCMALLOC_LDFLAGS="-lccmalloc"; - fi + CCMALLOC_LIBS=${CCMALLOC_LIBS:-$prefix/lib/ccmalloc-c++.o} + CCMALLOC_LDFLAGS=${CCMALLOC_LDFLAGS:--lccmalloc} AC_MSG_RESULT([yes ($CCMALLOC_LIBS $CCMALLOC_LDFLAGS)]) else enable_ccmalloc="no" @@ -890,8 +844,7 @@ AC_SUBST(CCMALLOC_LIBS) if test "$enable_efence" = "yes" && test "$enable_ccmalloc" = "yes"; then AC_MSG_FAILURE([Please enable Electric Fence _or_ ccmalloc otherwise strange things will happen.]) -fi - +fi ######## # ccache @@ -906,7 +859,6 @@ else fi AC_SUBST(enable_ccache) - ############################## # Internationalisation support ############################## @@ -952,12 +904,10 @@ AC_DEFINE_UNQUOTED([DEFAULT_PLAYER_AUDIO], ["$default_player_audio"], [Default a # Set some friendly strings if some of the above aren't detected. -if test -z "$default_player_audio"; then - default_player_audio="NONE" -fi +default_player_audio=${default_player_audio:-NONE} ############### -# Misc settings +# Misc settings ############### AC_SUBST(found_audio_player) @@ -1009,6 +959,7 @@ Configure settings Install prefix: $prefix SVN Revision: $SVN_REVISION Debug $enable_debug $msg_debug + CFLAGS $CFLAGS CXXFLAGS $CXXFLAGS CPPFLAGS $CPPFLAGS LDFLAGS $LDFLAGS diff --git a/aegisub/libaegisub/Makefile b/aegisub/libaegisub/Makefile index f76f7b3de..aec294110 100644 --- a/aegisub/libaegisub/Makefile +++ b/aegisub/libaegisub/Makefile @@ -6,7 +6,7 @@ LIB_SHARED = libaegisub-3.0.so LIB_SHARED_INSTALL = yes LIB_VERSION = 3 -CXXFLAGS = -Iinclude -I../src -I.. -DLAGI -fPIC -Wno-variadic-macros +CXXFLAGS += -Iinclude -I../src -I.. -DLAGI -fPIC -Wno-variadic-macros $(DEBUG_FLAGS) PRECOMPILED_HEADER_NAME = lagi_pre.h lagi_pre.h.gch: CXXFLAGS := $(CXXFLAGS) diff --git a/aegisub/src/Makefile b/aegisub/src/Makefile index 6c26731a4..0bdeae39e 100644 --- a/aegisub/src/Makefile +++ b/aegisub/src/Makefile @@ -5,23 +5,24 @@ PROGRAM_INSTALL = yes PRECOMPILED_HEADER_NAME=agi_pre.h -CXXFLAGS += -DAEGISUB -D__STDC_FORMAT_MACROS -I. -I.. -Iinclude -I../libaegisub/include $(CFLAGS_PTHREAD) $(CPPFLAGS_WX) $(CFLAGS_FFTW3) +AEGISUB_CFLAGS = -I. -I.. -Iinclude -I../libaegisub/include -DAEGISUB $(CFLAGS_PTHREAD) $(CFLAGS_FFTW3) $(DEBUG_FLAGS) $(CFLAGS_PROFILE) + +CFLAGS += $(AEGISUB_CFLAGS) +CXXFLAGS += $(AEGISUB_CFLAGS) -D__STDC_FORMAT_MACROS $(CXXFLAGS_WX) LDFLAGS += -L../libaegisub -laegisub-3.0 -LDFLAGS += $(CFLAGS_DEBUG) $(CFLAGS_PROFILE) $(LDFLAGS_CCMALLOC) -LDFLAGS += $(LDFLAGS_EFENCE) $(LDFLAGS_GL) $(LDFLAGS_PTHREAD) $(LDFLAGS_WX) -LDFLAGS += $(LDFLAGS_FREETYPE) $(LDFLAGS_FONTCONFIG) $(LDFLAGS_FFTW3) +LDFLAGS += $(LDFLAGS_CCMALLOC) $(LDFLAGS_EFENCE) $(LDFLAGS_GL) +LDFLAGS += $(LDFLAGS_PTHREAD) $(LDFLAGS_WX) $(LDFLAGS_FREETYPE) +LDFLAGS += $(LDFLAGS_FONTCONFIG) $(LDFLAGS_FFTW3) LDFLAGS_POST += $(LDFLAGS_UCHARDET) ifdef BUILD_DARWIN LDFLAGS += -lz endif - ############### # AUDIO PLAYERS ############### - ifeq (yes, $(HAVE_ALSA)) SRC_OPT += audio_player_alsa.cpp audio_player_alsa.o: CXXFLAGS += $(CFLAGS_ALSA) @@ -50,7 +51,6 @@ ifeq (yes, $(HAVE_OSS)) SRC_OPT += audio_player_oss.cpp endif - ####################### # AUDIO / VIDEO SUPPORT ####################### @@ -62,7 +62,6 @@ LDFLAGS += $(LDFLAGS_FFMS) LDFLAGS_POST += $(LDFLAGS_FFMS) endif - ########### # SUBTITLES ########### @@ -73,7 +72,6 @@ LDFLAGS += $(LDFLAGS_LIBASS) LDFLAGS_POST += $(LDFLAGS_LIBASS) endif - ############ # AUTOMATION ############ @@ -83,7 +81,6 @@ auto4_lua.o auto4_lua_assfile.o auto4_lua_dialog.o auto4_lua_progresssink.o aut LDFLAGS += $(LDFLAGS_LUA) endif - ############## # MISCELLANOUS ############## @@ -93,7 +90,6 @@ spellchecker_hunspell.o: CXXFLAGS += $(CFLAGS_HUNSPELL) LDFLAGS += $(LDFLAGS_HUNSPELL) endif - ##################### # SOURCE-LEVEL CFLAGS #####################