File: Makefile

package info (click to toggle)
gretl 2016d-1
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 48,620 kB
  • ctags: 22,779
  • sloc: ansic: 345,830; sh: 4,648; makefile: 2,712; xml: 570; perl: 364
file content (621 lines) | stat: -rw-r--r-- 17,034 bytes parent folder | download
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
# This makefile can be used for cross-compiling gretl for Windows
# on Linux, or for a native build on MS Windows.  In both cases we
# assume that the mingw compiler is used.  The build type is
# controlled by the BUILDTYPE variable in config.mk, included
# below.

include config.mk

# directories
topsrc = ..
libsrcdir  = $(topsrc)/lib/src
plugindir = $(topsrc)/plugin
zipdir = $(topsrc)/plugin/zipunzip
guidir = $(topsrc)/gui2
imports = ./import-libs
host_builddir = $(topsrc)/build

# tools (can add -fopenmp to CC if wanted)
CC = $(MGW_PREFIX)gcc -msse2 -fopenmp -Wall -O2 -mms-bitfields -DWIN32
AS = $(MGW_PREFIX)as
DLLWRAP = $(MGW_PREFIX)dllwrap
DLLWRAP_FLAGS = --as=$(AS) --export-all --driver-name $(CC) -s
RC = $(MGW_PREFIX)windres
RCFLAGS = --define __WIN32__ --define __WIN95__ --define MSRC \
	--define __GNUWIN32__

# libraries
GTKLIBS := $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --libs gtk+-win32-2.0)
GLIBLIB := $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --libs glib-2.0)
JSON_LIB = $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --libs json-glib-1.0)
RL_LIBS = -lreadline
GUI_LIBS = -lwsock32 -lole32 -lshlwapi $(GTKLIBS) -lgtksourceview-2.0 -lxml2.dll -L$(imports)
GRETLLIB = -L$(imports) -lgretl -lintl
LIBS = -lm $(GRETLLIB) -ladvapi32
FFTW_LIBS = -lfftw3
CURL_LIBS = -lcurl.dll

# flags/defines
CFLAGS = -I. -I$(libsrcdir) -I$(plugindir) -I$(guidir) -I$(zipdir) -I$(XML2_INC) $(RLIB_CFLAGS) 
GTK_CFLAGS := $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --cflags gtk+-win32-2.0 gtksourceview-2.0 json-glib-1.0)

ifeq ($(BUILDTYPE),cross)
  GRETL_LANG = cross_lang
  GRETL_NEWS = cross_news
  BUILDDATE = cross_builddate
else
  GRETL_LANG = native_lang
  GRETL_NEWS = native_news
  BUILDDATE = native_builddate
endif

ifeq ($(have_mpi),yes)
  MPICLI = gretlmpi.exe
  MPI_LIB = -lmsmpi
endif

ifeq ($(use_openblas),yes)
  LAPACK_LIBS = -lopenblas.dll
else
  LAPACK_LIBS = -llapack.dll -lblas.dll
endif

# source paths
vpath %.c $(libsrcdir)
vpath %.c $(topsrc)/cephes
vpath %.c $(topsrc)/minpack
vpath %.c $(topsrc)/dcmt
vpath %.c $(topsrc)/cli
vpath %.c $(guidir)
vpath %.c $(plugindir)
vpath %.c $(plugindir)/libole2
vpath %.c $(plugindir)/zipunzip
vpath %.c $(plugindir)/rq
vpath %.c $(topsrc)/tests
vpath %.h $(libsrcdir):$(topsrc)/cli:$(guidir):$(plugindir):.
vpath %.h $(topsrc)/cephes:..
vpath %.rc $(topsrc)/win32

#### End of system configuration section. ####

PLUGINSRC = \
	arbond.c \
	excel_import.c \
	xlsx_import.c \
	gnumeric_import.c \
	eviews_import.c \
	stata_import.c \
	stata_export.c \
	spss_import.c \
	sas_import.c \
	jmulti_import.c \
	ods_import.c \
	johansen.c \
	jrestrict.c \
	jalpha.c \
	kernel.c \
	vif.c \
	leverage.c \
	mp_ols.c \
	pca.c \
	progress_bar.c \
	range-mean.c \
	fractals.c \
	poisson.c \
	duration.c \
	stats_tables.c \
	sysest.c \
	fiml.c \
	liml.c \
	tramo_options.c \
	tramo-x12a.c \
	nistcheck.c \
	arma_cml.c \
	arma_init.c \
	arma.c \
        arma_x12.c \
	workbook.c \
	mod_garch.c \
	fcp.c \
	garch.c \
        audio.c \
	urcdist.c \
	gretlzip.c \
	heckit.c \
	odbc_import.c \
	quantreg.c \
	interval.c \
	anova.c \
	biprobit.c \
	reprobit.c

PLUGINOBJ = $(PLUGINSRC:.c=.o)

PLUGINS = plugins/stats_tables.dll \
	plugins/progress_bar.dll \
	plugins/gnumeric_import.dll \
	plugins/eviews_import.dll \
	plugins/excel_import.dll \
	plugins/xlsx_import.dll \
	plugins/stata_import.dll \
	plugins/spss_import.dll \
	plugins/sas_import.dll \
	plugins/jmulti_import.dll \
	plugins/ods_import.dll \
	plugins/stata_export.dll \
	plugins/mp_ols.dll \
	plugins/sysest.dll \
	plugins/johansen.dll \
	plugins/kernel.dll \
	plugins/arbond.dll \
	plugins/arma.dll \
	plugins/arma_x12.dll \
	plugins/range-mean.dll \
	plugins/fractals.dll \
	plugins/poisson.dll \
	plugins/duration.dll \
	plugins/tramo-x12a.dll \
	plugins/leverage.dll \
	plugins/pca.dll \
	plugins/nistcheck.dll \
	plugins/garch.dll \
        plugins/audio.dll \
	plugins/vif.dll \
	plugins/urcdist.dll \
	plugins/gretlzip.dll \
	plugins/heckit.dll \
	plugins/odbc_import.dll \
	plugins/quantreg.dll \
	plugins/interval.dll \
	plugins/anova.dll \
	plugins/interpolate.dll \
	plugins/biprobit.dll \
	plugins/reprobit.dll \
	plugins/panurc.dll \
	plugins/json_get.dll

LIBSRC = adf_kpss.c \
	bhhh_max.c \
	bootstrap.c \
	boxplots.c \
	calendar.c \
	compare.c \
	compat.c \
	csvdata.c \
	dataio.c \
	dataset.c \
	dbread.c \
	dbwrite.c \
	describe.c \
        discrete.c \
	estimate.c \
	flow_control.c \
	forecast.c \
	geneval.c \
	genfuncs.c \
	genlex.c \
	genmain.c \
	gensyntax.c \
        gmm.c \
	graphing.c \
	gretl_array.c \
	gretl_bfgs.c \
	gretl_bundle.c \
	gretl_commands.c \
	gretl_data_io.c \
	gretl_errors.c \
	gretl_fft.c \
	gretl_foreign.c \
	gretl_func.c \
	gretl_intl.c \
	gretl_help.c \
	gretl_list.c \
	gretl_matrix.c \
	gretl_midas.c \
	gretl_model.c \
	gretl_normal.c \
	gretl_panel.c \
	gretl_paths.c \
	gretl_plot.c \
	gretl_prn.c \
	gretl_restrict.c \
	gretl_string_table.c \
	gretl_typemap.c \
	gretl_untar.c \
	gretl_utils.c \
	gretl_win32.c \
	gretl_www.c \
	gretl_xml.c \
	gretl_zip.c \
	interact.c \
	kalman.c \
	libglue.c \
	libset.c \
	matrix_extra.c \
	missing.c \
	modelprint.c \
	monte_carlo.c \
	nls.c \
	nonparam.c \
	objstack.c \
	options.c \
	plotspec.c \
	plugins.c \
	printout.c \
	printscan.c \
	pvalues.c \
	qr_estimate.c \
	random.c \
	strutils.c \
	subsample.c \
	system.c \
	texprint.c \
	transforms.c \
	tsls.c \
        usermat.c \
	uservar.c \
	var.c \
	varprint.c \
	vartest.c \
	irfboot.c

ifeq ($(have_mpi),yes)
  LIBSRC += gretl_mpi.c
endif

LIBOBJ = $(LIBSRC:.c=.o)

CLISRC = gretlcli.c complete.c 

CLIOBJ = $(CLISRC:.c=.o)

GUISRC = about.c \
	calculator.c \
	callbacks.c \
	cmdstack.c \
	console.c \
	database.c \
	datafiles.c \
	datawiz.c \
	dialogs.c \
	dlgutils.c \
	filelists.c \
	fileselect.c \
	filters.c \
	fncall.c \
	fnsave.c \
	gfn_arglists.c \
	gpt_control.c \
	gpt_dialog.c \
	graphics.c \
	graph_page.c \
	gretl.c \
	gretlwin32.c \
	gretl_ipc.c \
	guiprint.c \
	gui_recode.c \
	gui_utils.c \
	helpfiles.c \
	join-gui.c \
	lagpref.c \
	library.c \
	menustate.c \
	model_table.c \
	objectsave.c \
	obsbutton.c \
	selector.c \
	series_view.c \
	session.c \
	settings.c \
	ssheet.c \
	tabwin.c \
	textbuf.c \
	textutil.c \
	toolbar.c \
	treeutils.c \
	update.c \
	varinfo.c \
	winstack.c

ifeq ($(HAVE_GTK_SPINNER),no)
  GUISRC += spinner.c
endif

GUIOBJ = $(GUISRC:.c=.o)

PROBSRC = airy.c const.c hyp2f1.c igami.c j1.c kn.c pdtr.c struve.c \
	bdtr.c expx2.c hyperg.c incbet.c jn.c mtherr.c polevl.c unity.c \
	btdtr.c fdtr.c i0.c incbi.c jv.c  nbdtr.c polrt.c yn.c \
	chbevl.c gamma.c i1.c iv.c k0.c kv.c ndtr.c psi.c \
	chdtr.c gdtr.c igam.c j0.c k1.c ndtri.c stdtr.c

PROBOBJ = $(PROBSRC:.c=.o)

MINSRC = chkder.c enorm.c fdjac2.c lmder.c lmdif.c lmpar.c \
	qrfac.c qrsolv.c lbfgsb.c
MINOBJ = $(MINSRC:.c=.o)

DCMTSRC = check32.c eqdeg.c genmtrand.c mt19937.c prescr.c seive.c
DCMTOBJ = $(DCMTSRC:.c=.o)

OBJS = $(LIBOBJ) $(CLIOBJ) $(GUIOBJ) $(PLUGINOBJ)

MOFILES = mo/de.po mo/el.mo mo/es.mo mo/eu.mo mo/fr.mo mo/it.mo mo/pl.mo \
	mo/pt.mo mo/ru.mo mo/rw.mo mo/tr.mo mo/cs.mo mo/sq.mo

%.o: %.c
	$(CC) -c $(GTK_CFLAGS) $(CFLAGS) $<
	$(CC) -MM $(GTK_CFLAGS) $(CFLAGS) $< > $*.d 

# targets begin

all: buildstamp dirs dlls/libprob.dll dlls/libgretl.dll \
	$(PLUGINS) gretlcli.exe gretl.exe $(MPICLI) $(MOFILES) $(GRETL_LANG) $(GRETL_NEWS)

gretlcli.exe: $(CLIOBJ)
	$(CC) -o $@ $^ $(LIBS) $(RL_LIBS) -lz -lmingwex -s

gretlmpi.exe: gretlcli-mpi.o
	$(CC) -o $@ $< $(MPI_LIB) $(LIBS) -lz -lmingwex -s

gretl.exe: $(GUIOBJ) gretlres.o
	$(CC) -mwindows -o $@ $^ $(LIBS) $(GUI_LIBS) -lz -lmingwex -s

gretlres.o: gretl.rc 
	$(RC) $(RCFLAGS) $< $@

cross_lang: $(libsrcdir)/options.c $(libsrcdir)/genlex.c $(libsrcdir)/gretl_commands.c
	HERE=$$PWD ; cd $(host_builddir)/gui2 && make mklang && ./mklang > $$HERE/gretl.lang ; cd $$HERE

cross_news: $(topsrc)/ChangeLog
	HERE=$$PWD ; cd $(host_builddir)/gui2 && make mknews && cd $$HERE && $(topsrc)/build/gui2/mknews $< > NEWS

mklang.o: mklang.c $(libsrcdir)/options.c $(libsrcdir)/genlex.c $(libsrcdir)/gretl_commands.c
	$(CC) -c -I. -I$(libsrcdir) -I$(XML2_INC) $<

mklang.exe: mklang.o
	$(CC) -o $@ $< $(GRETLLIB) -lxml2.dll -lz

mknews.exe: mknews.c
	$(CC) -o $@ $<

native_lang: mklang.exe
	PATH=/bin:./dlls:/mingw/winbuild/misc-dll ./mklang.exe > gretl.lang

native_news: mknews.exe
	./mknews.exe $(topsrc)/ChangeLog > NEWS

$(MOFILES):
	make -C mo

dlls/libgretl.dll: $(LIBOBJ) $(MINOBJ) $(DCMTOBJ) dllinit.o
	$(DLLWRAP) $(DLLWRAP_FLAGS) \
	--output-def libgretl.def --implib $(imports)/libgretl.a \
	-o $@ $^ -lm -L$(imports) -lxml2.dll -lz -lintl -lprob -lgmp.dll \
	-lmingwex -lwsock32 $(GLIBLIB) $(LAPACK_LIBS) $(FFTW_LIBS) $(CURL_LIBS)

dlls/libprob.dll: $(PROBOBJ) dllinit.o
	$(DLLWRAP) $(DLLWRAP_FLAGS) \
	--output-def libprob.def --implib $(imports)/libprob.a \
	-o $@ $^ 

plugins/stats_tables.dll: stats_tables.o dllinit.o 
	$(DLLWRAP) $(DLLWRAP_FLAGS) --output-def $(<:.o=.def) -o $@ \
	--implib plugins/$(<:.o=.a) $^ -lz $(GRETLLIB)

plugins/range-mean.dll: range-mean.o dllinit.o 
	$(DLLWRAP) $(DLLWRAP_FLAGS) --output-def $(<:.o=.def) -o $@ \
	--implib plugins/$(<:.o=.a) $^ $(GRETLLIB)

plugins/fractals.dll: fractals.o dllinit.o 
	$(DLLWRAP) $(DLLWRAP_FLAGS) --output-def $(<:.o=.def) -o $@ \
	--implib plugins/$(<:.o=.a) $^ $(GRETLLIB)

plugins/poisson.dll: poisson.o dllinit.o 
	$(DLLWRAP) $(DLLWRAP_FLAGS) --output-def $(<:.o=.def) -o $@ \
	--implib plugins/$(<:.o=.a) $^ $(GRETLLIB) -lprob

plugins/duration.dll: duration.o dllinit.o 
	$(DLLWRAP) $(DLLWRAP_FLAGS) --output-def $(<:.o=.def) -o $@ \
	--implib plugins/$(<:.o=.a) $^ $(GRETLLIB)

plugins/kernel.dll: kernel.o dllinit.o
	$(DLLWRAP) $(DLLWRAP_FLAGS) --output-def $(<:.o=.def) -o $@ \
	--implib plugins/$(<:.o=.a) $^ $(GRETLLIB) 

plugins/vif.dll: vif.o dllinit.o
	$(DLLWRAP) $(DLLWRAP_FLAGS) --output-def $(<:.o=.def) -o $@ \
	--implib plugins/$(<:.o=.a) $^ $(GRETLLIB) $(LAPACK_LIBS)

plugins/urcdist.dll: urcdist.o dllinit.o
	$(DLLWRAP) $(DLLWRAP_FLAGS) --output-def $(<:.o=.def) -o $@ \
	--implib plugins/$(<:.o=.a) $^ -lz -lm -lintl $(GRETLLIB)

plugins/tramo-x12a.dll: tramo-x12a.o tramo_options.o dllinit.o
	$(DLLWRAP) $(DLLWRAP_FLAGS) --output-def $(<:.o=.def) -o $@ \
	--implib plugins/$(<:.o=.a) $^ $(GRETLLIB) $(GTKLIBS)

plugins/progress_bar.dll: progress_bar.o dllinit.o
	$(DLLWRAP) $(DLLWRAP_FLAGS) --output-def $(<:.o=.def) -o $@ \
	--implib plugins/$(<:.o=.a) $^ $(GTKLIBS) -L$(imports) -lintl

plugins/gnumeric_import.dll: gnumeric_import.o dllinit.o
	$(DLLWRAP) $(DLLWRAP_FLAGS) --output-def $(<:.o=.def) -o $@ \
	--implib plugins/$(<:.o=.a) $^ -L$(imports) -lxml2.dll \
	$(GRETLLIB) $(GTKLIBS)

plugins/ods_import.dll: ods_import.o dllinit.o
	$(DLLWRAP) $(DLLWRAP_FLAGS) --output-def $(<:.o=.def) -o $@ \
	--implib plugins/$(<:.o=.a) $^ -L$(imports) -lxml2.dll \
	$(GRETLLIB) $(GTKLIBS)

plugins/xlsx_import.dll: xlsx_import.o dllinit.o
	$(DLLWRAP) $(DLLWRAP_FLAGS) --output-def $(<:.o=.def) -o $@ \
	--implib plugins/$(<:.o=.a) $^ -L$(imports) -lxml2.dll \
	$(GRETLLIB) $(GTKLIBS)

plugins/excel_import.dll: excel_import.o workbook.o ms-ole.o dllinit.o
	$(DLLWRAP) $(DLLWRAP_FLAGS) --output-def $(<:.o=.def) -o $@ \
	--implib plugins/$(<:.o=.a) $^ $(GRETLLIB) $(GTKLIBS) -lmoldname

plugins/eviews_import.dll: eviews_import.o dllinit.o
	$(DLLWRAP) $(DLLWRAP_FLAGS) --output-def $(<:.o=.def) -o $@ \
	--implib plugins/$(<:.o=.a) $^ $(GRETLLIB)

plugins/stata_import.dll: stata_import.o dllinit.o
	$(DLLWRAP) $(DLLWRAP_FLAGS) --output-def $(<:.o=.def) -o $@ \
	--implib plugins/$(<:.o=.a) $^ $(GLIBLIB) $(GRETLLIB)

plugins/stata_export.dll: stata_export.o dllinit.o
	$(DLLWRAP) $(DLLWRAP_FLAGS) --output-def $(<:.o=.def) -o $@ \
	--implib plugins/$(<:.o=.a) $^ $(GLIBLIB) $(GRETLLIB)

plugins/spss_import.dll: spss_import.o dllinit.o
	$(DLLWRAP) $(DLLWRAP_FLAGS) --output-def $(<:.o=.def) -o $@ \
	--implib plugins/$(<:.o=.a) $^ $(GLIBLIB) $(GRETLLIB)

plugins/sas_import.dll: sas_import.o dllinit.o
	$(DLLWRAP) $(DLLWRAP_FLAGS) --output-def $(<:.o=.def) -o $@ \
	--implib plugins/$(<:.o=.a) $^ $(GRETLLIB)

plugins/jmulti_import.dll: jmulti_import.o dllinit.o
	$(DLLWRAP) $(DLLWRAP_FLAGS) --output-def $(<:.o=.def) -o $@ \
	--implib plugins/$(<:.o=.a) $^ $(GRETLLIB)

plugins/mp_ols.dll: mp_ols.o dllinit.o 
	$(DLLWRAP) $(DLLWRAP_FLAGS) --output-def $(<:.o=.def) -o $@ \
	--implib plugins/$(<:.o=.a) $^ $(GRETLLIB) -lmpfr.dll -lgmp.dll

plugins/sysest.dll: sysest.o fiml.o liml.o dllinit.o
	$(DLLWRAP) $(DLLWRAP_FLAGS) --output-def $(<:.o=.def) -o $@ \
	--implib plugins/$(<:.o=.a) $^ $(GRETLLIB) $(LAPACK_LIBS)

plugins/johansen.dll: johansen.o jrestrict.o jalpha.o dllinit.o
	$(DLLWRAP) $(DLLWRAP_FLAGS) --output-def $(<:.o=.def) -o $@ \
	--implib plugins/$(<:.o=.a) $^ $(GRETLLIB) $(LAPACK_LIBS)

plugins/leverage.dll: leverage.o dllinit.o
	$(DLLWRAP) $(DLLWRAP_FLAGS) --output-def $(<:.o=.def) -o $@ \
	--implib plugins/$(<:.o=.a) $^ $(GRETLLIB) $(GTKLIBS) $(LAPACK_LIBS)

plugins/pca.dll: pca.o dllinit.o
	$(DLLWRAP) $(DLLWRAP_FLAGS) --output-def $(<:.o=.def) -o $@ \
	--implib plugins/$(<:.o=.a) $^ $(GRETLLIB) $(GTKLIBS) $(LAPACK_LIBS)

plugins/nistcheck.dll: nistcheck.o dllinit.o
	$(DLLWRAP) $(DLLWRAP_FLAGS) --output-def $(<:.o=.def) -o $@ \
	--implib plugins/$(<:.o=.a) $^ $(GRETLLIB) $(LAPACK_LIBS)

plugins/arbond.dll: arbond.o dllinit.o
	$(DLLWRAP) $(DLLWRAP_FLAGS) --output-def $(<:.o=.def) -o $@ \
	--implib plugins/$(<:.o=.a) $^ $(GRETLLIB) $(LAPACK_LIBS)

plugins/arma.dll: arma.o arma_cml.o arma_init.o dllinit.o
	$(DLLWRAP) $(DLLWRAP_FLAGS) --output-def $(<:.o=.def) -o $@ \
	--implib plugins/$(<:.o=.a) $^ $(GRETLLIB) $(LAPACK_LIBS) -lprob

plugins/arma_x12.dll: arma_x12.o dllinit.o
	$(DLLWRAP) $(DLLWRAP_FLAGS) --output-def $(<:.o=.def) -o $@ \
	--implib plugins/$(<:.o=.a) $^ $(GRETLLIB) $(GTKLIBS) $(LAPACK_LIBS)

plugins/garch.dll: garch.o fcp.o mod_garch.o dllinit.o
	$(DLLWRAP) $(DLLWRAP_FLAGS) --output-def $(<:.o=.def) -o $@ \
	--implib plugins/$(<:.o=.a) $^ $(GRETLLIB) $(LAPACK_LIBS)

plugins/audio.dll: audio.o midi_utils.o dllinit.o
	$(DLLWRAP) $(DLLWRAP_FLAGS) --output-def $(<:.o=.def) -o $@ \
	--implib plugins/$(<:.o=.a) $^ $(GRETLLIB) $(GTKLIBS) -lole32 -lsapi

plugins/gretlzip.dll: gretlzip.o zfileio.o zipfile.o zipmain.o zipwork.o \
	zsystem.o dllinit.o
	$(DLLWRAP) $(DLLWRAP_FLAGS) --output-def $(<:.o=.def) -o $@ \
	--implib plugins/$(<:.o=.a) $^ $(GLIBLIB) -lz $(GRETLLIB)

plugins/heckit.dll: heckit.o dllinit.o
	$(DLLWRAP) $(DLLWRAP_FLAGS) --output-def $(<:.o=.def) -o $@ \
	--implib plugins/$(<:.o=.a) $^ $(GRETLLIB)

plugins/odbc_import.dll: odbc_import.o dllinit.o
	$(DLLWRAP) $(DLLWRAP_FLAGS) --output-def $(<:.o=.def) -o $@ \
	--implib plugins/$(<:.o=.a) $^ $(GRETLLIB) -lodbc32

plugins/quantreg.dll: quantreg.o rqfnb.o rqbr.o dllinit.o
	$(DLLWRAP) $(DLLWRAP_FLAGS) --output-def $(<:.o=.def) -o $@ \
	--implib plugins/$(<:.o=.a) $^ $(GRETLLIB) $(LAPACK_LIBS)

plugins/interval.dll: interval.o dllinit.o
	$(DLLWRAP) $(DLLWRAP_FLAGS) --output-def $(<:.o=.def) -o $@ \
	--implib plugins/$(<:.o=.a) $^ $(GRETLLIB) 

plugins/anova.dll: anova.o dllinit.o
	$(DLLWRAP) $(DLLWRAP_FLAGS) --output-def $(<:.o=.def) -o $@ \
	--implib plugins/$(<:.o=.a) $^ $(GRETLLIB) $(GLIBLIB) 

plugins/interpolate.dll: interpolate.o dllinit.o
	$(DLLWRAP) $(DLLWRAP_FLAGS) --output-def $(<:.o=.def) -o $@ \
	--implib plugins/$(<:.o=.a) $^ $(GRETLLIB)

plugins/biprobit.dll: biprobit.o dllinit.o
	$(DLLWRAP) $(DLLWRAP_FLAGS) --output-def $(<:.o=.def) -o $@ \
	--implib plugins/$(<:.o=.a) $^ $(GRETLLIB)

plugins/reprobit.dll: reprobit.o dllinit.o
	$(DLLWRAP) $(DLLWRAP_FLAGS) --output-def $(<:.o=.def) -o $@ \
	--implib plugins/$(<:.o=.a) $^ $(GRETLLIB)

plugins/panurc.dll: panurc.o dllinit.o
	$(DLLWRAP) $(DLLWRAP_FLAGS) --output-def $(<:.o=.def) -o $@ \
	--implib plugins/$(<:.o=.a) $^ $(GRETLLIB) $(GLIBLIB)

plugins/json_get.dll: json_get.o dllinit.o
	$(DLLWRAP) $(DLLWRAP_FLAGS) --output-def $(<:.o=.def) -o $@ \
	--implib plugins/$(<:.o=.a) $^ $(GRETLLIB) $(JSON_LIB)

ms-ole.o: ms-ole.c $(topsrc)/plugin/libole2/ms-ole.h
	$(CC) -c $(CFLAGS) $(GTK_CFLAGS) $<

workbook.o: workbook.c $(topsrc)/plugin/libole2/ms-ole.h
	$(CC) -c $(CFLAGS) $(GTK_CFLAGS) $<

midi_utils.o: midi_utils.c $(topsrc)/plugin/midi_utils.h
	$(CC) -c $(CFLAGS) $(GTK_CFLAGS) $<

-include $(OBJS:.o=.d)

# Distribution executable

dist.stamp:
	bash ./mkwindist $(BUILDTYPE)

.PHONY:

dirs:
	mkdir -p dlls 
	mkdir -p plugins 
	mkdir -p import-libs

cross_builddate: $(topsrc)/builddate.c
	gcc -Wall -o builddate $<

native_builddate: $(topsrc)/builddate.c
	$(CC) -Wall -o builddate $<

buildstamp: $(BUILDDATE)
	./builddate

clean:
	rm -f *.o *.d *.def *.exe $(CLIPROG) $(GUIPROG) $(MPICLI) $(CHECKER) dlls/*
	rm -f plugins/* $(PLUGINS)
	rm -f $(imports)/*.a 
	rm -f gretl.stamp gretl.lang builddate build.h
	rm -f windist/MANIFEST windist/gretl.iss 
	rm -rf windist/gretl windist/Output
	make -C mo clean
	make -C db clean

cleandist:
	rm -f windist/MANIFEST windist/gretl.iss
	rm -rf windist/gretl windist/gnuplot windist/Output

dist: all dist.stamp