diff --git a/Makefile b/Makefile
index cbf7005bcb83d1d207ffe9f273b21e905e022e3d..a6ed5085b09053a4ac0dde77fdeb265588ae8e8e 100644
--- a/Makefile
+++ b/Makefile
@@ -253,13 +253,13 @@ ASTCFLAGS+=$(MALLOC_DEBUG)$(BUSYDETECT)$(OPTIONS)
 
 MOD_SUBDIRS:=channels pbx apps codecs formats cdr funcs
 OTHER_SUBDIRS:=utils agi
-SUBDIRS:=$(OTHER_SUBDIRS) $(MOD_SUBDIRS)
 # in cygwin we need to build main (i.e. asterisk.dll) first, then res.
 ifneq ($(findstring $(OSARCH), mingw32 cygwin ),)
   SUBDIRS+= main res
 else
-  OTHER_SUBDIRS += res main
+  MOD_SUBDIRS += res main
 endif
+SUBDIRS:=$(OTHER_SUBDIRS) $(MOD_SUBDIRS)
 SUBDIRS_INSTALL:=$(SUBDIRS:%=%-install)
 SUBDIRS_CLEAN:=$(SUBDIRS:%=%-clean)
 SUBDIRS_DIST_CLEAN:=$(SUBDIRS:%=%-dist-clean)