1#  Copyright (C) 2001-2010 Artifex Software, Inc.
2#  All Rights Reserved.
3#
4#  This software is provided AS-IS with no warranty, either express or
5#  implied.
6#
7#  This software is distributed under license and may not be copied, modified
8#  or distributed except as expressly authorized under the terms of that
9#  license.  Refer to licensing information at http://www.artifex.com/
10#  or contact Artifex Software, Inc.,  7 Mt. Lassen Drive - Suite A-134,
11#  San Rafael, CA  94903, U.S.A., +1(415)492-9861, for further information.
12#
13# $Id: winint.mak 10700 2010-02-03 22:29:34Z giles $
14# Common interpreter makefile section for 32-bit MS Windows.
15
16# This makefile must be acceptable to Microsoft Visual C++, Watcom C++,
17# and Borland C++.  For this reason, the only conditional directives
18# allowed are !if[n]def, !else, and !endif.
19
20
21# Include the generic makefile.
22!include $(PSSRCDIR)\int.mak
23
24# Define the C++ compiler invocation for library modules.
25GLCPP=$(CPP) $(CO) $(I_)$(GLI_)$(_I)
26
27# Define the compilation rule for Windows interpreter code.
28# This requires PS*_ to be defined, so it has to come after int.mak.
29PSCCWIN=$(CC_WX) $(CCWINFLAGS) $(I_)$(PSI_)$(_I) $(PSF_)
30
31# Define the name of this makefile.
32WININT_MAK=$(PSSRC)winint.mak
33
34# Define the location of the WinZip self-extracting-archive-maker.
35!ifndef WINZIPSE_XE
36!ifdef WIN64
37WINZIPSE_XE="C:\Program Files (x86)\WinZip Self-Extractor\WZIPSE32.EXE"
38!else
39WINZIPSE_XE="C:\Program Files\WinZip Self-Extractor\WZIPSE32.EXE"
40!endif
41!endif
42
43# Define the name and location of the zip archive maker.
44!ifndef ZIP_XE
45ZIP_XE="zip.exe" -X
46!endif
47
48# Define the setup and install programs, which are only suitable
49# for the DLL build.
50# If MAKEDLL==0, these names are never referenced.
51!ifndef SETUP_XE_NAME
52SETUP_XE_NAME=setupgs.exe
53!endif
54!ifndef SETUP_XE
55SETUP_XE=$(BINDIR)\$(SETUP_XE_NAME)
56!endif
57!ifndef UNINSTALL_XE_NAME
58UNINSTALL_XE_NAME=uninstgs.exe
59!endif
60!ifndef UNINSTALL_XE
61UNINSTALL_XE=$(BINDIR)\$(UNINSTALL_XE_NAME)
62!endif
63
64# Define the RCOMP switch for including INCDIR.
65!if "$(INCDIR)"==""
66i_INCDIR=
67!else
68i_INCDIR=-i$(INCDIR)
69!endif
70
71
72# ----------------------------- Main program ------------------------------ #
73
74ICONS=$(GLGEN)gswin.ico $(GLGEN)gswin16.ico
75
76GS_ALL=$(INT_ALL)\
77  $(LIB_ALL) $(LIBCTR) $(ld_tr) $(GSDLL_OBJ).res $(PSSRC)$(GSDLL).def $(ICONS)
78
79dwdll_h=$(PSSRC)dwdll.h
80dwimg_h=$(PSSRC)dwimg.h
81dwtrace_h=$(PSSRC)dwtrace.h
82dwres_h=$(PSSRC)dwres.h
83dwtext_h=$(PSSRC)dwtext.h
84dwreg_h=$(PSSRC)dwreg.h
85
86# Make the icons from their text form.
87
88$(GLGEN)gswin.ico: $(GLSRC)gswin.icx $(ECHOGS_XE) $(WININT_MAK)
89	$(ECHOGS_XE) -wb $(GLGEN)gswin.ico -n -X -r $(GLSRC)gswin.icx
90
91$(GLGEN)gswin16.ico: $(GLSRC)gswin16.icx $(ECHOGS_XE) $(WININT_MAK)
92	$(ECHOGS_XE) -wb $(GLGEN)gswin16.ico -n -X -r $(GLSRC)gswin16.icx
93
94# resources for short EXE loader (no dialogs)
95$(GS_OBJ).res: $(PSSRC)dwmain.rc $(dwres_h) $(ICONS) $(WININT_MAK)
96	$(ECHOGS_XE) -w $(PSGEN)_exe.rc -x 23 define -s gstext_ico $(GLGENDIR)\gswin.ico
97	$(ECHOGS_XE) -a $(PSGEN)_exe.rc -x 23 define -s gsgraph_ico $(GLGENDIR)\gswin.ico
98	$(ECHOGS_XE) -a $(PSGEN)_exe.rc -R $(PSSRC)dwmain.rc
99	$(RCOMP) -i$(PSSRCDIR) -i$(PSGENDIR) $(i_INCDIR) -r $(RO_)$(GS_OBJ).res $(PSGEN)_exe.rc
100	del $(PSGEN)_exe.rc
101
102# resources for main program (includes dialogs)
103$(GSDLL_OBJ).res: $(PSSRC)gsdll32.rc $(gp_mswin_h) $(ICONS) $(WININT_MAK)
104	$(ECHOGS_XE) -w $(PSGEN)_dll.rc -x 23 define -s gstext_ico $(GLGENDIR)\gswin.ico
105	$(ECHOGS_XE) -a $(PSGEN)_dll.rc -x 23 define -s gsgraph_ico $(GLGENDIR)\gswin.ico
106	$(ECHOGS_XE) -a $(PSGEN)_dll.rc -R $(PSSRC)gsdll32.rc
107	$(RCOMP) -i$(PSSRCDIR) -i$(PSGENDIR) -i$(GLSRCDIR) $(i_INCDIR) -r $(RO_)$(GSDLL_OBJ).res $(PSGEN)_dll.rc
108	del $(PSGEN)_dll.rc
109
110
111# Modules for big EXE
112
113!if $(DEBUG)
114DWTRACE=$(GLOBJ)dwtrace.obj
115!else
116DWTRACE=
117!endif
118
119
120DWOBJNO = $(PSOBJ)dwnodll.obj $(GLOBJ)dwimg.obj $(DWTRACE) $(PSOBJ)dwmain.obj \
121$(GLOBJ)dwtext.obj $(GLOBJ)dwreg.obj
122
123$(PSOBJ)dwnodll.obj: $(PSSRC)dwnodll.c $(AK)\
124 $(dwdll_h) $(iapi_h)
125	$(PSCCWIN) $(COMPILE_FOR_EXE) $(PSO_)dwnodll.obj $(C_) $(PSSRC)dwnodll.c
126
127# Compile gsdll.c, the main program of the DLL.
128
129$(PSOBJ)gsdll.obj: $(PSSRC)gsdll.c $(AK) $(iapi_h) $(ghost_h)
130	$(PSCCWIN) $(COMPILE_FOR_DLL) $(PSO_)gsdll.$(OBJ) $(C_) $(PSSRC)gsdll.c
131
132$(GLOBJ)gp_msdll.obj: $(GLSRC)gp_msdll.c $(AK) $(iapi_h)
133	$(PSCCWIN) $(COMPILE_FOR_DLL) $(GLO_)gp_msdll.$(OBJ) $(C_) $(GLSRC)gp_msdll.c
134
135# Modules for console mode EXEs
136
137OBJC=$(PSOBJ)dwmainc.obj $(PSOBJ)dwdllc.obj $(GLOBJ)gscdefs.obj $(GLOBJ)gp_wgetv.obj \
138$(GLOBJ)dwimg.obj $(DWTRACE) $(GLOBJ)dwreg.obj
139
140OBJCNO=$(PSOBJ)dwmainc.obj $(PSOBJ)dwnodllc.obj $(GLOBJ)dwimg.obj $(DWTRACE) $(GLOBJ)dwreg.obj
141
142$(PSOBJ)dwmainc.obj: $(PSSRC)dwmainc.c $(AK) $(windows__h) $(fcntl__h) $(unistd__h) \
143  $(iapi_h) $(vdtrace_h) $(gdevdsp_h) $(dwdll_h) $(dwimg_h) $(dwtrace_h)
144	$(PSCCWIN) $(COMPILE_FOR_CONSOLE_EXE) $(PSO_)dwmainc.obj $(C_) $(PSSRC)dwmainc.c
145
146$(PSOBJ)dwdllc.obj: $(PSSRC)dwdll.c $(AK) $(dwdll_h) $(iapi_h)
147	$(PSCCWIN) $(COMPILE_FOR_CONSOLE_EXE) $(PSO_)dwdllc.obj $(C_) $(PSSRC)dwdll.c
148
149$(PSOBJ)dwnodllc.obj: $(PSSRC)dwnodll.c $(AK) $(dwdll_h) $(iapi_h)
150	$(PSCCWIN) $(COMPILE_FOR_CONSOLE_EXE) $(PSO_)dwnodllc.obj $(C_) $(PSSRC)dwnodll.c
151
152
153# Modules for small EXE loader.
154
155DWOBJ=$(PSOBJ)dwdll.obj $(GLOBJ)dwimg.obj $(DWTRACE) $(PSOBJ)dwmain.obj \
156$(PSOBJ)dwtext.obj $(GLOBJ)gscdefs.obj $(GLOBJ)gp_wgetv.obj $(PSOBJ)dwreg.obj
157
158$(PSOBJ)dwdll.obj: $(PSSRC)dwdll.c $(AK)\
159 $(dwdll_h) $(iapi_h)
160	$(PSCCWIN) $(COMPILE_FOR_EXE) $(PSO_)dwdll.obj $(C_) $(PSSRC)dwdll.c
161
162$(PSOBJ)dwimg.obj: $(PSSRC)dwimg.c $(AK)\
163 $(dwres_h) $(dwdll_h) $(dwtext_h) $(dwimg_h) $(gdevdsp_h) $(stdio__h) \
164 $(gscdefs_h) $(dwreg_h)
165        $(PSCCWIN) $(COMPILE_FOR_EXE) $(PSO_)dwimg.obj $(C_) $(PSSRC)dwimg.c
166
167$(PSOBJ)dwtrace.obj: $(PSSRC)dwtrace.c $(AK)\
168 $(dwimg_h) $(dwtrace_h)\
169 $(gscdefs_h) $(stdpre_h) $(gsdll_h) $(vdtrace_h)
170        $(PSCCWIN) $(COMPILE_FOR_EXE) $(PSO_)dwtrace.obj $(C_) $(PSSRC)dwtrace.c
171
172$(PSOBJ)dwmain.obj: $(PSSRC)dwmain.c $(AK)  $(windows__h) \
173 $(iapi_h) $(vdtrace_h) $(dwres_h) $(dwdll_h) $(dwtext_h) $(dwimg_h) $(dwtrace_h) \
174 $(dwreg_h) $(gdevdsp_h)
175	$(PSCCWIN) $(COMPILE_FOR_EXE) $(PSO_)dwmain.obj $(C_) $(PSSRC)dwmain.c
176
177$(PSOBJ)dwtext.obj: $(PSSRC)dwtext.c $(AK) $(dwtext_h)
178        $(PSCCWIN) $(COMPILE_FOR_EXE) $(PSO_)dwtext.obj $(C_) $(PSSRC)dwtext.c
179
180$(PSOBJ)dwreg.obj: $(PSSRC)dwreg.c $(AK) $(dwreg_h)
181        $(PSCCWIN) $(COMPILE_FOR_EXE) $(PSO_)dwreg.obj $(C_) $(PSSRC)dwreg.c
182
183
184# ---------------------- Setup and uninstall program ---------------------- #
185
186
187# Modules for setup program
188# These modules shouldn't be referenced if MAKEDDLL==0,but dependencies here
189# don't hurt.
190
191$(PSOBJ)dwsetup.res: $(PSSRC)dwsetup.rc $(PSSRC)dwsetup.h $(GLGEN)gswin.ico
192	$(RCOMP) -i$(PSSRCDIR) -i$(PSGENDIR) -i$(PSOBJDIR) $(i_INCDIR) -r $(RO_)$(PSOBJ)dwsetup.res $(PSSRC)dwsetup.rc
193
194$(PSOBJ)dwsetup.obj: $(PSSRC)dwsetup.cpp $(PSSRC)dwsetup.h $(PSSRC)dwinst.h
195	$(PSCCWIN) $(COMPILE_FOR_EXE) $(PSO_)dwsetup.obj $(C_) $(PSSRC)dwsetup.cpp
196
197$(PSOBJ)dwinst.obj: $(PSSRC)dwinst.cpp $(PSSRC)dwinst.h
198	$(PSCCWIN) $(COMPILE_FOR_EXE) $(PSO_)dwinst.obj $(C_) $(PSSRC)dwinst.cpp
199
200# Modules for uninstall program
201
202$(PSOBJ)dwuninst.res: $(PSSRC)dwuninst.rc $(PSSRC)dwuninst.h $(GLGEN)gswin.ico
203	$(RCOMP) -i$(PSSRCDIR) -i$(PSGENDIR) -i$(PSOBJDIR) $(i_INCDIR) -r $(RO_)$(PSOBJ)dwuninst.res $(PSSRC)dwuninst.rc
204
205$(PSOBJ)dwuninst.obj: $(PSSRC)dwuninst.cpp $(PSSRC)dwuninst.h
206	$(PSCCWIN) $(COMPILE_FOR_EXE) $(PSO_)dwuninst.obj $(C_) $(PSSRC)dwuninst.cpp
207
208
209# ------------------------- Distribution archive -------------------------- #
210
211# The following section of this makefile was developed by, and is maintained
212# by, the developer of GSview.  If you have any questions about it, please
213# contact bug-gswin@ghostscript.com.
214
215# Create a self-extracting archive with setup program.
216# This assumes that the current directory is named gs#.## relative to its
217# parent, where #.## is the Ghostscript version, and that the files and
218# directories listed in ZIPTEMPFILE are the complete list
219# of needed files and directories relative to the current directory's parent.
220
221ZIPTEMPFILE=gs$(GS_DOT_VERSION)\obj\dwfiles.rsp
222ZIPPROGFILE1=gs$(GS_DOT_VERSION)\bin\gsdll32.dll
223ZIPPROGFILE2=gs$(GS_DOT_VERSION)\bin\gsdll32.lib
224ZIPPROGFILE3=gs$(GS_DOT_VERSION)\bin\gswin32.exe
225ZIPPROGFILE4=gs$(GS_DOT_VERSION)\bin\gswin32c.exe
226ZIPPROGFILE5=gs$(GS_DOT_VERSION)\doc
227ZIPPROGFILE6=gs$(GS_DOT_VERSION)\examples
228ZIPPROGFILE7=gs$(GS_DOT_VERSION)\lib
229!if $(COMPILE_INITS)
230!else
231ZIPPROGFILE8=gs$(GS_DOT_VERSION)\Resource
232!endif
233
234# Make the zip archive.
235FILELIST_TXT=filelist.txt
236!ifdef WIN64
237ZIPTARGET=gs$(GS_VERSION)w64
238!else
239ZIPTARGET=gs$(GS_VERSION)w32
240!endif
241zip: $(SETUP_XE) $(UNINSTALL_XE)
242	cd ..
243	copy gs$(GS_DOT_VERSION)\$(SETUP_XE) make_filelist.exe
244	copy gs$(GS_DOT_VERSION)\$(SETUP_XE) .
245	copy gs$(GS_DOT_VERSION)\$(UNINSTALL_XE) .
246	echo $(ZIPPROGFILE1) >  $(ZIPTEMPFILE)
247	echo $(ZIPPROGFILE2) >> $(ZIPTEMPFILE)
248	echo $(ZIPPROGFILE3) >> $(ZIPTEMPFILE)
249	echo $(ZIPPROGFILE4) >> $(ZIPTEMPFILE)
250	echo $(ZIPPROGFILE5) >> $(ZIPTEMPFILE)
251	echo $(ZIPPROGFILE6) >> $(ZIPTEMPFILE)
252	echo $(ZIPPROGFILE7) >> $(ZIPTEMPFILE)
253!if $(COMPILE_INITS)
254!else
255	echo $(ZIPPROGFILE8) >> $(ZIPTEMPFILE)
256!endif
257	make_filelist.exe -title "GPL Ghostscript $(GS_DOT_VERSION)" -dir "gs$(GS_DOT_VERSION)" -list "$(FILELIST_TXT)" @$(ZIPTEMPFILE)
258	-del $(ZIPTARGET).zip
259	$(ZIP_XE) -9 $(ZIPTARGET).zip $(SETUP_XE_NAME) $(UNINSTALL_XE_NAME) $(FILELIST_TXT)
260	$(ZIP_XE) -9 -r $(ZIPTARGET).zip $(ZIPPROGFILE1)
261	$(ZIP_XE) -9 -r $(ZIPTARGET).zip $(ZIPPROGFILE2)
262	$(ZIP_XE) -9 -r $(ZIPTARGET).zip $(ZIPPROGFILE3)
263	$(ZIP_XE) -9 -r $(ZIPTARGET).zip $(ZIPPROGFILE4)
264	$(ZIP_XE) -9 -r $(ZIPTARGET).zip $(ZIPPROGFILE5)
265	$(ZIP_XE) -9 -r $(ZIPTARGET).zip $(ZIPPROGFILE6)
266	$(ZIP_XE) -9 -r $(ZIPTARGET).zip $(ZIPPROGFILE7)
267!if $(COMPILE_INITS)
268!else
269	$(ZIP_XE) -9 -r $(ZIPTARGET).zip $(ZIPPROGFILE8)
270!endif
271	-del $(ZIPTEMPFILE)
272	-del make_filelist.exe
273	-del $(SETUP_XE_NAME)
274	-del $(UNINSTALL_XE_NAME)
275	-del $(FILELIST_TXT)
276	cd gs$(GS_DOT_VERSION)
277
278# Now convert to a self extracting archive.
279# This involves making a few temporary files.
280ZIP_RSP = $(PSOBJ)setupgs.rsp
281# Note that we use ECHOGS_XE rather than echo for the .txt files
282# to avoid ANSI/OEM character mapping.
283# Use a special icon WinZip SE can't handle 48 pixel 32-bit icons
284# as used by Windows XP.
285archive: zip $(PSOBJ)gswin16.ico $(ECHOGS_XE)
286	$(ECHOGS_XE) -w $(ZIP_RSP) -q "-win32 -setup"
287	$(ECHOGS_XE) -a $(ZIP_RSP) -q -st -x 22 GPL Ghostscript $(GS_DOT_VERSION) for Win32 -x 22
288	$(ECHOGS_XE) -a $(ZIP_RSP) -q -i -s $(PSOBJ)gswin16.ico
289	$(ECHOGS_XE) -a $(ZIP_RSP) -q -a -s $(PSOBJ)about.txt
290	$(ECHOGS_XE) -a $(ZIP_RSP) -q -t -s $(PSOBJ)dialog.txt
291	$(ECHOGS_XE) -a $(ZIP_RSP) -q -c -s $(SETUP_XE_NAME)
292	$(ECHOGS_XE) -w $(PSOBJ)about.txt "GPL Ghostscript is Copyright " -x A9 " 2010 Artifex Software, Inc."
293	$(ECHOGS_XE) -a $(PSOBJ)about.txt See license in gs$(GS_DOT_VERSION)\doc\COPYING.
294	$(ECHOGS_XE) -a $(PSOBJ)about.txt See gs$(GS_DOT_VERSION)\doc\Commprod.htm regarding commercial distribution.
295	$(ECHOGS_XE) -w $(PSOBJ)dialog.txt This installs GPL Ghostscript $(GS_DOT_VERSION).
296	$(ECHOGS_XE) -a $(PSOBJ)dialog.txt GPL Ghostscript displays, prints and converts PostScript and PDF files.
297	$(WINZIPSE_XE) ..\$(ZIPTARGET) @$(PSOBJ)setupgs.rsp
298# Don't delete temporary files, because make continues
299# before these files are used.
300#	-del $(ZIP_RSP)
301#	-del $(PSOBJ)about.txt
302#	-del $(PSOBJ)dialog.txt
303
304
305# -------------------- Distribution source archive ------------------- #
306# This creates a zip file containing the files needed to build
307# ghostscript on MS-Windows.  We don't distribute this zip file,
308# but use it to build the executable distribution.
309#
310# The MS-Windows build process for a release is
311#  gzip -d ghostscript-N.NN.tar.gz
312#  tar -xvf ghostscript-N.NN.tar
313#  cd ghostscript-N.NN
314#  nmake -f psi/msvc32.mak srczip
315#  cd gsN.NN
316#  nmake -f psi/msvc32.mak
317#  nmake -f psi/msvc32.mak archive
318
319gs$(GS_VERSION)src.zip:
320	-rmdir /s /q gs$(GS_DOT_VERSION)
321	-del temp.zip
322	zip -r -X temp.zip LICENSE doc examples icclib ijs jasper jbig2dec jpeg lib libpng base psi Resource tiff zlib -x ".svn/*" -x "*/.svn/*" -x "*/*/.svn/*" -x "*/*/*/.svn/*" -x "*/*/*/*/.svn/*" -x "*/*/*/*/*/.svn/*"
323	mkdir gs$(GS_DOT_VERSION)
324	cd gs$(GS_DOT_VERSION)
325	unzip -a ../temp.zip
326	cd ..
327	zip -9 -r -X gs$(GS_VERSION)src.zip gs$(GS_DOT_VERSION)
328
329srczip: gs$(GS_VERSION)src.zip
330
331# end of winint.mak
332
333