aboutsummaryrefslogtreecommitdiff
path: root/externals/Makefile
blob: 7b763dccaf33d90caf7305769c839c06719fd3bd (plain)
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
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
#==============================================================================#
#
# Centralized build system for "externals".  
#
# see README for instructions  <hans@at.or.at>
#
#==============================================================================#

# TODO: maybe this should be moved to the root like all the others

CWD := $(shell pwd)

# these are setup to be overridden by the packages/Makefile
cvs_root_dir = $(CWD)/..
DESTDIR = $(CWD)/build/
BUILDLAYOUT_DIR = $(cvs_root_dir)/packages

# default target
default: all

.SUFFIXES: .$(EXTENSION)


include $(BUILDLAYOUT_DIR)/Makefile.buildlayout


# these are sent to all of the various Makefiles so that they all copy their
# output to the same directory tree
DEST_PATHS = BUILDLAYOUT_DIR=$(BUILDLAYOUT_DIR) \
				cvs_root_dir=$(cvs_root_dir) \
				DESTDIR=$(DESTDIR) \
				prefix=$(prefix)

#==============================================================================#
#
# COMPILE TARGETS
#
#==============================================================================#

OPT_CFLAGS = -O3 -funroll-loops -fomit-frame-pointer

# this variable is to support old "win" directories, rather than "windows"
BUILDSRC_OS_NAME = $(OS_NAME)

CFLAGS = -DPD $(OPT_CFLAGS) -I$(pd_src)/src -Wall -W
LDFLAGS =  
LIBS = -lm

ifeq ($(OS_NAME),darwin)
  CFLAGS += -I/sw/include -DMACOSX -DUNIX -Dunix
  LDFLAGS += -bundle -bundle_loader $(pd_src)/bin/pd -L/sw/lib
  LIBS += -lc
  STRIP = strip -x
else
  ifeq ($(OS_NAME),windows)
    BUILDSRC_OS_NAME = win
	 WINDOWS_HACKS = -D'O_NONBLOCK=1' -D'srand48(n)=srand((n))' \
      -D'drand48()=((double)rand()/RAND_MAX)' -D'bzero(p,n)=memset(p,0,n)'
# These don't seem to be needed:
#	-D'PROT_READ=1' \
#	-D'MAP_PRIVATE=2' \
#	-D'O_NDELAY=O_NONBLOCK'
    CFLAGS += -mms-bitfields -DMSW -DNT $(WINDOWS_HACKS)
    LDFLAGS += -shared
# all of these included libs are part of libc in UNIX platforms.  All except
# libregex are in DLLs, so they get stripped from the external's .dll binary
    LIBS += -L$(pd_src)/bin -lpd \
      -lwsock32 -lpthreadGC2 -lkernel32 -luser32 -lgdi32 -lregex
    STRIP = strip --strip-unneeded -R .note -R .comment
  else
    CFLAGS +=  -DUNIX -Dunix -fPIC
    LDFLAGS += -Wl,-export_dynamic  -shared
    LIBS += -lc
    STRIP = strip --strip-unneeded -R .note -R .comment
  endif
endif

CXXFLAGS = $(CFLAGS)

%.o: %.c
	$(CC) $(CFLAGS) -o "$*.o" -c "$*.c"

%.o: %.cpp
	$(CXX) $(CXXFLAGS) -o "$*.o" -c "$*.cpp"

%.o: %.cc
	$(CXX) $(CXXFLAGS) -o "$*.o" -c "$*.cc"

%.$(EXTENSION): %.o
	$(CC) $(LDFLAGS) -o "$*.$(EXTENSION)" "$*.o"  $(LIBS) \
		`test -f $*.libs && cat $*.libs`	\
		`test -f $(dir $*)../$(BUILDSRC_OS_NAME)/$(notdir $*).libs && \
			cat $(dir $*)../$(BUILDSRC_OS_NAME)/$(notdir $*).libs`
	chmod a-x "$*.$(EXTENSION)"
	$(STRIP) $*.$(EXTENSION)
	rm -f -- $*.o


#------------------------------------------------------------------------------#
# ALL

# if your library isn't included in LIB_TARGETS, it won't be built with
# Pd-extended.  For libraries that build on all platforms, add them directly
# below, otherwise add to the correct platforms below.
LIB_TARGETS = buildsrc creb cxc cyclone ext13 freeverb iemabs iemlib \
iemmatrix loaders markex maxlib mjlib motex oscx pddp pdogg pmpd \
sigpack smlib toxy unauthorized vbap zexy

# this is for libraries that don't compile (yet) on all platforms
ifeq ($(OS_NAME),windows)
  LIB_TARGETS += 
else
  ifeq ($(OS_NAME),darwin)
    LIB_TARGETS += hid pdp 
  else
    # GNU/Linux, BSD, IRIX, etc.
    LIB_TARGETS += hid pdp pidip
  endif
endif


all: pre_all_$(OS_NAME) buildsrc $(LIB_TARGETS)
	@echo " "
	@echo "Compiled external for $(OS_NAME) aka $(UNAME)"

# these targets are for platform-specific needs that run before objects:
pre_all_darwin:

pre_all_linux:

pre_all_windows:

pre_all_unknown:
# this target is for "everything else"


#------------------------------------------------------------------------------#
# INSTALL
install: $(examplesdir) $(helpdir) $(manualsdir) $(objectsdir) \
all unfiltered_install $(patsubst %, %_install,$(LIB_TARGETS))
	@echo " "
	@echo "externals install succeeded!"


#==============================================================================#
#
# OLD EXTERNALS BUILD SYSTEM TARGETS
#
# this is all stuff related to the externals/build/src/*.c links
#
#==============================================================================#


BUILDSRC_OBJECTS := $(wildcard $(externals_src)/build/src/*.c)

buildsrc: $(BUILDSRC_OBJECTS:.c=.$(EXTENSION))


buildsrc_install: $(helpdir) $(objectsdir)
	install -p $(BUILDSRC_OBJECTS:.c=.$(EXTENSION)) $(objectsdir)
# all standard objs' help files
#    it had to be broken up because the list is soo long
	install -p \
			$(externals_src)/aenv~/*.pd \
			$(externals_src)/arraysize/*.pd \
			$(externals_src)/beatpipe/*.pd \
			$(externals_src)/control/*/*.pd \
			$(externals_src)/bbogart/chaos/tools/*.pd \
			$(externals_src)/bbogart/*/*.pd \
			$(externals_src)/creb/doc/*.pd \
				$(helpdir)
	install -p \
			$(externals_src)/creb/doc/examples/*.pd \
			$(externals_src)/dfx/*/*.pd \
			$(externals_src)/ggee/*/*-help.pd \
			$(externals_src)/ggee/*/*.gif \
			$(externals_src)/gem2pdp/*.pd \
			$(externals_src)/ff/*.pd \
			$(externals_src)/hcs/*-help.pd \
				$(helpdir)
	install -p \
			$(externals_src)/hcs/*/doc/*.pd \
			$(externals_src)/hcs/pan/*-help.pd \
			$(externals_src)/iem/comport/*/*-help.pd \
			$(externals_src)/nusmuk/line3/*.pd\
				$(helpdir)
	install -p \
			$(externals_src)/pdogg/*/*.pd \
			$(externals_src)/pdp/doc/objects/*.* \
			$(externals_src)/pidip/doc/*.pd \
			$(externals_src)/plugin~/*.pd \
			$(externals_src)/rhythm_estimator/*.p? \
			$(externals_src)/signal/*/*.pd \
			$(externals_src)/sprinkler/sprinkler-help.pd \
			$(externals_src)/susloop~/*.pd \
			$(externals_src)/svf~/*.pd \
			$(externals_src)/vbap/*.pd \
			$(externals_src)/vst/*.pd \
			$(externals_src)/zhzxh~/*.pd \
				$(helpdir)


buildsrc_clean:
	-rm -f -- $(BUILDSRC_OBJECTS:.c=.$(EXTENSION))
	-rm -f -- $(externals_src)/build/src/*.*~
	-rm -f -- $(externals_src)/build/src/*.c.bak


#==============================================================================#
#
# PROJECT TARGETS
#
#==============================================================================#

# this is the template for creating new entries:

#------------------------------------------------------------------------------#
# TEMPLATE
TEMPLATE_NAME=template
TEMPLATE_OBJECTS := $(wildcard $(externals_src)/template/*.c)
template: $(TEMPLATE_OBJECTS:.c=.$(EXTENSION))

template_install: template
	install -d $(objectsdir)/$(TEMPLATE_NAME)
	$(scripts_src)/generate-libdir-metafile.sh $(objectsdir) $(TEMPLATE_NAME) \
		--author "" \
		--description "" \
		--license "" \
		--version ""
	install -p $(TEMPLATE_OBJECTS:.c=.$(EXTENSION)) $(objectsdir)/$(TEMPLATE_NAME)
	install -d $(helpdir)/$(TEMPLATE_NAME)
	install -p $(externals_src)/template/help/*.pd \
		$(helpdir)/$(TEMPLATE_NAME)
	install -d $(manualsdir)/$(TEMPLATE_NAME)
	install -p $(externals_src)/template/README \
		$(manualsdir)/$(TEMPLATE_NAME)/README.txt
	install -d $(examplesdir)/$(TEMPLATE_NAME)
	install -p $(externals_src)/template/examples/*.pd \
		$(examplesdir)/$(TEMPLATE_NAME)

template_clean:
	-rm -f -- $(externals_src)/template/*.$(EXTENSION)
	-rm -f -- $(externals_src)/template/*.o
	-rm -f -- $(externals_src)/template/*.bak
	-rm -f -- $(externals_src)/template/*.*~


#------------------------------------------------------------------------------#
# CREB
CREB_NAME=creb
#CREB_OBJECTS := $(wildcard $(externals_src)/creb/modules/*.c)
#CREB_CXXOBJECTS := $(wildcard $(externals_src)/creb/modules++/*.cc)
#creb: $(CREB_CXXOBJECTS:.cc=.$(EXTENSION)) $(CREB_OBJECTS:.c=.$(EXTENSION))
creb:


creb_install: creb
	install -d $(objectsdir)/$(CREB_NAME)
	install -p $(externals_src)/creb/abs/*.pd $(objectsdir)/$(CREB_NAME)
	install -d $(helpdir)/$(CREB_NAME)
	install -p $(externals_src)/creb/doc/examples/*.* \
		$(helpdir)/$(CREB_NAME)
#	install -d $(manualsdir)/$(CREB_NAME)
#	install -d $(examplesdir)/$(CREB_NAME)

creb_clean:
	-rm -f -- $(externals_src)/creb/*.$(EXTENSION)
	-rm -f -- $(externals_src)/creb/*.o
	-rm -f -- $(externals_src)/creb/*.bak
	-rm -f -- $(externals_src)/creb/*.*~


#------------------------------------------------------------------------------#
# CXC
CXC_NAME=cxc
CXC_OBJECTS := $(wildcard $(externals_src)/cxc/???*.c)
cxc: $(CXC_OBJECTS:.c=.$(EXTENSION))

cxc_install: cxc
	install -d $(objectsdir)/$(CXC_NAME)
	$(scripts_src)/generate-libdir-metafile.sh $(objectsdir) $(CXC_NAME) \
		--author "jdl@xdv.org" \
		--description "" \
		--license "" \
		--version ""
	install -p $(CXC_OBJECTS:.c=.$(EXTENSION)) $(objectsdir)/$(CXC_NAME)
	install -d $(helpdir)/$(CXC_NAME)
	install -p $(wildcard $(externals_src)/cxc/reference/*.pd) \
		$(helpdir)/$(CXC_NAME)
	install -d $(manualsdir)/$(CXC_NAME)
	install -p $(externals_src)/cxc/README \
		 $(manualsdir)/$(CXC_NAME)/README.txt

cxc_clean:
	-rm -f -- $(CXC_OBJECTS:.c=.$(EXTENSION))
	-rm -f -- $(externals_src)/cxc/*.o
	-rm -f -- $(externals_src)/cxc/*.bak
	-rm -f -- $(externals_src)/cxc/*.*~


#------------------------------------------------------------------------------#
# CYCLONE
CYCLONE_NAME=cyclone
# cyclone is compiled straight into $(OUT_DIR)
CYCLONE_OUT_DIR=$(objectsdir)/$(CYCLONE_NAME)
cyclone: $(bindir)


cyclone_install: cyclone
	install -d $(objectsdir)/$(CYCLONE_NAME)
	$(scripts_src)/generate-libdir-metafile.sh $(objectsdir) $(CYCLONE_NAME) \
		--author "Kzrysztof Czaja" \
		--license "BSD" \
		--description "a library for porting and running Max/MSP patches in Pd"
	cd $(externals_src)/miXed/cyclone && $(MAKE) OUT_DIR=$(CYCLONE_OUT_DIR)
# install "cyclist" command line app with pd
# this doesn't build in the right place yet
#	install -p -m0755 $(CYCLONE_OUT_DIR)/cyclist $(bindir) && \
#		rm $(CYCLONE_OUT_DIR)/cyclist
# rename cyclone lib since it will pre-empt libdir functionality
#	mv $(CYCLONE_OUT_DIR)/cyclone.$(EXTENSION) \
#		$(CYCLONE_OUT_DIR)/cyclonelib.$(EXTENSION)
	install -d $(helpdir)/$(CYCLONE_NAME)
	cd $(externals_src)/miXed/doc/help/cyclone && \
		install -p *.* $(helpdir)/$(CYCLONE_NAME)
#	install -d $(manualsdir)/$(CYCLONE_NAME)
	install -d $(examplesdir)/$(CYCLONE_NAME)
	cd $(externals_src)/miXed/test/cyclone && \
		install -p *.* $(examplesdir)/$(CYCLONE_NAME)


cyclone_clean:
	-make -C $(externals_src)/miXed/cyclone $(DEST_PATHS) clean



#------------------------------------------------------------------------------#
# EXT13
EXT13_NAME=ext13
# openpatch and sfread.c doesn't compile, so exclude them
EXT13_FILES = catch13~.c kalashnikov.c ossmixer.c receive13~.c sfwrite13~.c \
wavinfo.c cdplayer.c mandelbrot.c piperead~.c scramble~.c streamin13~.c \
mandelbrot~.c pipewrite~.c send13.c streamout13~.c filesize.c messages.c \
promiscous~.c send13~.c strippath.c ftos.c receive13.c throw13~.c
EXT13_OBJECTS = $(patsubst %,$(externals_src)/ext13/%,$(EXT13_FILES))
ext13: $(EXT13_OBJECTS:.c=.$(EXTENSION))

ext13_test:
	@echo "objects: $(EXT13_OBJECTS)"


ext13_install: ext13
	install -d $(objectsdir)/$(EXT13_NAME)
	$(scripts_src)/generate-libdir-metafile.sh $(objectsdir) $(EXT13_NAME) \
		--author "d13@klingt.org" \
		--version "0.17"
	install -p $(EXT13_OBJECTS:.c=.$(EXTENSION)) $(objectsdir)/$(EXT13_NAME)
	install -d $(helpdir)/$(EXT13_NAME)
	install -p $(wildcard $(externals_src)/ext13/doc/*.pd) \
		$(helpdir)/$(EXT13_NAME)
	install -d $(manualsdir)/$(EXT13_NAME)
	install -p $(externals_src)/ext13/README \
		$(manualsdir)/$(EXT13_NAME)/README.txt

ext13_clean:
	-rm -f -- $(externals_src)/ext13/*.$(EXTENSION)
	-rm -f -- $(externals_src)/ext13/*.o
	-rm -f -- $(externals_src)/ext13/*.bak
	-rm -f -- $(externals_src)/ext13/*.*~



#------------------------------------------------------------------------------#
# FRANKENSTEIN
FRANKENSTEIN_NAME=frankenstein
# exclude test.c since it is not used
FRANKENSTEIN_OBJECTS := $(wildcard $(externals_src)/frankenstein/*.c)
frankenstein: $(FRANKENSTEIN_OBJECTS:.c=.$(EXTENSION))

frankenstein_install: frankenstein
	install -d $(objectsdir)/$(FRANKENSTEIN_NAME)
	$(scripts_src)/generate-libdir-metafile.sh $(objectsdir) $(FRANKENSTEIN_NAME) \
		--author "" \
		--description "" \
		--license "" \
		--version ""
	install -p $(FRANKENSTEIN_OBJECTS:.c=.$(EXTENSION)) $(objectsdir)/$(FRANKENSTEIN_NAME)
#	install -d $(helpdir)/$(FRANKENSTEIN_NAME)
#	install -p $(externals_src)/frankenstein/help/*.pd \
#		$(helpdir)/$(FRANKENSTEIN_NAME)
	install -d $(manualsdir)/$(FRANKENSTEIN_NAME)
	install -p $(externals_src)/frankenstein/doc/*.* \
		$(manualsdir)/$(FRANKENSTEIN_NAME)
	install -d $(examplesdir)/$(FRANKENSTEIN_NAME)
	install -p $(externals_src)/frankenstein/patches/*.* \
		$(examplesdir)/$(FRANKENSTEIN_NAME)

frankenstein_clean:
	-rm -f -- $(externals_src)/frankenstein/*.$(EXTENSION)
	-rm -f -- $(externals_src)/frankenstein/*.o
	-rm -f -- $(externals_src)/frankenstein/*.bak
	-rm -f -- $(externals_src)/frankenstein/*.*~



#------------------------------------------------------------------------------#
# FREEVERB
FREEVERB_NAME=freeverb
FREEVERB_OBJECTS := $(wildcard $(externals_src)/freeverb~/*.c)
freeverb: $(FREEVERB_OBJECTS:.c=.$(EXTENSION))

freeverb_install: freeverb
	install -d $(objectsdir)
#	$(scripts_src)/generate-libdir-metafile.sh $(objectsdir) $(FREEVERB_NAME) \
#		--author "Olaf Matthes and Jezar Wakefield" \
#		--description "Freeverb is a simple implementation of the standard Schroeder/Moorer reverb model" \
#		--license "GNU GPL" \
#		--version "1.2"
	install -p $(FREEVERB_OBJECTS:.c=.$(EXTENSION)) $(objectsdir)
	install -d $(helpdir)
	install -p $(wildcard $(externals_src)/freeverb~/*-help.pd) $(helpdir)
	install -d $(manualsdir)/$(FREEVERB_NAME)
	install -p $(externals_src)/freeverb~/README \
		$(manualsdir)/$(FREEVERB_NAME)/README.txt


freeverb_clean:
	-rm -f -- $(externals_src)/freeverb/*.$(EXTENSION)
	-rm -f -- $(externals_src)/freeverb/*.o
	-rm -f -- $(externals_src)/freeverb/*.bak
	-rm -f -- $(externals_src)/freeverb/*.*~




#------------------------------------------------------------------------------#
# HID
HID_NAME = hid
ifeq ($(OS_NAME),windows)
  HID_CFLAGS = $(CFLAGS) 
  HID_LIBS = $(LIBS) -lhid -lsetupapi
else
  ifeq ($(OS_NAME),darwin)
    FRAMEWORKS = Carbon IOKit ForceFeedback
	HID_CFLAGS = $(CFLAGS) -I$(externals_src)/hcs/hid/HID\ Utilities\ Source
    HID_LIBS = $(LIBS) -L$(externals_src)/hcs/hid/HID\ Utilities\ Source/build \
       -lHIDUtilities $(patsubst %,-weak_framework %,$(FRAMEWORKS))
  else
    HID_CFLAGS = $(CFLAGS) 
    HID_LIBS = $(LIBS)
  endif
endif

HID_SRC = input_arrays.c hid_$(OS_NAME).c hid.c
HID_OBJECTS := $(patsubst %.c, $(externals_src)/hcs/hid/%.o, $(HID_SRC))
$(HID_OBJECTS) : %.o : %.c
	$(CC) $(HID_CFLAGS) -o "$*.o" -c "$*.c"

$(externals_src)/hcs/hid/hid.$(EXTENSION): $(HID_OBJECTS)
	$(CC) $(LDFLAGS) -o $(externals_src)/hcs/hid/hid.$(EXTENSION) \
		$(HID_OBJECTS) $(HID_LIBS)
	$(STRIP) $(externals_src)/hcs/hid/hid.$(EXTENSION)

hid: $(externals_src)/hcs/hid/hid.$(EXTENSION)


hid_install: hid
	install -d $(objectsdir)/$(HID_NAME)
	$(scripts_src)/generate-libdir-metafile.sh $(objectsdir) $(HID_NAME) \
		--author "Hans-Christoph Steiner" \
		--description "" \
		--license "GNU GPL" \
		--version ""
	-install -p $(externals_src)/hcs/hid/hid.$(EXTENSION) $(objectsdir)
	install -p $(externals_src)/hcs/hid/*.pd $(objectsdir)/$(HID_NAME)
	install -d $(helpdir)/$(HID_NAME)
	install -p $(externals_src)/hcs/hid/doc/*.pd       $(helpdir)/$(HID_NAME)
	install -p $(externals_src)/hcs/hid/examples/*.pd $(helpdir)/$(HID_NAME)
	install -d $(examplesdir)/$(HID_NAME)
	install -p $(externals_src)/hcs/hid/examples/*.pd  $(examplesdir)/$(HID_NAME)

hid_clean:
	-rm -f -- $(externals_src)/hcs/hid/*.o
	-rm -f -- $(externals_src)/hcs/hid/*.$(EXTENSION)
	-rm -f -- $(externals_src)/hcs/hid/*.bak
	-rm -f -- $(externals_src)/hcs/hid/*.*~



#------------------------------------------------------------------------------#
# IEMABS
IEMABS_NAME=iemabs
iemabs:


iemabs_install: iemabs
#  iemabs still has the help patches in the old help-*.pd style
	install -d $(objectsdir)/$(IEMABS_NAME)
	$(scripts_src)/generate-libdir-metafile.sh $(objectsdir) $(IEMABS_NAME) \
		--description "a collection of objects written at IEM/KUG"
	cd $(externals_src)/iemlib/iemabs/ && \
		install -p $(shell cd $(externals_src)/iemlib/iemabs/ && ls -1 *.pd | \
			grep -v 'help') $(objectsdir)/$(IEMABS_NAME)
	install -d $(helpdir)/$(IEMABS_NAME)
	cd $(externals_src)/iemlib/iemabs/ && \
		install -p *help*.pd $(helpdir)/$(IEMABS_NAME)
	install -p $(externals_src)/iemlib/iemabs/*.mp3 $(helpdir)/$(IEMABS_NAME)
	install -p $(externals_src)/iemlib/iemabs/*.wav $(helpdir)/$(IEMABS_NAME)
	install -d $(manualsdir)/$(IEMABS_NAME)
	install -p $(externals_src)/iemlib/iemabs/*.txt \
		$(manualsdir)/$(IEMABS_NAME)



#------------------------------------------------------------------------------#
# IEMLIB
IEMLIB_NAME=iemlib
iemlib:


iemlib_install: iemlib
#	install -d $(objectsdir)/$(IEMLIB_NAME)
#	install -d $(helpdir)/$(IEMLIB_NAME)
	install -d $(helpdir)/iemhelp
	install -p $(externals_src)/iemlib/iemhelp/*.* $(helpdir)/iemhelp
#	install -d $(manualsdir)/$(IEMLIB_NAME)
	install -d $(examplesdir)/$(IEMLIB_NAME)
	install -p $(externals_src)/iemlib/examples/*.* \
		$(examplesdir)/$(IEMLIB_NAME)



#------------------------------------------------------------------------------#
# IEMMATRIX
IEMMATRIX_NAME=iemmatrix
iemmatrix:


iemmatrix_install: iemmatrix
	install -d $(objectsdir)/$(IEMMATRIX_NAME)
	$(scripts_src)/generate-libdir-metafile.sh $(objectsdir) $(IEMMATRIX_NAME) \
		--description "objects for matrix operations and math"
	mv $(objectsdir)/mtx*.$(EXTENSION) $(objectsdir)/$(IEMMATRIX_NAME)
	install -p $(shell ls -1 $(externals_src)/iem/iemmatrix/abs/*.* | \
		grep -v '\-help.pd') $(objectsdir)/$(IEMMATRIX_NAME)
	install -d $(helpdir)/$(IEMMATRIX_NAME)
	install -p $(externals_src)/iem/iemmatrix/doc/*.pd \
		$(helpdir)/$(IEMMATRIX_NAME)



#------------------------------------------------------------------------------#
# LOADERS
LOADERS_NAME=
LOADERS_OBJECTS := $(wildcard $(externals_src)/loaders/*.c)
loaders: $(LOADERS_OBJECTS:.c=.$(EXTENSION))

loaders_install: loaders
	install -d $(objectsdir)/$(LOADERS_NAME)
	install -p $(LOADERS_OBJECTS:.c=.$(EXTENSION)) $(objectsdir)/$(LOADERS_NAME)
	install -d $(helpdir)/$(LOADERS_NAME)
	install -p $(wildcard $(externals_src)/loaders/help/*.pd) \
		$(helpdir)/$(LOADERS_NAME)
#	install -d $(manualsdir)/$(LOADERS_NAME)
#	install -p $(externals_src)/loaders/README.txt $(manualsdir)/$(LOADERS_NAME)

loaders_clean:
	-rm -f -- $(externals_src)/loaders/*.$(EXTENSION)
	-rm -f -- $(externals_src)/loaders/*.o
	-rm -f -- $(externals_src)/loaders/*.bak
	-rm -f -- $(externals_src)/loaders/*.*~


#------------------------------------------------------------------------------#
# MARKEX
MARKEX_NAME=markex
MARKEX_OBJECTS := $(wildcard $(externals_src)/markex/*.c)
markex: $(MARKEX_OBJECTS:.c=.$(EXTENSION))

markex_install: markex
	install -d $(objectsdir)/$(MARKEX_NAME)
	$(scripts_src)/generate-libdir-metafile.sh $(objectsdir) $(MARKEX_NAME) \
		--author "Mark Danks" \
		--license "GNU GPL"
	install -p $(MARKEX_OBJECTS:.c=.$(EXTENSION)) $(objectsdir)/$(MARKEX_NAME)
	install -d $(helpdir)/$(MARKEX_NAME)
	install -p $(wildcard $(externals_src)/markex/*.pd) \
		$(helpdir)/$(MARKEX_NAME)
	install -d $(manualsdir)/$(MARKEX_NAME)
	install -p $(externals_src)/markex/README \
		$(manualsdir)/$(MARKEX_NAME)/README.txt

markex_clean:
	-rm -f -- $(externals_src)/markex/*.$(EXTENSION)
	-rm -f -- $(externals_src)/markex/*.o
	-rm -f -- $(externals_src)/markex/*.bak
	-rm -f -- $(externals_src)/markex/*.*~


#------------------------------------------------------------------------------#
# MAXLIB
MAXLIB_NAME=maxlib
MAXLIB_OBJECTS := $(wildcard $(externals_src)/maxlib/src/*.c)
maxlib: $(MAXLIB_OBJECTS:.c=.$(EXTENSION))

maxlib_install: maxlib
	install -d $(objectsdir)/$(MAXLIB_NAME)
	$(scripts_src)/generate-libdir-metafile.sh $(objectsdir) $(MAXLIB_NAME) \
		--author "Olaf Matthes <olaf.matthes@gmx.de>" \
		--license "GNU GPL" \
		--version "1.5.2-cvs"
	install -p $(MAXLIB_OBJECTS:.c=.$(EXTENSION)) $(objectsdir)/$(MAXLIB_NAME)
	install -d $(helpdir)/$(MAXLIB_NAME)
	install -p $(wildcard $(externals_src)/maxlib/help/*.pd) \
		$(helpdir)/$(MAXLIB_NAME)
	install -d $(manualsdir)/$(MAXLIB_NAME)
	install -p $(externals_src)/maxlib/README \
		$(manualsdir)/$(MAXLIB_NAME)/README.txt

maxlib_clean:
	-rm -f -- $(externals_src)/maxlib/src/*.$(EXTENSION)
	-rm -f -- $(externals_src)/maxlib/src/*.o
	-rm -f -- $(externals_src)/maxlib/*/*.bak
	-rm -f -- $(externals_src)/maxlib/*/*.*~
	-rm -f -- $(externals_src)/maxlib/*.*~


#------------------------------------------------------------------------------#
# MJLIB
MJLIB_NAME=mjlib
# exclude the library file mjLib.c
MJLIB_OBJECTS := $(wildcard $(externals_src)/mjlib/[a-z]?[a-z]*.c)
mjlib: $(MJLIB_OBJECTS:.c=.$(EXTENSION))

mjlib_install: mjlib
	install -d $(objectsdir)/$(MJLIB_NAME)
	$(scripts_src)/generate-libdir-metafile.sh $(objectsdir) $(MJLIB_NAME) \
		--author "mark williamson <mark@junklight.com>" \
		--license "GNU GPL" \
		--version "0.1"
	install -p $(MJLIB_OBJECTS:.c=.$(EXTENSION)) $(objectsdir)/$(MJLIB_NAME)
	install -d $(helpdir)/$(MJLIB_NAME)
	install -p $(wildcard $(externals_src)/mjlib/doc/*.pd) \
		$(helpdir)/$(MJLIB_NAME)
	install -d $(manualsdir)/$(MJLIB_NAME)
	install -p $(externals_src)/mjlib/readme.txt \
		$(manualsdir)/$(MJLIB_NAME)

mjlib_clean:
	-rm -f -- $(externals_src)/mjlib/*.$(EXTENSION)
	-rm -f -- $(externals_src)/mjlib/*.o
	-rm -f -- $(externals_src)/mjlib/*.bak
	-rm -f -- $(externals_src)/mjlib/*.*~


#------------------------------------------------------------------------------#
# MOTEX
MOTEX_NAME=motex
MOTEX_OBJECTS := $(wildcard $(externals_src)/motex/*.c)
motex: $(MOTEX_OBJECTS:.c=.$(EXTENSION))

motex_install: motex
	install -d $(objectsdir)/$(MOTEX_NAME)
	$(scripts_src)/generate-libdir-metafile.sh $(objectsdir) $(MOTEX_NAME) \
		--author "Iain Mott <iain.mott@bigpond.com>" \
		--license "GNU GPL" \
		--version "1.1.3-cvs"
	install -p $(MOTEX_OBJECTS:.c=.$(EXTENSION)) $(objectsdir)/$(MOTEX_NAME)
	install -p $(externals_src)/motex/noisegate~.pd $(objectsdir)/$(MOTEX_NAME)
	install -d $(helpdir)/$(MOTEX_NAME)
	install -p $(wildcard $(externals_src)/motex/*-help.pd) \
		$(helpdir)/$(MOTEX_NAME)
	install -d $(manualsdir)/$(MOTEX_NAME)
	install -p $(externals_src)/motex/README \
		$(manualsdir)/$(MOTEX_NAME)/README.txt

motex_clean:
	-rm -f -- $(externals_src)/motex/*.$(EXTENSION)
	-rm -f -- $(externals_src)/motex/*.o
	-rm -f -- $(externals_src)/motex/*.bak
	-rm -f -- $(externals_src)/motex/*.*~



#----------------------------------------------------------------------------
# OSCx
OSCX_NAME=oscx
$(externals_src)/OSCx/configure: $(externals_src)/OSCx/configure.ac
	cd $(externals_src)/OSCx && autoconf

$(externals_src)/OSCx/Makefile: $(externals_src)/OSCx/Makefile.in
	cd $(externals_src)/OSCx && ./configure
$(externals_src)/OSCx/libOSC/Makefile: $(externals_src)/OSCx/libOSC/Makefile.in
	cd $(externals_src)/OSCx && ./configure
$(externals_src)/OSCx/src/Makefile: $(externals_src)/OSCx/src/Makefile.in
	cd $(externals_src)/OSCx && ./configure

$(externals_src)/OSCx/src/OSCroute.$(EXTENSION):  $(externals_src)/OSCx/configure \
$(externals_src)/OSCx/Makefile
	make -C $(externals_src)/OSCx
$(externals_src)/OSCx/src/dumpOSC.$(EXTENSION):  $(externals_src)/OSCx/configure \
$(externals_src)/OSCx/Makefile
	make -C $(externals_src)/OSCx
$(externals_src)/OSCx/src/sendOSC.$(EXTENSION):  $(externals_src)/OSCx/configure \
$(externals_src)/OSCx/Makefile
	make -C $(externals_src)/OSCx

oscx: $(externals_src)/OSCx/src/OSCroute.$(EXTENSION) \
$(externals_src)/OSCx/src/dumpOSC.$(EXTENSION) \
$(externals_src)/OSCx/src/sendOSC.$(EXTENSION)

oscx_install: oscx
	install -d $(objectsdir)/$(OSCX_NAME)
	$(scripts_src)/generate-libdir-metafile.sh $(objectsdir) $(OSCX_NAME) \
		--author "<jdl@xdv.org>" \
		--license "BSD" \
		--description "objects for working with OpenSoundControl"
	install -p $(externals_src)/OSCx/src/*.$(EXTENSION) $(objectsdir)/$(OSCX_NAME)
	install -d $(helpdir)/$(OSCX_NAME)
	install -p $(externals_src)/OSCx/doc/*.* $(helpdir)/$(OSCX_NAME)


oscx_clean:
	-cd $(externals_src)/OSCx && make $(DEST_PATHS) clean
	-cd $(externals_src)/OSCx && $(MAKE) CC=gcc clean
	-rm $(externals_src)/OSCx/Makefile


#------------------------------------------------------------------------------#
# PDDP
PDDP_NAME=pddp
# pddp is compiled straight into $(OUT_DIR)
PDDP_OUT_DIR=$(objectsdir)/$(PDDP_NAME)
pddp:


pddp_install: pddp
	install -d $(objectsdir)/$(PDDP_NAME)
	$(scripts_src)/generate-libdir-metafile.sh $(objectsdir) $(PDDP_NAME) \
		--author "PDDP" \
		--license "BSD" \
		--description "objects for working with Tcl and Pd's Tk GUI"
	cd $(externals_src)/miXed/pddp && $(MAKE) OUT_DIR=$(PDDP_OUT_DIR)
#	install -d $(helpdir)/$(PDDP_NAME)
#	install -d $(manualsdir)/$(PDDP_NAME)
	install -d $(examplesdir)/$(PDDP_NAME)
	install -p $(externals_src)/miXed/test/pddp/*.*  \
		$(examplesdir)/$(PDDP_NAME)


pddp_clean:
	-make -C $(externals_src)/mixed/pddp $(DEST_PATHS) clean



#------------------------------------------------------------------------------#
# PDOGG
PDOGG_NAME=pdogg
PDOGG_OBJECTS := $(wildcard $(externals_src)/pdogg/*/*.c)
pdogg: $(PDOGG_OBJECTS:.c=.$(EXTENSION))

pdogg_install: pdogg
	install -d $(objectsdir)/$(PDOGG_NAME)
	$(scripts_src)/generate-libdir-metafile.sh $(objectsdir) $(PDOGG_NAME) \
		--author "Olaf Matthes" \
		--description "objects for reading, writing, and streaming ogg" \
		--license "LGPL" \
		--version "0.2"
	install -p $(PDOGG_OBJECTS:.c=.$(EXTENSION)) $(objectsdir)/$(PDOGG_NAME)
	install -d $(helpdir)/$(PDOGG_NAME)
	install -p $(externals_src)/pdogg/*/*.pd \
		$(helpdir)/$(PDOGG_NAME)
	install -d $(manualsdir)/$(PDOGG_NAME)
	install -p $(externals_src)/pdogg/readme \
		$(manualsdir)/$(PDOGG_NAME)/README.txt

pdogg_clean:
	-rm -f -- $(externals_src)/pdogg/*/*.$(EXTENSION)
	-rm -f -- $(externals_src)/pdogg/*/*.o
	-rm -f -- $(externals_src)/pdogg/*/*.bak
	-rm -f -- $(externals_src)/pdogg/*/*.*~
	-rm -f -- $(externals_src)/pdogg/*.*~



#------------------------------------------------------------------------------#
# PDP
PDP_NAME=pdp
$(externals_src)/pdp/configure: $(externals_src)/pdp/configure.ac
	cd $(externals_src)/pdp && autoconf

$(externals_src)/pdp/Makefile.config: $(externals_src)/pdp/Makefile.config.in
	cd $(externals_src)/pdp && ./configure

$(externals_src)/pdp/pdp.$(EXTENSION):  $(externals_src)/pdp/configure \
$(externals_src)/pdp/Makefile.config 
	make -C $(externals_src)/pdp

pdp: $(externals_src)/pdp/pdp.$(EXTENSION)

pdp_install: pdp
#	install -d $(objectsdir)/$(PDP_NAME)
#	$(scripts_src)/generate-libdir-metafile.sh $(objectsdir) $(PDP_NAME) \
#		--author "Tom Schouten" \
#		--description "Pure Data Packet" \
#		--license "GNU GPL"
	install -p $(externals_src)/pdp/*.$(EXTENSION) $(objectsdir)
#	install -p $(externals_src)/pdp/abstractions/*.pd $(objectsdir)/$(PDP_NAME)
	install -p $(externals_src)/pdp/abstractions/*.pd $(objectsdir)
	install -d $(helpdir)/$(PDP_NAME)
	install -p $(externals_src)/pdp/doc/objects/*.* $(helpdir)/$(PDP_NAME)
	install -d $(manualsdir)/$(PDP_NAME)
	install -p $(externals_src)/pdp/doc/reference.txt $(manualsdir)/$(PDP_NAME)
	install -p $(externals_src)/pdp/doc/introduction/*.* \
		$(manualsdir)/$(PDP_NAME)
	install -d $(examplesdir)/$(PDP_NAME)
	install -p $(externals_src)/pdp/doc/examples/*.* \
		$(examplesdir)/$(PDP_NAME)

pdp_clean:
	-rm -f -- $(externals_src)/pdp/*.$(EXTENSION)
	-find $(externals_src)/pdp -name '*.o' | xargs rm -f --
	-find $(externals_src)/pdp -name '*.bak' | xargs rm -f --
	-rm -f -- $(externals_src)/pdp/Makefile.config
	-rm -f -- $(externals_src)/pdp/configure


#------------------------------------------------------------------------------#
# PIDIP
PIDIP_NAME=pidip
$(externals_src)/pidip/configure: $(externals_src)/pidip/configure.ac
	cd $(externals_src)/pidip && autoconf

$(externals_src)/pidip/Makefile: $(externals_src)/pidip/Makefile.in
	-cd $(externals_src)/pidip && ./configure --with-pd=../../pd --with-pdp=../pdp

$(externals_src)/pidip/pidip.$(EXTENSION):  $(externals_src)/pidip/configure \
$(externals_src)/pidip/Makefile
	-make -C $(externals_src)/pidip

pidip: $(externals_src)/pidip/pidip.$(EXTENSION)

pidip_install:
	install -d $(objectsdir)/$(PIDIP_NAME)
	$(scripts_src)/generate-libdir-metafile.sh $(objectsdir) $(PIDIP_NAME) \
		--author "Yves Degoyon" \
		--description "PiDiP is Definitely in Pieces"
	-install -p $(externals_src)/pidip/*.$(EXTENSION) $(objectsdir)/$(PIDIP_NAME)
	install -d $(helpdir)/$(PIDIP_NAME)
	install -p $(externals_src)/pidip/doc/*.pd $(helpdir)/$(PIDIP_NAME)
	install -d $(examplesdir)/$(PIDIP_NAME)
	install -p $(externals_src)/pidip/patches/*.* $(examplesdir)/$(PIDIP_NAME)
	install -d $(manualsdir)/$(PIDIP_NAME)
	install -p $(externals_src)/pidip/README \
		$(manualsdir)/$(PIDIP_NAME)/README.txt
	install -d $(examplesdir)/$(PIDIP_NAME)/images
	install -p $(externals_src)/pidip/patches/images/*.* \
		$(examplesdir)/$(PIDIP_NAME)/images
	install -d $(examplesdir)/$(PIDIP_NAME)/morphology
	install -p $(externals_src)/pidip/patches/morphology/*.* \
		$(examplesdir)/$(PIDIP_NAME)/morphology

pidip_clean:
	-rm -f -- $(externals_src)/pidip/*.$(EXTENSION)
	-find $(externals_src)/pidip -name '*.o' | xargs rm -f --
	-rm -f -- $(externals_src)/pidip/*.bak
	-rm -f -- $(externals_src)/pidip/Makefile
	-rm -f -- $(externals_src)/pidip/configure


#------------------------------------------------------------------------------#
# PMPD
PMPD_NAME=pmpd
PMPD_OBJECTS := $(wildcard $(externals_src)/pmpd/src/[a-lq-z]*.c)
pmpd: $(PMPD_OBJECTS:.c=.$(EXTENSION))

pmpd_install: pmpd
	install -d $(objectsdir)/$(PMPD_NAME)
	$(scripts_src)/generate-libdir-metafile.sh $(objectsdir) $(PMPD_NAME) \
		--author "Cyrille Henry" \
		--description "Physical Modelling for Pd"
	-install -p $(externals_src)/pmpd/*.$(EXTENSION) $(objectsdir)/$(PMPD_NAME)
	install -d $(helpdir)/$(PMPD_NAME)
	install -p $(externals_src)/pmpd/help/*.pd $(helpdir)
	install -p $(externals_src)/pmpd/help/*.pd $(helpdir)/$(PMPD_NAME)
	install -d $(manualsdir)/$(PMPD_NAME)
	install -d $(manualsdir)/$(PMPD_NAME)
	install -p $(externals_src)/pmpd/doc/pmpd.pdf/pmpd.pdf \
		$(manualsdir)/$(PMPD_NAME)
	install -d $(examplesdir)/$(PMPD_NAME)
	install -p $(externals_src)/pmpd/exemples/*.pd \
		$(examplesdir)/$(PMPD_NAME)

pmpd_clean:
	-rm -f -- $(PMPD_OBJECTS:.c=.$(EXTENSION))
	-find $(externals_src)/pmpd -name '*.o' | xargs rm -f --
	-find $(externals_src)/pmpd -name '*.bak' | xargs rm -f --
	-find $(externals_src)/pmpd -name '*~' | xargs rm -f --


#------------------------------------------------------------------------------#
# SIGPACK
SIGPACK_NAME=sigpack
SIGPACK_OBJECTS := $(wildcard $(externals_src)/sigpack/source/*~.c)
SIGPACK_VERSION := $(shell grep "define VERSION" \
	$(externals_src)/sigpack/source/sIgpAck.c | cut -d '"' -f 2)

sigpack: $(SIGPACK_OBJECTS:.c=.$(EXTENSION))

sigpack_install: sigpack
	install -d $(objectsdir)/$(SIGPACK_NAME)
	$(scripts_src)/generate-libdir-metafile.sh $(objectsdir) $(SIGPACK_NAME) \
		--author "weiss@weiss-archiv.de" \
		--license "GNU GPL 2" \
		--version "$(SIGPACK_VERSION)"
	install -p $(SIGPACK_OBJECTS:.c=.$(EXTENSION)) $(objectsdir)/$(SIGPACK_NAME)
	install -d $(helpdir)/$(SIGPACK_NAME)
	install -p $(externals_src)/sigpack/help/*.pd \
		$(helpdir)/$(SIGPACK_NAME)
	install -d $(manualsdir)/$(SIGPACK_NAME)
	install -p $(externals_src)/sigpack/readme.txt \
		$(manualsdir)/$(SIGPACK_NAME)/README.txt

sigpack_clean:
	-rm -f -- $(externals_src)/sigpack/source/*.$(EXTENSION)
	-rm -f -- $(externals_src)/sigpack/source/*.o
	-rm -f -- $(externals_src)/sigpack/*/*.bak
	-rm -f -- $(externals_src)/sigpack/*/*.*~


#------------------------------------------------------------------------------#
# SMLIB
SMLIB_NAME=smlib
# exclude SMlib.c since its just for the compiled library
SMLIB_OBJECTS := $(wildcard $(externals_src)/smlib/source/[a-z]*.c)
smlib: $(SMLIB_OBJECTS:.c=.$(EXTENSION))

smlib_install: smlib
	install -d $(objectsdir)/$(SMLIB_NAME)
	$(scripts_src)/generate-libdir-metafile.sh $(objectsdir) $(SMLIB_NAME) \
		--author "Johannes Taelman <johannes.taelman@rug.ac.be>" \
		--license "GNU GPL" \
		--description "vector processing, vector analysis, vector synthesis, number stream analysis, number stream filters"
	install -p $(SMLIB_OBJECTS:.c=.$(EXTENSION)) $(objectsdir)/$(SMLIB_NAME)
	install -d $(helpdir)/$(SMLIB_NAME)
	install -p $(wildcard $(externals_src)/smlib/help/*.pd )\
		$(helpdir)/$(SMLIB_NAME)
	install -d $(manualsdir)/$(SMLIB_NAME)
	install -p $(externals_src)/smlib/readme.txt $(manualsdir)/$(SMLIB_NAME)
	install -d $(examplesdir)/$(SMLIB_NAME)
	install -p $(wildcard $(externals_src)/smlib/examples/*.pd) \
		$(examplesdir)/$(SMLIB_NAME)

smlib_clean:
	-rm -f -- $(SMLIB_OBJECTS:.c=.$(EXTENSION))
	-rm -f -- $(externals_src)/smlib/*.o
	-rm -f -- $(externals_src)/smlib/*.bak
	-rm -f -- $(externals_src)/smlib/*.*~


#------------------------------------------------------------------------------#
# TOXY
TOXY_NAME=toxy
# toxy is compiled straight into $(OUT_DIR)
TOXY_OUT_DIR=$(objectsdir)/$(TOXY_NAME)
toxy:


toxy_install: toxy
	install -d $(objectsdir)/$(TOXY_NAME)
	$(scripts_src)/generate-libdir-metafile.sh $(objectsdir) $(TOXY_NAME) \
		--author "Kzrysztof Czaja" \
		--license "BSD" \
		--description "objects for working with Tcl and Pd's Tk GUI"
	cd $(externals_src)/miXed/toxy && $(MAKE) OUT_DIR=$(TOXY_OUT_DIR)
	install -d $(helpdir)/$(TOXY_NAME)
	install -p $(externals_src)/miXed/doc/help/toxy/*.*  \
		$(helpdir)/$(TOXY_NAME)
#	install -d $(manualsdir)/$(TOXY_NAME)
	install -d $(examplesdir)/$(TOXY_NAME)
	install -p $(externals_src)/miXed/test/toxy/*.*  \
		$(examplesdir)/$(TOXY_NAME)


toxy_clean:
	-make -C $(externals_src)/mixed/toxy $(DEST_PATHS) clean


#------------------------------------------------------------------------------#
# UNAUTHORIZED
UNAUTHORIZED_NAME=unauthorized
# these need to be created before compiling the C
UNAUTHORIZED_TKFILES = $(wildcard $(externals_src)/unauthorized/*/*.tk)
%.tk2c: %.tk
	bash $(externals_src)/unauthorized/tk2c.bash < $*.tk > $*.tk2c

# [cooled~] doesn't compile under MinGW (yet) and it crashes Pd on Mac OS X,
# so its excluded from the build here
UNAUTHORIZED_OBJECTS := $(wildcard $(externals_src)/unauthorized/[a-bd-uw-z]*/*.c) \
$(wildcard $(externals_src)/unauthorized/c?[a-np-z]*/*.c)

# [vocoder~] is built separately since its made from a number of files
UNAUTHORIZED_VOCODER = $(wildcard $(externals_src)/unauthorized/vocoder*/*.c)
 $(externals_src)/unauthorized/vocoder~/vocoder~.$(EXTENSION): $(UNAUTHORIZED_VOCODER:.c=.o)
	$(CC) $(LDFLAGS) -o $(externals_src)/unauthorized/vocoder~/vocoder~.$(EXTENSION) \
		$(UNAUTHORIZED_VOCODER:.c=.o) $(LIBS)

unauthorized: $(externals_src)/unauthorized/vocoder~/vocoder~.$(EXTENSION) \
$(UNAUTHORIZED_TKFILES:.tk=.tk2c) $(UNAUTHORIZED_OBJECTS:.c=.$(EXTENSION))

unauthorized_install: unauthorized
	install -d $(objectsdir)/$(UNAUTHORIZED_NAME)
	$(scripts_src)/generate-libdir-metafile.sh $(objectsdir) $(UNAUTHORIZED_NAME) \
		--author "Yves Degoyon" \
		--license "GNU GPL" \
		--description "GUI and streaming objects"
	install -p $(externals_src)/unauthorized/*/*.$(EXTENSION) \
		$(objectsdir)/$(UNAUTHORIZED_NAME)
	install -d $(helpdir)/$(UNAUTHORIZED_NAME)
	install -p $(externals_src)/unauthorized/*/*.pd \
		$(helpdir)/$(UNAUTHORIZED_NAME)
	install -p $(externals_src)/unauthorized/*/*.pls \
		$(helpdir)/$(UNAUTHORIZED_NAME)
	install -d $(helpdir)/$(UNAUTHORIZED_NAME)/blm
	install -p $(externals_src)/unauthorized/blinkenlights/blm/*.* \
		$(helpdir)/$(UNAUTHORIZED_NAME)/blm
	install -d $(manualsdir)/$(UNAUTHORIZED_NAME)
	install -p $(externals_src)/unauthorized/*/*.txt \
		$(manualsdir)/$(UNAUTHORIZED_NAME)

unauthorized_clean:
	-rm -f -- $(UNAUTHORIZED_OBJECTS:.c=.$(EXTENSION))
	-rm -f -- $(UNAUTHORIZED_OBJECTS:.c=.o)
	-rm -f -- $(UNAUTHORIZED_VOCODER:.c=.$(EXTENSION))
	-rm -f -- $(UNAUTHORIZED_VOCODER:.c=.o)
	-rm -f -- $(externals_src)/unauthorized/*/*.bak
	-rm -f -- $(externals_src)/*/*.*~
	-rm -f -- $(externals_src)/*.*~


#------------------------------------------------------------------------------#
# VBAP
VBAP_NAME=vbap
vbap:


vbap_install: vbap
	install -d $(objectsdir)/$(VBAP_NAME)
#	install -d $(helpdir)/$(VBAP_NAME)
#	install -d $(manualsdir)/$(VBAP_NAME)
#	install -d $(examplesdir)/$(VBAP_NAME)
	install -p $(externals_src)/vbap/graph-to-aziele.pd \
		$(objectsdir)/$(VBAP_NAME)



#------------------------------------------------------------------------------#
# Zexy
ZEXY_NAME = zexy
ZEXY_OBJECTS := $(wildcard $(externals_src)/zexy/src/[a-y0]*.c $(externals_src)/zexy/src/z~.c)
ZEXY_VERSION := $(shell grep VERSION $(externals_src)/zexy/src/zexy.h | \
	grep -v _VERSION | cut -d ' ' -f 3 | cut -d '"' -f 2)

zexy: $(ZEXY_OBJECTS:.c=.$(EXTENSION))

zexy_install: zexy
	install -d $(objectsdir)/$(ZEXY_NAME)
	$(scripts_src)/generate-libdir-metafile.sh $(objectsdir) $(ZEXY_NAME) \
		--author "IOhannes m zmoelnig <zmoelnig@iem.kug.ac.at>" \
		--license "GNU GPL" \
		--description "GUI and streaming objects" \
		--version "$(ZEXY_VERSION)"
	install -p $(ZEXY_OBJECTS:.c=.$(EXTENSION)) $(objectsdir)/$(ZEXY_NAME)
	install -p $(shell ls -1 $(externals_src)/zexy/abs/*.pd | \
		grep -v '-help.pd' | sed 's|\(.*\)|"\1"|g') \
		$(objectsdir)/$(ZEXY_NAME)
# an escape pattern for the abstractions with special characters
#		grep -v '-help.pd' | sed 's/\([&<>|~]\)/\\\1/g') 
	install -d $(helpdir)/$(ZEXY_NAME)
	install -p $(shell ls -1 $(externals_src)/zexy/abs/*-help.pd | \
		sed 's|\(.*\)|"\1"|g') $(helpdir)/$(ZEXY_NAME)
	install -p $(externals_src)/zexy/zexy.pd  $(helpdir)
	install -p $(externals_src)/zexy/examples/*.* $(helpdir)/$(ZEXY_NAME)

zexy_clean:
	-rm -f -- $(ZEXY_OBJECTS:.c=.$(EXTENSION))
	-rm -f -- $(externals_src)/zexy/src/*.o
	-rm -f -- $(externals_src)/zexy/src/*.bak
	-rm -f -- $(externals_src)/*/*.*~
	-rm -f -- $(externals_src)/*.*~



#==============================================================================#
#
# UNFILTERED PROJECT TARGETS
#
#==============================================================================#
# this is not yet organized into libdirs, but just leftover <hans@at.or.at>

unfiltered_install:
#----------------------------------------------------------------------------
# hcs
	install -p $(shell ls -1 $(externals_src)/hcs/*.pd | \
			 grep -v '\-help.pd') $(objectsdir)
# general
	install -p $(externals_src)/hcs/general/*.pd $(objectsdir)
# pan
	install -p $(shell ls -1 $(externals_src)/hcs/pan/*.pd | \
			 grep -v '\-help.pd') $(objectsdir)


#==============================================================================#
#
# DEVELOPER'S TARGETS
#
#==============================================================================#

# make the symlinks necessary to simulate the installed environment
devsymlinks: 


#==============================================================================#
#
# CLEAN TARGETS
#
#==============================================================================#

# the destination-specific clean targets are in Makefile.buildlayout
clean:  $(patsubst %, %_clean,$(LIB_TARGETS))
	-rm -f -- $(BUILDSRC_OBJECTS:.c=.o) 
	-rm -f -- $(BUILDSRC_OBJECTS:.c=.$(EXTENSION)) 


distclean: clean cruft_clean


test_locations:
	@echo "PD_VERSION: $(PD_VERSION)"
	@echo "PACKAGE_VERSION: $(PACKAGE_VERSION)"
	@echo "CWD $(CWD)"
	@echo "DESTDIR $(DESTDIR)"
	@echo "PREFIX $(prefix)"
	@echo "BINDIR  $(bindir)"
	@echo "LIBDIR  $(libdir)"
	@echo "OBJECTSDIR  $(objectsdir)"
	@echo "PDDOCDIR  $(pddocdir)"
	@echo "LIBPDDIR  $(libpddir)"
	@echo "LIBPDBINDIR  $(libpdbindir)"
	@echo "HELPDIR  $(helpdir)"
	@echo "MANUALSDIR  $(manualsdir)"
	@echo "EXAMPLESDIR  $(examplesdir)"
	@echo " "
	@echo "Compiling these libs:"
	@echo "$(LIB_TARGETS)"


.PHONY: all install clean distclean test_locations $(LIB_TARGETS) \
$(patsubst %, %_install,$(LIB_TARGETS)) $(patsubst %, %_clean,$(LIB_TARGETS))