Initial release of Maemo 5 port of gnuplot
[gnuplot] / config / makefile.mgw
1 # Hello, emacs: this is a -*- Makefile -*-
2 # $Id: makefile.mgw,v 1.41.2.5 2009/02/11 10:00:32 mikulik Exp $
3 #
4 # GNUPLOT Makefile for MinGW32 MinGW32 on WinNT and Win95/98/..
5 #  This assumes that MinGW32 is used via the MSYS toolkit
6 #  (needed some changes to work around command line parsing gotchas)
7 #
8
9 # To compile gnuplot for WinXX:
10 #
11 # - compile the package: go to directory 'gnuplot' and therefrom run
12 #        make -C src -f ../config/makefile.mgw
13 #
14 # This makefile was tested with MSYS, MingW32 and Microsoft Help
15 # Workshop 4.03.
16 #
17
18 #
19 # ************** Begin of Configuration section ************************
20 #
21
22 # Comment out the definition lines to disable the according features:
23
24 # GIF, PNG, JPEG device drivers
25 # Requires gd library. There are two possibilities how to configure these
26 # drivers for use in gnuplot, depending on the gd version. See README.1ST for
27 # more details. 
28 #
29 # You should compile gnuplot with GD library v2.0 or newer.
30 # This library writes PNG, GIF and JPEG images.
31 # If libgd has been compiled with TrueType font support, then you can use
32 # scaled TrueType fonts. If not, then uncomment FREETYPE.
33 # Requires GD, PNG and Z libraries, optionally libfreetype.
34 # In some cases, libfreetype can depend on additional libraries such as
35 # fontconfig or iconv; then, uncomment GDAUTOCONFIGLIBS so that all of the
36 # libraries needed for linking will be taken by running 'gdlib-config'.
37 #
38 NEWGD=1
39 JPEG=1
40 FREETYPE=1
41 #GDAUTOCONFIGLIBS=1
42
43 # PDF device driver
44 # Requires PNG and Z libraries based on particular PDF library used, and
45 # optionally also TIFF library according to
46 # 1. defined PDF_NOTIFF:
47 #    'Light' pdf library (produces wgnuplot.exe only 200 KB larger!)
48 #    You can get this pdf library by compiling it without PNG, GD and TIFF
49 #    support: change  pdflib/p_intern.h  and recompile the pdf library.
50 #    Gnuplot does not use the tiff routines, and gd/png are elsewhere.
51 # 2. undefined PDF_NOTIFF:
52 #    Full pdf library (produces wgnuplot.exe 500 KB larger!)
53 #PDF=1
54 #PDF_NOTIFF=1
55
56 # DEBUGging support
57 # creates binaries suitable for debugging. Some bugs may come and go
58 # as opposed to a production build since we lower the optimization level
59 #DEBUG=1
60
61 # MOUSE support for the windows terminal
62 MOUSE=1
63
64 # PIPES: define if you would prefer support of pipes undef Windows (e.g.
65 # plot '<awk -f preprocess.awk my.dat'). Drawback: wgnuplot.exe keeps attached
66 # to a console=DOS window it was launched from, or it opens a new one.
67 # Also does not work properly with pgnuplot.
68 #PIPES=1
69
70 # WXWIDGETS interactive terminal
71 # Requires wxWidgets, Cairo, Pango, and their respective dependencies.
72 # Uncomment the following lines to compile it.
73 # WXT_LOCATION should give the path where can be found wx/*.h headers
74 #WXT=1
75 #WX_LOCATION=/usr/local/include/wx-2.6
76
77 # Below you can adapt paths according to your software setup:
78
79 # Where to place gnuplot.gih helpfile:
80 HELPFILE = wgnuplot.hlp
81
82 # Where to install the PostScript prologue files, relatively to the executable
83 # wgnuplot.exe
84 GNUPLOT_PS_DIR = share/PostScript
85
86 # Destination directory, used in 'make install':
87 DESTDIR = /c/Progra~1/Gnuplot4.2
88
89 # give here the path to MinGW compiler unless it is already in PATH
90 #GCCPATH = g:/mingw32/bin/
91 #GCCPATH = c:/apps/mingw/bin/
92
93 # Do you want some special optimization?
94 # -mpentium means optimise for Pentium processor
95 # -mpentiumpro means optimize for Pentium II and Pro procesors
96 CFLAGS =
97
98
99 # To compile the .hlp file you need hcw either out of Microsoft SDK or MS Help
100 # Workshop. The latter can be obtained from either of
101 # ftp://ftp.microsoft.com/softlib/mslfiles/hcwsetup.exe
102 # http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=34D35502-4DE9-4676-952C-34CC7F64F098
103 # Put the path to hcw here unless it is already in PATH:
104 HCWPATH = /c/Program\ Files/Help\ Workshop/
105 HCW = $(HCWPATH)hcw
106 # Switches are for HCW 4.03:
107 HCWFLAG =
108
109 # Choose which windres/rc do you want to use (GNU windres or MS RC):
110 GNU_RC = 1
111 ifndef GNU_RC
112   # If uncommented GNU_RC above and rc.exe not in PATH, then set:
113   MSSDK = c:/mssdk
114 endif
115
116 # GNU sort
117 GNUSORT = /bin/sort
118
119 #
120 # *************** End of Configuration section *************************
121 #
122
123
124 #         There shouldn't be anything to be changed below this line
125 # **********************************************************************
126 #
127
128
129 CC = $(GCCPATH)gcc
130 LD = $(GCCPATH)gcc
131 CXX = $(GCCPATH)g++
132 LDX = $(GCCPATH)g++
133
134 RM = rm -f
135 CP = cp -p
136
137 ifdef DEBUG
138   CFLAGS += -g
139   LDFLAGS += -g
140 else
141   CFLAGS += -O2
142   LDFLAGS += -s
143 endif
144
145 ifdef PIPES
146   OPTS += -DPIPES
147   LDFLAGS2 = -mconsole
148 endif
149
150 TOP = ..
151 TERMFLAGS = -DGNUPLOT_PS_DIR=\"$(GNUPLOT_PS_DIR)\" -I$(TOP)/term
152 TERMLIBS = 
153
154 CFLAGS += -I$(TOP) -I. -D_Windows -DHAVE_CONFIG_H\
155         $(OPTS)
156
157 ifdef MOUSE
158   CFLAGS += -DUSE_MOUSE=1 -DWIN_IPC
159 endif
160
161 ifdef NEWGD
162   GD=1
163   PNG=1
164 endif
165
166 ifdef GD
167   CFLAGS += -DHAVE_LIBGD
168   TERMLIBS += -lgd
169 endif
170
171 ifdef PNG
172   CFLAGS += -DHAVE_LIBPNG
173   ifndef GDAUTOCONFIGLIBS
174     TERMLIBS += -lpng -lz
175   endif
176 endif
177
178 ifdef NEWGD
179   CFLAGS += -DHAVE_GD_GIF -DGIF_ANIMATION -DHAVE_GD_PNG
180 ifdef JPEG
181   CFLAGS += -DHAVE_GD_JPEG
182   ifndef GDAUTOCONFIGLIBS
183     TERMLIBS += -ljpeg
184   endif
185 endif
186 ifdef FREETYPE
187   CFLAGS += -DHAVE_GD_TTF
188   ifndef GDAUTOCONFIGLIBS
189     TERMLIBS += -lfreetype
190   endif
191 endif
192 ifdef GDAUTOCONFIGLIBS
193   TERMLIBS += $(shell gdlib-config --libs)
194 endif
195 endif
196
197 ifdef PDF
198   CFLAGS += -DHAVE_LIBPDF
199 ifdef PDF_NOTIFF
200   TERMLIBS += -lpdf_notiff
201 else
202   TERMLIBS += -lpdf -ltiff
203 #  TERMLIBS += -lpdf-w -ltiff-w
204 endif
205 ifndef PNG
206   NEED_PNG_W = 1
207 else
208 ifndef NEWGD
209   NEED_PNG_W = 1
210 endif
211 endif
212 ifdef NEED_PNG_W
213   CFLAGS += -DHAVE_LIBPNG
214   TERMLIBS += -lpng-w -lz-w
215 endif
216 endif
217
218 ifdef WXT
219         CFLAGS += -DWXWIDGETS
220         CXXFLAGS += $(shell wx-config --cxxflags)
221         CAIRO_CFLAGS = $(shell pkg-config --cflags cairo)
222         CAIRO_LIBS = $(shell pkg-config --libs cairo)
223         PANGO_CFLAGS = $(shell pkg-config --cflags pangocairo)
224         PANGO_LIBS = $(shell pkg-config --libs pangocairo)
225         WX_LIBS = $(shell wx-config --libs)
226         WX_OBJS = wxt_gui.o gp_cairo.o
227 endif
228
229 ifdef GNU_RC
230   # RC = d:/cygnus/cygwin-b20/H-i586-cygwin32/bin/windres
231   RC  = $(GCCPATH)windres
232   RCFLAGS = --include-dir /mingw32/include \
233         --include-dir=win \
234         --define __WIN32__ --define __WIN95__ --define MSRC \
235         --define __GNUWIN32__ --use-temp-file
236   ifdef WXT
237         RCFLAGS += --define WXWIDGETS --include-dir=$(WX_LOCATION)
238   endif
239   RCOUT = wgplt_res.o
240   RES2COFF = echo wgplt_res.o
241 else
242   RC = $(MSSDK)/bin/rc
243   RCFLAGS = -v -i$(MSSDK)/include -iwin -dWIN32 -dMSRC
244   ifdef WXT
245         RCFLAGS += -dWXWIDGETS -i$(WX_LOCATION)
246   endif
247   RCOUT = -fowgnuplot.res
248   RES2COFF = res2coff -i wgnuplot.res -o wgplt_res.o
249 endif
250
251 # macros for makefile.all
252 O=o
253 T=../term/
254 D=../docs/
255 L=docs/latex/                   # HBB FIXME 20060430: what's this for?
256 M=../demo/
257
258
259 default: wgnuplot.exe $(HELPFILE) wgnuplot.mnu $(M)bf_test.exe \
260         pgnuplot.exe
261
262 all:    default gnuplot.ps gnuplot.pdf
263
264
265 # include the 'core makefile template'
266 include makefile.all
267
268 OBJS = $(COREOBJS) version.$(O) gpexecute.$(O) $(WX_OBJS)
269
270 WINOBJS = winmain.$(O) wgnuplib.$(O) wgraph.$(O) wprinter.$(O) wtext.$(O) wpause.$(O) wmenu.$(O)
271
272 WINDOWS = makefile.win makefile.nt README.win win/wcommon.h \
273         win/wgnuplib.c win/wgnuplib.def win/wgnuplib.h win/wgnuplib.rc \
274         win/wgnuplot.def win/wgnuplot.hpj win/wgnuplot.mnu win/wgraph.c \
275         win/winmain.c win/wmenu.c win/wpause.c win/wprinter.c \
276         win/wresourc.h win/wtext.c win/wtext.h win/geticon.c \
277         $(D)doc2rtf.c $(T)win.trm win/grpicon.ico win/texticon.ico
278
279
280 # default rules
281 .SUFFIXES: .exe .o .c
282 .c.o:
283         $(CC) -c $(CFLAGS) $*.c
284
285 LDLIBS = -lkernel32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -ladvapi32
286
287 #
288 # Create config.h
289 #
290 config.h: ../config/config.mgw
291         cp $< $@
292
293 $(OBJS) $(WINOBJS) dbinary.$(O): config.h
294
295 wgnuplot.exe: $(OBJS) $(WINOBJS) win/wgnuplot.def wgplt_res.o texticon.ico grpicon.ico
296         $(LDX) $(LDFLAGS) $(LDFLAGS2) -mwindows -o $@ $(OBJS) $(WINOBJS) wgplt_res.o $(LDLIBS)\
297         $(TERMLIBS) $(WX_LIBS) $(CAIRO_LIBS) $(PANGO_LIBS)
298
299 pgnuplot.exe: win/pgnuplot.c version.o
300         $(CC) -O2 -DHAVE_STDBOOL_H -s -o pgnuplot.exe win/pgnuplot.c version.o -I. -luser32
301
302 # rules
303
304 wgplt_res.o :  win/wgnuplot.rc win/wgnuplib.rc win/wresourc.h texticon.ico grpicon.ico
305         $(RC) $(RCFLAGS) --include-dir=win win/wgnuplot.rc $(RCOUT)
306         $(RES2COFF)
307
308 show.o: show.c plot.h setshow.h
309         $(CC) -c $(CFLAGS) -DHELPFILE=\"$(HELPFILE)\" -DBINDIR=\"$(bindir)\" -c $<
310
311 term.$(O): term.c term.h plot.h setshow.h bitmap.h $(CORETERM)
312         $(CC) -c $(CFLAGS) $(TERMFLAGS) term.c
313
314 version.$(O): version.c
315
316 WINDEPS = win/wgnuplib.h win/wcommon.h win/wresourc.h
317
318 winmain.$(O): win/winmain.c win/wgnuplib.h win/wtext.h plot.h
319         $(CC) -c $(CFLAGS) -DHELPFILE=\"$(HELPFILE)\"  win/winmain.c
320
321 wgnuplib.$(O): win/wgnuplib.c $(WINDEPS)
322         $(CC) -c $(CFLAGS) win/wgnuplib.c
323
324 wmenu.$(O): win/wmenu.c $(WINDEPS)
325         $(CC) -c $(CFLAGS) win/wmenu.c
326
327 wtext.$(O): win/wtext.c $(WINDEPS)
328         $(CC) -c $(CFLAGS) win/wtext.c
329
330 wpause.$(O): win/wpause.c wxterminal/wxt_term.h $(WINDEPS)
331         $(CC) -c $(CFLAGS) win/wpause.c
332
333 wprinter.$(O): win/wprinter.c $(WINDEPS)
334         $(CC) -c $(CFLAGS) win/wprinter.c
335
336 wgraph.$(O): win/wgraph.c $(WINDEPS)
337         $(CC) -c $(CFLAGS) win/wgraph.c
338
339 wgnuplot.mnu: win/wgnuplot.mnu
340         $(CP) $^ $@
341
342 wxt_gui.$(O): wxterminal/wxt_gui.cpp wxterminal/wxt_gui.h $(WX_LOCATION)
343         $(CXX) -c $(CFLAGS) $(CXXFLAGS) $(CAIRO_CFLAGS) wxterminal/wxt_gui.cpp
344
345 gp_cairo.$(O): wxterminal/gp_cairo.c wxterminal/gp_cairo.h
346         $(CC) -c $(CFLAGS) $(CXXFLAGS) $(CAIRO_CFLAGS) $(PANGO_CFLAGS) wxterminal/gp_cairo.c
347
348 # extract icons from wgnuplot.rc
349 texticon.ico: grpicon.ico
350
351 grpicon.ico: geticon.exe win/wgnuplot.rc
352         ./geticon win/wgnuplot.rc
353
354 geticon.exe: win/geticon.c
355         $(LD) $(LDFLAGS) -o $@ win/geticon.c
356
357 # convert gnuplot.doc to gnuplot.rtf
358 $(HELPFILE): doc2rtf.exe $(D)gnuplot.doc win/wgnuplot.hpj
359         ./doc2rtf $(D)gnuplot.doc win/gnuplot.rtf
360         $(HCW) -c -e win/wgnuplot.hpj
361
362 doc2rtf.exe: $(D)doc2rtf.c $(D)termdoc.c $(D)xref.c
363         $(LD) $(LDFLAGS) -o $@ -DWINDOWS_NO_GUI $(CFLAGS) -I. -I$(D:/=) -I$(T:/=) $^
364
365 #make binary demo files
366 $(M)bf_test.exe : bf_test.c dbinary.$(O) alloc.$(O)
367         $(LD) $(LDFLAGS) $(CFLAGS) -U_Windows -o $@ $^
368         (cd $(M) ; ./bf_test.exe )
369 #       cd ..
370
371 # _Windows causes wtext.h to define fread() etc
372 dbinary.$(O): binary.c
373         $(CC) -c $(CFLAGS) -U_Windows -o $@ $<
374
375
376 # Create documentation in various formats
377 #
378 ALL_TERMINALS_DOC=1
379 ifdef ALL_TERMINALS_DOC
380 # Generate TeX documentation with the complete list of all terminals
381 # (gnuplot.tex should be the same on all platforms):
382 SORT_TERMINALS=1
383 ifdef SORT_TERMINALS
384 # sort alphabetically all terminals (note: req. GNU sort, not from MS)
385 allterm.h: $(CORETERM)
386         @echo "Building allterm.h"
387         @for e in `egrep "^[    ]*START_HELP" $(CORETERM) |\
388              $(GNUSORT) -f -t':' -k2` ; do \
389           f=`echo $$e |cut -d\: -f1` ; s=`echo $$e | cut -d\: -f2` ;\
390           sed -n "/^[   ]*$$s/,/^[      ]*END_HELP/p" $$f ; \
391         done >$@
392 else
393 # sequence of terminals according to "ls term/*.trm":
394 allterm.h: $(CORETERM)
395         @echo "Building allterm.h"
396         @cat $(T)*.trm > allterm.c
397         $(CPP) $(CFLAGS) -I$(T:/=) -DTERM_DRIVER_H -DTERM_HELP allterm.c | \
398           sed '/^ *$$/d;/^#/d' > allterm.h
399         @rm -f allterm.c
400 endif
401 doc2tex.exe: $(D)doc2tex.c $(D)termdoc.c allterm.h
402         $(LD) $(LDFLAGS) -o $@ -DWINDOWS_NO_GUI -DALL_TERM_DOC $(CFLAGS) \
403           -I. -I$(D:/=) -I$(T:/=) $(D)doc2tex.c $(D)termdoc.c
404 else
405 # Old version: generate documentation with only currently used terminals:
406 doc2tex.exe: $(D)doc2tex.c $(D)termdoc.c
407         $(LD) $(LDFLAGS) -o $@ -DWINDOWS_NO_GUI $(CFLAGS) -I. -I$(D) -I$(T) $^
408 endif
409
410 gnuplot.tex: $(D)gnuplot.doc doc2tex.exe
411         doc2tex $(D)gnuplot.doc gnuplot.tex
412
413 # Call LaTeX three times to get the toc right.
414 gnuplot.dvi: gnuplot.tex $(D)titlepag.tex
415         cp gnuplot.tex $(D)gp_tex2.tex
416         cp $(D)../VERSION $(D)
417         cd $(D) && latex gp_tex2.tex && latex gp_tex2.tex && latex gp_tex2.tex
418         mv $(D)gp_tex2.dvi gnuplot.dvi
419         rm -f $(D)gp_tex2.*
420 gnuplot.ps: gnuplot.dvi
421         dvips -o gnuplot.ps gnuplot.dvi
422 gnuplot.pdf: gnuplot.tex $(D)titlepag.tex
423         cp gnuplot.tex $(D)gp_tex2.tex
424         cp $(D)../VERSION $(D)
425         cd $(D) && pdflatex gp_tex2.tex && pdflatex gp_tex2.tex && pdflatex gp_tex2.tex
426         mv $(D)gp_tex2.pdf gnuplot.pdf
427         rm -f $(D)gp_tex2.*
428
429
430 # clean up temporary files
431 clean:
432         $(RM) config.h *.$(O) wgnuplot.map wgnuplot.res win/gnuplot.rtf
433         $(RM) wxterminal/*.$(O)
434         $(RM) doc2rtf.exe win/wgnuplib.res wgnuplib.map wgnuplot.lib
435         $(RM) $(M)bf_test.exe *.ico geticon.exe allterm.h allterm.c
436         $(RM) gnuplot.tex gnuplot.dvi gnuplot.ps gnuplot.pdf
437
438 realclean: veryclean
439 veryclean: clean
440         $(RM) wgnuplot.exe wgnuplot.hlp wgnuplot.mnu wgnuplot.gid
441         $(RM) $(M)binary[123] $(M)fit.log $(M)soundfit.par
442
443 # now move the whole stuff to its destination
444 install: default
445         mkdir -p $(DESTDIR)
446         cp wgnuplot.exe $(DESTDIR)/wgnuplot.exe
447         cp win/wgnuplot.mnu $(DESTDIR)/wgnuplot.mnu
448         cp wgnuplot.hlp $(DESTDIR)/wgnuplot.hlp
449         cp pgnuplot.exe $(DESTDIR)/pgnuplot.exe
450         mkdir -p $(DESTDIR)/share/PostScript
451         cp ../term/PostScript/*.ps $(DESTDIR)/$(GNUPLOT_PS_DIR)