[Pdmtl] Compilation d'externes pd sous OS X
Thomas O Fredericks
iamonthebeach at gmail.com
Lun 11 Oct 11:21:33 EDT 2010
Ok, je me suis basé sur le Makefile de pd-extended.
Voir à la fin de ce courriel pour voir le fichier. Il y a trois paramètres à déterminer: PD_SRC, PD_BIN et OUTPUT.
Le fichier marche très bien, sauf qu'il y a quelques petits irritants.
Disons que mon dossier contient les fichiers "Makefile alpha.c beta.c".
1) Pour compiler l'externe "alpha", je dois tapper "make alpha.pd_darwin". Comment puis-je modifier mon fichier pour tapper "make alpha.c" ou "make alpha"? Pour l'instant, si je tappe "make alpha", le fichier est compilé en tant qu'application.
2) Je voudrais que le "default:" du Makefile soit déduit automatiquement à partir des fichiers qui se trouvent dans le dossier (alpha.c beta.c). Comment puis-je faire pour que le default compile automatiquement tous mes fichiers en externes?
Merci.
Thomas
--------------
Makefile
--------------
#
# SETUP
#
# Points to the folder that contains pd's /src dir
PD_SRC = ../../../pd
# Points to the folder that contains pd's compiled /bin dir (for OS X)
PD_BIN = /Applications/Pd-extended.app/Contents/Resources
# Points to the folder to which you want to move the built file
OUTPUT = ~/Make/pd/tof
#
# FIND OS
#
UNAME := $(shell uname -s)
ifeq ($(UNAME),Linux)
OS_NAME = linux
EXTENSION = pd_linux
DYLIB_EXTENSION = so
endif
ifeq ($(UNAME),Darwin)
OS_NAME = darwin
EXTENSION = pd_darwin
DYLIB_EXTENSION = dylib
endif
ifeq (MINGW,$(findstring MINGW,$(UNAME)))
OS_NAME = windows
EXTENSION = dll
DYLIB_EXTENSION = dll
endif
ifeq (CYGWIN,$(findstring CYGWIN,$(UNAME)))
OS_NAME = windows
EXTENSION = dll
DYLIB_EXTENSION = dll
endif
# which CPU to compile for
UNAME_MACHINE := $(shell uname -m)
ifeq ($(UNAME_MACHINE),i386)
ARCH = i386
endif
ifeq ($(UNAME_MACHINE),i686)
ARCH = i386
endif
ifeq ($(UNAME_MACHINE),ppc)
ARCH = powerpc
endif
#
# COMPILE OPTIONS
#
CWD := $(shell pwd)
# turn on weak linking and dlopen support
export MACOSX_DEPLOYMENT_TARGET = 10.3
# DEFAULT TARGET # Find a way to list all c files target
ALL = $((patsubst %.c,%.o,$(wildcard *.c)))
default: $(ALL)
.SUFFIXES: .$(EXTENSION) .$(SHARED_LIB)
# this variable is to support old "win" directories, rather than "windows"
BUILDSRC_OS_NAME = $(OS_NAME)
CFLAGS = -DPD -I$(PD_SRC)/src -Wall -W $(DEBUG_CFLAGS)
LDFLAGS =
LIBS = -lm
ifeq ($(OS_NAME),darwin)
# 10.4 Tiger
FAT_FLAGS = -arch ppc -arch ppc64 -arch i386
# 10.5 Leopard
# FAT_FLAGS = -arch ppc -arch ppc7400 -arch ppc64 -arch i386 -arch x86_64
CFLAGS += -I/sw/include -DMACOSX -DUNIX -Dunix -DDL_OPEN -arch $(ARCH)
LDFLAGS += -bundle -bundle_loader $(PD_BIN)/bin/pd -undefined dynamic_lookup \
-L/sw/lib -weak_framework Carbon -arch $(ARCH)
LIBS += -lc
DYLIB_LDFLAGS = -dynamiclib -undefined dynamic_lookup -read_only_relocs warning -L/sw/lib
STRIP = strip -x
endif
ifeq ($(OS_NAME),linux)
CFLAGS += -DUNIX -Dunix -DDL_OPEN -fPIC
LDFLAGS += -Wl,--export-dynamic -shared -fPIC
LIBS += -lc
DYLIB_LDFLAGS = $(LDFLAGS)
STRIP = strip --strip-unneeded -R .note -R .comment
endif
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 += -s -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)/src -L$(PD_SRC)/bin -L$(PD_SRC)/obj -lpd \
-lwsock32 -liphlpapi -lpthreadGC2 -lkernel32 -luser32 -lgdi32 -lregex
DYLIB_LDFLAGS = -shared
STRIP = strip --strip-unneeded -R .note -R .comment
endif
CXXFLAGS = $(CFLAGS)
### C++ files
%.$(EXTENSION): %.cpp
%.$(EXTENSION): %.cc
$(CXX) $(OPT_CFLAGS) $(CXXFLAGS) -o "$*.o" -c "$<"
$(CXX) $(LDFLAGS) -o "$*.$(EXTENSION)" "$*.o" $(LIBS)
chmod a-x "$*.$(EXTENSION)"
# $(STRIP) $*.$(EXTENSION)
# rm -f -- $*.o
mv $*.$(EXTENSION) $(OUTPUT)
%.o: %.cpp
%.o: %.cc
$(CXX) $(OPT_CFLAGS) $(CXXFLAGS) -o "$*.o" -c "$<"
### C files
%.o: %.c
$(CC) $(OPT_CFLAGS) $(CFLAGS) -o "$*.o" -c "$*.c"
%.$(EXTENSION): %.o
$(CC) $(LDFLAGS) -o "$*.$(EXTENSION)" "$*.o" $(LIBS) \
`test -f $*.libs && cat $*.libs` \
`my_dylib=$(patsubst $(externals_src)/%,%,$(@D)); test -f $(@D)/lib$${my_dylib}.$(DYLIB_EXTENSION) && echo -L$(@D) -l$$my_dylib` \
`my_obj=$(patsubst $(externals_src)/%,%,$(@D)); test -f $(@D)/shared/$${my_obj}.o && echo $(@D)/shared/$${my_obj}.o` \
`test -f $(dir $*)../$(BUILDSRC_OS_NAME)/$(notdir $*).libs && \
cat $(dir $*)../$(BUILDSRC_OS_NAME)/$(notdir $*).libs`
chmod a-x "$*.$(EXTENSION)"
$(STRIP) $*.$(EXTENSION)
rm -f -- $*.o
mv $*.$(EXTENSION) $(OUTPUT)
Plus d'informations sur la liste de diffusion Pdmtl