Adaptions to compile Win32 on CLI (native XP or Wine)
[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_FULLNAME ?= $(PLUGIN_NAME).dll
17 INSTALL_LIB =   cp $(PLUGIN_FULLNAME) ../..
18
19 ifdef OLSRD_PLUGIN
20 LDFLAGS +=      -L$(TOPDIR)
21 #LIBS +=        $(TOPDIR)/src/win32/compat.o
22 LIBS +=         -lolsrd
23 endif
24
25 OS_LIB_PTHREAD =
26 OS_CFLAG_PTHREAD =
27 OS_LIB_DYNLOAD =
28
29 PROGDIR = c:/Programme
30 PROGCYG = /cygdrive/c/Programme
31 PSDKDIR = $(PROGDIR)/Microsoft SDK
32 PSDKCYG = $(PROGCYG)/Microsoft\ SDK
33 MSVCDIR = $(PROGDIR)/Microsoft Visual Studio
34 MSVCCYG = $(PROGCYG)/Microsoft\ Visual\ Studio
35 NSISDIR = $(PROGDIR)/NSIS
36 NSISCYG = $(PROGCYG)/NSIS
37
38 # Necessary for running cygwin under wine. Both the "-C" option and MAKELEVEL will oops...
39 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)
40
41 gui/win32/Shim/Release/shim.obj: gui/win32/Shim/shim.c
42                 test -d $(dir $@) || mkdir -p $(dir $@)
43                 $(MSVCCYG)/VC98/Bin/CL.EXE \
44                         /I"$(PSDKDIR)/Include" /I"$(MSVCDIR)/VC98/Include" \
45                         /nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" \
46                         /Fp"$(dir $@)/Shim.pch" /YX /Fo"$(dir $@)/" /Fd"$(dir $@)/" /FD /c "$<"
47
48 gui/win32/Shim/Release/Shim.exe: gui/win32/Shim/Release/shim.obj
49                 $(MSVCCYG)/VC98/Bin/LINK.EXE \
50                         /LIBPATH:"$(PSDKDIR)/Lib" /LIBPATH:"$(MSVCDIR)/VC98/Lib" \
51                         kernel32.lib user32.lib \
52                         /nologo /subsystem:console /incremental:no /machine:I386 /out:"$@" "$^"
53
54 WIN32FILES+=Frontend
55 WIN32FILES+=FrontendDlg
56 WIN32FILES+=HnaEntry
57 WIN32FILES+=MidEntry
58 WIN32FILES+=MprEntry
59 WIN32FILES+=MyDialog1
60 WIN32FILES+=MyDialog2
61 WIN32FILES+=MyDialog3
62 WIN32FILES+=MyDialog4
63 WIN32FILES+=MyEdit
64 WIN32FILES+=MyTabCtrl
65 WIN32FILES+=NodeEntry
66 WIN32FILES+=StdAfx
67 WIN32FILES+=TrayIcon
68
69 WIN32CPPFILES=$(addprefix gui/win32/Main/, $(addsuffix .cpp,  $(WIN32FILES)))
70 WIN32OBJFILES=$(addprefix gui/win32/Main/Release/, $(addsuffix .obj,  $(WIN32FILES)))
71
72 gui/win32/Main/Release/Frontend.res: gui/win32/Main/Frontend.rc
73                 test -d $(dir $@) || mkdir -p $(dir $@)
74                 $(PSDKCYG)/Bin/RC.Exe /l 0x407 /i"$(PSDKDIR)/Include" /i"$(MSVCDIR)/VC98/MFC/Include" /fo"$@" /d NDEBUG $<
75
76 gui/win32/Main/Release/Switch.exe: gui/win32/Main/olsrd_cfgparser.lib gui/win32/Main/Release/Frontend.res $(WIN32CPPFILES)
77                 test -d $(dir $@) || mkdir -p $(dir $@)
78                 $(MSVCCYG)/VC98/Bin/CL.EXE \
79                         /I"$(PSDKDIR)/Include" /I"$(MSVCDIR)/VC98/Include" /I"$(MSVCDIR)/VC98/MFC/Include" /I"src" \
80                         /nologo /MT /W4 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" \
81                         /Fp"$(dir $@)/Frontend.pch" /YX"stdafx.h" /Fo"$(dir $@)/" /Fd"$(dir $@)/" /FD /c \
82                         $(WIN32CPPFILES)
83                 $(MSVCCYG)/VC98/Bin/LINK.EXE \
84                         /LIBPATH:"$(PSDKDIR)/Lib" /LIBPATH:"$(MSVCDIR)/VC98/Lib" /LIBPATH:"$(MSVCDIR)/VC98/MFC/Lib" \
85                         ws2_32.lib iphlpapi.lib \
86                         gui/win32/Main/olsrd_cfgparser.lib gui/win32/Main/Release/Frontend.res \
87                         /nologo /subsystem:windows /incremental:no /machine:I386 /out:"$@" \
88                         $(WIN32OBJFILES)
89
90 win32setup: gui/win32/Inst/installer.nsi gui/win32/Shim/Release/Shim.exe gui/win32/Main/Release/Switch.exe
91                 $(NSISCYG)/makensis.exe $<
92
93 win32lib: gui/win32/Main/olsrd_cfgparser.lib
94
95 gui/win32/Main/olsrd_cfgparser.lib: cfgparser
96                 @# Using the cygwin dlltool does not work (missing functions hooks)
97                 @# dlltool --input-def src/cfgparser/olsrd_cfgparser.def --dllname src/cfgparser/olsrd_cfgparser.dll --output-lib $@
98                 @# Use the Microsoft Lib Tool instead
99                 $(MSVCCYG)/VC98/Bin/LIB.EXE /machine:i386 /def:src/cfgparser/olsrd_cfgparser.def /out:gui/win32/Main/olsrd_cfgparser.lib
100
101 # Local Variables:
102 # mode: makefile
103 # End: