current: all

PD_DEFINES = -DPD -DUNIX

#################################
# path to private Pd-headers 
PDSOURCE ?= /usr/local/src/pd/src

# path to iemlib.h
IEMLIB_INCLUDE = ../../include

#define to true if private Pd-header g_canvas.h is in out search-path
PD_DEFINES += -DHAVE_G_CANVAS_H 
#################################


.SUFFIXES: .pd_linux

EXT = pd_linux

STRIP = strip

PD_LDFLAGS = --export-dynamic -shared $(LD_FLAGS)
PD_LIB = -lm -lc $(LIB)

#select either the DBG and OPT compiler flags below:

DBG_CFLAGS=-W -Wno-parentheses -Wno-switch -Wno-unused
CFLAGS=-g -O6 -funroll-loops -fomit-frame-pointer -fno-strict-aliasing
PD_CFLAGS = $(PD_DEFINES) -fPIC -fno-stack-protector $(DBG_CFLAGS) $(CFLAGS)

PD_INCLUDES = -I. -I$(IEMLIB_INCLUDE) -I$(PDSOURCE) -I../../../../pd/src

# the sources
#SRC = $(sort $(filter %.c, $(wildcard *.c)))
	
OBJ = $(SRC:.c=.o) 

#
#  ------------------ targets ------------------------------------
#

clean:
	-rm -f ../../lib/$(TARGET).$(EXT) $(TARGET).$(EXT)
	-rm -f *.o

all: $(TARGET).$(EXT)
	-cp $< ../../lib/
	$(STRIP) --strip-unneeded ../../lib/$<

.PHONY: current clean all

$(TARGET).$(EXT): $(OBJ)
	@echo :: $^
	$(LD) $(PD_LDFLAGS) -o $@ $^ $(PD_LIB)

%.o : %.c
	$(CC) $(PD_CFLAGS) $(PD_INCLUDES) -c -o $@ $<

%.$(EXT): %.o
	$(LD) $(PD_LDFLAGS) -o $@ $^ $(PD_LIB)