diff options
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 52 |
1 files changed, 28 insertions, 24 deletions
@@ -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)" |