included MinGW build instructions for Windows/Win32
[olsrd.git] / make / Makefile.win32
1 #
2 # WINDOWS32 SPECIFIC CONFIGURATION
3 #
4
5 DESTDIR ?=
6 EXENAME = olsrd.exe
7
8 SRCS +=         $(wildcard src/win32/*.c)
9 HDRS +=         $(wildcard src/win32/*.h)
10
11 CPPFLAGS +=     -DWIN32 -D_WIN32_WINNT=0x0600
12 LIBS +=         -mno-cygwin -lws2_32 -liphlpapi
13 CPPFLAGS +=     -I$(TOPDIR)/src/win32
14 CFLAGS +=       -mno-cygwin
15
16 PLUGIN_SONAME ?= $(PLUGIN_NAME)
17 PLUGIN_FULLNAME ?= $(PLUGIN_NAME).dll
18 INSTALL_LIB =   cp $(PLUGIN_FULLNAME) ../..
19 UNINSTALL_LIB = del /F ../../$(PLUGIN_FULLNAME)
20
21 ifdef OLSRD_PLUGIN
22 LDFLAGS +=      -L$(TOPDIR)
23 #LIBS +=        $(TOPDIR)/src/win32/compat.o
24 LIBS +=         -lolsrd
25 endif
26
27 OS_LIB_PTHREAD =
28 OS_CFLAG_PTHREAD =
29 OS_LIB_DYNLOAD =
30
31
32 # Notes for compiling olsrd.exe under Windows using MinGW
33 # ----------------------------------------------------
34 # You can build olsrd.exe using MinGW on either Windows or GNU/Linux.
35 # For MinGW on Windows, run this in the msys shell:
36 #
37 #   cd olsrd
38 #   make clean_all
39 #   make build_all OS=win32
40 #
41 # MinGW also runs on GNU/Linux so you can build Windows binaries on
42 # any GNU/Linux machine.  It is especially easy on a
43 # Debian/Ubuntu/Mint system:
44 #
45 #   sudo apt-get install mingw32 flex bison make
46 #   cd olsrd
47 #   make clean_all
48 #   CC=i586-mingw32msvc-gcc make build_all OS=win32
49
50
51 # Notes for compiling olsrd.exe under Windows using Cygwin
52 # ----------------------------------------------------
53 # You need at least Cygwin installed. Start the Cygwin setup and select
54 # flex,bison,make,mingw-core. Then run "make all libs" to compile olsrd.exe
55 # and the plugin DLLs. To compile the GUI, you need MSVC6, PlatformSDK and
56 # the NSIS installer. Adapt the path names below and run "make win32setup".
57 # Alternatively, set environment vars e.g. in the Windows registry under
58 # HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment e.g.
59 #
60 # set PATH=C:\PROGRA~1\MICROS~4\VC98\BIN;C:\PROGRA~1\MIFD68~1\BIN;C:\PROGRA~1\NSIS;%PATH%
61 # set LIB=C:\PROGRA~1\MIFD68~1\LIB;C:\PROGRA~1\MICROS~4\VC98\LIB;C:\PROGRA~1\MICROS~4\VC98\MFC\LIB
62 # set INCLUDE=C:\PROGRA~1\MIFD68~1\INCLUDE;C:\PROGRA~1\MICROS~4\VC98\INCLUDE;C:\PROGRA~1\MICROS~4\VC98\MFC\INCLUDE
63 #
64 # You can install Cygwin under Wine. Then "wineconsole make all libs win32lib"
65 # does it's job (slowly), but there may be issues while re-invoking MSVC from
66 # bash.exe during "wineconsole win32setup". Note, that Wine on EXT2/EXT3 prevents
67 # the Cygwin "!<symlink>" files from working somehow. You may need to install Cygwin
68 # under Windows to get a correct gcc/mingw setup, then copy to your Linux
69 # box, then replace all "!<symlink>" files by real symlinks, e.g.
70 #
71 # cd ~/.wine/drive_c/Programme/cygwin
72 # for src in $(grep '!<symlink>' . -rl 2>&-);do
73 #  if [ $(stat -c "%s" $src) -lt 100 ];then
74 #   dst=$(sed -e's/^\!<symlink>//' $src)
75 #   echo "ln -sf $dst $src"
76 #  fi
77 # done
78 #
79 # Required software versions:
80 # MSVC6 GUI (with MFC!) runs under Wine (copy MFC42.DLL & MSVCP60.DLL)
81 # Platform SDK, search for "February 2003 SDK"
82 # Cygwin 1.5.x and Wine-1.1.0 or above
83
84 PROGDIR = c:/Programme
85 PROGCYG = /cygdrive/c/Programme
86 PSDKDIR = $(PROGDIR)/Microsoft SDK
87 PSDKCYG = $(PROGCYG)/Microsoft\ SDK
88 MSVCDIR = $(PROGDIR)/Microsoft Visual Studio
89 MSVCCYG = $(PROGCYG)/Microsoft\ Visual\ Studio
90 NSISDIR = $(PROGDIR)/NSIS
91 NSISCYG = $(PROGCYG)/NSIS
92
93 # Necessary for running cygwin under wine. Both the "-C" option and MAKELEVEL>0 will oops...
94 MAKE := sh -c 'cmd=$$0;while [ 0 -lt $$\# ];do case $$1 in -C) cmd="cd $$2 && $$cmd";shift 2;; *) cmd="$$cmd \"$$1\"";shift;;esac;done;sh -c "export MAKELEVEL=0 && $$cmd"' $(MAKE)
95
96 gui/win32/Shim/Release/shim.obj: gui/win32/Shim/shim.c
97                 test -d $(dir $@) || mkdir -p $(dir $@)
98                 PATH=$(MSVCCYG)/VC98/Bin:$$PATH && CL.EXE \
99                         /I"$(PSDKDIR)/Include" /I"$(MSVCDIR)/VC98/Include" \
100                         /nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" \
101                         /Fp"$(dir $@)/Shim.pch" /YX /Fo"$(dir $@)/" /Fd"$(dir $@)/" /FD /c "$<"
102
103 gui/win32/Shim/Release/Shim.exe: gui/win32/Shim/Release/shim.obj
104                 PATH=$(MSVCCYG)/VC98/Bin:$$PATH && LINK.EXE \
105                         /LIBPATH:"$(PSDKDIR)/Lib" /LIBPATH:"$(MSVCDIR)/VC98/Lib" \
106                         kernel32.lib user32.lib \
107                         /nologo /subsystem:console /incremental:no /machine:I386 /out:"$@" "$^"
108
109 WIN32FILES+=Frontend
110 WIN32FILES+=FrontendDlg
111 WIN32FILES+=HnaEntry
112 WIN32FILES+=MidEntry
113 WIN32FILES+=MprEntry
114 WIN32FILES+=MyDialog1
115 WIN32FILES+=MyDialog2
116 WIN32FILES+=MyDialog3
117 WIN32FILES+=MyDialog4
118 WIN32FILES+=MyEdit
119 WIN32FILES+=MyTabCtrl
120 WIN32FILES+=NodeEntry
121 WIN32FILES+=StdAfx
122 WIN32FILES+=TrayIcon
123
124 WIN32CPPFILES=$(addprefix gui/win32/Main/, $(addsuffix .cpp,  $(WIN32FILES)))
125 WIN32OBJFILES=$(addprefix gui/win32/Main/Release/, $(addsuffix .obj,  $(WIN32FILES)))
126
127 gui/win32/Main/Release/Frontend.res: gui/win32/Main/Frontend.rc
128                 test -d $(dir $@) || mkdir -p $(dir $@)
129                 PATH=$(PSDKCYG)/Bin:$(MSVCCYG)/Common/MSDev98/Bin:$$PATH && RC.EXE \
130                         /l 0x407 /i"$(PSDKDIR)/Include" /i"$(MSVCDIR)/VC98/MFC/Include" /fo"$@" /d NDEBUG "$<"
131
132 gui/win32/Main/Release/Switch.exe: gui/win32/Main/olsrd_cfgparser.lib gui/win32/Main/Release/Frontend.res $(WIN32CPPFILES)
133                 test -d $(dir $@) || mkdir -p $(dir $@)
134                 PATH=$(MSVCCYG)/VC98/Bin:$$PATH && CL.EXE \
135                         /I"$(PSDKDIR)/Include" /I"$(MSVCDIR)/VC98/Include" /I"$(MSVCDIR)/VC98/MFC/Include" /I"src" \
136                         /nologo /MT /W4 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" \
137                         /Fp"$(dir $@)/Frontend.pch" /YX"stdafx.h" /Fo"$(dir $@)/" /Fd"$(dir $@)/" /FD /c \
138                         $(WIN32CPPFILES)
139                 PATH=$(MSVCCYG)/VC98/Bin:$$PATH && LINK.EXE \
140                         /LIBPATH:"$(PSDKDIR)/Lib" /LIBPATH:"$(MSVCDIR)/VC98/Lib" /LIBPATH:"$(MSVCDIR)/VC98/MFC/Lib" \
141                         ws2_32.lib iphlpapi.lib \
142                         gui/win32/Main/olsrd_cfgparser.lib gui/win32/Main/Release/Frontend.res \
143                         /nologo /subsystem:windows /incremental:no /machine:I386 /out:"$@" \
144                         $(WIN32OBJFILES)
145
146 win32setup: gui/win32/Inst/installer.nsi default_target libs gui/win32/Shim/Release/Shim.exe gui/win32/Main/Release/Switch.exe
147                 PATH=$(NSISCYG):$$PATH && makensis.exe $<
148
149 win32lib: gui/win32/Main/olsrd_cfgparser.lib
150
151 gui/win32/Main/olsrd_cfgparser.lib: cfgparser
152                 @# Using the cygwin dlltool does not work (missing functions hooks)
153                 @# dlltool --input-def src/cfgparser/olsrd_cfgparser.def --dllname src/cfgparser/olsrd_cfgparser.dll --output-lib $@
154                 @# Use the Microsoft Lib Tool instead
155                 PATH=$(MSVCCYG)/VC98/Bin:$$PATH && LIB.EXE \
156                         /machine:i386 /def:src/cfgparser/olsrd_cfgparser.def /out:gui/win32/Main/olsrd_cfgparser.lib
157
158 # Local Variables:
159 # mode: makefile
160 # End: