Fix install mechanism
[jelmer/ptabtools.git] / Makefile
1 prefix = /usr/local
2 bindir = $(prefix)/bin
3 mandir = $(prefix)/share/man
4 libdir = $(prefix)/lib
5 includedir = $(prefix)/include
6 pkgconfigdir = $(libdir)/pkgconfig
7 PTB_VERSION=0.2
8 PROGS = ptb2ly ptb2ascii $(shell pkg-config --exists libxml-2.0 && echo ptb2xml ptb2musicxml)
9 LIBS = libptb-$(PTB_VERSION).so 
10 PROGS_MANPAGES = $(patsubst %,%.1,$(PROGS))
11 INSTALL = install
12 CFLAGS = -g -Wall -DPTB_VERSION=\"$(PTB_VERSION)\" 
13
14 PTB2LY_OBJS = ptb2ly.o ptb.o
15 PTB2ASCII_OBJS = ptb2ascii.o ptb.o
16 PTB2MUSICXML_OBJS = ptb2musicxml.o ptb.o
17 PTB2XML_OBJS = ptb2xml.o ptb.o
18 PTBSO_OBJS = ptb.o
19
20 all: $(PROGS) $(LIBS)
21
22 ptb2xml.o: ptb2xml.c
23         $(CC) $(CFLAGS) -c $< `pkg-config --cflags glib-2.0 libxml-2.0`
24
25 ptb2musicxml.o: ptb2musicxml.c
26         $(CC) $(CFLAGS) -c $< `pkg-config --cflags glib-2.0 libxml-2.0`
27
28 %.o: %.c
29         $(CC) $(CFLAGS) -c $< `pkg-config --cflags glib-2.0`
30
31 libptb-$(PTB_VERSION).so: $(PTBSO_OBJS)
32         $(CC) -shared $(CFLAGS) -o $@ $(PTBSO_OBJS) `pkg-config --libs glib-2.0`
33
34 ptb2xml: $(PTB2XML_OBJS)
35         $(CC) $(CFLAGS) -o $@ $(PTB2XML_OBJS) `pkg-config --libs glib-2.0 libxml-2.0` -lpopt
36         
37 ptb2musicxml: $(PTB2MUSICXML_OBJS)
38         $(CC) $(CFLAGS) -o $@ $(PTB2MUSICXML_OBJS) `pkg-config --libs glib-2.0 libxml-2.0` -lpopt
39
40 ptb2ascii: $(PTB2ASCII_OBJS)
41         $(CC) $(CFLAGS) -o $@ $(PTB2ASCII_OBJS) `pkg-config --libs glib-2.0` -lpopt
42
43 ptb2ly: $(PTB2LY_OBJS)
44         $(CC) $(CFLAGS) -o $@ $(PTB2LY_OBJS) `pkg-config --libs glib-2.0` -lpopt
45
46 install: all
47         $(INSTALL) $(PROGS) $(DESTDIR)$(bindir)
48         $(INSTALL) -m 644 $(PROGS_MANPAGES) $(DESTDIR)$(mandir)/man1
49         $(INSTALL) $(LIBS) $(DESTDIR)$(libdir)
50         $(INSTALL) -m 644 ptb.h $(DESTDIR)$(includedir)
51         $(INSTALL) -m 644 ptabtools.pc $(DESTDIR)$(pkgconfigdir)
52
53 tags: *.c *.h
54         ctags *.c *.h
55
56 clean: 
57         rm -f *.o core $(PROGS) $(LIBS)