-prefix = /usr/local
-bindir = $(prefix)/bin
-mandir = $(prefix)/share/man
-libdir = $(prefix)/lib
-includedir = $(prefix)/include
-pkgconfigdir = $(libdir)/pkgconfig
-PTB_VERSION=0.3
-PROGS = ptb2ly ptb2ascii ptbinfo $(shell pkg-config --exists libxml-2.0 libxslt && echo ptb2xml)
-LIBS = libptb-$(PTB_VERSION).so
-PROGS_MANPAGES = $(patsubst %,%.1,$(PROGS))
-INSTALL = install
-CFLAGS = -g -Wall -DPTB_VERSION=\"$(PTB_VERSION)\"
-
-PTB2LY_OBJS = ptb2ly.o ptb.o
-PTBINFO_OBJS = ptbinfo.o ptb.o
-PTB2ASCII_OBJS = ptb2ascii.o ptb.o
-PTB2XML_OBJS = ptb2xml.o ptb.o
-PTBSO_OBJS = ptb.o
-
-all: $(PROGS) $(LIBS)
+-include Makefile.settings
+
+SOVERSION = 0
+
+PTBLIB_OBJS = ptb.o gp.o ptb-tuning.o
+TARGETS = $(TARGET_BINS) $(TARGET_LIBS)
+
+all: $(TARGETS)
+
+tests/check: tests/check.o tests/ptb.o tests/gp.o ptb.o
+ $(CC) $(FLAGS) $^ -o $@ $(CHECK_LIBS)
ptb2xml.o: ptb2xml.c
- $(CC) $(CFLAGS) -c $< `pkg-config --cflags glib-2.0 libxml-2.0 libxslt`
+ $(CC) $(CFLAGS) -c $< $(LIBXSLT_CFLAGS) $(LIBXML_CFLAGS) $(XSLT_DEFINE)
%.o: %.c
- $(CC) $(CFLAGS) -c $< `pkg-config --cflags glib-2.0`
+ $(CC) $(CFLAGS) -c $< -o $@
+
+%.po: %.c
+ $(CC) $(CFLAGS) -fPIC -c $< -o $@
-libptb-$(PTB_VERSION).so: $(PTBSO_OBJS)
- $(CC) -shared $(CFLAGS) -o $@ $(PTBSO_OBJS) `pkg-config --libs glib-2.0`
+ptb.dll: $(PTBLIB_OBJS)
+ $(CC) $(SHFLAGS) $(CFLAGS) -Wl,--out-implib=ptb.dll.a -o $@ $^
-ptb2xml: $(PTB2XML_OBJS)
- $(CC) $(CFLAGS) -o $@ $(PTB2XML_OBJS) `pkg-config --libs glib-2.0 libxml-2.0 libxslt` -lpopt
+libptb.so.$(VERSION): $(PTBLIB_OBJS:.o=.po)
+ $(CC) $(SHFLAGS) -Wl,-soname,libptb.so.$(SOVERSION) $(CFLAGS) -o $@ $^
+
+libptb.a: $(PTBLIB_OBJS)
+ $(AR) rs $@ $^
+
+ptb2xml$(EXEEXT): ptb2xml.o ptb.o
+ $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) $(LIBXML_LIBS) $(LIBXSLT_LIBS) $(POPT_LIBS)
-ptb2ascii: $(PTB2ASCII_OBJS)
- $(CC) $(CFLAGS) -o $@ $(PTB2ASCII_OBJS) `pkg-config --libs glib-2.0` -lpopt
+ptb2ascii$(EXEEXT): ptb2ascii.o ptb.o
+ $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) $(POPT_LIBS)
+
+ptb2ptb$(EXEEXT): ptb2ptb.o ptb.o
+ $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) $(POPT_LIBS)
+
+ptb2ly$(EXEEXT): ptb2ly.o ptb.o
+ $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) $(POPT_LIBS)
+
+ptb2abc$(EXEEXT): ptb2abc.o ptb.o
+ $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) $(POPT_LIBS)
-ptb2ly: $(PTB2LY_OBJS)
- $(CC) $(CFLAGS) -o $@ $(PTB2LY_OBJS) `pkg-config --libs glib-2.0` -lpopt
+gp2ly$(EXEEXT): gp2ly.o gp.o
+ $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) $(POPT_LIBS)
-ptbinfo: $(PTBINFO_OBJS)
- $(CC) $(CFLAGS) -o $@ $(PTBINFO_OBJS) `pkg-config --libs glib-2.0` -lpopt
+ptbinfo$(EXEEXT): ptbinfo.o ptb.o
+ $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) $(POPT_LIBS)
+ptbdict$(EXEEXT): ptbdict.o ptb.o ptb-tuning.o
+ $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) $(POPT_LIBS)
+
install: all
- $(INSTALL) $(PROGS) $(DESTDIR)$(bindir)
+ $(INSTALL) -d $(DESTDIR)$(bindir)
+ test -z "$(TARGET_BINS)" || $(INSTALL) $(TARGET_BINS) $(DESTDIR)$(bindir)
+ $(INSTALL) -d $(DESTDIR)$(mandir)/man1
$(INSTALL) -m 644 $(PROGS_MANPAGES) $(DESTDIR)$(mandir)/man1
- $(INSTALL) $(LIBS) $(DESTDIR)$(libdir)
+ $(INSTALL) -d $(DESTDIR)$(libdir)
+ test -z "$(TARGET_LIBS)" || $(INSTALL) -m 644 $(TARGET_LIBS) $(DESTDIR)$(libdir)
+ $(INSTALL) -d $(DESTDIR)$(includedir)
$(INSTALL) -m 644 ptb.h $(DESTDIR)$(includedir)
+ $(INSTALL) -m 644 gp.h $(DESTDIR)$(includedir)
+ $(INSTALL) -d $(DESTDIR)$(pkgconfigdir)
$(INSTALL) -m 644 ptabtools.pc $(DESTDIR)$(pkgconfigdir)
+ $(INSTALL) -d $(DESTDIR)$(datadir)
+ $(INSTALL) -m 644 ptbxml2musicxml.xsl $(DESTDIR)$(datadir)
+ $(INSTALL) -m 644 ptbxml.dtd $(DESTDIR)$(datadir)
+
+test: all ptb2ptb
+ $(MAKE) -C tests
-tags: *.c *.h
+tags: $(wildcard *.c) $(wildcard *.h)
ctags *.c *.h
+check:: tests/check
+ ./tests/check
+
+configure: configure.in
+ autoreconf -f
+
+config.status: configure
+ ./configure
+
+Makefile.settings: config.status
+ ./config.status
+
clean:
- rm -f *.o core $(PROGS) $(LIBS)
+ rm -f *.o core $(TARGETS) *.po
+ rm -f tests/check tests/*.o
+
+distclean: clean
+ rm -f Makefile.settings config.h config.log
+ rm -f *~ ptabtools.spec ptabtools.pc
+ rm -f tags config.status aclocal.m4
+ rm -rf autom4te.cache/
+
+realclean: distclean
+ rm -f configure
+
+ctags:
+ ctags -R .