aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2010-08-21 19:18:31 +0000
committerIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2010-08-21 19:18:31 +0000
commit56d210d14ad3997d563904fd535b1da8c223d546 (patch)
tree6e2148e151907794d1f42155e1a731b2d7f23af1 /Makefile
parentef58f9caaa803c1d42b8c5b9b6e0a208968478ac (diff)
cleaned up Makefile
- use $@, $^ and $< rather than reexpanding manually - added SOURCES_LIB for sources that provide shared functions but no object - removed SOURCES_android as there is no android support yet - use HELPPATCHES to enumerate -help.pd; is usually generated but can be forced to user defined values svn path=/trunk/externals/template/; revision=13880
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile52
1 files changed, 28 insertions, 24 deletions
diff --git a/Makefile b/Makefile
index 732f676..0c5ea72 100644
--- a/Makefile
+++ b/Makefile
@@ -3,19 +3,22 @@
# http://puredata.info/docs/developer/MakefileTemplate
LIBRARY_NAME = template
-# add your .c source files to the SOURCES variable, help files will be
+# add your .c source files (one object per file) to the SOURCES variable, help files will be
# included automatically
SOURCES = mycobject.c
# For objects that only build on certain platforms, add those to the SOURCES
# line for the right platforms.
-SOURCES_android =
SOURCES_cygwin =
SOURCES_macosx =
SOURCES_iphoneos =
SOURCES_linux =
SOURCES_windows =
+# extra .c files that do not relate to a Pd object class
+# (common functionality - static library)
+SOURCES_LIB =
+
# list all pd objects (i.e. myobject.pd) files here, and their helpfiles will
# be included automatically
PDOBJECTS = mypdobject.pd
@@ -59,15 +62,15 @@ INSTALL_DIR = $(INSTALL) -p -m 755 -d
CFLAGS = -DPD -I$(PD_PATH)/src -Wall -W -g
LDFLAGS =
LIBS =
-ALLSOURCES := $(SOURCES) $(SOURCES_android) $(SOURCES_cygwin) $(SOURCES_macosx) \
+ALLSOURCES := $(SOURCES) $(SOURCES_LIB) $(SOURCES_android) $(SOURCES_cygwin) $(SOURCES_macosx) \
$(SOURCES_iphoneos) $(SOURCES_linux) $(SOURCES_windows)
DISTDIR=$(LIBRARY_NAME)-$(LIBRARY_VERSION)
ORIGDIR=pd-$(LIBRARY_NAME)_$(LIBRARY_VERSION)
UNAME := $(shell uname -s)
+CPU := $(shell uname -p)
ifeq ($(UNAME),Darwin)
- CPU := $(shell uname -p)
ifeq ($(CPU),arm) # iPhone/iPod Touch
SOURCES += $(SOURCES_iphoneos)
EXTENSION = pd_darwin
@@ -143,24 +146,30 @@ ifeq (MINGW,$(findstring MINGW,$(UNAME)))
DISTBINDIR=$(DISTDIR)-$(OS)
endif
+# in case somebody manually set the HELPPATCHES above
+HELPPATCHES ?= $(SOURCES:.c=-help.pd) $(PDOBJECTS:.c=-help.pd)
+
CFLAGS += $(OPT_CFLAGS)
-.PHONY = install libdir_install single_install install-doc install-exec install-examples install-manual clean dist etags
+.PHONY = install libdir_install single_install install-doc install-exec install-examples install-manual clean dist etags $(LIBRARY_NAME)
all: $(SOURCES:.c=.$(EXTENSION))
%.o: %.c
- $(CC) $(CFLAGS) -o "$*.o" -c "$*.c"
+ $(CC) $(CFLAGS) -o "$@" -c "$<"
-%.$(EXTENSION): %.o
- $(CC) $(LDFLAGS) -o "$*.$(EXTENSION)" "$*.o" $(LIBS)
- chmod a-x "$*.$(EXTENSION)"
+%.$(EXTENSION): %.o $(SOURCES_LIB:.c=.o)
+ $(CC) $(LDFLAGS) -o "$@" $^ $(LIBS)
+ chmod a-x "$@"
# this links everything into a single binary file
-$(LIBRARY_NAME): $(SOURCES:.c=.o) $(LIBRARY_NAME).o
- $(CC) $(LDFLAGS) -o $(LIBRARY_NAME).$(EXTENSION) $(SOURCES:.c=.o) $(LIBRARY_NAME).o $(LIBS)
- chmod a-x $(LIBRARY_NAME).$(EXTENSION)
+$(LIBRARY_NAME).$(EXTENSION): $(SOURCES:.c=.o) $(SOURCES_LIB:.c=.o) $(LIBRARY_NAME).o
+ $(CC) $(LDFLAGS) -o "$@" $^ $(LIBS)
+ chmod a-x $@
+
+$(LIBRARY_NAME): $(LIBRARY_NAME).$(EXTENSION)
+ @echo "finished building $@"
install: libdir_install
@@ -186,11 +195,8 @@ single_install: $(LIBRARY_NAME) install-doc install-exec
install-doc:
$(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
- test -z "$(strip $(SOURCES))" || \
- $(INSTALL_FILE) $(SOURCES:.c=-help.pd) \
- $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
- test -z "$(strip $(PDOBJECTS))" || \
- $(INSTALL_FILE) $(PDOBJECTS:.pd=-help.pd) \
+ test -z "$(strip $(SOURCES) $(PDOBJECTS))" || \
+ $(INSTALL_FILE) $(HELPPATCHES) \
$(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
$(INSTALL_FILE) README.txt $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/README.txt
$(INSTALL_FILE) LICENSE.txt $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/LICENSE.txt
@@ -211,7 +217,7 @@ install-manual:
clean:
- -rm -f -- $(SOURCES:.c=.o)
+ -rm -f -- $(SOURCES:.c=.o) $(SOURCES_LIB:.c=.o)
-rm -f -- $(SOURCES:.c=.$(EXTENSION))
-rm -f -- $(LIBRARY_NAME).o
-rm -f -- $(LIBRARY_NAME).$(EXTENSION)
@@ -231,7 +237,7 @@ $(DISTBINDIR):
libdir: all $(DISTBINDIR)
$(INSTALL_FILE) $(LIBRARY_NAME)-meta.pd $(DISTBINDIR)
$(INSTALL_FILE) $(SOURCES) $(DISTBINDIR)
- $(INSTALL_FILE) $(SOURCES:.c=-help.pd) $(DISTBINDIR)
+ $(INSTALL_FILE) $(HELPPATCHES) $(DISTBINDIR)
test -z "$(strip $(EXTRA_DIST))" || \
$(INSTALL_FILE) $(EXTRA_DIST) $(DISTBINDIR)
# tar --exclude-vcs -czpf $(DISTBINDIR).tar.gz $(DISTBINDIR)
@@ -249,12 +255,10 @@ dist: $(DISTDIR)
$(INSTALL_FILE) $(LIBRARY_NAME)-meta.pd $(DISTDIR)
test -z "$(strip $(ALLSOURCES))" || \
$(INSTALL_FILE) $(ALLSOURCES) $(DISTDIR)
- test -z "$(strip $(ALLSOURCES))" || \
- $(INSTALL_FILE) $(ALLSOURCES:.c=-help.pd) $(DISTDIR)
test -z "$(strip $(PDOBJECTS))" || \
$(INSTALL_FILE) $(PDOBJECTS) $(DISTDIR)
- test -z "$(strip $(PDOBJECTS))" || \
- $(INSTALL_FILE) $(PDOBJECTS:.pd=-help.pd) $(DISTDIR)
+ test -z "$(strip $(HELPPATCHES))" || \
+ $(INSTALL_FILE) $(HELPPATCHES) $(DISTDIR)
test -z "$(strip $(EXTRA_DIST))" || \
$(INSTALL_FILE) $(EXTRA_DIST) $(DISTDIR)
test -z "$(strip $(EXAMPLES))" || \
@@ -280,7 +284,7 @@ dpkg-source:
cd .. && dpkg-source -b $(LIBRARY_NAME)
etags:
- etags *.h $(SOURCES) ../../pd/src/*.[ch] /usr/include/*.h /usr/include/*/*.h
+ etags *.h $(SOURCES) $(SOURCES_LIB) ../../pd/src/*.[ch] /usr/include/*.h /usr/include/*/*.h
showsetup:
@echo "PD_PATH: $(PD_PATH)"