Updated Makefile for libbulletml

Ivy Foster code at escondida.tk
Thu Feb 1 23:32:38 UTC 2018


Hi, guys,

Thanks for your work on...well, quite a few packages. While building
libbulletml, I noticed that it has some trouble properly picking up
some CFLAGS and LDFLAGS, and that in order to use -fPIC -fpic, it's
necesary to rebuild object files with them explicitly passed on the
command line.

Well, one thing led to another and I wound up basically rewriting the
whole Makefile. Some notable changes from the one resulting from your
makefile patch:

- Removes commented variables
- Allows the user to set their own CXXFLAGS and LDFLAGS without
  clobbering anything important
- Each real target *only* creates the file(s) it promises to create
- Use VPATH to build tinyxml stuff rather than fiddling with the
  tinyxml Makefile, too
- clean cleans everything
- simplified some invocations, like the yacc call for calc.cpp
- Use -fPIC -fpic
- Add install target for ease of use, complete with option to specify
  prefix, libdir and includedir
- Add .PHONY for the various phony targets

If this is helpful to you, I donate it unreservedly to the cause.
Share and enjoy.

Thanks,
Ivy

Makefile:

INCLUDES = -I. -I../d_cpp
CXXFLAGS ?= -O2 -W -Wall -ansi -pedantic
CXXFLAGS += -ansi
CFLAGS ?= -O2
prefix ?= /usr/local
VDIR = tinyxml

includedir ?= $(prefix)/include
libdir ?= $(prefix)/lib

MAJOR=0d2
MINOR=0

VPATH=.:tinyxml
OBJS = bulletmlparser-tinyxml.o bulletmlparser.o bulletmltree.o calc.o \
	formula-variables.o bulletmlrunner.o bulletmlrunnerimpl.o
TINYXML = tinyxml.o tinyxmlerror.o tinyxmlparser.o

all:  bulletml.d libbulletml.a libbulletml.so.$(MAJOR).$(MINOR)

libbulletml.a: $(OBJS) $(TINYXML)
	$(AR) cru $@ $^

libbulletml.so.$(MAJOR).$(MINOR): $(OBJS) $(TINYXML)
	$(CXX) $(CXXFLAGS) $(LDFLAGS) -shared -fPIC -fpic \
		-Wl,-soname,libbulletml.so.$(MAJOR) \
		-o $@ $^

bulletml.d: bulletml_d.cpp
	perl ../d_cpp/create_d_import.pl bulletml_d.cpp bulletml.d

clean:
	rm -f calc.cpp libbulletml.a libbulletml.so.$(MAJOR).$(MINOR) *.o tinyxml/*.o

calc.cpp: calc.yy
		bison -y calc.yy -o calc.cpp

$(OBJS) $(TINYXML): %.o: %.cpp
	$(CXX) -c $(CXXFLAGS) -fPIC -fpic $(INCLUDES) $<

doxy:
	doxygen

install: all
	install -D -m 644 bulletml.d $(DESTDIR)/$(includedir)/d/bulletml.d
	install -D -m 644 tinyxml/tinyxml.h \
		$(DESTDIR)/$(includedir)/bulletml/tinyxml/tinyxml.h
	install -m 644 *.h $(DESTDIR)/$(includedir)/bulletml
	install -d $(DESTDIR)/$(libdir)
	install -m 644 libbulletml.a $(DESTDIR)/$(libdir)
	install -m 644 libbulletml.so.$(MAJOR).$(MINOR) $(DESTDIR)/$(libdir)
	ln -f -r -s \
		$(DESTDIR)/$(libdir)/libbulletml.so.$(MAJOR).$(MINOR) \
		$(DESTDIR)/$(libdir)/libbulletml.so.$(MAJOR)
	ln -f -r -s \
		$(DESTDIR)/$(libdir)/libbulletml.so.$(MAJOR).$(MINOR) \
		$(DESTDIR)/$(libdir)/libbulletml.so

.PHONY: all clean doxy install



More information about the Pkg-games-devel mailing list