view examples/calculator/Makefile @ 175:67e13d694230

Fix bug of src/Makefile.am & examples accept PREFIX variable. - src/Makefile.am install header files into $(prefix)/include/mb instead of $(prefix)/include original. - examples find headers, M4 macro files, and tools with PREFIX varaible. - default value of PREFIX is /usr/local. - user can change PREFIX with paramter of make command, for example 'make PREFIX=../../build/dest', if MadButterfly was installed there. - Users can install MadButterfly in their specified directory, for example, './configure --prefix=${PWD}/dest', the binary will installed in dest/.
author Thinker K.F. Li <thinker@branda.to>
date Fri, 31 Oct 2008 15:15:44 +0800
parents 5535899513ce
children
line wrap: on
line source

SVG=calculator_scr.svg
PREFIX?=/usr/local
INCDIR?=$(PREFIX)/include
LIBDIR?=$(PREFIX)/lib
TOOLSDIR?=$(PREFIX)/share/mb
BINDIR?=$(PREFIX)/bin
INCS=-I$(INCDIR)
CFLAGS+=$(INCS) `pkg-config --cflags cairo` -Wall
LDFLAGS=-L$(LIBDIR) `pkg-config --libs cairo`
LIBS=-lmbfly
BINS=	calc
SVG2CODE=	$(BINDIR)/svg2code.py
MB_C_HEADER=    $(TOOLSDIR)/mb_c_header.m4
MB_C_SOURCE=    $(TOOLSDIR)/mb_c_source.m4

all:	$(BINS)

calc:	main.o $(SVG:C/.svg/.o/)
	$(CC) $(LDFLAGS) -o $@ $(.ALLSRC) $(LIBS)

main.o:	main.c $(SVG:C/.svg/.h/)
	$(CC) $(CFLAGS) -c -o $@ main.c

$(SVG:C/.svg/.o/): $(SVG:C/.svg/.c/) $(SVG:C/.svg/.h/)
	$(CC) -c $(CFLAGS) -o $@ $(SVG:C/.svg/.c/)

$(SVG:C/.svg/.mb/): $(SVG)
	$(SVG2CODE) $(.ALLSRC) $@

$(SVG:C/.svg/.c/): $(SVG:C/.svg/.mb/)
	m4 -I $(TOOLSDIR) $(MB_C_SOURCE) $(.ALLSRC) > $@

$(SVG:C/.svg/.h/): $(SVG:C/.svg/.mb/)
	m4 -I $(TOOLSDIR) $(MB_C_HEADER) $(.ALLSRC) > $@

clean:
	for i in *.mb *.o *.core *~ $(SVG:C/.svg/.c/) $(SVG:C/.svg/.h/) $(BINS); do \
		if [ -e "$$i" ]; then \
			echo "delete $$i"; \
			rm -f "$$i"; \
		fi; \
	done