File: makefile.os2

package info (click to toggle)
gnuplot 6.0.2%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 14,940 kB
  • sloc: ansic: 95,319; cpp: 7,590; makefile: 2,470; javascript: 2,328; sh: 1,531; lisp: 664; perl: 304; pascal: 191; tcl: 88; python: 46
file content (648 lines) | stat: -rw-r--r-- 19,909 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
#
# GNUPLOT Makefile for use on OS/2
#  either using EMX 0.9 and GNU make,
#  or using GCC and kLIBC
#
# To compile gnuplot, run the following command in the gnuplot\src directory:
#
#	make -f ..\config\makefile.os2 MAKESHELL=cmd.exe
#
# Note the MAKESHELL argument, which is required for GCC/kLIBC.

# The following tools and libraries are recommended/required to use this
# makefile out of the box with EMX:
#
#	- GNU make, e.g. http://hobbes.nmsu.edu/pub/os2/dev/util/make-3.81beta3-r2-bin.zip
#	- IPFC included in the OS/2 developer kit
#	- emtex is only required for some parts of the documentation
#
#	- GD library, http://hobbes.nmsu.edu/pub/os2/util/gd-2-0-33.zip
#	- PNG library, http://hobbes.nmsu.edu/download/pub/os2/dev/mm/libpng-1.0.18.zip
#	- ICONV library, http://hobbes.nmsu.edu/download/pub/os2/util/iconv0.2.1a.zip
#	[ LUA library, http://hobbes.nmsu.edu/download/pub/os2/dev/lua-5.1.5-ecs.os2.zip - recompiled ]
#	[ PDFlib Lite 6.0 or later compiled for emx (available as source from http://www.pdflib.com/ ) ]
#	[ XFree86 libraries, ftp://ftp.netlabs.org/pub/xfree86/4.5.0 ]
#
#	- GBM binaries for image conversion, http://hobbes.nmsu.edu/download/pub/os2/apps/graphics/gbmos2_176_bin.zip
#
# With GCC/kLIBC we recommend installing the following libraries and development packages
# using yum/ANPM:
#
#	gdlib, zlib, freetype, libpng, libjpeg-turbo,
#	lua, libiconv,
# 	cairo, pango, pangocairo, libglib, libobject, libwebp,
#	exceptq
#

# We aim to distinguish between the original EMX/GCC and the newer GCC/kLIBC
# using the compiler version and assume that 3.2.1 was the last to rely solely
# on EMX libs.
ISKLIBC := $(shell gcc -dumpversion | gawk -F. "{print ($$3+100*($$2+100*$$1)) >= 30202}")

# We depend on using cmd.exe (or a compatible one) and the
# standard OS/2 tool set. (additionally we use 'cat', 'awk')
SHELL=cmd.exe
#MAKESHELL=cmd.exe

#
# ***************** Begin of Configuration section ***************************
#

#
# Comment out the definition lines to disable the according features:
#

# X11 driver
# requires installed XFree86 libraries and headers
ifeq ($(ISKLIBC),0)
X11=1
endif

# GIF, PNG, JPEG device drivers
# Requires gd library (not part of gnuplot)
#
# You can use the following set of options for GD library v2.0 something
# or newer. This library writes PNG, JPEG and GIF images.
# If libgd has been compiled with TrueType font support, then you can use
# scaled TrueType fonts in PNG images. If not, then uncomment FREETYPE.
# The pre-compiled GD library by Ilya Zakharevich available at
# http://hobbes.nmsu.edu/pub/os2/util/gd-2-0-33.zip
# is strongly recommended. This packages already includes the required
# GD, JPEG and Z and freetype libraries.
GD=1
PNG=1
GIF=1
JPEG=1
FREETYPE=1

# ICONV library
ICONV=1

# cairo/pango terminals:  pdfcairo, pngcairo, cairolatex, webp
# requires pango / cairo
# Note that cairo/pango are only available for newer gcc/kLIBC, not EMX.
# WARNING: The pango binary library is BROKEN (it cannot locate any plugins).
#          So let's not include cairo/pango terminals by default.
ifeq ($(ISKLIBC),1)
# CAIRO=1
endif

# webp terminal
# requires CAIRO and webp, webdemux
# Note that is only available for newer gcc/kLIBC, not EMX.
ifeq ($(ISKLIBC),1)
WEBP=1
endif

# PDF device driver
# requires PDFlib or PDFlib-Lite
# Note that you also need to uncomment the inclusion in term.h
#PDF=1

# Terminals based on the bitmap.c code
# These are mostly old printers, but also include the pnm, sixel, and block
# terminals.
BITMAP=1

# VESAkit support
# requires SVGA- and VESA Kit (not part of gnuplot)
# VESA=1

# LUA support - lua/tikz terminal
LUA=1

# GNU_ReadLine support
# requires GNU readline library (static or DLL; not part of gnuplot)
# GNU_RL=1

# Uncomment if you have libcerf
# http://sourceforge.net/projects/libcerf/
ifeq ($(ISKLIBC),1)
CERF=1
endif

# AMOS functions
# requires the AMOS Fortran library
AMOS=1

# DEBUGging support
# creates binaries suitable for debugging. Some bugs may come and go
# as opposed to a production build since we lower the optimization level
# DEBUG=1

# Helper library for debugging only:
PMPRINTF=1

# ExceptQ
# Crash reporting via exceptq library.
EXCEPTQ=1

# MOUSE support for PM and X11 terminals
# NOTE: This cannot be disabled
MOUSE=1

# Include image in gnuplot.inf
IMAGEHELP=1

#
# ****************** End of Configuration section ****************************
#

#
# Miscellaneous setup
#

.PHONY: all runtime alldocs demo binaries infomin clean veryclean
.SUFFIXES: .c .trm .o .obj .exe .rc .res .dll

ifeq ($(ISKLIBC),1)
$(info This seems to be a GCC with kLIBC!)
else
$(info This seems to be EMX/GCC!)
endif

# A reasonable default
default: runtime

# A basic help screen
help:
	   @echo " Usage: $(MAKE) -f makefile.os2 target"
	   @echo "   where target is one of:"
	   @echo "   all runtime alldocs demo binaries infomin help clean veryclean"

#
# Definitions of flags and symbols used by makefile.all and makefile.os2
#

# these definitions are used by makefile.all
T=../term/
D=../docs/
L=$(D)latextut/
M=../demo/

#
# Definitions valid for all targets on OS/2
#

OS2DIR  = os2
DOCDIR  = ..\docs
DEMODIR = ..\demo
TERMDIR = ..\term


# where to place gnuplot.gih helpfile
HELPFILE = $(DOCDIR)\gnuplot.gih

# Where to install the PostScript prologue files, relatively to the executable
# gnuplot.exe
GNUPLOT_PS_DIR = share/PostScript

# Similarly for javascript files for the canvas terminal:
GNUPLOT_JS_DIR = share/js

# Similarly for scripts used by the lua terminal
GNUPLOT_LUA_DIR = share/lua

#
# Two sets of variables are defined and used to create
#   1: gnuplot.exe, and utilities
#   2: gnupmdrv.exe (the PM-driver executable)
#
CC  = gcc
CC2 = gcc
O  = o
O2 = obj

# Flags for compiler and linker under OS/2
OS2FLAGS = -DOS2
TERMFLAGS = -DOS2

# Flags for compiling with EMX/GCC
# Special note: -ffloat-store is necessary to avoid some strange behaviour
# of this code:
#   reset; set key; set xlabel "Year"; set xdata time; set timefmt "%y%m%d"
#   set format x "%y"; set xrange ["900621" : "950126"];
#   plot '-' using 1:2 title 'Fitted IO' with lines 1
#   900621 20
#   950126 55
#   e
# Confirmed for gcc 2.7.x/2.8.x; graphics.c used to be the culprit, but as
# of today (20010918) it isn't any more ...
#
EMXSPECIFIC = -DHAVE_CONFIG_H -ffloat-store
LIBS =

#
# Choose flags suitable for a debugging or for a production build
#
WARNFLAGS = -Wall -Wno-comment
ifeq ($(ISKLIBC),1)
WARNFLAGS += -Wno-pointer-sign -Wno-unused-but-set-variable
endif
ifdef DEBUG
CFLAGS  = -g $(OS2FLAGS) $(EMXSPECIFIC) $(WARNFLAGS) -O0 -Zmt
LDFLAGS  = -g -Zmt -Zcrtdll
CFLAGS2 = -g $(OS2FLAGS) $(EMXSPECIFIC) $(WARNFLAGS) -O0 -Zmt -Zomf
LDFLAGS2 = -g -Zmt -Zcrtdll -Zomf
else
CFLAGS  = $(OS2FLAGS) $(EMXSPECIFIC) -O4 $(WARNFLAGS) -Zmt
LDFLAGS  = -s -Zmt -Zcrtdll
CFLAGS2 = $(OS2FLAGS) $(EMXSPECIFIC) -O4 $(WARNFLAGS) -Zmt -Zomf
LDFLAGS2 = -s -Zmt -Zcrtdll -Zomf
endif
ifeq ($(ISKLIBC),0)
CFLAGS   += -Zbsd-signals
LDFLAGS  += -Zbsd-signals
CFLAGS2  += -Zbsd-signals
LDFLAGS2 += -Zbsd-signals
EXTRADEP += inttypes.h
endif

#
# Settings for the terminals to be included
#
TERMFLAGS = -DGNUPLOT_PS_DIR=\"$(GNUPLOT_PS_DIR)\" -DGNUPLOT_JS_DIR=\"$(GNUPLOT_JS_DIR)\"
TERMFLAGS += -DGNUPLOT_LUA_DIR=\"$(GNUPLOT_LUA_DIR)\" -I. -I.. -I$(T)

ifdef GD
  CFLAGS += -DHAVE_LIBGD -DHAVE_GD_H
  TERMLIBS += -lgd
ifdef FREETYPE
  CFLAGS += -DHAVE_GD_TTF
endif
ifdef PNG
  CFLAGS += -DHAVE_GD_PNG
endif
ifdef GIF
  CFLAGS += -DHAVE_GD_GIF -DGIF_ANIMATION
endif
ifdef JPEG
  CFLAGS += -DHAVE_GD_JPEG
endif
endif

ifdef CAIRO
  CFLAGS += -DHAVE_CAIROPDF -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pango-1.0
  TERMFLAGS += -DHAVE_CAIROEPS
  TERMLIBS  += -lcairo -lpangocairo-1.0 -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -lfreetype -lglib-2.0 -lintl -lpthread
  CAIROOBJS = gp_cairo.$(O) gp_cairo_helpers.$(O)
ifdef WEBP
  TERMFLAGS += -DHAVE_WEBP
  TERMLIBS  += -lwebp -lwebpmux
endif
endif

ifdef PDF
  TERMFLAGS += -DHAVE_LIBPDF -DHAVE_PDFLIB_H
  TERMLIBS  += -lpdflib
endif

# SVGA-/VESAkit support
ifdef VESA
  TERMFLAGS += -DEMXVESA
  TERMLIBS  += -ljmgraph -lvesa
endif

# LUA support
ifdef LUA
  TERMFLAGS += -DHAVE_LUA
  TERMLIBS  += -llua
  LUA_HELP  =  $(D)\gnuplot-tikz.help
endif

# X11 support
ifdef X11
  TERMFLAGS += -DX11 -DX11_DRIVER_DIR=\".\"
endif

# BITMAP support
ifndef BITMAP
  TERMFLAGS += -DNO_BITMAP_SUPPORT
endif

# MOUSE support
ifdef MOUSE
  TERMFLAGS += -DUSE_MOUSE
  # the interprocess communication flag OS2_IPC is #defined in config.(os2,h)
endif

# GNU readline support
ifdef GNU_RL
  CFLAGS  += -DHAVE_LIBREADLINE -D HAVE_READLINE_READLINE_H -DHAVE_READLINE_HISTORY_H -DHAVE_READLINE_RESET
  LIBS    += -lreadline -lncurses
else
  CFLAGS  += -DREADLINE
endif

# iconv support
ifdef ICONV
  CFLAGS  += -DHAVE_ICONV
  LIBS    += -liconv
endif

# cerf library support
ifdef CERF
  CFLAGS  += -DHAVE_LIBCERF
  LIBS    += -lcerf
endif

# AMOS function support (translated using f2c)
ifdef AMOS
  CFLAGS  += -DHAVE_AMOS
  LIBS    += -lamos -lf2c
endif

ifdef DEBUG
ifdef PMPRINTF
  CFLAGS2 += -DHAVE_PMPRINTF
  LDFLAGS2 += -lpmprintf
endif
endif

ifdef EXCEPTQ
  CFLAGS2  += -DHAVE_EXCEPTQ
  LDFLAGS2 += -Zmap -Zlinker /map -Zlinker /linenumbers
endif

# TOOLS
CPP = cpp
# Do not name this variable "IPFC"!! This won't work out...
IPF_C = ipfc.exe

# Tools for buildings the docs
DVIPS    = dvips
LATEX    = latex
PDFLATEX = vlatex
PLAINTEX = tex

#
# Default Rules
#
.c.$(O):
	$(CC)  $(CFLAGS) $(TERMFLAGS) -MMD -o $*.$(O) -c $*.c
.c.obj:
	$(CC2) $(CFLAGS2) $(TERMFLAGS) -MMD -o $*.obj -c $*.c

#
# Include dependencies valid for all platforms from makefile.all
#
include makefile.all


#
# Pre-defined sets of targets:
#
all:         runtime demo
alldocs:     $(DOCDIR)\gnuplot.gih $(DOCDIR)\gnuplot.inf $(DOCDIR)\gnuplot.html \
             $(DOCDIR)\gnuplot.info $(DOCDIR)\gnuplot.ps \
             $(DOCDIR)\gnuplot.pdf
runtime:     config.h binaries infomin $(DOCDIR)\gnuplot.inf
infomin:     gnupmdrv.hlp $(DOCDIR)\gnuplot.gih
demo:        $(M)binary1 $(M)binary2 $(M)binary3
ifdef X11
binaries: gnuplot.exe gnupmdrv.exe gnuplot_x11.exe
else
binaries: gnuplot.exe gnupmdrv.exe
endif

OBJS = $(COREOBJS) $(CAIROOBJS) version.$(O)


term.$(O): $(CORETERM) term.h config.h $(OS2DIR)\pm_msgs.h

gp_cairo.$(O): wxterminal/gp_cairo.c
	$(CC)  $(CFLAGS) $(TERMFLAGS) -o $*.$(O) -c $<

gp_cairo_helpers.$(O): wxterminal/gp_cairo_helpers.c
	$(CC)  $(CFLAGS) $(TERMFLAGS) -o $*.$(O) -c $<

$(OBJS): config.h

gnuplot.exe: $(EXTRADEP) $(OBJS)
	$(CC) $(LDFLAGS) -o $@ $(OBJS) $(TERMLIBS) $(LIBS)

inttypes.h: $(firstword $(MAKEFILE_LIST))
	@echo Creating a minimal inttypes.h for gnuplot
	@echo #if defined(__EMX__) > $@
	@echo #define PRId64 "lld" >> $@
	@echo #define PRIi64 "lli" >> $@
	@echo #define PRIo64 "llo" >> $@
	@echo #define PRIu64 "llu" >> $@
	@echo #define PRIx64 "llx" >> $@
	@echo #define PRIX64 "llX" >> $@
	@echo #define INT64_MAX LLONG_MAX >> $@
	@echo #define INT64_MIN LLONG_MIN >> $@
	@echo typedef unsigned long long uint64_t; >> $@
	@echo typedef long long int64_t; >> $@
	@echo #endif >> $@

#
# Build the PM outboard driver
#
$(OS2DIR)\gnupmdrv.$(O2): $(OS2DIR)\gnupmdrv.c $(OS2DIR)\gnupmdrv.h $(OS2DIR)\dialogs.h	config.h
$(OS2DIR)\gclient.$(O2):  $(OS2DIR)\gclient.c  $(OS2DIR)\gnupmdrv.h $(OS2DIR)\dialogs.h	config.h \
	$(OS2DIR)\pm_msgs.h gpexecute.h mousecmn.h mouse.h
$(OS2DIR)\dialogs.$(O2):  $(OS2DIR)\dialogs.c  $(OS2DIR)\gnupmdrv.h $(OS2DIR)\dialogs.h	config.h
$(OS2DIR)\print.$(O2):    $(OS2DIR)\print.c    $(OS2DIR)\gnupmdrv.h $(OS2DIR)\dialogs.h	config.h
$(OS2DIR)\gpexecute.$(O2): gpexecute.c gpexecute.h mousecmn.h config.h

$(OS2DIR)\gnupmdrv.res :   $(OS2DIR)\gnupmdrv.rc  $(OS2DIR)\gnuplot.ico $(OS2DIR)\dialogs.h
	cd $(OS2DIR) && rc -i \usr\include\os2tk45 -r gnupmdrv.rc & cd ..

OS2OBJ = $(OS2DIR)\gnupmdrv.$(O2) $(OS2DIR)\gclient.$(O2) $(OS2DIR)\print.$(O2) \
         $(OS2DIR)\dialogs.$(O2) gpexecute.$(O2)

gnupmdrv.exe: $(OS2OBJ) $(OS2DIR)\gnupmdrv.res $(OS2DIR)\gnupmdrv.def
	$(CC2) $(LDFLAGS2) -o $@ $(OS2DIR)\gnupmdrv.res $(OS2OBJ) $(OS2DIR)\gnupmdrv.def
ifdef EXCEPTQ
	mapxqs gnupmdrv.map
endif

gnupmdrv.hlp: $(OS2DIR)\gnupmdrv.ipf
#	Cannot use the command
#	$(IPF_C) $< $@
#	because IPFC 2.1 does not support this syntax. Use instead:
	copy $< . && $(IPF_C) gnupmdrv.ipf && del gnupmdrv.ipf

#
# Build the X11 outboard driver
#

# X11 libraries
X11LIBS = -L$(X11ROOT)/XFree86/lib -lX11 -lsocket -Zbsd-signals -Zcrtdll
# X11 includes
X11INCLUDES = -I$(X11ROOT)/XFree86/include
X11FLAGS= -I. -Zmt -D__UNIXOS2__ -DI_NEED_OS2_H -DGenericEvent=-1
ifdef MOUSE
X11FLAGS += -DUSE_MOUSE
endif
X11OBJS = gplt_x11.o gpexecute.o getcolor_x11.o version.o

gnuplot_x11.exe: $(EXTRADEP) $(X11OBJS)
	$(CC) $(LDFLAGS) $(X11FLAGS) $(EMXSPECIFIC) -o $@ -DGPLT_X11_MODE $(X11OBJS) $(X11LIBS)

gplt_x11.o: gplt_x11.c mouse.h gpexecute.h config.h
	$(CC) $(CFLAGS) $(X11FLAGS) $(EMXSPECIFIC) $(X11INCLUDES) -c -o $@ $<

getcolor_x11.o: getcolor.c
	$(CC) $(CFLAGS) $(X11FLAGS) $(EMXSPECIFIC) -DGPLT_X11_MODE -c -o $@ $<

#
# pull in dependency info for existing object files
#
ifndef NODEPS
-include $(OBJS:.$(O)=.d)
-include $(OS2OBJS:.$(O2)=.d)
endif

#
# Create config.h
# This file is preferable over having explicit gcc command longer than 10 lines:
# gcc ... -DHAVE_ -DHAVE_ ... -DHAVE_ -DHAVE_ ... myfile.c
#
config.h: ..\config\config.os2
	if exist $@ del $@
	copy $< $@

ifdef LUA
$(LUA_HELP): $(T)/lua/gnuplot-tikz.lua
	lua $< termhelp > $@
endif

#
# Create documentation in various formats
#
# The idea behind the renaming business is that we may want to
# use various LaTeX systems which may choke if they find existing
# intermediate files from other systems.
# Call LaTeX three times to get the toc right.
$(DOCDIR)\gnuplot.dvi: $(DOCDIR)\gnuplot.tex
	copy $(DOCDIR)\gnuplot.tex $(DOCDIR)\gnuplot_2.tex
	cd $(DOCDIR) && $(LATEX) gnuplot_2.tex && $(LATEX) gnuplot_2.tex && $(LATEX) gnuplot_2.tex
	if exist $(DOCDIR)\gnuplot.dvi del $(DOCDIR)\gnuplot.dvi
	move $(DOCDIR)\gnuplot_2.dvi $(DOCDIR)\gnuplot.dvi
	del $(DOCDIR)\gnuplot_2.*
$(DOCDIR)\gnuplot.ps: $(DOCDIR)\gnuplot.dvi
	$(DVIPS) -o $@ $(DOCDIR)\gnuplot.dvi
$(DOCDIR)\gnuplot.pdf: $(DOCDIR)\gnuplot.tex
	copy $(DOCDIR)\gnuplot.tex $(DOCDIR)\gnuplot_3.tex
	cd $(DOCDIR) && $(PDFLATEX) gnuplot_3.tex && $(PDFLATEX) gnuplot_3.tex && $(PDFLATEX) gnuplot_3.tex
	if exist $(DOCDIR)\gnuplot.pdf del $(DOCDIR)\gnuplot.pdf
	move $(DOCDIR)\gnuplot_3.pdf $(DOCDIR)\gnuplot.pdf
	del $(DOCDIR)\gnuplot_3.*
$(DOCDIR)\gnuplot.tex:  $(DOCDIR)\gnuplot.doc $(DOCDIR)\doc2tex.exe
	$(DOCDIR)\doc2tex.exe $(DOCDIR)\gnuplot.doc $@
$(DOCDIR)\gnuplot.inf:  $(DOCDIR)\gnuplot.ipf $(DOCDIR)\plotstyles.gnu
ifdef IMAGEHELP
	gnuplot -d -e "set loadpath '../demo'; winhelp=1; cd '$(D)'" plotstyles.gnu
	cd $(DOCDIR) && plotstyles_cvt.cmd
endif
#	Cannot use the command
#	$(IPF_C) /INF $< $@
#	because IPFC 2.1 does not support this syntax. Use instead:
	cd $(DOCDIR) && $(IPF_C) /INF gnuplot.ipf
$(DOCDIR)\gnuplot.gih:  $(DOCDIR)\gnuplot.doc $(DOCDIR)\doc2gih.exe
	$(DOCDIR)\doc2gih.exe $(DOCDIR)\gnuplot.doc $@
$(DOCDIR)\gnuplot.html: $(DOCDIR)\gnuplot.texi $(DOCDIR)\gnuplot.doc
	$(MAKEINFO) --html -I$(DOCDIR) $(DOCDIR)\gnuplot.texi --no-split --output=$@
$(DOCDIR)\gnuplot.info: $(DOCDIR)\gnuplot.texi $@
	$(MAKEINFO) -I$(DOCDIR) $(DOCDIR)\gnuplot.texi --no-split --output=$@
# $(DOCDIR)\gnuplot.texi: $(DOCDIR)\gnuplot.doc $(DOCDIR)\doc2texi.pl
#	perl $(DOCDIR)\doc2texi.pl $(DOCDIR)\gnuplot.doc >$@
$(DOCDIR)\gnuplot.rtf:  $(DOCDIR)\gnuplot.doc $(DOCDIR)\doc2rtf.exe
	$(DOCDIR)\doc2rtf.exe $(DOCDIR)\gnuplot.doc $@
$(DOCDIR)\gnuplot.ms:   $(DOCDIR)\gnuplot.doc $(DOCDIR)\doc2ms.exe
	$(DOCDIR)\doc2ms.exe $(DOCDIR)\gnuplot.doc $@
$(DOCDIR)\gnuplot.ipf:  $(DOCDIR)\gnuplot.doc $(DOCDIR)\doc2ipf.exe
	$(DOCDIR)\doc2ipf.exe $(DOCDIR)\gnuplot.doc $@
# Assume we need A4 format

#
# Tools for converting the documentation from docs\gnuplot.doc
# in various formats
#

# Some dependencies - no rule!
$(DOCDIR)\doc2gih.exe $(DOCDIR)\doc2ipf.exe $(DOCDIR)\doc2info.exe \
$(DOCDIR)\doc2tex.exe $(DOCDIR)\doc2rtf.exe: \
      $(DOCDIR)\termdoc.c $(DOCDIR)\xref.c $(DOCDIR)\allterm.h ..\src\config.h $(LUA_HELP)


SORT_TERMINALS=1
ifdef SORT_TERMINALS
# sort alphabetically all terminals
$(DOCDIR)\allterm.h: $(CORETERM)
	@echo "Building allterm.h"
	@..\src\os2\4allterm.cmd sort
else
# SORT_TERMINALS==0, then sequence of terminals according to "ls term/*.trm":
$(DOCDIR)\allterm.h: $(CORETERM)
	@echo "Building allterm.h"
	@..\src\os2\4allterm.cmd nosort
endif

$(DOCDIR)\doc2gih.exe:  $(DOCDIR)\doc2gih.c $(DOCDIR)\termdoc.c $(OS2TERM)
	$(CC) $(CFLAGS) $(TERMFLAGS) -DALL_TERM_DOC -o $@ $(DOCDIR)\doc2gih.c $(DOCDIR)\termdoc.c
$(DOCDIR)\doc2ipf.exe:  $(DOCDIR)\doc2ipf.c $(DOCDIR)\termdoc.c $(DOCDIR)\xref.c $(OS2TERM)
	$(CC) $(CFLAGS) $(TERMFLAGS) -DALL_TERM_DOC -o $@ $(DOCDIR)\doc2ipf.c $(DOCDIR)\termdoc.c $(DOCDIR)\xref.c
$(DOCDIR)\doc2tex.exe:  $(DOCDIR)\doc2tex.c $(DOCDIR)\termdoc.c $(OS2TERM) $(DOCDIR)\allterm.h
	$(CC) $(CFLAGS) $(TERMFLAGS) -DALL_TERM_DOC -o $@ $(DOCDIR)\doc2tex.c $(DOCDIR)\termdoc.c
$(DOCDIR)\doc2rtf.exe:  $(DOCDIR)\doc2rtf.c $(DOCDIR)\termdoc.c $(DOCDIR)\xref.c $(OS2TERM)
	$(CC) $(CFLAGS) $(TERMFLAGS) -DALL_TERM_DOC -o $@ $(DOCDIR)\doc2rtf.c $(DOCDIR)\termdoc.c $(DOCDIR)\xref.c
$(DOCDIR)\doc2ms.exe:   $(DOCDIR)\doc2ms.c $(DOCDIR)\termdoc.c $(OS2TERM)
	$(CC) $(CFLAGS) $(TERMFLAGS) -DALL_TERM_DOC -o $@ $(DOCDIR)\doc2ms.c $(DOCDIR)\termdoc.c
#
# Create binary demo files
#
$(M)binary1 $(M)binary2 $(M)binary3: $(M)bf_test.exe
	cd $(DEMODIR) && bf_test.exe

$(M)bf_test.exe : bf_test.c
	$(CC) $(CFLAGS) -o $@ bf_test.c

#
# Clean up
#

# Clean up all files temporary used
clean:
	if exist config.h                  del config.h
	if exist *.$(O)                    del *.$(O)
	if exist *.$(O2)                   del *.$(O2)
	cd $(OS2DIR) && if exist *.$(O2)   del *.$(O2)
	if exist *.d                       del *.d
	if exist inttypes.h                del inttypes.h
	if exist $(OS2DIR)\gnupmdrv.res    del $(OS2DIR)\gnupmdrv.res
	if exist $(DEMODIR)\bf_test.exe    del $(DEMODIR)\bf_test.exe
	if exist $(DOCDIR)\doc2*.exe       del $(DOCDIR)\doc2*.exe
	if exist $(DOCDIR)\gnuplot.ipf     del $(DOCDIR)\gnuplot.ipf
	if exist $(DOCDIR)\figure_*.bmp    del $(DOCDIR)\figure_*.bmp
	if exist $(DOCDIR)\windows\figure_*.png  del $(DOCDIR)\windows\figure_*.png
	if exist $(DOCDIR)\gnuplot_2*      del $(DOCDIR)\gnuplot_2*
	if exist $(DOCDIR)\gnuplot_3*      del $(DOCDIR)\gnuplot_3*
	if exist core                      del core
	if exist $(DEMODIR)\core           del $(DEMODIR)\core
	if exist $(DEMODIR)\fit.log        del $(DEMODIR)\fit.log
	if exist $(DOCDIR)\allterm.?       del $(DOCDIR)\allterm.?

# Clean up ALL files that were not part of the source distribution
veryclean: clean
	if exist *.exe                     del *.exe
	if exist gnupmdrv.hlp              del gnupmdrv.hlp
	if exist gnuplot.gih               del gnuplot.gih
	if exist $(DOCDIR)\gnuplot.dvi     del $(DOCDIR)\gnuplot.dvi
	if exist $(DOCDIR)\gnuplot.gih     del $(DOCDIR)\gnuplot.gih
	if exist $(DOCDIR)\gnuplot.html    del $(DOCDIR)\gnuplot.html
	if exist $(DOCDIR)\gnuplot.inf     del $(DOCDIR)\gnuplot.inf
	if exist $(DOCDIR)\gnuplot.info    del $(DOCDIR)\gnuplot.info
	if exist $(DOCDIR)\gnuplot.ms      del $(DOCDIR)\gnuplot.ms
	if exist $(DOCDIR)\gnuplot.ps      del $(DOCDIR)\gnuplot.ps
	if exist $(DOCDIR)\gnuplot.pdf     del $(DOCDIR)\gnuplot.pdf
	if exist $(DOCDIR)\gnuplot.rtf     del $(DOCDIR)\gnuplot.rtf
	if exist $(DOCDIR)\gnuplot.tex     del $(DOCDIR)\gnuplot.tex
	if exist $(DOCDIR)\gnuplot_tikz.help  del $(DOCDIR)\gnuplot_tikz.help
	if exist $(DOCDIR)\*.dvi           del $(DOCDIR)\*.dvi
	if exist $(DOCDIR)\*.log           del $(DOCDIR)\*.log
	if exist $(DOCDIR)\*.aux           del $(DOCDIR)\*.aux
	if exist $(DOCDIR)\*.toc           del $(DOCDIR)\*.toc
	if exist $(DEMODIR)\binary?        del $(DEMODIR)\binary?