Box2D Forums

It is currently Sat May 18, 2013 8:25 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 28 posts ]  Go to page Previous  1, 2, 3
Author Message
PostPosted: Wed Feb 25, 2009 9:05 am 
Offline

Joined: Fri May 16, 2008 10:09 am
Posts: 337
Hi, I may come across sounding a little ignorant, please forgive me.

The way that I have been maintaining my code so far is by simply including the Box2D source code in my project's source. It works just fine on both linux and windows (I use both platforms more or less equally to do my development -- using mingw with eclipse cdt in windows), and every time I checkout the box2d svn and look at the stuff in there (especially those makefiles --- god!) I wonder if there is a simpler way to do whatever it is that those makefiles are accomplishing.

That wasn't quite so much a question as an observation, but I do have a legitimate question. What exactly do the branches, tags, and trunk versions mean? I understand that some of them are more up-to-date than others and some would be more bug-free... but which is which? I periodically update the source in my project with the source from the box2d repository. Which one of these folders should I grab it from?


Top
 Profile  
 
PostPosted: Wed Feb 25, 2009 10:07 am 
Offline

Joined: Sun Feb 08, 2009 1:57 pm
Posts: 34
dc443 wrote:
That wasn't quite so much a question as an observation, but I do have a legitimate question. What exactly do the branches, tags, and trunk versions mean? I understand that some of them are more up-to-date than others and some would be more bug-free... but which is which? I periodically update the source in my project with the source from the box2d repository. Which one of these folders should I grab it from?


the 'trunk' directory is the original code, while the 'branches/groundzero' currently contains the code which has been modified by me according the discussion that has been held on the previous two pages.

so if you use the 'trunk' directory, it will work the same as the old root.


Top
 Profile  
 
PostPosted: Thu Feb 26, 2009 5:37 pm 
Offline

Joined: Wed Feb 25, 2009 6:48 pm
Posts: 5
udoprog wrote:
Update: Branch is now in svn, check it out with:
Code:
svn co https://box2d.svn.sourceforge.net/svnroot/branches/groundzero groundzero


I think this should be:
Code:
svn co https://box2d.svn.sourceforge.net/svnroot/box2d/branches/groundzero groundzero


Top
 Profile  
 
PostPosted: Thu Feb 26, 2009 5:47 pm 
Offline

Joined: Wed Feb 25, 2009 6:48 pm
Posts: 5
Great stuff! I checked it out, ran make, it built.

The only thing that didn't work was running the examples without a 'make install'. This is the only change I made to achieve that for myself:

Code:
Index: Build/gnumake/Makefile.TestBed
===================================================================
--- Build/gnumake/Makefile.TestBed   (revision 203)
+++ Build/gnumake/Makefile.TestBed   (working copy)
@@ -15,7 +15,7 @@
 LDFLAGS+=-lglut
 LDFLAGS+=-lGL
 LDFLAGS+=-lGLU
-LDFLAGS+=-lbox2d
+LDFLAGS+=${ROOT}/Box2D/build/libbox2d.a
 
 SOURCES=Source/Main.c
 SOURCES+=Source/Test.c


There might be a better/preferable way.


Top
 Profile  
 
PostPosted: Fri Feb 27, 2009 1:01 am 
Offline

Joined: Wed Jan 02, 2008 3:19 am
Posts: 67
I agree with blue_puyo fix above. We should not require someone to "install" the libraries or the include files in order to build the testbed. By doing so one forestalls development on the box2d source. Remember that some people USE box2d and others DEVELOP box2d and the makefiles should be designed for both audiences, not just the users.


Top
 Profile  
 
PostPosted: Fri Feb 27, 2009 1:45 am 
Offline

Joined: Sun Feb 08, 2009 1:57 pm
Posts: 34
That is correct, libbox2d was always installed on my system so I overlooked this issue.

Good fix! Thank you for pointing this out!

Also notice that there is no install target yet.


Edit: I am suggesting the following (hopefully temporary) install target for gnu make:
Code:
PREFIX?=/usr/local
INSTALL_HEADERS=find Box2D -path .svn -prune -o -name *.h
INSTALL_LIBRARIES=Box2D/build/libbox2d.a Box2D/build/libbox2d.so

... other targets ...

install:
  @for file in $$(${INSTALL_HEADERS}); do\
    echo "Installing: $$file";\
    echo "        to: $(PREFIX)/include/$$file";\
    mkdir -p $$(dirname $(PREFIX)/include/$$file);\
    test $$? -ne 0 && exit $$?;\
    install $$file $(PREFIX)/include/$$file;\
    test $$? -ne 0 && exit $$?;\
  done
 
  @for file in ${INSTALL_LIBRARIES}; do\
    echo "Installing: $$file";\
    echo "        to: $(PREFIX)/lib/$$(basename $$file)";\
    install $$file $(PREFIX)/lib/$$(basename $$file);\
    test $$? -ne 0 && exit $$?;\
  done


This will by default allow people to install the library in /usr/local by default, or specified target prefix by running:

Code:
PREFIX=/usr make install


And this is where the wrinkles of 'make' starts to shine through, there is no easy way to make sure that one of the target has been built, therefore the developer or packager has to make certain that the libraries listed in INSTALL_LIBRARIES exist.

By using mkdir and 'install' it will produce very sensible errors. mkdir will early trigger permission errors (which is also true for install), and install will explain that the source file does not exist.


Top
 Profile  
 
PostPosted: Thu Jul 02, 2009 4:37 am 
Offline

Joined: Wed Feb 25, 2009 6:48 pm
Posts: 5
bump?

Also: Do you want somebody to Ubuntu package it? I was thinking of learning how to do it, anyway.


Top
 Profile  
 
PostPosted: Thu Jul 02, 2009 5:45 am 
Offline

Joined: Wed Feb 25, 2009 6:48 pm
Posts: 5
Based on your one but I made it compile the libs if they're not already compiled, and symlink the .so file... and an uninstall target. I don't really know how unix-portable it is. Works On My Machine (TM) (Ubuntu jaunty).

Code:
Index: Build/gnumake/Makefile.box2d
===================================================================
--- Build/gnumake/Makefile.box2d   (revision 220)
+++ Build/gnumake/Makefile.box2d   (working copy)
@@ -1,6 +1,5 @@
 ROOT=.
 PACKAGE=${ROOT}/Box2D
-INSTALL_DIR=/usr/local
 TARGET=${PACKAGE}/build/libbox2d
 
 DEFINES=
Index: Makefile
===================================================================
--- Makefile   (revision 220)
+++ Makefile   (working copy)
@@ -1,4 +1,10 @@
-all: box2d glut glui testbed
+PREFIX?=/usr/local
+INSTALL_HEADERS=$(shell find Box2D -path .svn -prune -o -name *.h)
+INSTALL_LIBRARIES=Box2D/build/libbox2d.a Box2D/build/libbox2d.so
+VERSION_MAJOR = 2
+VERSION_MINOR = 0
+VERSION_REVISION = 1
+VERSION = $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_REVISION)
 
 box2d:
    make -f Build/gnumake/Makefile.box2d all
@@ -77,3 +83,35 @@
 #   - diff --unified /dev/null Source/Contrib/b2Polygon.h >> $(PATCH)
 #   - diff --unified /dev/null Source/Contrib/b2Triangle.cpp >> $(PATCH)
 #   - diff --unified /dev/null Source/Contrib/b2Triangle.h >> $(PATCH)
+
+$(INSTALL_LIBRARIES):
+   @$(MAKE) -f Build/gnumake/Makefile.box2d $@
+
+install: install-headers install-libs
+
+install-headers: $(INSTALL_HEADERS)
+   install -m 755 -d $(PREFIX)/include/Box2D
+   @for file in ${INSTALL_HEADERS}; do\
+      dir=$$(dirname $(PREFIX)/include/$$file);\
+      if test ! -d $$dir; then\
+         echo install -d 755 $$dir;\
+         install -d 755 $$dir;\
+      fi;\
+      ifile=$(PREFIX)/include/$$file;\
+      echo install -m 644 $$file $$ifile;\
+      install -m 644 $$file $$ifile;\
+   done
+
+install-libs: $(INSTALL_LIBRARIES)
+   install -m 644 Box2D/build/libbox2d.a $(PREFIX)/lib/libbox2d.a
+   install -m 644 Box2D/build/libbox2d.so $(PREFIX)/lib/libbox2d.so.$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_REVISION)
+   ln -sf $(PREFIX)/lib/libbox2d.so.$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_REVISION) $(PREFIX)/lib/libbox2d.so.$(VERSION_MAJOR)
+   ln -sf $(PREFIX)/lib/libbox2d.so.$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_REVISION) $(PREFIX)/lib/libbox2d.so
+
+uninstall: uninstall-headers uninstall-libs
+
+uninstall-headers:
+   $(RM) -r $(PREFIX)/include/Box2D
+
+uninstall-libs:
+   $(RM) -r $(PREFIX)/lib/libbox2d.*


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 28 posts ]  Go to page Previous  1, 2, 3

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group