Source: boulder-game
Version: 1.02+ds-1
Tags: patch upstream
User: [email protected]
Usertags: ftcbfs

boulder-game fails to cross build from source for two distinct reasons.

The immediate failure arises from hard coding the build architecture 
pkg-config in the upstream Makefile. The result is that a package cannot 
be found and the missing flags result in an #include not being found. 
Once making pkg-config substitutable, dh_auto_build is able to supply a 
host architecture one.

The other failure arises from storing g++ in CC. The CC variable is 
typically used for the C compiler, so dh_auto_build overrides it with a 
C cross compiler. That doesn't go well when the actual source is C++. 
Renaming the variable to CXX - the common variable for a C++ compiler - 
fixes this aspect.

I'm attaching a patch for your convenience. Please also consider 
forwarding it upstream.

Helmut
--- boulder-game-1.02+ds.orig/build/linux/Makefile
+++ boulder-game-1.02+ds/build/linux/Makefile
@@ -15,18 +15,19 @@
 #########
 #setup
 
-CC = g++
+CXX = g++
+PKG_CONFIG ?= pkg-config
 COMPILERFLAGS = -Wall
 
 ifeq ($(TARGET_OS),Linux)
  LDFLAGS_PLAIN = -lpthread $(LDFLAGS)
  EXE_PATH = ../../exe/linux_x64/
- LDFLAGS_GFX += `pkg-config --libs sdl2` '-Wl,-R,$$ORIGIN/.'
+ LDFLAGS_GFX += `$(PKG_CONFIG) --libs sdl2` '-Wl,-R,$$ORIGIN/.'
 
  LDFLAGS_GFX_GL = -lGL -L/usr/X11R6/lib -lX11
- LOCAL_CFLAGS = $(CFLAGS) $(COMPILERFLAGS) -I../../src/common -I../../src/boulder -I../../src/graph -I../../ext_include/pa `pkg-config --cflags sdl2` `pkg-config --cflags stb`
+ LOCAL_CFLAGS = $(CFLAGS) $(COMPILERFLAGS) -I../../src/common -I../../src/boulder -I../../src/graph -I../../ext_include/pa `$(PKG_CONFIG) --cflags sdl2` `$(PKG_CONFIG) --cflags stb`
  LOCAL_CPPFLAGS = $(CPPFLAGS)
- LOCAL_CXXFLAGS = $(CXXFLAGS) $(COMPILERFLAGS) -I../../src/common -I../../src/boulder -I../../src/graph -I../../ext_include/pa `pkg-config --cflags sdl2` `pkg-config --cflags stb`
+ LOCAL_CXXFLAGS = $(CXXFLAGS) $(COMPILERFLAGS) -I../../src/common -I../../src/boulder -I../../src/graph -I../../ext_include/pa `$(PKG_CONFIG) --cflags sdl2` `$(PKG_CONFIG) --cflags stb`
 endif
 
 #########
@@ -59,16 +60,16 @@
 # fix so that a new or renamed .h file will cause a rebuild
 # and finally fix paths in the .d file
 %.o: %.cpp
-	$(CC) -c $(LOCAL_CPPFLAGS) $(LOCAL_CXXFLAGS) $*.cpp -o $*.o
-	$(CC) -MM $(LOCAL_CPPFLAGS) $(LOCAL_CXXFLAGS) $*.cpp > $*.d
+	$(CXX) -c $(LOCAL_CPPFLAGS) $(LOCAL_CXXFLAGS) $*.cpp -o $*.o
+	$(CXX) -MM $(LOCAL_CPPFLAGS) $(LOCAL_CXXFLAGS) $*.cpp > $*.d
 	@mv -f $*.d $*.d.tmp
 	@sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d
 	@sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$/:/' >> $*.d
 	@rm -f $*.d.tmp
 
 %.o: %.c
-	$(CC) -c $(LOCAL_CPPFLAGS) $(LOCAL_CFLAGS) $*.c -o $*.o
-	$(CC) -MM $(LOCAL_CPPFLAGS) $(LOCAL_CFLAGS) $*.c > $*.d
+	$(CXX) -c $(LOCAL_CPPFLAGS) $(LOCAL_CFLAGS) $*.c -o $*.o
+	$(CXX) -MM $(LOCAL_CPPFLAGS) $(LOCAL_CFLAGS) $*.c > $*.d
 	@mv -f $*.d $*.d.tmp
 	@sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d
 	@sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$/:/' >> $*.d
@@ -104,21 +105,21 @@
 #private
 
 boulder: $(BOULDER_OBJECTS)
-	$(CC) -o ./boulder $(BOULDER_OBJECTS) $(LDFLAGS_PLAIN) $(LDFLAGS_GFX)
+	$(CXX) -o ./boulder $(BOULDER_OBJECTS) $(LDFLAGS_PLAIN) $(LDFLAGS_GFX)
 -include $(BOULDER_OBJECTS:.o=.d)
 
 mapeditor: $(EDITOR_OBJECTS)
-	$(CC) -o ./mapeditor $(EDITOR_OBJECTS) $(LDFLAGS_PLAIN) $(LDFLAGS_GFX)
+	$(CXX) -o ./mapeditor $(EDITOR_OBJECTS) $(LDFLAGS_PLAIN) $(LDFLAGS_GFX)
 -include $(EDITOR_OBJECTS:.o=.d)
 
 ../../utils/res_comp/res_comp: $(RES_COMP_OBJECTS)
-	$(CC) -o ../../utils/res_comp/res_comp $(RES_COMP_OBJECTS) $(LDFLAGS_PLAIN)
+	$(CXX) -o ../../utils/res_comp/res_comp $(RES_COMP_OBJECTS) $(LDFLAGS_PLAIN)
 -include $(RES_COMP_OBJECTS:.o=.d)
 
 ../../utils/img_cut/img_cut: $(IMG_CUT_OBJECTS)
-	$(CC) -o ../../utils/img_cut/img_cut $(IMG_CUT_OBJECTS) $(LDFLAGS_PLAIN) $(LDFLAGS_GFX)
+	$(CXX) -o ../../utils/img_cut/img_cut $(IMG_CUT_OBJECTS) $(LDFLAGS_PLAIN) $(LDFLAGS_GFX)
 -include $(IMG_CUT_OBJECTS:.o=.d)
 
 ../../utils/fnt_comp/fnt_comp: $(FNT_COMP_OBJECTS)
-	$(CC) -o ../../utils/fnt_comp/fnt_comp $(FNT_COMP_OBJECTS) $(LDFLAGS_PLAIN) $(LDFLAGS_GFX_GL)
+	$(CXX) -o ../../utils/fnt_comp/fnt_comp $(FNT_COMP_OBJECTS) $(LDFLAGS_PLAIN) $(LDFLAGS_GFX_GL)
 -include $(FNT_COMP_OBJECTS:.o=.d)

Reply via email to