move the declaration of struct ast_channel ast_frame and ast_module
[asterisk/asterisk.git] / Makefile
index a3e7e51..7730cdf 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -15,7 +15,6 @@
 #
 # ASTCFLAGS - compiler options
 # ASTLDFLAGS - linker flags (not libraries)
-# AST_LIBS - libraries to build binaries XXX
 # LIBS - additional libraries, at top-level for all links,
 #      on a single object just for that object
 # SOLINK - linker flags used only for creating shared objects (.so files),
@@ -62,12 +61,6 @@ export DOWNLOAD
 export GREP
 export ID
 export OSARCH
-export CURSES_DIR
-export NCURSES_DIR
-export TERMCAP_DIR
-export TINFO_DIR
-export GTK2_LIB
-export GTK2_INCLUDE
 
 # even though we could use '-include makeopts' here, use a wildcard
 # lookup anyway, so that make won't try to build makeopts if it doesn't
@@ -77,8 +70,9 @@ ifneq ($(wildcard makeopts),)
 endif
 
 # Some build systems, such as the one in openwrt, like to pass custom target
-# CFLAGS in the COPTS variable.
+# CFLAGS and LDFLAGS in the COPTS and LDOPTS variables.
 ASTCFLAGS+=$(COPTS)
+ASTLDFLAGS+=$(LDOPTS)
 
 #Uncomment this to see all build commands instead of 'quiet' output
 #NOISY_BUILD=yes
@@ -107,6 +101,8 @@ ifeq ($(OSARCH),SunOS)
   ASTETCDIR=/var/etc/asterisk
   ASTLIBDIR=/opt/asterisk/lib
   ASTVARLIBDIR=/var/opt/asterisk
+  ASTDBDIR=$(ASTVARLIBDIR)
+  ASTKEYDIR=$(ASTVARLIBDIR)
   ASTSPOOLDIR=/var/spool/asterisk
   ASTLOGDIR=/var/log/asterisk
   ASTHEADERDIR=/opt/asterisk/include
@@ -127,9 +123,12 @@ else
 ifneq ($(findstring BSD,$(OSARCH)),)
   ASTVARLIBDIR=$(prefix)/share/asterisk
   ASTVARRUNDIR=$(localstatedir)/run/asterisk
+  ASTDBDIR=$(localstatedir)/db/asterisk
 else
   ASTVARLIBDIR=$(localstatedir)/lib/asterisk
+  ASTDBDIR=$(ASTVARLIBDIR)
 endif
+  ASTKEYDIR=$(ASTVARLIBDIR)
 endif
 ifeq ($(ASTDATADIR),)
   ASTDATADIR:=$(ASTVARLIBDIR)
@@ -194,7 +193,11 @@ ifeq ($(OSARCH),linux-gnu)
   endif
 endif
 
-ASTCFLAGS+=-pipe -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG)
+ifeq ($(findstring -save-temps,$(ASTCFLAGS)),)
+ASTCFLAGS+=-pipe
+endif
+
+ASTCFLAGS+=-Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG)
 
 ASTCFLAGS+=-include $(ASTTOPDIR)/include/asterisk/autoconfig.h
 
@@ -219,7 +222,6 @@ ifeq ($(OSARCH),FreeBSD)
   # -V is understood by BSD Make, not by GNU make.
   BSDVERSION=$(shell make -V OSVERSION -f /usr/share/mk/bsd.port.subdir.mk)
   ASTCFLAGS+=$(shell if test $(BSDVERSION) -lt 500016 ; then echo "-D_THREAD_SAFE"; fi)
-  AST_LIBS+=$(shell if test  $(BSDVERSION) -lt 502102 ; then echo "-lc_r"; else echo "-pthread"; fi)
 endif
 
 ifeq ($(OSARCH),NetBSD)
@@ -249,11 +251,12 @@ endif
 
 ASTCFLAGS+=$(MALLOC_DEBUG)$(BUSYDETECT)$(OPTIONS)
 
-MOD_SUBDIRS:=res channels pbx apps codecs formats cdr funcs main
+MOD_SUBDIRS:=channels pbx apps codecs formats cdr funcs main res
 OTHER_SUBDIRS:=utils agi
 SUBDIRS:=$(OTHER_SUBDIRS) $(MOD_SUBDIRS)
 SUBDIRS_INSTALL:=$(SUBDIRS:%=%-install)
 SUBDIRS_CLEAN:=$(SUBDIRS:%=%-clean)
+SUBDIRS_DIST_CLEAN:=$(SUBDIRS:%=%-dist-clean)
 SUBDIRS_UNINSTALL:=$(SUBDIRS:%=%-uninstall)
 MOD_SUBDIRS_EMBED_LDSCRIPT:=$(MOD_SUBDIRS:%=%-embed-ldscript)
 MOD_SUBDIRS_EMBED_LDFLAGS:=$(MOD_SUBDIRS:%=%-embed-ldflags)
@@ -261,7 +264,6 @@ MOD_SUBDIRS_EMBED_LIBS:=$(MOD_SUBDIRS:%=%-embed-libs)
 
 ifneq ($(findstring darwin,$(OSARCH)),)
   ASTCFLAGS+=-D__Darwin__
-  AUDIO_LIBS=-framework CoreAudio
   SOLINK=-dynamic -bundle -undefined suppress -force_flat_namespace
 else
 # These are used for all but Darwin
@@ -275,6 +277,10 @@ ifeq ($(OSARCH),SunOS)
   SOLINK=-shared -fpic -L/usr/local/ssl/lib
 endif
 
+ifneq ($(findstring $(OSARCH), mingw32 cygwin ),)
+  SOLINK=-Xlinker -r
+endif
+
 # This is used when generating the doxygen documentation
 ifneq ($(DOT),:)
   HAVEDOT=yes
@@ -282,16 +288,24 @@ else
   HAVEDOT=no
 endif
 
+# $(MAKE) is printed in several places, and we want it to be a
+# fixed size string. Define a variable whose name has also the
+# same size, so we can easily align text.
+ifeq ($(MAKE), gmake)
+       mK="gmake"
+else
+       mK=" make"
+endif
+
+# comment to print directories during submakes
+PRINT_DIR:= --no-print-directory
+
 all: _all
        @echo " +--------- Asterisk Build Complete ---------+"  
        @echo " + Asterisk has successfully been built, and +"  
        @echo " + can be installed by running:              +"
        @echo " +                                           +"
-ifeq ($(MAKE), gmake)
-       @echo " +               $(MAKE) install               +"  
-else
-       @echo " +               $(MAKE) install                +"  
-endif
+       @echo " +               $(mK) install               +"  
        @echo " +-------------------------------------------+"  
 
 _all: cleantest $(SUBDIRS)
@@ -307,34 +321,46 @@ menuselect.makeopts: menuselect/menuselect menuselect-tree
        menuselect/menuselect --check-deps $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS) menuselect.makeopts
 
 $(MOD_SUBDIRS_EMBED_LDSCRIPT):
-       @echo "EMBED_LDSCRIPTS+="`$(MAKE) --quiet --no-print-directory -C $(@:-embed-ldscript=) SUBDIR=$(@:-embed-ldscript=) __embed_ldscript` >> makeopts.embed_rules
+       @echo "EMBED_LDSCRIPTS+="`$(MAKE) --quiet $(PRINT_DIR) -C $(@:-embed-ldscript=) SUBDIR=$(@:-embed-ldscript=) __embed_ldscript` >> makeopts.embed_rules
 
 $(MOD_SUBDIRS_EMBED_LDFLAGS):
-       @echo "EMBED_LDFLAGS+="`$(MAKE) --quiet --no-print-directory -C $(@:-embed-ldflags=) SUBDIR=$(@:-embed-ldflags=) __embed_ldflags` >> makeopts.embed_rules
+       @echo "EMBED_LDFLAGS+="`$(MAKE) --quiet $(PRINT_DIR) -C $(@:-embed-ldflags=) SUBDIR=$(@:-embed-ldflags=) __embed_ldflags` >> makeopts.embed_rules
 
 $(MOD_SUBDIRS_EMBED_LIBS):
-       @echo "EMBED_LIBS+="`$(MAKE) --quiet --no-print-directory -C $(@:-embed-libs=) SUBDIR=$(@:-embed-libs=) __embed_libs` >> makeopts.embed_rules
+       @echo "EMBED_LIBS+="`$(MAKE) --quiet $(PRINT_DIR) -C $(@:-embed-libs=) SUBDIR=$(@:-embed-libs=) __embed_libs` >> makeopts.embed_rules
 
 makeopts.embed_rules: menuselect.makeopts
        @echo "Generating embedded module rules ..."
        @rm -f $@
-       @$(MAKE) --no-print-directory $(MOD_SUBDIRS_EMBED_LDSCRIPT)
-       @$(MAKE) --no-print-directory $(MOD_SUBDIRS_EMBED_LDFLAGS)
-       @$(MAKE) --no-print-directory $(MOD_SUBDIRS_EMBED_LIBS)
+       @$(MAKE) $(PRINT_DIR) $(MOD_SUBDIRS_EMBED_LDSCRIPT)
+       @$(MAKE) $(PRINT_DIR) $(MOD_SUBDIRS_EMBED_LDFLAGS)
+       @$(MAKE) $(PRINT_DIR) $(MOD_SUBDIRS_EMBED_LIBS)
 
 $(SUBDIRS): include/asterisk/version.h include/asterisk/build.h include/asterisk/buildopts.h defaults.h makeopts.embed_rules
 
-# ensure that all module subdirectories are processed before 'main' during
-# a parallel build, since if there are modules selected to be embedded the
-# directories containing them must be completed before the main Asterisk
-# binary can be built
+ifeq ($(findstring $(OSARCH), mingw32 cygwin ),)
+    # Non-windows:
+    # ensure that all module subdirectories are processed before 'main' during
+    # a parallel build, since if there are modules selected to be embedded the
+    # directories containing them must be completed before the main Asterisk
+    # binary can be built
 main: $(filter-out main,$(MOD_SUBDIRS))
+else
+    # Windows: we need to build main (i.e. the asterisk dll) first,
+    # followed by res, followed by the other directories, because
+    # dll symbols must be resolved during linking and not at runtime.
+D1:= $(filter-out main,$(MOD_SUBDIRS))
+D1:= $(filter-out res,$(D1))
+
+$(D1): res
+res:   main
+endif
 
 $(MOD_SUBDIRS):
-       @ASTCFLAGS="$(MOD_SUBDIR_CFLAGS) $(ASTCFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" AST_LIBS="$(AST_LIBS)" $(MAKE) --no-print-directory --no-builtin-rules -C $@ SUBDIR=$@ all
+       @ASTCFLAGS="$(MOD_SUBDIR_CFLAGS) $(ASTCFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" $(MAKE) $(PRINT_DIR) --no-builtin-rules -C $@ SUBDIR=$@ all
 
 $(OTHER_SUBDIRS):
-       @ASTCFLAGS="$(OTHER_SUBDIR_CFLAGS) $(ASTCFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" AUDIO_LIBS="$(AUDIO_LIBS)" $(MAKE) --no-print-directory --no-builtin-rules -C $@ SUBDIR=$@ all
+       @ASTCFLAGS="$(OTHER_SUBDIR_CFLAGS) $(ASTCFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" $(MAKE) $(PRINT_DIR) --no-builtin-rules -C $@ SUBDIR=$@ all
 
 defaults.h: makeopts
        @build_tools/make_defaults_h > $@.tmp
@@ -365,7 +391,10 @@ include/asterisk/build.h:
        @rm -f $@.tmp
 
 $(SUBDIRS_CLEAN):
-       @$(MAKE) --no-print-directory -C $(@:-clean=) clean
+       @$(MAKE) $(PRINT_DIR) -C $(@:-clean=) clean
+
+$(SUBDIRS_DIST_CLEAN):
+       @$(MAKE) $(PRINT_DIR) -C $(@:-dist-clean=) dist-clean
 
 clean: $(SUBDIRS_CLEAN)
        rm -f defaults.h
@@ -376,7 +405,7 @@ clean: $(SUBDIRS_CLEAN)
 
 dist-clean: distclean
 
-distclean: clean
+distclean: $(SUBDIRS_DIST_CLEAN) clean
        @$(MAKE) -C menuselect dist-clean
        @$(MAKE) -C sounds dist-clean
        rm -f menuselect.makeopts makeopts menuselect-tree menuselect.makedeps
@@ -500,22 +529,14 @@ install: datafiles bininstall $(SUBDIRS_INSTALL)
        @echo " + configuration files (overwriting any      +"
        @echo " + existing config files), run:              +"  
        @echo " +                                           +"
-ifeq ($(MAKE), gmake)
-       @echo " +               $(MAKE) samples               +"
-else
-       @echo " +               $(MAKE) samples                +"
-endif
+       @echo " +               $(mK) samples               +"
        @echo " +                                           +"
        @echo " +-----------------  or ---------------------+"
        @echo " +                                           +"
        @echo " + You can go ahead and install the asterisk +"
        @echo " + program documentation now or later run:   +"
        @echo " +                                           +"
-ifeq ($(MAKE), gmake)
-       @echo " +              $(MAKE) progdocs               +"
-else
-       @echo " +              $(MAKE) progdocs                +"
-endif
+       @echo " +              $(mK) progdocs               +"
        @echo " +                                           +"
        @echo " + **Note** This requires that you have      +"
        @echo " + doxygen installed on your local system    +"
@@ -524,37 +545,49 @@ endif
 
 upgrade: bininstall
 
+# XXX why *.adsi is installed first ?
 adsi:
-       mkdir -p $(DESTDIR)$(ASTETCDIR)
-       for x in configs/*.adsi; do \
-               if [ ! -f $(DESTDIR)$(ASTETCDIR)/$$x ]; then \
-                       $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x` ; \
+       @echo Installing adsi config files...
+       @mkdir -p $(DESTDIR)$(ASTETCDIR)
+       @for x in configs/*.adsi; do \
+               dst="$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x`" ; \
+               if [ -f $${dst} ] ; then \
+                       echo "Overwriting $$x" ; \
+               else \
+                       echo "Installing $$x" ; \
                fi ; \
+               $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x` ; \
        done
 
 samples: adsi
-       mkdir -p $(DESTDIR)$(ASTETCDIR)
-       for x in configs/*.sample; do \
-               if [ -f $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample` ]; then \
+       @echo Installing other config files...
+       @mkdir -p $(DESTDIR)$(ASTETCDIR)
+       @for x in configs/*.sample; do \
+               dst="$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample`" ;        \
+               if [ -f $${dst} ]; then \
                        if [ "$(OVERWRITE)" = "y" ]; then \
-                               if cmp -s $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample` $$x ; then \
+                               if cmp -s $${dst} $$x ; then \
                                        echo "Config file $$x is unchanged"; \
                                        continue; \
                                fi ; \
-                               mv -f $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample` $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample`.old ; \
+                               mv -f $${dst} $${dst}.old ; \
                        else \
                                echo "Skipping config file $$x"; \
                                continue; \
                        fi ;\
                fi ; \
-               $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample` ;\
+               echo "Installing file $$x"; \
+               $(INSTALL) -m 644 $$x $${dst} ;\
        done
-       if [ "$(OVERWRITE)" = "y" ] || [ ! -f $(DESTDIR)$(ASTCONFPATH) ]; then \
+       @if [ "$(OVERWRITE)" = "y" ] || [ ! -f $(DESTDIR)$(ASTCONFPATH) ]; then \
+               echo "Creating asterisk.conf"; \
                ( \
                echo "[directories]" ; \
                echo "astetcdir => $(ASTETCDIR)" ; \
                echo "astmoddir => $(MODULES_DIR)" ; \
                echo "astvarlibdir => $(ASTVARLIBDIR)" ; \
+               echo "astdbdir => $(ASTDBDIR)" ; \
+               echo "astkeydir => $(ASTKEYDIR)" ; \
                echo "astdatadir => $(ASTDATADIR)" ; \
                echo "astagidir => $(AGI_DIR)" ; \
                echo "astspooldir => $(ASTSPOOLDIR)" ; \
@@ -562,9 +595,34 @@ samples: adsi
                echo "astlogdir => $(ASTLOGDIR)" ; \
                echo "" ; \
                echo ";[options]" ; \
+               echo ";verbose = 3" ; \
+               echo ";debug = 3" ; \
+               echo ";alwaysfork = yes ; same as -F at startup" ; \
+               echo ";nofork = yes ; same as -f at startup" ; \
+               echo ";quiet = yes ; same as -q at startup" ; \
+               echo ";timestamp = yes ; same as -T at startup" ; \
+               echo ";execincludes = yes ; support #exec in config files" ; \
+               echo ";console = yes ; Run as console (same as -c at startup)" ; \
+               echo ";highpriority = yes ; Run realtime priority (same as -p at startup)" ; \
+               echo ";initcrypto = yes ; Initialize crypto keys (same as -i at startup)" ; \
+               echo ";nocolor = yes ; Disable console colors" ; \
+               echo ";dontwarn = yes ; Disable some warnings" ; \
+               echo ";dumpcore = yes ; Dump core on crash (same as -g at startup)" ; \
+               echo ";languageprefix = yes ; Use the new sound prefix path syntax" ; \
                echo ";internal_timing = yes" ; \
                echo ";systemname = my_system_name ; prefix uniqueid with a system name for global uniqueness issues" ; \
                echo ";autosystemname = yes ; automatically set systemname to hostname - uses 'localhost' on failure, or systemname if set" ; \
+               echo ";maxcalls = 10 ; Maximum amount of calls allowed" ; \
+               echo ";maxload = 0.9 ; Asterisk stops accepting new calls if the load average exceed this limit" ; \
+               echo ";maxfiles = 1000 ; Maximum amount of openfiles" ; \
+               echo ";minmemfree = 1 ; in MBs, Asterisk stops accepting new calls if the amount of free memory falls below this watermark" ; \
+               echo ";cache_record_files = yes ; Cache recorded sound files to another directory during recording" ; \
+               echo ";record_cache_dir = /tmp ; Specify cache directory (used in cnjunction with cache_record_files)" ; \
+               echo ";transmit_silence_during_record = yes ; Transmit SLINEAR silence while a channel is being recorded" ; \
+               echo ";transcode_via_sln = yes ; Build transcode paths via SLINEAR, instead of directly" ; \
+               echo ";runuser = asterisk ; The user to run as" ; \
+               echo ";rungroup = asterisk ; The group to run as" ; \
+               echo "" ; \
                echo "; Changing the following lines may compromise your security." ; \
                echo ";[files]" ; \
                echo ";astctlpermissions = 0660" ; \
@@ -625,20 +683,20 @@ progdocs:
 config:
        @if [ "${OSARCH}" = "linux-gnu" ]; then \
                if [ -f /etc/redhat-release -o -f /etc/fedora-release ]; then \
-                       $(INSTALL) -m 755 contrib/init.d/rc.redhat.asterisk /etc/rc.d/init.d/asterisk; \
-                       /sbin/chkconfig --add asterisk; \
+                       $(INSTALL) -m 755 contrib/init.d/rc.redhat.asterisk $(DESTDIR)/etc/rc.d/init.d/asterisk; \
+                       if [ -z "$(DESTDIR)" ]; then /sbin/chkconfig --add asterisk; fi; \
                elif [ -f /etc/debian_version ]; then \
-                       $(INSTALL) -m 755 contrib/init.d/rc.debian.asterisk /etc/init.d/asterisk; \
-                       /usr/sbin/update-rc.d asterisk start 10 2 3 4 5 . stop 91 2 3 4 5 .; \
+                       $(INSTALL) -m 755 contrib/init.d/rc.debian.asterisk $(DESTDIR)/etc/init.d/asterisk; \
+                       if [ -z "$(DESTDIR)" ]; then /usr/sbin/update-rc.d asterisk start 50 2 3 4 5 . stop 91 2 3 4 5 .; fi; \
                elif [ -f /etc/gentoo-release ]; then \
-                       $(INSTALL) -m 755 contrib/init.d/rc.gentoo.asterisk /etc/init.d/asterisk; \
-                       /sbin/rc-update add asterisk default; \
-               elif [ -f /etc/mandrake-release ]; then \
-                       $(INSTALL) -m 755 contrib/init.d/rc.mandrake.asterisk /etc/rc.d/init.d/asterisk; \
-                       /sbin/chkconfig --add asterisk; \
+                       $(INSTALL) -m 755 contrib/init.d/rc.gentoo.asterisk $(DESTDIR)/etc/init.d/asterisk; \
+                       if [ -z "$(DESTDIR)" ]; then /sbin/rc-update add asterisk default; fi; \
+               elif [ -f /etc/mandrake-release -o -f /etc/mandriva-release ]; then \
+                       $(INSTALL) -m 755 contrib/init.d/rc.mandrake.asterisk $(DESTDIR)/etc/rc.d/init.d/asterisk; \
+                       if [ -z "$(DESTDIR)" ]; then /sbin/chkconfig --add asterisk; fi; \
                elif [ -f /etc/SuSE-release -o -f /etc/novell-release ]; then \
-                       $(INSTALL) -m 755 contrib/init.d/rc.suse.asterisk /etc/init.d/asterisk; \
-                       /sbin/chkconfig --add asterisk; \
+                       $(INSTALL) -m 755 contrib/init.d/rc.suse.asterisk $(DESTDIR)/etc/init.d/asterisk; \
+                       if [ -z "$(DESTDIR)" ]; then /sbin/chkconfig --add asterisk; fi; \
                elif [ -f /etc/slackware-version ]; then \
                        echo "Slackware is not currently supported, although an init script does exist for it." \
                else \
@@ -659,7 +717,7 @@ cleantest:
        @cmp -s .cleancount .lastclean || $(MAKE) clean
 
 $(SUBDIRS_UNINSTALL):
-       @$(MAKE) --no-print-directory -C $(@:-uninstall=) uninstall
+       @$(MAKE) $(PRINT_DIR) -C $(@:-uninstall=) uninstall
 
 _uninstall: $(SUBDIRS_UNINSTALL)
        rm -f $(DESTDIR)$(MODULES_DIR)/*
@@ -685,11 +743,7 @@ uninstall: _uninstall
        @echo " + directories, and logs, run the following  +"
        @echo " + command:                                  +"
        @echo " +                                           +"
-ifeq ($(MAKE), gmake)
-       @echo " +            $(MAKE) uninstall-all            +"  
-else
-       @echo " +            $(MAKE) uninstall-all             +"  
-endif
+       @echo " +            $(mK) uninstall-all            +"  
        @echo " +-------------------------------------------+"  
 
 uninstall-all: _uninstall
@@ -710,17 +764,21 @@ menuselect: menuselect/menuselect menuselect-tree
 gmenuselect: menuselect/gmenuselect menuselect-tree
        -@menuselect/gmenuselect $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS) menuselect.makeopts && (echo "menuselect changes saved!"; rm -f channels/h323/Makefile.ast main/asterisk) || echo "menuselect changes NOT saved!"
 
-menuselect/menuselect: makeopts menuselect/menuselect.c menuselect/menuselect_curses.c menuselect/menuselect_stub.c menuselect/menuselect.h menuselect/linkedlists.h makeopts
+menuselect/menuselect: menuselect/makeopts
+       echo "doing menuselect with $(HOST_CC)"
        @CC="$(HOST_CC)" LD="" AR="" RANLIB="" CFLAGS="" $(MAKE) -C menuselect CONFIGURE_SILENT="--silent"
 
-menuselect/gmenuselect: makeopts menuselect/menuselect.c menuselect/menuselect_gtk.c menuselect/menuselect_stub.c menuselect/menuselect.h menuselect/linkedlists.h makeopts
-       @CC="$(HOST_CC)" CXX="$(CXX)" LD="" AR="" RANLIB="" CFLAGS="" $(MAKE) -C menuselect _gmenuselect CONFIGURE_SILENT="--silent"
+menuselect/gmenuselect: menuselect/makeopts
+       @CC="$(HOST_CC)" CXX="$(CXX)" LD="" AR="" RANLIB="" CFLAGS="" $(MAKE) -C menuselect gmenuselect CONFIGURE_SILENT="--silent"
+
+menuselect/makeopts:
+       @CC="$(HOST_CC)" CXX="$(CXX)" LD="" AR="" RANLIB="" CFLAGS="" $(MAKE) -C menuselect makeopts CONFIGURE_SILENT="--silent"
 
-menuselect-tree: $(foreach dir,$(filter-out main,$(MOD_SUBDIRS)),$(wildcard $(dir)/*.c) $(wildcard $(dir)/*.cc)) build_tools/cflags.xml sounds/sounds.xml build_tools/embed_modules.xml
+menuselect-tree: $(foreach dir,$(filter-out main,$(MOD_SUBDIRS)),$(wildcard $(dir)/*.c) $(wildcard $(dir)/*.cc)) build_tools/cflags.xml sounds/sounds.xml build_tools/embed_modules.xml configure
        @echo "Generating input for menuselect ..."
        @build_tools/prep_moduledeps > $@
 
 asterisk.pdf:
        $(MAKE) -C doc/tex asterisk.pdf
 
-.PHONY: menuselect main sounds clean dist-clean distclean all prereqs cleantest uninstall _uninstall uninstall-all dont-optimize $(SUBDIRS_INSTALL) $(SUBDIRS_CLEAN) $(SUBDIRS_UNINSTALL) $(SUBDIRS) $(MOD_SUBDIRS_EMBED_LDSCRIPT) $(MOD_SUBDIRS_EMBED_LDFLAGS) $(MOD_SUBDIRS_EMBED_LIBS) menuselect.makeopts
+.PHONY: menuselect main sounds clean dist-clean distclean all prereqs cleantest uninstall _uninstall uninstall-all dont-optimize $(SUBDIRS_INSTALL) $(SUBDIRS_DIST_CLEAN) $(SUBDIRS_CLEAN) $(SUBDIRS_UNINSTALL) $(SUBDIRS) $(MOD_SUBDIRS_EMBED_LDSCRIPT) $(MOD_SUBDIRS_EMBED_LDFLAGS) $(MOD_SUBDIRS_EMBED_LIBS) menuselect.makeopts