1####### Main Makefile for building the various biosig tools ####################
2###
3###  Copyright (C) 2010-2020 Alois Schloegl <alois.schloegl@gmail.com>
4###  This file is part of the "BioSig for C/C++" repository
5###  (biosig4c++) at http://biosig.sf.net/
6###
7################################################################################
8
9exec_prefix ?= $(prefix)
10
11first :: lib tools
12
13java: lib
14	$(MAKE) -C biosig4c++/java
15
16lib:
17	$(MAKE) -C biosig4c++ lib
18
19tools: lib
20	$(MAKE) -C biosig4c++ tools
21
22mma mathematica: lib
23	$(MAKE) -C biosig4c++/mma
24
25mex4m matlab: lib
26	$(MAKE) -C biosig4c++/mex mex4m
27
28R: lib
29	$(MAKE) -C biosig4c++/R
30
31install ::
32	$(MAKE) -C biosig4c++ install
33	install -d $(DESTDIR)/usr/local/share/biosig/matlab
34	cp -r biosig4matlab/* $(DESTDIR)/usr/local/share/biosig/matlab/
35	-rm -rf $(DESTDIR)/usr/local/share/biosig/matlab/maybe-missing
36
37uninstall ::
38	$(MAKE) -C biosig4c++ uninstall
39	-rm -rf $(DESTDIR)/usr/local/share/biosig
40
41clean ::
42	$(MAKE) -C biosig4c++/mma clean
43	$(MAKE) -C biosig4c++ clean
44	-rm mexbiosig*.src.tar.gz
45	-rm biosig4octave*.src.tar.gz
46
47distclean : clean
48        # also configure.ac for list of files
49	-rm config.log
50	-rm config.status
51	rm Makefile biosig4c++/Makefile biosig4c++/*/Makefile \
52		biosig4c++/python/setup.py \
53		biosig4c++/R/DESCRIPTION
54
55ifneq (:,/usr/bin/java)
56ifneq (:,/usr/bin/javac)
57first :: lib
58	-$(MAKE) -C biosig4c++/java
59endif
60clean ::
61	-$(MAKE) -C biosig4c++/java clean
62test ::
63	-$(MAKE) -C biosig4c++/java test
64endif
65
66ifneq (:,:)
67first :: lib
68	$(MAKE) -C biosig4c++/mma
69install ::
70	-$(MAKE) -C biosig4c++/mma install
71uninstall ::
72	-$(MAKE) -C biosig4c++/mma uninstall
73endif
74
75ifneq (:,:)
76MATLAB_MEX := $(shell dirname :)/mex
77first ::
78	$(MAKE) -C biosig4c++/mex mex4m
79install ::
80	$(MAKE) -C biosig4c++/mex install
81uninstall ::
82	$(MAKE) -C biosig4c++/mex uninstall
83endif
84
85# source package mexbiosig and biosig4octave
86first :: biosig4octave
87mexbiosig ::
88	$(MAKE) -C biosig4c++ mexbiosig
89	ln -sf biosig4c++/mex/mexbiosig-2.3.3.src.tar.gz
90biosig4octave ::
91	$(MAKE) -C biosig4c++ biosig4octave
92	ln -sf biosig4c++/mex/biosig4octave-2.3.3.src.tar.gz
93
94ifneq (:,/usr/bin/octave)
95ifneq (:,/usr/bin/mkoctfile)
96BIOSIG_MEX_DIR = $(DESTDIR)$(shell octave-config -p LOCALOCTFILEDIR)/biosig
97BIOSIG_DIR     = $(DESTDIR)$(shell octave-config -p LOCALFCNFILEDIR)/biosig
98first ::
99	MKOCTFILE="/usr/bin/mkoctfile" $(MAKE) -C biosig4c++/mex mex4o
100install ::
101	# mexbiosig
102	#-/usr/bin/octave --no-gui --eval "pkg install -global biosig4c++/mex/mexbiosig-2.3.3.src.tar.gz"
103	# *.mex
104	install -d $(BIOSIG_MEX_DIR)
105	install biosig4c++/mex/*.mex $(BIOSIG_MEX_DIR)
106	# biosig for octave and matlab
107	install -d $(BIOSIG_DIR)
108	cp -r biosig4matlab/*  $(BIOSIG_DIR)
109	-rm -rf $(BIOSIG_DIR)/maybe-missing
110
111uninstall ::
112	# mexbiosig
113	#-/usr/bin/octave --no-gui --eval "pkg uninstall -global mexbiosig"
114	# *.mex
115	-rm -rf $(BIOSIG_MEX_DIR)
116	# biosig for octave and matlab
117	-rm -rf $(BIOSIG_DIR)
118endif
119endif
120
121ifneq (:,:)
122first ::
123	-$(MAKE) -C biosig4c++/php
124install ::
125	-$(MAKE) -C biosig4c++/php install
126clean ::
127	-$(MAKE) -C biosig4c++/php clean
128endif
129
130ifneq (:,/usr/bin/python3)
131first :: python
132python ::
133	-PYTHON=/usr/bin/python3 $(MAKE) -C biosig4c++/python sdist
134	-$(foreach py, $(shell pyversions -i),  PYTHON=$(py) $(MAKE) -C biosig4c++/python build; )
135	-$(foreach py, $(shell py3versions -i), PYTHON=$(py) $(MAKE) -C biosig4c++/python build; )
136install ::
137	-PYTHON=/usr/bin/python3 $(MAKE) -C biosig4c++/python install
138	-$(foreach py, $(shell pyversions -i),  PYTHON=$(py) $(MAKE) -C biosig4c++/python install; )
139	-$(foreach py, $(shell py3versions -i), PYTHON=$(py) $(MAKE) -C biosig4c++/python install; )
140uninstall ::
141	-/usr/bin/python3 -m pip uninstall -y Biosig
142	-$(foreach py, $(shell pyversions -i),  $(py) -m pip uninstall -y Biosig;)
143	-$(foreach py, $(shell py3versions -i), $(py) -m pip uninstall -y Biosig;)
144clean ::
145	$(MAKE) -C biosig4c++/python clean
146endif
147
148ifneq (:,/usr/bin/R)
149first ::
150	-$(MAKE) -C biosig4c++/R build
151install ::
152	-$(MAKE) -C biosig4c++/R install
153clean ::
154	-$(MAKE) -C biosig4c++/R clean
155endif
156
157all: first #win32 win64 #sigviewer #win32/sigviewer.exe win64/sigviewer.exe #biosig_client biosig_server mma java tcl perl php ruby #sigviewer
158
159#---- automatic remaking ---------------------------------------------------#
160#   https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Automatic-Remaking.html#Automatic-Remaking
161#---------------------------------------------------------------------------#
162$(srcdir)/configure: configure.ac aclocal.m4
163	autoconf
164
165# autoheader might not change config.h.in, so touch a stamp file.
166$(srcdir)/config.h.in: stamp-h.in
167$(srcdir)/stamp-h.in: configure.ac aclocal.m4
168	autoheader
169	echo timestamp > '$(srcdir)/stamp-h.in'
170
171config.h: stamp-h
172stamp-h: config.h.in config.status
173	./config.status
174
175Makefile: Makefile.in config.status
176	./config.status
177
178config.status: configure
179	./config.status --recheck
180
181