aboutsummaryrefslogtreecommitdiff
path: root/cyclone/Makefile.libdir
blob: 91e2a3a8bc8003e393292fc681a7365822660274 (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
# this Makefile builds a libdir for cyclone

# where to install the library, overridden below depending on platform
prefix = /usr/local
libdir = $(prefix)/lib
bindir = $(prefix)/bin
pkglibdir = $(libdir)/pd-externals
objectsdir = $(pkglibdir)

INSTALL = install
INSTALL_PROGRAM = $(INSTALL) -p -m 755
INSTALL_DATA = $(INSTALL) -p -m 644
INSTALL_DIR     = $(INSTALL) -p -m 755 -d

UNAME := $(shell uname -s)
ifeq ($(UNAME),Darwin)
  CPU := $(shell uname -p)
  ifeq ($(CPU),arm) # iPhone/iPod Touch
    EXTENSION = pd_darwin
    OS = iphoneos
    PD_PATH = /Applications/Pd-extended.app/Contents/Resources
    IPHONE_BASE=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin
    CC=$(IPHONE_BASE)/gcc
    CPP=$(IPHONE_BASE)/cpp
    CXX=$(IPHONE_BASE)/g++
    ISYSROOT = -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk
    IPHONE_CFLAGS = -miphoneos-version-min=3.0 $(ISYSROOT) -arch armv6
    OPT_CFLAGS = -fast -funroll-loops -fomit-frame-pointer
	CFLAGS := $(IPHONE_CFLAGS) $(OPT_CFLAGS) $(CFLAGS)
    LDFLAGS += -arch armv6 -bundle -undefined dynamic_lookup $(ISYSROOT)
    LIBS += -lc 
    STRIP = strip -x
  else # Mac OS X
    EXTENSION = pd_darwin
    OS = macosx
    PD_PATH = /Applications/Pd-extended.app/Contents/Resources
    OPT_CFLAGS = -ftree-vectorize -ftree-vectorizer-verbose=2 -fast
# build universal 32-bit on 10.4 and 32/64 on newer
    ifeq ($(shell uname -r | sed 's|\([0-9][0-9]*\)\.[0-9][0-9]*\.[0-9][0-9]*|\1|'), 8)
      FAT_FLAGS = -arch ppc -arch i386 -mmacosx-version-min=10.4
    else
      FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=10.4
    endif
    CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib
    # if the 'pd' binary exists, check the linking against it to aid with stripping
    LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd)
    LIBS += -lc 
    STRIP = strip -x
# install into ~/Library/Pd on Mac OS X since /usr/local isn't used much
    pkglibdir=$(HOME)/Library/Pd
  endif
endif
ifeq ($(UNAME),Linux)
  CPU := $(shell uname -m)
  EXTENSION = pd_linux
  OS = linux
  PD_PATH = /usr
  OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer
  CFLAGS += -fPIC
  LDFLAGS += -Wl,--export-dynamic  -shared -fPIC
  LIBS += -lc
  STRIP = strip --strip-unneeded -R .note -R .comment
endif
ifeq (CYGWIN,$(findstring CYGWIN,$(UNAME)))
  CPU := $(shell uname -m)
  EXTENSION = dll
  OS = cygwin
  PD_PATH = $(cygpath $(PROGRAMFILES))/pd
  OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer
  CFLAGS += 
  LDFLAGS += -Wl,--export-dynamic -shared -L"$(PD_PATH)/src" -L"$(PD_PATH)/bin"
  LIBS += -lc -lpd
  STRIP = strip --strip-unneeded -R .note -R .comment
endif
ifeq (MINGW,$(findstring MINGW,$(UNAME)))
  CPU := $(shell uname -m)
  EXTENSION = dll
  OS = windows
  PD_PATH = $(shell cd "$(PROGRAMFILES)"/pd && pwd)
  OPT_CFLAGS = -O3 -funroll-loops -fomit-frame-pointer
  CFLAGS += -mms-bitfields
  LDFLAGS += -s -shared -Wl,--enable-auto-import
  LIBS += -L"$(PD_PATH)/src" -L"$(PD_PATH)/bin" -L"$(PD_PATH)/obj" -lpd -lwsock32 -lkernel32 -luser32 -lgdi32
  STRIP = strip --strip-unneeded -R .note -R .comment
endif

cyclone:
	$(MAKE) -j4 -f Makefile \
		OPT_CFLAGS="-O6 -funroll-loops -fomit-frame-pointer -fno-strict-aliasing -fPIC"

install: cyclone
	$(INSTALL_DIR) $(DESTDIR)$(objectsdir)/cyclone
	$(INSTALL_DATA) cyclone-meta.pd $(DESTDIR)$(objectsdir)/cyclone
	$(INSTALL_DATA) ../LICENSE.txt $(DESTDIR)$(objectsdir)/cyclone
	$(INSTALL_DATA) README.txt $(DESTDIR)$(objectsdir)/cyclone
# cyclone is compiled straight into $(OUT_DIR), yes a kludge, but the code of
# this build system is impenetrable
	$(MAKE) -j4 OUT_DIR=$(DESTDIR)$(objectsdir)/cyclone
	$(STRIP) $(DESTDIR)$(objectsdir)/cyclone/*.$(EXTENSION)
	chmod a-x $(DESTDIR)$(objectsdir)/cyclone/*.$(EXTENSION)
# install "maxmode" libraries into subdir, so they don't override the libdir
	$(INSTALL_DIR) $(DESTDIR)$(objectsdir)/cyclone/maxmode
	$(INSTALL_DATA) ../bin/cyclone.$(EXTENSION) \
		../bin/hammer.$(EXTENSION) \
		../bin/sickle.$(EXTENSION) \
		../bin/maxmode.$(EXTENSION) \
		$(DESTDIR)$(objectsdir)/cyclone/maxmode
	$(STRIP) $(DESTDIR)$(objectsdir)/cyclone/maxmode/*.$(EXTENSION)
# install "cyclist" command line app with pd
	$(INSTALL_DIR) $(DESTDIR)$(bindir)
	$(INSTALL_PROGRAM) ../bin/cyclist $(DESTDIR)$(bindir)
	$(STRIP) $(DESTDIR)$(bindir)/cyclist
	$(INSTALL_DATA) ../doc/help/cyclone/*.* \
		$(DESTDIR)$(objectsdir)/cyclone
	$(INSTALL_DIR) $(DESTDIR)$(objectsdir)/cyclone/examples
	$(INSTALL_DATA) ../test/cyclone/*.* \
		$(DESTDIR)$(objectsdir)/cyclone/examples

clean:
	-$(MAKE) -f Makefile $(DEST_PATHS) clean
	-rm -f ../bin/*.pd_linux
	-rm -f ../bin/cyclist
	-rm -f Makefile.deps
	-rm -f shadow/Makefile.deps
	-rm -f hammer/Makefile.deps
	-rm -f sickle/Makefile.deps
	-rm -f ../build-stamp