diff --git a/platform/win32/Makefile b/platform/win32/Makefile
index 461edbe92..213d87010 100644
--- a/platform/win32/Makefile
+++ b/platform/win32/Makefile
@@ -40,20 +40,24 @@ all: contiki-main $(PRGS:=.prg) $(DSCS:=.dsc)
appname = ${subst processes,process-list,${subst www,webbrowser,$(1)}}
# Omit all the target and network stack specific shell commands
+
SHELL_SOURCEFILES = shell.c shell-file.c shell-ps.c shell-run.c \
shell-text.c shell-time.c shell-wget.c \
http-strings.c http-user-agent-string.c \
webclient.c list.c random.c
# Use gui-shell.c instead of serial-shell.c to get CTK support
+
override shell_src = gui-shell.c ctk-textentry-cmdline.c \
$(SHELL_SOURCEFILES)
# Add telnetd-gui.c to get CTK support
+
override telnetd_src = telnetd.c telnetd-gui.c memb.c \
$(SHELL_SOURCEFILES)
# Use webserver.c instead of webserver-nogui.c to get CTK support
+
override webserver_src = webserver.c httpd.c http-strings.c psock.c \
memb.c httpd-fs.c httpd-cgi.c
diff --git a/platform/win32/Makefile.customrules-win32 b/platform/win32/Makefile.customrules-win32
new file mode 100644
index 000000000..677729551
--- /dev/null
+++ b/platform/win32/Makefile.customrules-win32
@@ -0,0 +1,26 @@
+ifdef VCINSTALLDIR
+
+VCFLAGS = -Od -Z7 $(filter-out -Wall -g -O,$(CFLAGS))
+
+CUSTOM_RULE_C_TO_OBJECTDIR_O = 1
+$(OBJECTDIR)/%.o: %.c | $(OBJECTDIR)
+ $(TRACE_CC)
+ $(Q)cl -nologo $(VCFLAGS) -c $< -Fo$@
+ $(Q)makedepend $(CFLAGS) -o.o -f- $< 2> nul: | sed -e s!$(<:.c=.o)!$@! -e s!\\!/!g > $(@:.o=.d)
+
+CUSTOM_RULE_C_TO_CO = 1
+%.co: %.c
+ $(TRACE_CC)
+ $(Q)cl -nologo $(VCFLAGS) -DAUTOSTART_ENABLE -c $< -Fo$@
+
+CUSTOM_RULE_ALLOBJS_TO_TARGETLIB = 1
+contiki-$(TARGET).a: $(CONTIKI_OBJECTFILES)
+ $(TRACE_AR)
+ $(Q)lib -nologo $^ -out:$@
+
+CUSTOM_RULE_LINK = 1
+%.$(TARGET): %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a
+ $(TRACE_LD)
+ $(Q)link -nologo $(LINKFLAGS) -debug -map:contiki-$(TARGET).map $^ user32.lib ws2_32.lib iphlpapi.lib -out:$@
+
+endif # VCINSTALLDIR
diff --git a/platform/win32/Makefile.win32 b/platform/win32/Makefile.win32
index 83e82bf7d..f8bf088ea 100644
--- a/platform/win32/Makefile.win32
+++ b/platform/win32/Makefile.win32
@@ -31,6 +31,8 @@
# Author: Oliver Schmidt
#
+.SUFFIXES:
+
TARGET_LIBFILES = /lib/w32api/libws2_32.a /lib/w32api/libiphlpapi.a
CONTIKI_TARGET_DIRS = . cfs ctk loader
@@ -39,9 +41,10 @@ CONTIKI_TARGET_SOURCEFILES = contiki-main.c clock.c cfs-win32-dir.c ctk-console.
CONTIKI_SOURCEFILES += $(CTK) cfs-posix.c ctk-conio.c wpcap.c wpcap-drv.c \
$(CONTIKI_TARGET_SOURCEFILES)
-.SUFFIXES:
+MODULES += core/ctk core/net/ip core/net/ipv4 core/net/ipv6
+
+# Define the CPU directory
-### Define the CPU directory
CONTIKI_CPU = $(CONTIKI)/cpu/native
include $(CONTIKI)/cpu/native/Makefile.native
@@ -56,11 +59,13 @@ else
CONTIKI_TARGET_SOURCEFILES += unload.c
endif
-### Set a target-specific variable value
+# Set a target-specific variable value
+
${foreach PRG,$(PRGS),${addprefix $(OBJECTDIR)/, \
$(${call appname,$(PRG)_src:.c=.o})}}: CFLAGS += -D_USRDLL
-### Generate the module-link prerequisites
+# Generate the module-link prerequisites
+
define prg_template
$(1).prg: $${addprefix $$(OBJECTDIR)/,$$($(2)_src:.c=.o)}
endef
@@ -70,7 +75,8 @@ endef
${foreach PRG,$(PRGS),${eval ${call prg_template,$(PRG),${call appname,$(PRG)}}}}
${foreach DSC,$(DSCS),${eval ${call dsc_template,$(DSC),${call appname,$(DSC)}}}}
-### Generic module-link rules, no prerequisites here
+# Generic module-link rules, no prerequisites here
+
$(PRGS:=.prg) $(DSCS:=.dsc):
$(TRACE_LD)
ifdef VCINSTALLDIR
@@ -78,30 +84,3 @@ ifdef VCINSTALLDIR
else
$(Q)$(LD) -shared $^ contiki-main.$(TARGET).a -o $@
endif
-
-ifdef VCINSTALLDIR
-
-VCFLAGS = -Od -Z7 $(filter-out -Wall -g -O,$(CFLAGS))
-
-CUSTOM_RULE_C_TO_OBJECTDIR_O = 1
-$(OBJECTDIR)/%.o: %.c | $(OBJECTDIR)
- $(TRACE_CC)
- $(Q)cl -nologo $(VCFLAGS) -c $< -Fo$@
- $(Q)makedepend $(CFLAGS) -o.o -f- $< 2> nul: | sed -e s!$(<:.c=.o)!$@! -e s!\\!/!g > $(@:.o=.d)
-
-CUSTOM_RULE_C_TO_CO = 1
-%.co: %.c
- $(TRACE_CC)
- $(Q)cl -nologo $(VCFLAGS) -DAUTOSTART_ENABLE -c $< -Fo$@
-
-CUSTOM_RULE_ALLOBJS_TO_TARGETLIB = 1
-contiki-$(TARGET).a: $(CONTIKI_OBJECTFILES)
- $(TRACE_AR)
- $(Q)lib -nologo $^ -out:$@
-
-CUSTOM_RULE_LINK = 1
-%.$(TARGET): %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a
- $(TRACE_LD)
- $(Q)link -nologo $(LINKFLAGS) -debug -map:contiki-$(TARGET).map $^ user32.lib ws2_32.lib iphlpapi.lib -out:$@
-
-endif # VCINSTALLDIR
\ No newline at end of file
diff --git a/platform/win32/contiki-conf.h b/platform/win32/contiki-conf.h
index 1cc8b5a43..41d4b1f08 100644
--- a/platform/win32/contiki-conf.h
+++ b/platform/win32/contiki-conf.h
@@ -182,8 +182,9 @@ typedef unsigned short uip_stats_t;
#ifdef PLATFORM_BUILD
#define WWW_CONF_WEBPAGE_WIDTH 76
#define WWW_CONF_WEBPAGE_HEIGHT 30
-#endif /* PLATFORM_BUILD */
+#else /* PLATFORM_BUILD */
#define WWW_CONF_WGET_EXEC(url) execlp("wget.win32", "wget.win32", \
"192.168.0.2", url, (char *)NULL)
+#endif /* PLATFORM_BUILD */
#endif /* CONTIKI_CONF_H_ */