Make the U3 and PortableApps "clean" and "distclean" targets more
[obnox/wireshark/wip.git] / packaging / u3 / win32 / Makefile.nmake
1 #
2 # $Id$
3 #
4
5 include ../../../config.nmake
6 include <win32.mak>
7
8 CC      = cl
9 LINK    = link
10
11 LDFLAGS = /NOLOGO /INCREMENTAL:no /MACHINE:I386 /ENTRY:mainCRTStartup $(LOCAL_LDFLAGS)
12
13 DEVICE  = device
14 HOST    = host
15 MANIFEST= manifest
16 DATA    = data
17
18 WSMANIFEST      = ../../wireshark.manifest
19
20 TOPDIR  = ..\..\..
21 TOOLSDIR= ..\tools
22 COPY    = xcopy
23 MKDIR   = mkdir
24 COPY_FLAGS      = /d /y
25
26 !undef UPX
27 UPX_FLAGS = -q
28
29 U3_VERSION=$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_MICRO)
30
31 all:    package
32
33
34 uuid.sed: $(TOPDIR)\config.nmake
35         cd $(TOOLSDIR)
36         $(MAKE) /$(MAKEFLAGS) -f makefile.nmake
37         cd ..\win32
38         $(TOOLSDIR)\utest.exe "$(VERSION)" > $@
39
40 manifest.u3i:   manifest.tmpl uuid.sed
41         sed -e 's/$$(U3_VERSION)/$(U3_VERSION)/g' \
42             -e 's/$$(VERSION)/$(VERSION)/g' \
43 #ifdef UPX
44             -e 's/$$(SIZE)/50/g' \
45 #else
46             -e 's/$$(SIZE)/65/g' \
47 #endif
48             -f  uuid.sed < manifest.tmpl > manifest.u3i
49
50 u3-dirs:
51         if not exist $(HOST) $(MKDIR) $(HOST)
52         if not exist $(DEVICE) $(MKDIR) $(DEVICE)
53         if not exist $(DATA) $(MKDIR) $(DATA)
54         if not exist $(DATA)\"My Captures" $(MKDIR) $(DATA)\"My Captures"
55         if not exist $(MANIFEST) $(MKDIR) $(MANIFEST)
56
57 nsis-bits:
58         cd ../../nsis
59         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake user-guide.chm
60         cd ../u3/win32
61
62 distribution.nmake:     makenmake.pl
63         cd ../..
64         $(MAKE) /$(MAKEFLAGS) -f makefile.nmake wireshark.manifest
65         cd u3/win32
66         $(PERL) makenmake.pl $(WSMANIFEST) > $@ 
67
68 distribution: u3-dirs manifest.u3i u3util.exe nsis-bits wireshark.bat distribution.nmake
69 # manifest
70         $(COPY) manifest.u3i $(MANIFEST) $(COPY_FLAGS)
71         $(COPY) $(TOPDIR)\image\wireshark.ico $(MANIFEST) $(COPY_FLAGS)
72         $(COPY) u3util.exe $(HOST) $(COPY_FLAGS)
73         $(MAKE) /$(MAKEFLAGS) -f distribution.nmake 
74
75 verify-tools:   
76 !IFDEF UPX
77         @if not exist $(UPX) echo Error: $(UPX) not found. &&\
78 echo Either: &&\
79 echo a) run 'nmake -f makefile.nmake setup' at the toplevel; or &&\
80 echo b) comment out UPX in config.nmake at the top level, to build without compressing the dlls and exes \
81 && exit 2
82 !endif
83
84 pack:   distribution
85 !IFDEF UPX
86         -$(UPX) $(UPX_FLAGS) $(DEVICE)\plugins\$(VERSION)\*.dll
87         -$(UPX) $(UPX_FLAGS) $(HOST)\*.dll
88         -$(UPX) $(UPX_FLAGS) $(HOST)\lib\gtk-2.0\$(GTK_LIB_DIR)\loaders\*.dll
89         -$(UPX) $(UPX_FLAGS) $(HOST)\lib\gtk-2.0\$(GTK_LIB_DIR)\engines\*.dll
90         -$(UPX) $(UPX_FLAGS) $(HOST)\$(GTK_WIMP_DLLDST_DIR)\*.dll
91         -$(UPX) $(UPX_FLAGS) $(HOST)\*.exe      
92 !ENDIF
93
94 test:           pack
95         wireshark.bat -D
96
97 package:        verify-tools test
98         zip -r wireshark-$(VERSION).u3p $(MANIFEST) $(DEVICE) $(DATA) $(HOST) wireshark.bat
99
100 CFLAGS  = -DWINPCAP_PACKAGE="\"\\\\WinPcap_$(PCAP_VERSION).exe\""
101
102 u3util_LIBS= user32.lib shell32.lib
103
104 u3util.exe:     u3util.obj ../../../config.nmake
105         @echo Linking $@
106         $(LINK) @<<
107                 /OUT:u3util.exe $(guiflags) $(LDFLAGS) u3util.obj $(u3util_LIBS) $(guilibsdll)
108 <<
109 !IFDEF MANIFEST_INFO_REQUIRED
110         mt.exe -nologo -manifest "u3util.exe.manifest" -outputresource:u3util.exe;1
111 !ENDIF
112
113 clean:
114         cd ../tools
115         $(MAKE) -f makefile.nmake $@
116         cd ../win32
117         cd ../../
118         $(MAKE) -f makefile.nmake $@
119         cd u3/win32
120         rm -rf manifest.u3i
121         rm -rf uuid.sed
122         rm -rf nodeid state
123         rm -rf $(HOST)
124         rm -rf $(DEVICE)
125         rm -rf $(DATA)
126         rm -rf $(MANIFEST)
127         rm -rf u3util.{exe,obj,pdb}
128         rm -rf wireshark-$(VERSION).u3p
129         rm -rf distribution.nmake
130         rm -rf *~ *.*~
131
132 distclean:      clean
133         rm -rf wireshark*.u3p
134
135 maintainer-clean:       distclean