Results 1 to 2 of 2

Thread: Makefile fix for Linux x86_64

  1. #1
    Junior Member
    Join Date
    Mar 2005
    Location
    Netherlands
    Posts
    8

    Makefile fix for Linux x86_64

    In order to compile the viewwer from the COLLADA_120 distribution for the x86_64 architecture under SuSE 9.2, I needed to modify the Makefile. I replaced all instances of "/lib" by "/lib$(ARCH)" and defined ARCH as "64". SuSE 9.2 allows both 32- and 64-bit application to be build but I only have the 64-bit GLX and Cg toolkit installed. Here is the Makefile...

    Code :
    ##=========================================================================================================
    ## Interchange file viewer
    ##
    ## AUTHOR:	Gabor Nagy, Fabien Goslin
    ## DATE:	2004-Dec-19 02:16:28
    ##
    ## Copyright 2004 Sony Computer Entertainment America
    ## 
    ## Permission is hereby granted, free of charge, to any person obtaining a
    ## copy of this software and associated documentation files (the "Software"),
    ## to deal in the Software without restriction, including without limitation
    ## the rights to use, copy, modify, merge, publish, distribute, sublicense,
    ## and/or sell copies of the Software, and to permit persons to whom the
    ## Software is furnished to do so, subject to the following conditions:
    ## 
    ## The above copyright notice and this permission notice shall be included in
    ## all copies or substantial portions of the Software.
    ## 
    ## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    ## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    ## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    ## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    ## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    ## FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    ## DEALINGS IN THE SOFTWARE.
    ##=========================================================================================================
     
    CvVERSION    =	2.2.0
     
    VERSI = $(shell $(CC) --version )
     
    ifneq ($(findstring Apple,$(VERSI)),)
    V_PLATFORM   =  Apple
    else
    V_PLATFORM   =	Linux
    endif
     
     
    GUI =			glut
    GFX_API =		GL
    HW_SHADING_LANGUAGE =	Cg
    ARCH = 			64
     
    ##leave blank after = if you don't want to use one of the following librairies
    ## make sure to 'make clean' after each change
    TEXTURE_PNG = PNG
    TEXTURE_JPEG = JPEG
    TEXTURE_TIFF = TIFF 
    ##----------------------------------------------------------------------------- 
     
    ifeq ($(findstring Apple,$(V_PLATFORM)),)
     RM =		rm -rf
     MKSYM =	-s
     
    	TEXTURES_LIB = -lz -lm 
    	SYS_LIBS = -L/usr/lib$(ARCH) -L/usr/X11R6/lib$(ARCH) -lX11 -lXi -lXext -lXmu -lglut -lGLU -lGL -lxml2 
     
     	ifneq ($(findstring PNG,$(TEXTURE_PNG)),) 	
    	 SYS_LIBS =	-L/usr/local/lib$(ARCH) -L/usr/lib$(ARCH) -L/usr/X11R6/lib$(ARCH) -lX11 -lXi -lXext -lXmu -lglut -lGLU -lGL -lxml2 
       TEXTURES_LIB+= -lpng12 
    	 TEXTURE_FLAG += -DUSE_PNG
    	endif
    	ifneq ($(findstring JPEG,$(TEXTURE_JPEG)),) 	
    	 SYS_LIBS =	-L/usr/local/lib$(ARCH) -L/usr/lib$(ARCH) -L/usr/X11R6/lib$(ARCH) -lX11 -lXi -lXext -lXmu -lglut -lGLU -lGL -lxml2 
    	 TEXTURES_LIB += -ljpeg
    	 TEXTURE_FLAG += -DUSE_JPEG	
    	endif
    	ifneq ($(findstring TIFF,$(TEXTURE_TIFF)),) 	
    	 SYS_LIBS =	-L/usr/local/lib$(ARCH) -L/usr/lib$(ARCH) -L/usr/X11R6/lib$(ARCH) -lX11 -lXi -lXext -lXmu -lglut -lGLU -lGL -lxml2  
    	 TEXTURES_LIB += -ltiff
    	 TEXTURE_FLAG += -DUSE_TIFF	
    	endif
     
      GFX_API_CFLAGS = -DUSEOpenGL
     
    else
    ## APPLE
     RM =		rm -rf
     MKSYM =	-s
     SYS_LIBS =	-L/System/Library/Frameworks/OpenGL.framework/Libraries -framework OpenGL -framework GLUT -lobjc 
     GFX_API_CFLAGS = -I/System/Library/Frameworks/Carbon.framework/Libraries/CIncludes -DUSEOpenGL -I/System/Library/Frameworks/GLUT.framework/Versions/A/Headers/
    endif
     
     
    TOP     =	../..
    XML_DIR =	 /usr/include/libxml2
    DAE_DIR =	..
     
    OPTFLAG =	
     
    ifneq ($(findstring GCC,$(VERSI)),)
    CFBASE =	-W -Wall  -Wno-unused-parameter -Wno-unused-function -Wstrict-prototypes
    CF =		$(CFBASE)
    DEBUG_FLAG =	-ggdb3
    ifeq ($(findstring ++,$(VERSI)),)
     ifneq ($(findstring 3.3.,$(VERSI)),)
    CF =  $(CFBASE) ##-Wdeclaration-after-statement
     endif
     ifneq ($(findstring 3.4.,$(VERSI)),)
    CF =  $(CFBASE) ## -Wdeclaration-after-statement
     endif
    endif
    ifneq ($(findstring 2.9.,$(VERSI)),)
    CC = MUST_USE_GCC_3_x_NOT_2_9
    endif
     
    else
    CF = 
    DEBUG_FLAG =	-g
    endif
     
    ## Simply remove -DDAE_1_1 to support COLLADA 1.0 files
    ##
    #CFLAGS	= $(DEBUG_FLAG) $(CF) $(OPTFLAG) -I. -I./include -I$(DAE_DIR)/include -I$(XML_DIR)
    CFLAGS	= $(DEBUG_FLAG) $(CF) $(OPTFLAG) -DDAE_1_1 -I. -I./include -I$(DAE_DIR)/include -I$(XML_DIR)
     
     
    CvOBJ_DIR =	$(TOP)/viewerobj
    CvLIB_DIR =	$(TOP)/cv_lib
    BIN_DIR =	.
     
    LDFLAGS	= $(SYS_LIBS) -L$(CvLIB_DIR) -lcv -lm -ldl  
    #LDFLAGS	= $(MKSYM) $(SYS_LIBS) -L$(CvLIB_DIR) -lcv -lX11 -lXi -lXext -lXmu -lglut -lGLU -lGL -lm -ldl
     
     
     
    GUI_OBJS =	$(CvOBJ_DIR)/$(GUI)/gui.o
     
    LIB_OBJS =	$(CvOBJ_DIR)/Animation.o\
    		$(CvOBJ_DIR)/Camera.o\
    		$(CvOBJ_DIR)/Geometry.o\
    		$(CvOBJ_DIR)/Pow2.o \
    		$(CvOBJ_DIR)/Material.o\
    		$(CvOBJ_DIR)/Matrix.o\
    		$(CvOBJ_DIR)/Mesh.o\
    		$(CvOBJ_DIR)/Node.o\
    		$(CvOBJ_DIR)/Polygon.o\
    		$(CvOBJ_DIR)/Scene.o\
    		$(CvOBJ_DIR)/Spline.o\
    		$(CvOBJ_DIR)/dae.o\
    		$(CvOBJ_DIR)/nodes.o\
    		$(CvOBJ_DIR)/Vector.o\
    		$(CvOBJ_DIR)/read.o\
    		$(CvOBJ_DIR)/Texture.o\
    		$(CvOBJ_DIR)/TargaLoader.o\
    		$(CvOBJ_DIR)/Triangulation.o $(CvOBJ_DIR)/tri.o $(CvOBJ_DIR)/monotone.o $(CvOBJ_DIR)/construct.o
     
    GFX_API_OBJS = 	$(CvOBJ_DIR)/$(GFX_API)/Draw.o\
    		$(CvOBJ_DIR)/$(GFX_API)/Texture.o\
    		$(CvOBJ_DIR)/$(GFX_API)/VertexArray.o
     
     
    DAE_OBJS =	$(CvOBJ_DIR)/DAE/DAE.o $(CvOBJ_DIR)/DAE/Read.o
     
    CvLIB_OBJS =	$(DAE_OBJS) $(LIB_OBJS) $(GFX_API_OBJS) $(GUI_OBJS)
    OBJS =		$(CvOBJ_DIR)/main.o
     
     
    ifeq ($(HW_SHADING_LANGUAGE),Cg)
     GFX_API_CFLAGS +=	-DUSE_Cg
     
     ifneq ($(findstring Apple,$(V_PLATFORM)),)
      LDFLAGS +=		-framework Cg
     else
      LDFLAGS +=		-lCg -lCgGL
     endif
     
     GFX_API_OBJS += 	$(CvOBJ_DIR)/$(GFX_API)/Cg/CgDraw.o
    endif
     
     
    GCC = GCC
    all:		$(CvLIB_DIR) $(CvOBJ_DIR) $(CvOBJ_DIR)/DAE $(CvOBJ_DIR)/$(GFX_API) $(CvOBJ_DIR)/$(GFX_API)/Cg $(CvOBJ_DIR)/$(GUI) $(CvLIB_DIR)/libcv.a $(BIN_DIR)/cviewer
     
     
    $(CvLIB_DIR)/libcv.a:	 $(CvLIB_OBJS) Makefile
    		$(RM) $@
    		ar -r $@ $(CvLIB_OBJS)
    		ranlib $@
     
    clean:
    		$(RM) $(CvOBJ_DIR)/* $(CvOBJ_DIR)/*/* core core.*
     
     
    ## Generic compile rules
    ##
    $(CvOBJ_DIR) $(CvOBJ_DIR)/DAE $(CvOBJ_DIR)/$(GFX_API) $(CvOBJ_DIR)/$(GFX_API)/Cg $(CvOBJ_DIR)/$(GUI) $(CvLIB_DIR):
    				mkdir -p $@
     
    $(CvOBJ_DIR)/%.o:		%.c $<
    				$(CC) $(CFLAGS) -DCvVERSION='"$(CvVERSION)"' $(GFX_API_CFLAGS) -c $< -o $@
     
    $(CvOBJ_DIR)/Texture.o:		Texture.c $<
    				$(CC) $(CFLAGS) -DCvVERSION='"$(CvVERSION)"' $(GFX_API_CFLAGS) $(TEXTURE_FLAG) -c $< -o $@
     
    $(CvOBJ_DIR)/DAE/%.o:		../%.c $<
    				$(CC) $(CFLAGS) -c $< -o $@
     
    $(CvOBJ_DIR)/$(GFX_API)/%.o:	$(GFX_API)/%.c $<
    				$(CC) $(CFLAGS) -c $< -o $@
     
    $(CvOBJ_DIR)/$(GUI)/%.o:	%.c $<
    				$(CC) $(CFLAGS) -c $< -o $@
     
     
    ## Viewer application link rule
    ##
    $(BIN_DIR)/cviewer:	$(OBJS) $(CvLIB_DIR)/libcv.a
    			$(CC) -o $@ $(MKLF) $(MK_DLINK_FLAG) $(OBJS) $(LDFLAGS) $(TEXTURES_LIB)
     
    ## Lint application link rule
    ##
    $(BIN_DIR)/cllint:	$(CvOBJ_DIR)/cllint.o
    			$(CC) -o $@ $(MKLF) $(MK_DLINK_FLAG) $< $(LDFLAGS)   $(TEXTURES_LIB)
    Gino van den Bergen
    www.dtecta.com

  2. #2
    Senior Member
    Join Date
    Aug 2004
    Location
    California
    Posts
    771
    Thanks I've made a note to include this in the next release of the sample code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •