703873ca5594735a8580c2df33e7783b7e97d03b
[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 # Notes for compiling olsrd under Windows
32 # ---------------------------------------
33 # You need at least Cygwin installed. Start the Cygwin setup and select
34 # flex,bison,make,mingw-core. Then run "make all libs" to compile olsrd.exe
35 # and the plugin DLLs. To compile the GUI, you need MSVC6, PlatformSDK and
36 # the NSIS installer. Adapt the path names below and run "make win32setup".
37 # Alternatively, set environment vars e.g. in the Windows registry under
38 # HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment e.g.
39 #
40 # set PATH=C:\PROGRA~1\MICROS~4\VC98\BIN;C:\PROGRA~1\MIFD68~1\BIN;C:\PROGRA~1\NSIS;%PATH%
41 # set LIB=C:\PROGRA~1\MIFD68~1\LIB;C:\PROGRA~1\MICROS~4\VC98\LIB;C:\PROGRA~1\MICROS~4\VC98\MFC\LIB
42 # set INCLUDE=C:\PROGRA~1\MIFD68~1\INCLUDE;C:\PROGRA~1\MICROS~4\VC98\INCLUDE;C:\PROGRA~1\MICROS~4\VC98\MFC\INCLUDE
43 #
44 # You can install Cygwin under Wine. Then "wineconsole make all libs win32lib"
45 # does it's job (slowly), but there may be issues while re-invoking MSVC from
46 # bash.exe during "wineconsole win32setup". Note, that Wine on EXT2/EXT3 prevents
47 # the Cygwin "!<symlink>" files from working somehow. You may need to install Cygwin
48 # under Windows to get a correct gcc/mingw setup, then copy to your Linux
49 # box, then replace all "!<symlink>" files by real symlinks, e.g.
50 #
51 # cd ~/.wine/drive_c/Programme/cygwin
52 # for src in $(grep '!<symlink>' . -rl 2>&-);do
53 #  if [ $(stat -c "%s" $src) -lt 100 ];then
54 #   dst=$(sed -e's/^\!<symlink>//' $src)
55 #   echo "ln -sf $dst $src"
56 #  fi
57 # done
58 #
59 # Required software versions:
60 # MSVC6 GUI (with MFC!) runs under Wine (copy MFC42.DLL & MSVCP60.DLL)
61 # Platform SDK, search for "February 2003 SDK"
62 # Cygwin 1.5.x and Wine-1.1.0 or above
63
64 PROGDIR = c:/Programme
65 PROGCYG = /cygdrive/c/Programme
66 PSDKDIR = $(PROGDIR)/Microsoft SDK
67 PSDKCYG = $(PROGCYG)/Microsoft\ SDK
68 MSVCDIR = $(PROGDIR)/Microsoft Visual Studio
69 MSVCCYG = $(PROGCYG)/Microsoft\ Visual\ Studio
70 NSISDIR = $(PROGDIR)/NSIS
71 NSISCYG = $(PROGCYG)/NSIS
72
73 # Necessary for running cygwin under wine. Both the "-C" option and MAKELEVEL>0 will oops...
74 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)
75
76 gui/win32/Shim/Release/shim.obj: gui/win32/Shim/shim.c
77                 test -d $(dir $@) || mkdir -p $(dir $@)
78                 PATH=$(MSVCCYG)/VC98/Bin:$$PATH && CL.EXE \
79                         /I"$(PSDKDIR)/Include" /I"$(MSVCDIR)/VC98/Include" \
80                         /nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" \
81                         /Fp"$(dir $@)/Shim.pch" /YX /Fo"$(dir $@)/" /Fd"$(dir $@)/" /FD /c "$<"
82
83 gui/win32/Shim/Release/Shim.exe: gui/win32/Shim/Release/shim.obj
84                 PATH=$(MSVCCYG)/VC98/Bin:$$PATH && LINK.EXE \
85                         /LIBPATH:"$(PSDKDIR)/Lib" /LIBPATH:"$(MSVCDIR)/VC98/Lib" \
86                         kernel32.lib user32.lib \
87                         /nologo /subsystem:console /incremental:no /machine:I386 /out:"$@" "$^"
88
89 WIN32FILES+=Frontend
90 WIN32FILES+=FrontendDlg
91 WIN32FILES+=HnaEntry
92 WIN32FILES+=MidEntry
93 WIN32FILES+=MprEntry
94 WIN32FILES+=MyDialog1
95 WIN32FILES+=MyDialog2
96 WIN32FILES+=MyDialog3
97 WIN32FILES+=MyDialog4
98 WIN32FILES+=MyEdit
99 WIN32FILES+=MyTabCtrl
100 WIN32FILES+=NodeEntry
101 WIN32FILES+=StdAfx
102 WIN32FILES+=TrayIcon
103
104 WIN32CPPFILES=$(addprefix gui/win32/Main/, $(addsuffix .cpp,  $(WIN32FILES)))
105 WIN32OBJFILES=$(addprefix gui/win32/Main/Release/, $(addsuffix .obj,  $(WIN32FILES)))
106
107 gui/win32/Main/Release/Frontend.res: gui/win32/Main/Frontend.rc
108                 test -d $(dir $@) || mkdir -p $(dir $@)
109                 PATH=$(PSDKCYG)/Bin:$(MSVCCYG)/Common/MSDev98/Bin:$$PATH && RC.EXE \
110                         /l 0x407 /i"$(PSDKDIR)/Include" /i"$(MSVCDIR)/VC98/MFC/Include" /fo"$@" /d NDEBUG "$<"
111
112 gui/win32/Main/Release/Switch.exe: gui/win32/Main/olsrd_cfgparser.lib gui/win32/Main/Release/Frontend.res $(WIN32CPPFILES)
113                 test -d $(dir $@) || mkdir -p $(dir $@)
114                 PATH=$(MSVCCYG)/VC98/Bin:$$PATH && CL.EXE \
115                         /I"$(PSDKDIR)/Include" /I"$(MSVCDIR)/VC98/Include" /I"$(MSVCDIR)/VC98/MFC/Include" /I"src" \
116                         /nologo /MT /W4 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" \
117                         /Fp"$(dir $@)/Frontend.pch" /YX"stdafx.h" /Fo"$(dir $@)/" /Fd"$(dir $@)/" /FD /c \
118                         $(WIN32CPPFILES)
119                 PATH=$(MSVCCYG)/VC98/Bin:$$PATH && LINK.EXE \
120                         /LIBPATH:"$(PSDKDIR)/Lib" /LIBPATH:"$(MSVCDIR)/VC98/Lib" /LIBPATH:"$(MSVCDIR)/VC98/MFC/Lib" \
121                         ws2_32.lib iphlpapi.lib \
122                         gui/win32/Main/olsrd_cfgparser.lib gui/win32/Main/Release/Frontend.res \
123                         /nologo /subsystem:windows /incremental:no /machine:I386 /out:"$@" \
124                         $(WIN32OBJFILES)
125
126 win32setup: gui/win32/Inst/installer.nsi default_target libs gui/win32/Shim/Release/Shim.exe gui/win32/Main/Release/Switch.exe
127                 PATH=$(NSISCYG):$$PATH && makensis.exe $<
128
129 win32lib: gui/win32/Main/olsrd_cfgparser.lib
130
131 gui/win32/Main/olsrd_cfgparser.lib: cfgparser
132                 @# Using the cygwin dlltool does not work (missing functions hooks)
133                 @# dlltool --input-def src/cfgparser/olsrd_cfgparser.def --dllname src/cfgparser/olsrd_cfgparser.dll --output-lib $@
134                 @# Use the Microsoft Lib Tool instead
135                 PATH=$(MSVCCYG)/VC98/Bin:$$PATH && LIB.EXE \
136                         /machine:i386 /def:src/cfgparser/olsrd_cfgparser.def /out:gui/win32/Main/olsrd_cfgparser.lib
137
138 # Local Variables:
139 # mode: makefile
140 # End: