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