Jump to content

makefiles


Recommended Posts

has anybody used the makefiles that ship with Houdini?

I can't seem to get 'em to work.

What platform?

I used hcustom with good results on suse 10.3

There was also a discussion on the SESI-List recently about windows vs makefiles ... but I'm not sure ...

Link to comment
Share on other sites

has anybody used the makefiles that ship with Houdini?

Yes, I've been including the bundled "Makefile.linux" without any problems, though 99% of what I build are VEX dso's which make very light use of the HDK (some of the UT_* classes and not much else). I've tested on Suse10.3 (64-bit) and Suse11.1 (32-bit). On Suse11.1 I had to install gcc4.2.1 separately as it comes with gcc4.3.2, I believe, and the HDK expects 4.2.1 (mostly because it includes some deprecated libs, which are no longer there in 4.3.2), but otherwise, everything seems to be fine. No idea about Windows or OSX though.

Link to comment
Share on other sites

I must admit, I'm pretty feeble on these types of issues; I am having trouble on the most basic level.

I copied the Makefile.linux to Makefile.

If I run

hcustom SOP_Flatten.C

I get a compiled SOP, all happy like.

if I run

make SOP_Flatten.C

make: Nothing to be done for `SOP_Flatten.C'.

if I run

make SOP_Flatten

it doesn't find any of the $HT/include/ headers...

Yes, I've been including the bundled "Makefile.linux" without any problems, though 99% of what I build are VEX dso's which make very light use of the HDK (some of the UT_* classes and not much else). I've tested on Suse10.3 (64-bit) and Suse11.1 (32-bit). On Suse11.1 I had to install gcc4.2.1 separately as it comes with gcc4.3.2, I believe, and the HDK expects 4.2.1 (mostly because it includes some deprecated libs, which are no longer there in 4.3.2), but otherwise, everything seems to be fine. No idea about Windows or OSX though.
Link to comment
Share on other sites

I must admit, I'm pretty feeble on these types of issues; I am having trouble on the most basic level.

I copied the Makefile.linux to Makefile.

if I run

make SOP_Flatten.C

make: Nothing to be done for `SOP_Flatten.C'.

I believe the intent behind the makefiles that ship with Houdini is that you'll include them in your own project's Makefile -- i.e: they're not meant to be used directly as they don't define any targets, they just define the flags needed to build the different kinds of houdini objects:

$OBJFLAGS (for compiling object files)

$DSOFLAGS (for linking shared libs -- a.k.a: "dso" files)

$SAFLAGS (for compiling + linking stand-alone apps)

Then, in your project's Makefile, you can include one of these toolkit makefiles and define your own targets using those variables.

For example, let's say you copy SOP_Flatten.C and SOP_Flatten.h to some directory. Then create a Makefile (in the same directory) with something like this inside it:

# Include the toolkit's makefile
include $(HT)/makefiles/Makefile.linux

# Override optimizer settings, if you want
# OPTIMIZER   = -O2

# Define some compiler-related stuff
#CC          = /opt/gcc/4.2.1/bin/c++
CC          = c++
LINK        = $(CC)
TAGINFO     = $(shell (echo -n "Compiled on:" `date`" by:" `whoami`"\n$(SESI_TAGINFO)") | sesitag -m)

# Set the source files. This assumes that each *.C file in the curr dir
# is the source for a different .so -- adjust to taste
OPS      = $(wildcard *.C)

# Output path for built ops
OUTDIR      = .

# Define .o, .so, and any dependency files (based on the value of $OPS above)
OBJFILES = $(OPS:%.C=%.o)
DSOFILES = $(OBJFILES:%.o=$(OUTDIR)/%.so)
DEPFILES = $(OBJFILES:%.o=%.d)

# Include directories ($HT should point to the toolkit's install dir)
INCDIRS     = -I./ -I$(HT)/include

# Extra objects to link with
LNKOBJS     =
# Extra library paths 
LIBDIRS     =  #e.g: -L/path/to/mylibs -L/path/to/boost
# Extra libraries 
LIBS        =  #e.g: "-lkewl" will look for "libkewl.so(.a)" in $LIBDIRS

# Some flags for building dependencies...
MAKEDEP     = cpp -MM -MF $@
DEPWFLAGS   = -Wall -W -Wno-parentheses -Wno-sign-compare -Wno-reorder \
              -Wno-uninitialized -Wno-unused
DEPDEFS     = -DMAKING_DEPS

DEPFLAGS    = $(ARCHDEFS) $(DEPDEFS) $(VEXINC) $(INCINC) $(DEPWFLAGS)

# Flags for building objects
MYOBJFLAGS = $(INCDIRS) $(OBJFLAGS) -DMAKING_DSO $(TAGINFO)

# Flags for linking
MYLINKFLAGS= $(SHAREDFLAG) $(DSOFLAGS)

#------------------------------------------------------------------------
# You should be able to leave the rest alone
#------------------------------------------------------------------------
all: $(DEPFILES) $(OBJFILES) $(DSOFILES)
.PHONY: all

.SUFFIXES:

%.d: %.C
	@echo Building dependencies for $<
	$(MAKEDEP) $(DEPFLAGS) $<

%.o: %.C %.d
	@echo Compiling $<
	$(CC) $(MYOBJFLAGS) $(OBJOUPUT) $<

$(OUTDIR)/%.so: %.o $(LNKOBJS)
	@echo Linking $@
	$(LINK) $(MYLINKFLAGS) $(LNKOBJS) $(DSOOUTPUT) $@ $<


# Include dependencies if they exist
-include $(DEPFILES)


clean:
	@rm $(OBJFILES)

clobber: clean
	@rm $(DSOFILES) $(DEPFILES) $(TESTERSX) $(SHADERS)

Then, if you type 'make' in that directory, it should build 'SOP_Flatte.so' for you (hopefully without any errors :)). That's a very basic Makefile, but hopefully it gives you an idea of how the bundled makefiles could be used in a project.

Cheers.

Link to comment
Share on other sites

The makefiles in $HT/makefiles aren't that complicated. I recommend looking through them and understanding the basic set up and rules. In particular, it's important that you read the comments at the top of Makefile.gnu.

FWIW, I just tried the following as a Makefile in $SHT/samples and it worked:

DSONAME=SOP_Star.so # or SOP_Star.dll for Windows
SOURCES=SOP_Star.C

include $(HT)/makefiles/Makefile.gnu

Now, all that is needed is:

make

The above Makefile is simpler than Mario's but in any reasonably sized project, you will want auto-dependencies of your C files. :)

Link to comment
Share on other sites

if I run

make SOP_Flatten.C

make: Nothing to be done for `SOP_Flatten.C'.

This doesn't work because you're asking make to produce SOP_Flatten.C, which already exists.

if I run

make SOP_Flatten

it doesn't find any of the $HT/include/ headers...

This doesn't work since "SOP_Flatten" isn't a target. What you want is either "SOP_Flatten.dll" or "SOP_Flatten.so".

Finally, it also can't possibly work if you just copy Makefile.linux without telling it something about what files to compile and what files to produce. :)

Link to comment
Share on other sites

Guest xionmark
This doesn't work because you're asking make to produce SOP_Flatten.C, which already exists.

This doesn't work since "SOP_Flatten" isn't a target. What you want is either "SOP_Flatten.dll" or "SOP_Flatten.so".

Finally, it also can't possibly work if you just copy Makefile.linux without telling it something about what files to compile and what files to produce. :)

This is a good reference:

http://www.gnu.org/software/make/manual/make.html

Link to comment
Share on other sites

Yep, I'm playing with scons at the moment. You have the complete power of python at your fingertips which is useful. If you look at the latest version of the HOT you can see I've got a SConscript file that builds the dso's (osx and linux, win32 not completed yet).

I have a function in the script to grab the various compile options by running hcustom on a dummy file, then build a scons "Environment" and use it to do the building. The one problem at the moment is that scons is too smart in it's dependency tracking and thinks that it should always rebuild from scratch because sidefx's tagging mechanism is always changing one of the compile flags by placing the compile time in the tag. One way around it is to have a small source file, eg tag.C, that simply has the line "#include <UT/UT_DSOVersion.h>" and is compiled with the flag -DUT_DSO_TAGINFO=\"3262197....etc..., but have the rest of the source files compiled with an environment that doesn't use the taginfo. This minimizes the rebuilding while developing.

It's also possible that CMake could be used to build dso's in a platform independent way, I'm currently doing a project that uses the InsightToolkit and OpenScenegraph, both huge libraries that use cmake for cross platform building. It's obviously very powerful but nowhere near as elegant as scons. If I was going to use it for hdk work I'd write a small python program to the same sort of thing as scons, ie run hcustom on a dummy file, grab the compile options and then stuff them into an cmake macro file. You would rerun the script whenever you changed houdini version or achitecture, something that could probably be automated.

All this would be a lot easier if sidefx implemented my RFE to include a hdk-config tool ...

-Drew

Speaking of Makefiles and their historical annoyances and limitations, are any of you guys using SCONS?

http://www.scons.org/

I would love to see "make" go bye bye permanently.

Mark

Link to comment
Share on other sites

Guest xionmark
Yep, I'm playing with scons at the moment. You have the complete power of python at your fingertips which is useful. If you look at the latest version of the HOT you can see I've got a SConscript file that builds the dso's (osx and linux, win32 not completed yet).

<SNIP>

All this would be a lot easier if sidefx implemented my RFE to include a hdk-config tool ...

-Drew

Wow, great post. I looked at the scons script for the latest HOT, helpful as I;m just getting to know it.

What did you have in mind for a hdk-config tool?

Mark

Link to comment
Share on other sites

What did you have in mind for a hdk-config tool?

Mark

Eg

$ fltk-config
Usage: fltk-config [OPTIONS]
Options:
		[--version]
		[--api-version]

Options telling what we are doing:
		[--use-gl]		use GL
		[--use-images]	use extra image formats (PNG, JPEG)
		[--use-glut]	  use glut compatibility layer
		[--use-forms]	 use forms compatibility layer

Options telling what information we request:
		[--cc]			return C compiler used to compile FLTK
		[--cxx]		   return C++ compiler used to compile FLTK
		[--cflags]		return flags to compile C using FLTK
		[--cxxflags]	  return flags to compile C++ using FLTK
		[--ldflags]	   return flags to link against FLTK
		[--ldstaticflags] return flags to link against static FLTK library
										  even if there are DSOs installed
		[--libs]		  return FLTK libraries full path for dependencies

Option to compile and link an application:
		[-g]			  compile the program with debugging information
		[--compile program.cxx]
		[--post program]

I actually have something like this going now under linux, the plan is to use it for cmake building.So e.g. here is a CMakeLists for SOP_Star.C.

cmake_minimum_required(VERSION 2.6)
project(SOP_Star)

# run our helper process to grab the compile and link flags from hcustom
execute_process(COMMAND hython ${PROJECT_SOURCE_DIR}/hdk-config.py --cmake=HdkDefs.cmake)
include(${CMAKE_BINARY_DIR}/HdkDefs.cmake)

set(SOP_Star_SRCS SOP_Star.C)

add_definitions(${HDK_DEFINITIONS})
include_directories(${HDK_INCLUDE_DIRS})

add_custom_command(OUTPUT sesitag.C
				   DEPENDS ${SOP_Star_SRCS}
				   COMMAND hython ${PROJECT_SOURCE_DIR}/hdk-config.py --tagfile=sesitag.C)

add_library(SOP_Star SHARED ${SOP_Star_SRCS}  sesitag.C)
set_target_properties(SOP_Star PROPERTIES PREFIX "")

Where the hdk-config.py command wrote the file HdkDefs.cmake as -

set(HDK_INCLUDE_DIRS /opt/hfs9.5.303/toolkit/include /opt/hfs9.5.303/toolkit/include/htools)
set(HDK_DEFINITIONS -DVERSION=\"9.5.303\" -DDLLEXPORT= -D_GNU_SOURCE -DLINUX -DAMD64 -m64 -fPIC -DSIZEOF_VOID_P=8 -DSESI_LITTLE_ENDIAN -DENABLE_THREADS -DUSE_PTHREADS -D_REENTRANT -D_FILE_OFFSET_BITS=64 -c -DGCC4 -DGCC3 -Wno-deprecated -Wall -W -Wno-parentheses -Wno-sign-compare -Wno-reorder -Wno-uninitialized -Wunused -Wno-unused-parameter -O2 -DMAKING_DSO -D__UT_DSOVersion__)
set(HDK_LIBS -L/usr/X11R6/lib -lGLU -lGL -lX11 -lXext -lXi -ldl)

The sesitag.C file looks like -

//
// Warning: do not edit, this file is written automatically by hdk-config.py.
//
#ifdef __UT_DSOVersion__
#undef  __UT_DSOVersion__
#endif
#define UT_DSO_TAGINFO "3262197cbf165b037af65da8542e94f02a5cd6b0917c87ce30f990485e46e4887b912bda9f4621614320e8ea67cb231c5afeef01f7d8ed5753042de86ec081ac5bbe45a0ff9249d6fa3c8d4c15ed08ecbb2e86a48aee9876f0"
#include &lt;UT/UT_DSOVersion.h&gt;

Then to get standard HDK code to compile, like SOP_Star.C, I always add the -D__UT_DSOVersion__ to make sure that the tag isn't defined in multiple object files.

With some cleaning up this may be a useful community tool ? I may put it up on bitbucket and call for volunteers to do the windows port ;) The python program could also be used used as a importable module for scons building similar to the HOT example.

-Drew

Link to comment
Share on other sites

This is what it looks like at the moment ...

$ python ../hdk-config.py --help
Usage: hdk-config.py [options]

Options:
  -h, --help			show this help message and exit
  -C CMAKEFILE, --cmake=CMAKEFILE
						write out the compile defs to a cmake package module
  -T TAGFILE, --tagfile=TAGFILE
						generate a C++ file with a sesitag defined, ie no need
						to compile -DUT_DSO_VERSION
  --cxx				 return C++ compiler used to compile HDK
  --cxxflags			return flags to compile C++ using the HDK
  --ldflags			 return flags to link C++ using the HDK
  --g				   compile the program with debug information
  --notag			   do not include the UT_DSO_TAGINFO in flags

$ python ../hdk-config.py --cxxflags
-DUT_DSO_TAGINFO=\"3262197cbf165b037af65da8542e94f02a5cd6b0917c87ce10f990485e46e4887b912bda9f321d7c1646cbed25da200e4bffe40afbd1e35442162fe867f3abac5bbe45a0ff924994e17f970847fe43abb25ec5da\" -DVERSION=\"9.5.303\" -DDLLEXPORT= -D_GNU_SOURCE -DLINUX -DAMD64 -m64 -fPIC -DSIZEOF_VOID_P=8 -DSESI_LITTLE_ENDIAN -DENABLE_THREADS -DUSE_PTHREADS -D_REENTRANT -D_FILE_OFFSET_BITS=64 -c -DGCC4 -DGCC3 -Wno-deprecated -I/opt/hfs9.5.303/toolkit/include -I/opt/hfs9.5.303/toolkit/include/htools -Wall -W -Wno-parentheses -Wno-sign-compare -Wno-reorder -Wno-uninitialized -Wunused -Wno-unused-parameter -O2 -DMAKING_DSO

-Drew

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...