File: Makefile.win32

package info (click to toggle)
biosig 2.1.2-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 12,504 kB
  • sloc: ansic: 42,918; cpp: 11,987; sh: 4,378; objc: 2,283; makefile: 1,247; python: 88; awk: 73; php: 40; perl: 36; java: 14; ruby: 7
file content (725 lines) | stat: -rw-r--r-- 27,657 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
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
####### Makefile for "BioSig for C/C++" #####################
###
###  $Id$
###  Copyright (C) 2006,2007,2008,2009 Alois Schloegl <a.schloegl@ieee.org>
###  This file is part of the "BioSig for C/C++" repository
###  (biosig4c++) at http://biosig.sf.net/
###
##############################################################


## make save2gdf   - makes converter
## make mex4o      - makes mexSLOAD, mexSOPEN for Octave (requires Octave-headers)
## make mex4m      - makes mexSLOAD, mexSOPEN for Matlab (requires Matlab, mex -setup must be configured)
## make mex        - mex4o and mex4m combined
## make libbiosig  - makes libbiosig
## make biosig4python - makes python interface (requires Python)
## make biosig4java - makes Java interface (experimental)
## make biosig4php - makes PHP interface (experimental)
## make biosig4perl - makes perl interface (experimental)
## make biosig4ruby - makes ruby interface (experimental)
## make biosig4tcl - makes tcl/tk interface (experimental)
## make win32      - makes save2gdf.exe,libbiosig.lib,libbiosig.dll, for MSWindows, requires MinGW
## make sigviewer  - makes sigviewer 

###############################
# whether dynamic or static linking is used, can be controlled with 
# LIBEXT. Setting it to 'a' links statically, 'so' links dynamically
#
LIBEXT        = a
#LIBEXT	      = so
###############################

### User-specified options: its likely you want to change this
MEX_OPTION    = -largeArrayDims # turn on for 64 bit Matlab, otherwise empty
PathToSigViewer = ../../src/sigviewer
PathToSigViewerWIN32 = ../../src/sigviewer4win32
PathToMinGW   = $(HOME)/R:/src/mingw-cross-env
PathToMinGW64   = $(HOME)/R:/src/mce-w64

## default options 

CC            = gcc
CXX           = g++
#DEFINES      = -D=WITHOUT_SCP_DECODE
DEFINES       = -D=HARDCODED_EVENTTABLE -D=__4HAERTEL__ -D=WITH_FAMOS #-D=WITH_FEF #D=WITH_CHOLMOD -D=WITH_ZLIB -D=WITH_PDP -D=WITH_DICOM #-D=WITH_GDCM #-D=WITH_GSL #-D=WITH_EEPROBE #-D=SOFTCODED_PHYSDIMTABLE # if you have zlib
#DEFINES      += -D=CNT32
CFLAGS        = -pipe -fPIC -Wall -O2 -Wextra $(DEFINES) # -I cntopenlib/include/
CXXFLAGS      = -pipe -fPIC -Wall -O2 -Wextra $(DEFINES) # -I cntopenlib/include/
AR            = ar crs
INCPATH       = -I /usr/local/include/gdcm-2.0/
#		../gdcm-2.0.10/Source/DataStructureAndEncodingDefinition \
#		../gdcm-2.0.10/Source/InformationObjectDefinition  	\
#		../gdcm-2.0.10/Source/MediaStorageAndFileFormat 	\
#		../gdcm-2.0.10/Source/DataDictionary 			\
#		../gdcm-2.0.10/Source/Common
LINK          = $(CXX) 
LFLAGS_dynamic = -L/usr/local/lib/ -L.
LIBS_dynamic  = -lbiosig
LFLAGS_static = -L/usr/local/lib/ 
LIBS_static   = libbiosig.a
ifeq ($(LIBEXT),so)
  LFLAGS      = $(LFLAGS_dynamic)
  LIBS        = $(LIBS_dynamic)
else
  LFLAGS      = $(LFLAGS_static)
  LIBS        = $(LIBS_static)
endif
LDLIBS        = -static-libgcc -static-libstdc++ -lws2_32 #-lgdcmDSED 	# static
LIBS         += $(LDLIBS)
DELETE        = rm
COPY          = cp -f
TEMP_DIR      = /tmp/

##########################################################
## set Matlab and Octave variables
ifneq ($(shell which matlab), )
  MATLABDIR  := $(dir $(shell readlink -f $(shell which matlab) ) )
  MEX         = $(MATLABDIR)mex
  MEX_EXT    := $(shell $(MATLABDIR)mexext)
endif
octVER        = # default
OCT           = mkoctfile$(octVER)
##########################################################

##########################################################
## set variables for Python
SWIG          = swig
PYTHONVER     = $(shell python -c "import sys; print sys.version[:3]")
##########################################################
 
##########################################################
## set variables for MinGW Crosscompiler: compile on linux binaries for windows
##
CROSS	     = i586-mingw32msvc-
CROSS	     = $(PathToMinGW)/usr/bin/i686-pc-mingw32-
CROSS64	     = $(PathToMinGW64)/usr/bin/x86_64-w64-mingw32-
MinGWCC      = $(CROSS)gcc
MinGWCXX     = $(CROSS)g++
MinGWDEF     = -D=HARDCODED_EVENTTABLE -D=__4HAERTEL__ -D=WITH_FAMOS -D=WITH_CHOLMOD #-D=WITH_ZLIB #-D=WITH_FEF #-D=WITH_DICOM #-D=WITH_GDCM #-D=WITH_GSL #-D=WITH_EEPROBE #-D=SOFTCODED_PHYSDIMTABLE
MinGWCFLAGS  = -pipe -fPIC -O2 -D_REENTRANT -D=BUILD_DLL $(MinGWDEF) -I$(PathToMinGW)/usr/i686-pc-mingw32/include/
MinGWLIBS    = win32/libbiosig.a -L$(PathToMinGW)/usr/i686-pc-mingw32/lib/ -lz -lws2_32 $(LDLIBS) # static
MinGWLINK    = $(MinGWCXX)
##########################################################

# Versioning
MAJOR_VERSION := $(word 3, $(shell grep '\#define BIOSIG_VERSION_MAJOR' biosig.h))
MINOR_VERSION := $(word 3, $(shell grep '\#define BIOSIG_VERSION_MINOR' biosig.h))
STEPPING      := $(word 3, $(shell grep '\#define BIOSIG_VERSION_STEPPING' biosig.h))
TODAY         := $(shell date +%Y%m%d)

####### Output directory

OBJ	      = ./obj
BIN	      = $(DESTDIR)/usr/bin
LIB	      = $(DESTDIR)/usr/lib

####### Files
SOURCES       = biosig.c \
		XMLParser/tinyxml.cpp \
		XMLParser/tinyxmlparser.cpp \
		XMLParser/tinyxmlerror.cpp \
		XMLParser/tinystr.cpp \
		t210/sopen_scp_read.c \
		t210/sopen_famos_read.c \
		t210/sopen_alpha_read.c \
		t210/scp-decode.cpp \
		t220/sopen_scp_write.c \
		t220/crc4scp.c \
		t230/sopen_hl7aecg.c \
		t240/sopen_fef_read.c \
		test0/sandbox.c \
		physicalunits.c \
		biosig-network.c \
		save2gdf.c \
		biosig_client.c \
		biosig_server.c


OBJECTS       = \
		crc4scp.o \
		biosig.o \
		getlogin_r.o \
		tinyxml.o \
		tinyxmlparser.o \
		tinyxmlerror.o \
		tinystr.o \
		sopen_scp_read.o \
		sopen_alpha_read.o \
		sopen_scp_write.o \
		sopen_hl7aecg.o \
		biosig-network.o \
		sandbox.o \


MinGWOBJECTS  = \
		win32/crc4scp.obj \
		win32/biosig.obj \
		win32/getlogin_r.obj \
		win32/tinyxml.obj \
		win32/tinyxmlparser.obj \
		win32/tinyxmlerror.obj \
		win32/tinystr.obj \
		win32/sopen_scp_read.obj \
		win32/sopen_alpha_read.obj \
		win32/sopen_scp_write.obj \
		win32/sopen_hl7aecg.obj \
		win32/biosig-network.obj \
		win32/sandbox.obj \

ifneq (,$(findstring WITH_FAMOS, $(DEFINES)))
  OBJECTS      += sopen_famos_read.o
endif
ifneq (,$(findstring WITH_FAMOS, $(MinGWDEF)))
  MinGWOBJECTS += win32/sopen_famos_read.obj
endif
ifneq (,$(findstring WITH_FEF, $(DEFINES)))
  OBJECTS      += sopen_fef_read.o
endif
ifneq (,$(findstring WITH_FEF, $(MinGWDEF)))
  MinGWOBJECTS += win32/sopen_fef_read.obj
endif
ifeq (,$(findstring WITHOUT_SCP_DECODE, $(DEFINES)))
  OBJECTS      += scp-decode.o
endif
ifeq (,$(findstring WITHOUT_SCP_DECODE, $(MinGWDEF)))
  MinGWOBJECTS += win32/scp-decode.obj
endif

TARGET        = save2gdf save2aecg save2scp libbiosig.a mex4o libbiosig.so

first: $(TARGET)
all:   $(TARGET) mex4o biosig4python win32 biosig_client biosig_server mma java tcl perl php ruby #sigviewer 
lib:	libbiosig.a libbiosig.so win32/libbiosig.dll libbiosig.lib

#############################################################
#	Compilation: Implicit, default rules
#############################################################

.SUFFIXES: .o .c .cpp .cc .cxx .C

.cpp.o:
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
.cc.o:
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
.cxx.o:
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
.C.o:
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
.c.o:
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"

%.o: %.c biosig.h biosig-dev.h
	$(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
%.o: t210/%.c biosig.h biosig-dev.h
	$(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
%.o: t220/%.c biosig.h biosig-dev.h
	$(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
%.o: t230/%.c biosig.h biosig-dev.h
	$(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
%.o: t240/%.c biosig.h biosig-dev.h
	$(CC) -c $(CFLAGS) -I t240 $(INCPATH) -o "$@" "$<"
%.o: test0/%.c biosig.h biosig-dev.h
	$(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
%.o: XMLParser/%.cpp
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"

win32/%.obj: %.c  biosig-dev.h biosig.h 
	$(MinGWCC) -c $(MinGWCFLAGS) $(INCPATH) -o "$@" "$<"
win32/%.obj: t210/%.c  biosig-dev.h biosig.h 
	$(MinGWCC) -c $(MinGWCFLAGS) $(INCPATH) -o "$@" "$<"
win32/%.obj: t220/%.c  biosig-dev.h biosig.h 
	$(MinGWCC) -c $(MinGWCFLAGS) $(INCPATH) -o "$@" "$<"
win32/%.obj: t230/%.c  biosig-dev.h biosig.h 
	$(MinGWCC) -c $(MinGWCFLAGS) $(INCPATH) -o "$@" "$<"
win32/%.obj: t240/%.c  biosig-dev.h biosig.h 
	$(MinGWCC) -c $(MinGWCFLAGS) -I t240 $(INCPATH) -o "$@" "$<"
win32/%.obj: XMLParser/%.cpp 
	$(MinGWCXX) -c $(MinGWCFLAGS) $(INCPATH) -o "$@" "$<"


#############################################################
#	event table: conversion from ascii to C code
#############################################################

biosig.c: eventcodes.i

eventcodes.i : ../biosig/doc/eventcodes.txt
	cat ../biosig/doc/eventcodes.txt | awk "-F\t" '/^[^#]/ {print "\t"$$1", \""$$2,"\","}' > eventcodes.i


#############################################################
#	Compilation: exceptions, explicit rules
#############################################################

sandbox.o: test0/sandbox.c biosig.h
	$(CXX) -c $(CFLAGS) $(INCPATH) -o sandbox.o test0/sandbox.c

sopen_fef_read.o: t240/sopen_fef_read.c biosig-dev.h biosig.h
#	cd t240
#	#asn1c -fcompound-names -pdu=SessionArchiveSection -S /home/schloegl/cvs/asn1c/skeletons fef.asn1
#	asn1c -fcompound-names -pdu=SessionArchiveSection fef.asn1
#	#asn1c -fcompound-names iso11073-10471.asn1
#	#asn1c -fcompound-names iso11073-20601.asn1
#	cd ..
#	$(MAKE) -C t240 -f Makefile.am.sample
	$(CC) -c $(CFLAGS) -I t240 $(INCPATH) -o "$@" "$<"

sopen_hl7aecg.o: t230/sopen_hl7aecg.c biosig-dev.h biosig.h XMLParser/tinyxml.h XMLParser/tinystr.h
	$(CXX) -c $(CFLAGS) $(INCPATH) -o  "$@" "$<"

sopen_scp_read.o: t210/sopen_scp_read.c biosig-dev.h biosig.h biosig.h t210/structures.h
	$(CXX) -c $(CFLAGS) $(INCPATH) -o  "$@" "$<"

scp-decode.o: t210/scp-decode.cpp biosig-dev.h biosig.h t210/structures.h t210/codes.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o  "$@" "$<"

getlogin_r.o: win32/getlogin_r.c
	$(CC) -c $(CFLAGS) $(INCPATH) -o  "$@" "$<"

#strtod.o: gnulib/strtod.c
#	$(CC) -c $(CFLAGS) $(INCPATH) -o strtod.o gnulib/strtod.c

win32/sandbox.obj: test0/sandbox.c biosig.h 
	$(MinGWCXX) -c $(MinGWCFLAGS) $(INCPATH) -o  "$@" "$<"

win32/sopen_scp_read.obj: t210/sopen_scp_read.c biosig-dev.h biosig.h t210/structures.h
	$(MinGWCXX) -c $(MinGWCFLAGS) $(INCPATH) -o  "$@" "$<"

win32/sopen_alpha_read.obj: t210/sopen_alpha_read.c biosig-dev.h
	$(MinGWCC) -c $(MinGWCFLAGS) $(INCPATH) -o  "$@" "$<"

win32/scp-decode.obj: t210/scp-decode.cpp biosig-dev.h biosig.h t210/structures.h t210/codes.h
	$(MinGWCXX) -c $(MinGWCFLAGS) $(INCPATH) -o  "$@" "$<"

#win32/sopen_fef_read.obj: t240/sopen_fef_read.c biosig-dev.h biosig.h
#	$(MinGWCC) -c $(MinGWCFLAGS) -I t240 $(INCPATH) -o win32/sopen_fef_read.obj t240/sopen_fef_read.c

win32/sopen_hl7aecg.obj: t230/sopen_hl7aecg.c biosig-dev.h biosig.h XMLParser/tinyxml.h XMLParser/tinystr.h
	$(MinGWCXX) -c $(MinGWCFLAGS) $(INCPATH) -o  "$@" "$<"

win32/getlogin_r.obj: win32/getlogin_r.c
	$(MinGWCC) -c $(MinGWCFLAGS) $(INCPATH) -o  "$@" "$<"

win32/sigviewer.exe: win32/libbiosig.a win32/libbiosig.dll
	-$(DELETE) $(PathToSigViewerWIN32)/extern/include/*.h
	-$(COPY) biosig.h $(PathToSigViewerWIN32)/extern/include
	-$(DELETE) $(PathToSigViewerWIN32)/extern/lib/lib*
	-$(COPY) win32/libbiosig.a $(PathToSigViewerWIN32)/extern/lib
	-(cd $(PathToSigViewerWIN32)/src; $(CROSS)qmake; make)
	-$(COPY) $(PathToSigViewerWIN32)/bin/sigviewer.exe win32/


#############################################################
#	other language bindings (on Linux)
#############################################################

biosig4python : python/_biosig.so python/biosig.py

python/biosig.py python/swig_wrap.cxx: python/swig.i
	$(SWIG) -c++ -python -I/usr/include -I/usr/share/pyshared/numpy/core/include/numpy -o python/swig_wrap.cxx python/swig.i

python/_biosig.so : python/swig_wrap.cxx  libbiosig.$(LIBEXT)
	$(CXX) -c $(CXXFLAGS) python/swig_wrap.cxx -o python/swig_wrap.o -I/usr/include/python$(PYTHONVER) -I/usr/share/pyshared/numpy/core/include/numpy
	$(CXX) -shared python/swig_wrap.o  $(LFLAGS) $(LIBS) -o python/_biosig.so


java: libbiosig.$(LIBEXT) java/biosig.i
	$(MAKE) -C java
perl: libbiosig.$(LIBEXT) perl/biosig.i
	$(MAKE) -C perl
php: libbiosig.$(LIBEXT) php/biosig.i
	$(MAKE) -C php
python: libbiosig.$(LIBEXT) python/swig.i
	$(MAKE) -C python
ruby: libbiosig.$(LIBEXT) ruby/biosig.i
	$(MAKE) -C ruby
tcl: libbiosig.$(LIBEXT) tcl/biosig.i
	$(MAKE) -C tcl


#############################################################
#	WIN32 - BUILD
#############################################################

win32/libbiosig.lib: win32/libbiosig.a 
	$(COPY) win32/libbiosig.a win32/libbiosig.lib

win32/libbiosig.a: $(MinGWOBJECTS) win32/libcnsfef.a biosig.h biosig-dev.h
	-$(DELETE) win32/libbiosig.a
	$(CROSS)$(AR) win32/libbiosig.a $(MinGWOBJECTS) t240/*.obj

win32/libcnsfef.a:
	make CROSS=$(CROSS) -C t240 ../win32/libcnsfef.a 

win32/libbiosig.dll: $(MinGWOBJECTS) biosig.h biosig-dev.h
	$(MinGWLINK) -shared -fPIC  $(MinGWOBJECTS) $(MinGWLIBS) -o win32/libbiosig.dll -Wl,--output-def,win32/libbiosig.def,--out-implib,win32/libbiosig.dll.a
	-$(COPY) win32/libbiosig.dll $(PathToSigViewerWIN32)/extern/lib/

win32/save2gdf.exe: save2gdf.c win32/libbiosig.a
	$(MinGWLINK) $(MinGWCFLAGS) save2gdf.c $(MinGWLIBS) -o win32/save2gdf.exe

win32/pdp2gdf.exe: pdp2gdf.c win32/libbiosig.a
	$(MinGWLINK) $(MinGWCFLAGS) pdp2gdf.c $(MinGWLIBS) -o win32/pdp2gdf.exe

win32 exe: win32/save2gdf.exe win32/libbiosig.dll mma #win32/sigviewer.exe


#############################################################
#	GNU/Linux - BUILD
#############################################################

t240/libcnsfef.a:
#	$(MAKE) -C t240 regen		#
	$(MAKE) -C t240 libcnsfef.a	# generate t240/*.o files

libbiosig.a: $(OBJECTS) biosig.h biosig-dev.h #t240/libcnsfef.a
	-$(DELETE) libbiosig.a
	$(AR) libbiosig.a $(OBJECTS) #t240/*.o

libbiosig.so: $(OBJECTS) t240/libcnsfef.a biosig.h biosig-dev.h
	$(CXX) -shared -fPIC -Wl,-soname,libbiosig.so.${MAJOR_VERSION} $(LDLIBS) \
		-o libbiosig.so.${MAJOR_VERSION}.${MINOR_VERSION}.${STEPPING} $(OBJECTS) t240/*.o
	ln -sf libbiosig.so.${MAJOR_VERSION}.${MINOR_VERSION}.${STEPPING} libbiosig.so.${MAJOR_VERSION}
	ln -sf libbiosig.so.${MAJOR_VERSION} libbiosig.so

save2gdf: save2gdf.o libbiosig.$(LIBEXT) Makefile
	$(LINK) $(CXXFLAGS) save2gdf.o $(LFLAGS) $(LIBS) -o save2gdf

pdp2gdf: pdp2gdf.o libbiosig.$(LIBEXT)
	$(LINK) $(CXXFLAGS) pdp2gdf.o $(LFLAGS) $(LIBS) -o pdp2gdf

physicalunits: physicalunits.o libbiosig.$(LIBEXT)
	$(LINK) $(CXXFLAGS) physicalunits.o $(LFLAGS) $(LIBS) -o physicalunits

bscs: biosig_client biosig_server sandbox.o biosig.o
biosig_client: biosig_client.c libbiosig.$(LIBEXT) biosig-network.o Makefile
	$(LINK) $(CXXFLAGS) biosig_client.c  biosig-network.o $(LFLAGS) $(LIBS) -o biosig_client

biosig_server: biosig_server.c libbiosig.$(LIBEXT) biosig-network.o Makefile
	$(LINK) $(CXXFLAGS) biosig_server.c  biosig-network.o $(LFLAGS) $(LIBS) -o biosig_server


#############################################################
#	MathLink interface to Mathematica 
#############################################################
mma: libbiosig.a
	$(MAKE) -C mma -f Makefile.win32

mex mex4m mex4o mexw32 oct:
	$(MAKE) -C mex $@

#############################################################
#	MEX-files for Octave and Matlab
#############################################################
mex: 
	$(MAKE) -C mex mex -k

mex mex4m mex4o mexw32 oct:
	$(MAKE) -C mex $@

%.mex %.mex.$(MEX_EXT) %.mexw32:
	$(MAKE) -C mex $@

#############################################################
#	SigViewer
#############################################################

sigviewer: $(PathToSigViewer)/bin/sigviewer
	$(COPY) $(PathToSigViewer)/bin/release/sigviewer ~/bin/sigviewer-$(TODAY)
	mv $(PathToSigViewer)/bin/release/sigviewer $(PathToSigViewer)/bin/sigviewer-$(TODAY)
	ln -sf ~/bin/sigviewer-$(TODAY) ~/bin/sigviewer 
	
$(PathToSigViewer)/bin/sigviewer: libbiosig.$(LIBEXT) biosig.h
	$(COPY) -lf biosig.h $(PathToSigViewer)/extern/include/
	$(COPY) -lf libbiosig.$(LIBEXT) $(PathToSigViewer)/extern/lib/
#	touch $(PathToSigViewer)/tmp/basic_header.o
	(cd $(PathToSigViewer)/src; qmake;make;)

docs: 	docs/save2gdf.txt  docs/mexSLOAD.txt
	asciidoc -d manpage docs/save2gdf.txt
	asciidoc -d manpage docs/mexSLOAD.txt


# for backward compatibility
save2scp: save2gdf
save2aecg: save2gdf


#############################################################
#	INSTALL and DE-INSTALL
#############################################################

clean:
	-$(DELETE) *~
	-$(DELETE) *.a
	-$(DELETE) eventcodes.i
	-$(DELETE) *.o
	-$(DELETE) *.so
	-$(DELETE) *.so.*
	-$(DELETE) *.mex*
	-$(DELETE) *.oct
	-$(DELETE) python/biosig.py* _biosig.so
	-$(DELETE) python/swig_wrap.*
	-$(DELETE) win32/*.a
	-$(DELETE) win32/*.lib
	-$(DELETE) win32/*.o
	-$(DELETE) win32/*.obj
	-$(DELETE) win32/*.exe
	-$(DELETE) t240/*.o
	-$(DELETE) t240/libcnsfef.a
	-$(DELETE) t240/libbiosig.*
	-$(DELETE) t240/*.obj
	-$(DELETE) pdp2gdf
	-$(MAKE) -C java clean
	-$(MAKE) -C matlab clean
	-$(MAKE) -C mma clean
	-$(MAKE) -C php clean
	-$(MAKE) -C perl clean
	-$(MAKE) -C ruby clean
	-$(MAKE) -C tcl clean

install_sigviewer: sigviewer
	install $(PathToSigViewer)/bin/sigviewer $(BIN)
	install ../biosig/doc/eventcodes.txt $(BIN)

install_octave: mexSLOAD.mex
	mkdir -p  		$(DESTDIR)/usr/local/share/octave/site-m/
	install mex/mexSLOAD.mex 	$(DESTDIR)/usr/local/share/octave/site-m/
	install mex/mexSOPEN.mex 	$(DESTDIR)/usr/local/share/octave/site-m/

install: save2gdf libbiosig.a libbiosig.so doc/save2gdf.1
	install -d 		$(BIN)
	install save2gdf 	$(BIN)
	install save2aecg 	$(BIN)
	install save2scp  	$(BIN)
	#install rec2bin  	$(BIN)
	#install bin2rec  	$(BIN)
	install -d		$(LIB) $(DESTDIR)/usr/include
	install biosig.h    	$(DESTDIR)/usr/include
	install libbiosig.so.${MAJOR_VERSION}.${MINOR_VERSION}.${STEPPING} $(LIB)
	ln -sf libbiosig.so.${MAJOR_VERSION}.${MINOR_VERSION}.${STEPPING} $(LIB)/libbiosig.so.${MAJOR_VERSION}
	ln -sf libbiosig.so.${MAJOR_VERSION} $(LIB)/libbiosig.so
	install libbiosig.a	$(LIB)
	mkdir -p  		$(DESTDIR)/usr/share/man/man1
	install doc/*.1  	$(DESTDIR)/usr/share/man/man1
	#install libbiosig.man $(DESTDIR)/usr/share/
	#make install_sigviewer
	#make install_octave

remove:
	rm $(BIN)/save2gdf
	rm $(BIN)/save2scp
	rm $(BIN)/save2aecg
	#rm $(BIN)/rec2bin
	#rm $(BIN)/bin2rec
	rm $(BIN)/sigviewer
	rm $(BIN)/eventcodes.txt
	rm $(DESTDIR)/usr/include/biosig.h
	rm $(LIB)/libbiosig.*
	rm $(DESTDIR)/usr/share/man/man1/save2gdf.1
	rm $(DESTDIR)/usr/share/man/man1/mexSLOAD.1
	rm $(DESTDIR)/usr/share/man/man1/sigviewer.1
	#rm $(DESTDIR)/usr/share/man/man1/rec2bin.1
	#rm $(DESTDIR)/usr/share/man/man1/bin2rec.1


#############################################################
#	Testing
#############################################################
#	./save2gdf -V8 ~/data/test/tms32/small_test.float32.log
	./save2gdf -f=TMSi t0.scp t2.log
	cat t2.log

$(TEMP_DIR)t1.scp:
	# scp example data sets
	wget  -q -P$(TEMP_DIR) http://www.openecg.net/ECGsamples.zip
	wget  -q -P$(TEMP_DIR) http://www.openecg.net/ECGsamplesc.zip
	unzip -u $(TEMP_DIR)ECGsamples.zip "scp*.zip" -d $(TEMP_DIR)
	unzip -u $(TEMP_DIR)ECGsamplesc.zip "scp*.zip" -d $(TEMP_DIR)
	mkdir -p $(TEMP_DIR)scp/high
	mkdir -p $(TEMP_DIR)scp/highc
	mkdir -p $(TEMP_DIR)scp/redred
	mkdir -p $(TEMP_DIR)scp/redredc
	unzip -u $(TEMP_DIR)scp_high.zip -d $(TEMP_DIR)scp/high
	unzip -u $(TEMP_DIR)scp_highc.zip -d $(TEMP_DIR)scp/highc
	unzip -u $(TEMP_DIR)scp_redred.zip -d $(TEMP_DIR)scp/redred
	unzip -u $(TEMP_DIR)scp_redredc.zip -d $(TEMP_DIR)scp/redredc
	rm -rf $(TEMP_DIR)ECGsamples*.zip
	rm -rf $(TEMP_DIR)scp*.zip
	$(COPY) $(TEMP_DIR)scp/redred/PFE103.scp $(TEMP_DIR)t1.scp
	touch $(TEMP_DIR)t1.scp

$(TEMP_DIR)t1.hl7:
	# HL7aECG example data set
	wget -q -P$(TEMP_DIR) http://hl7.org/library/committees/rcrim/annecg/aECG%20Release%201%20Schema%20and%20Example%2Ezip
	unzip -u "$(TEMP_DIR)aECG Release 1 Schema and Example.zip"  -d $(TEMP_DIR)
	$(COPY) "$(TEMP_DIR)2003-12 Schema/example/Example aECG.xml" $(TEMP_DIR)t1.hl7
	rm -rf "$(TEMP_DIR)aECG Release 1 Schema and Example.zip"
	rm -rf "$(TEMP_DIR)2003-12 Schema"
	touch $(TEMP_DIR)t1.hl7

$(TEMP_DIR)t1.edf:
	# EDF+ example data set
	wget -q -P$(TEMP_DIR) http://www.edfplus.info/downloads/files/osas.zip
	unzip -u "$(TEMP_DIR)osas.zip"  -d $(TEMP_DIR)
	cp "$(TEMP_DIR)Osas2002plusQRS.edf" $(TEMP_DIR)t1.edf
	touch $(TEMP_DIR)t1.edf

asc: save2gdf
	./save2gdf -f=ASCII t0.xxx t1.asc

bin: save2gdf
	./save2gdf -f=BIN t0.xxx t1.bin

testbin: save2gdf $(TEMP_DIR)t1.edf
	./save2gdf -f=BIN $(TEMP_DIR)t1.edf $(TEMP_DIR)t1.hdr
	./save2gdf -f=BIN $(TEMP_DIR)t1.hdr $(TEMP_DIR)t2.hdr
	./save2gdf -f=GDF $(TEMP_DIR)t2.hdr $(TEMP_DIR)t2.gdf

testscp: save2gdf $(TEMP_DIR)t1.scp
	# test converting SCP data
	./save2gdf -f=HL7 $(TEMP_DIR)/t1.scp $(TEMP_DIR)/t1.scp.hl7
	./save2gdf -f=GDF $(TEMP_DIR)/t1.scp.hl7 $(TEMP_DIR)/t1.scp.hl7.gdf
	./save2gdf -f=SCP $(TEMP_DIR)/t1.scp.hl7.gdf $(TEMP_DIR)/t1.scp.hl7.gdf.scp
	./save2gdf -f=GDF $(TEMP_DIR)/t1.scp.hl7.gdf.scp $(TEMP_DIR)t1.scp.hl7.gdf.scp.gdf
	./save2gdf -f=HL7 $(TEMP_DIR)t1.scp.hl7.gdf.scp.gdf $(TEMP_DIR)t1.scp.hl7.gdf.scp.gdf.hl7
	./save2gdf -f=SCP $(TEMP_DIR)t1.scp.hl7.gdf.scp.gdf.hl7 $(TEMP_DIR)t1.scp.hl7.gdf.scp.gdf.hl7.scp
	./save2gdf -f=GDF $(TEMP_DIR)t1.scp $(TEMP_DIR)t1.scp.gdf
	./save2gdf -f=HL7 $(TEMP_DIR)t1.scp.gdf $(TEMP_DIR)t1.scp.gdf.hl7
	./save2gdf -f=SCP $(TEMP_DIR)t1.scp.gdf.hl7 $(TEMP_DIR)t1.scp.gdf.hl7.scp
	./save2gdf -f=HL7 $(TEMP_DIR)t1.scp.gdf.hl7.scp $(TEMP_DIR)t1.scp.gdf.hl7.scp.hl7
	./save2gdf -f=GDF $(TEMP_DIR)t1.scp.gdf.hl7.scp.hl7 $(TEMP_DIR)t1.scp.gdf.hl7.scp.hl7.gdf
	./save2gdf -f=SCP $(TEMP_DIR)t1.scp.gdf.hl7.scp.hl7.gdf $(TEMP_DIR)t1.scp.gdf.hl7.scp.hl7.gdf.scp

testhl7: save2gdf $(TEMP_DIR)t1.hl7
	# test converting HL7aECG data
	./save2gdf -f=GDF $(TEMP_DIR)t1.hl7 $(TEMP_DIR)t1.hl7.gdf
	./save2gdf -f=SCP $(TEMP_DIR)t1.hl7.gdf $(TEMP_DIR)t1.hl7.gdf.scp
	./save2gdf -f=HL7 $(TEMP_DIR)t1.hl7.gdf.scp $(TEMP_DIR)t1.hl7.gdf.scp.hl7
	./save2gdf -f=SCP $(TEMP_DIR)t1.hl7.gdf.scp.hl7 $(TEMP_DIR)t1.hl7.gdf.scp.hl7.scp
	./save2gdf -f=GDF $(TEMP_DIR)t1.hl7.gdf.scp.hl7.scp $(TEMP_DIR)t1.hl7.gdf.scp.hl7.scp.gdf
	./save2gdf -f=HL7 $(TEMP_DIR)t1.hl7.gdf.scp.hl7.scp.gdf $(TEMP_DIR)t1.hl7.gdf.scp.hl7.scp.gdf.hl7
	./save2gdf -f=SCP $(TEMP_DIR)t1.hl7 $(TEMP_DIR)t1.hl7.scp
	./save2gdf -f=GDF $(TEMP_DIR)t1.hl7.scp $(TEMP_DIR)t1.hl7.scp.gdf
	./save2gdf -f=HL7 $(TEMP_DIR)t1.hl7.scp.gdf $(TEMP_DIR)t1.hl7.scp.gdf.hl7
	./save2gdf -f=GDF $(TEMP_DIR)t1.hl7.scp.gdf.hl7 $(TEMP_DIR)t1.hl7.scp.gdf.hl7.gdf
	./save2gdf -f=SCP $(TEMP_DIR)t1.hl7.scp.gdf.hl7.gdf $(TEMP_DIR)t1.hl7.scp.gdf.hl7.gdf.scp
	./save2gdf -f=HL7 $(TEMP_DIR)t1.hl7.scp.gdf.hl7.gdf.scp $(TEMP_DIR)t1.hl7.scp.gdf.hl7.gdf.scp.hl7

test: $(TEMP_DIR)t1.scp save2scp save2aecg save2gdf
	# biosig4python
	# includes test for on-the-fly compression and decompression
	./save2gdf  -z  $(TEMP_DIR)t1.scp        $(TEMP_DIR)t1.scp.gdf
	./save2scp  -z 	$(TEMP_DIR)t1.scp        $(TEMP_DIR)t1.scp.scp
	./save2aecg -z 	$(TEMP_DIR)t1.scp        $(TEMP_DIR)t1.scp.hl7
	./save2gdf 	$(TEMP_DIR)t1.scp.gdf.gz $(TEMP_DIR)t1.scp.gdf.gdf
	./save2gdf 	$(TEMP_DIR)t1.scp.scp.gz $(TEMP_DIR)t1.scp.scp.gdf
	./save2gdf 	$(TEMP_DIR)t1.scp.hl7.gz $(TEMP_DIR)t1.scp.hl7.gdf
	./save2scp 	$(TEMP_DIR)t1.scp.gdf.gz $(TEMP_DIR)t1.scp.gdf.scp
	./save2scp 	$(TEMP_DIR)t1.scp.scp.gz $(TEMP_DIR)t1.scp.scp.scp
	./save2scp 	$(TEMP_DIR)t1.scp.hl7.gz $(TEMP_DIR)t1.scp.hl7.scp
	./save2aecg 	$(TEMP_DIR)t1.scp.gdf.gz $(TEMP_DIR)t1.scp.gdf.hl7
	./save2aecg	$(TEMP_DIR)t1.scp.scp.gz $(TEMP_DIR)t1.scp.scp.hl7
	./save2aecg	$(TEMP_DIR)t1.scp.hl7.gz $(TEMP_DIR)t1.scp.hl7.hl7
	# python test0/test.py

zip: $(TEMP_DIR)t1.scp save2gdf
	# test for on-the-fly compression and decompression
	# on-the-fly compression of output file
	./save2gdf -z -f=GDF $(TEMP_DIR)t1.scp t1.gdf
	./save2gdf -z -f=GDF1 $(TEMP_DIR)t1.scp t1.gd1
	./save2gdf -z -f=EDF $(TEMP_DIR)t1.scp t1.edf
	./save2gdf -z -f=BDF $(TEMP_DIR)t1.scp t1.bdf
	./save2gdf -z -f=SCP $(TEMP_DIR)t1.scp t1.scp
	./save2gdf -z -f=CFWB $(TEMP_DIR)t1.scp t1.cfw
	./save2gdf -z -f=MFER $(TEMP_DIR)t1.scp t1.mwf
	./save2gdf -z -f=HL7 $(TEMP_DIR)t1.scp t1.hl7

	gzip -c $(TEMP_DIR)t1.scp >$(TEMP_DIR)t1.scp.gz
	# on-the-fly decompression of input file
	./save2gdf -f=GDF $(TEMP_DIR)t1.scp.gz t1.gdf
	./save2gdf -f=EDF $(TEMP_DIR)t1.scp.gz t1.edf
	./save2gdf -f=BDF $(TEMP_DIR)t1.scp.gz t1.bdf
	./save2gdf -f=SCP $(TEMP_DIR)t1.scp.gz t1.scp
	./save2gdf -f=HL7 $(TEMP_DIR)t1.scp.gz t1.hl7
	./save2gdf -f=MFER $(TEMP_DIR)t1.scp.gz t1.mwf
	./save2gdf -f=CFWB $(TEMP_DIR)t1.scp.gz t1.cfw

test6: $(TEMP_DIR)t1.scp save2gdf
	$(COPY) $(TEMP_DIR)t1.scp t0.xxx
	#test7: $(TEMP_DIR)t1.edf save2gdf
	#$(COPY) $(TEMP_DIR)t1.edf t0.xxx
	./save2gdf -z -f=GDF1 t0.xxx t1.gd1
	./save2gdf -z -f=GDF t0.xxx t1.gdf
	./save2gdf -z -f=EDF t0.xxx t1.edf
	./save2gdf -z -f=BDF t0.xxx t1.bdf
	./save2gdf -z -f=SCP t0.xxx t1.scp
	./save2gdf    -f=HL7 t0.xxx t1.hl7   # -z not supported for HL7
	gzip t1.hl7
	./save2gdf -z -f=CFWB t0.xxx t1.cfw
	./save2gdf -z -f=MFER t0.xxx t1.mwf
	./save2gdf -z -f=BVA t0.xxx t1.bva
	./save2gdf -f=GDF1 t1.gd1.gz t2.gd1.gd1
	./save2gdf -f=GDF t1.gd1.gz t2.gd1.gdf
	./save2gdf -f=EDF t1.gd1.gz t2.gd1.edf
	./save2gdf -f=BDF t1.gd1.gz t2.gd1.bdf
	./save2gdf -f=SCP t1.gd1.gz t2.gd1.scp
	./save2gdf -f=HL7 t1.gd1.gz t2.gd1.hl7
	./save2gdf -f=CFWB t1.gd1.gz t2.gd1.cfw
	./save2gdf -f=GDF1 t1.gdf.gz t2.gdf.gd1
	./save2gdf -f=GDF t1.gdf.gz t2.gdf.gdf
	./save2gdf -f=EDF t1.gdf.gz t2.gdf.edf
	./save2gdf -f=BDF t1.gdf.gz t2.gdf.bdf
	./save2gdf -f=SCP t1.gdf.gz t2.gdf.scp
	./save2gdf -f=HL7 t1.gdf.gz t2.gdf.hl7
	./save2gdf -f=CFWB t1.gdf.gz t2.gdf.cfw
	./save2gdf -f=GDF1 t1.edf.gz t2.edf.gd1
	./save2gdf -f=GDF t1.edf.gz t2.edf.gdf
	./save2gdf -f=EDF t1.edf.gz t2.edf.edf
	./save2gdf -f=BDF t1.edf.gz t2.edf.bdf
	./save2gdf -f=SCP t1.edf.gz t2.edf.scp
	./save2gdf -f=HL7 t1.edf.gz t2.edf.hl7
	./save2gdf -f=CFWB t1.edf.gz t2.edf.cfw
	./save2gdf -f=GDF1 t1.bdf.gz t2.bdf.gd1
	./save2gdf -f=GDF t1.bdf.gz t2.bdf.gdf
	./save2gdf -f=EDF t1.bdf.gz t2.bdf.edf
	./save2gdf -f=BDF t1.bdf.gz t2.bdf.bdf
	./save2gdf -f=SCP t1.bdf.gz t2.bdf.scp
	./save2gdf -f=HL7 t1.bdf.gz t2.bdf.hl7
	./save2gdf -f=CFWB t1.bdf.gz t2.bdf.cfw
	./save2gdf -f=GDF1 t1.scp.gz t2.scp.gd1
	./save2gdf -f=GDF t1.scp.gz t2.scp.gdf
	./save2gdf -f=EDF t1.scp.gz t2.scp.edf
	./save2gdf -f=BDF t1.scp.gz t2.scp.bdf
#	./save2gdf -f=SCP t1.scp.gz t2.scp.scp
	./save2gdf -f=HL7 t1.scp.gz t2.scp.hl7
	./save2gdf -f=CFWB t1.scp.gz t2.scp.cfw
	./save2gdf -f=GDF1 t1.hl7.gz t2.hl7.gd1
	./save2gdf -f=GDF t1.hl7.gz t2.hl7.gdf
	./save2gdf -f=EDF t1.hl7.gz t2.hl7.edf
	./save2gdf -f=BDF t1.hl7.gz t2.hl7.bdf
	./save2gdf -f=SCP t1.hl7.gz t2.hl7.scp
	./save2gdf -f=HL7 t1.hl7.gz t2.hl7.hl7
	./save2gdf -f=CFWB t1.hl7.gz t2.hl7.cfw
	./save2gdf -f=GDF1 t1.cfw.gz t2.cfw.gd1
	./save2gdf -f=GDF t1.cfw.gz t2.cfw.gdf
	./save2gdf -f=EDF t1.cfw.gz t2.cfw.edf
	./save2gdf -f=BDF t1.cfw.gz t2.cfw.bdf
	./save2gdf -f=SCP t1.cfw.gz t2.cfw.scp
	./save2gdf -f=HL7 t1.cfw.gz t2.cfw.hl7
	./save2gdf -f=GDF1 t1.mwf.gz t2.mwf.gd1
	./save2gdf -f=GDF t1.mwf.gz t2.mwf.gdf
	./save2gdf -f=EDF t1.mwf.gz t2.mwf.edf
	./save2gdf -f=BDF t1.mwf.gz t2.mwf.bdf
	./save2gdf -f=SCP t1.mwf.gz t2.mwf.scp
	./save2gdf -f=HL7 t1.mwf.gz t2.mwf.hl7

testpybdf : $(TEMP_DIR)BDFtestfiles.zip
	unzip -u $(TEMP_DIR)BDFtestfiles.zip -d $(TEMP_DIR) && \
	python python/demo.py $(TEMP_DIR)*-256.bdf
	python python/example.py $(TEMP_DIR)*-256.bdf 256 && \
	python python/example.py $(TEMP_DIR)*-2048.bdf 2048

$(TEMP_DIR)BDFtestfiles.zip :
	wget -P$(TEMP_DIR) http://www.biosemi.com/download/BDFtestfiles.zip