diff --git a/configure b/configure index 6dc2668..a63a8c8 100755 --- a/configure +++ b/configure @@ -44,6 +44,9 @@ def main(): parser.add_argument('-c', '--cxx', nargs = 1, help = "specify compiler with optional path (e.g. clang++, /usr/bin/g++-4.9)") + parser.add_argument('-q', '--qmake', + nargs = 1, + help = "specify qmake with optional path (e.g. qmake, /usr/bin/qmake)") parser.add_argument('--toolchain', nargs = 1, help = "specify toolchain ("+Supported_Toolchains_display+")") @@ -83,6 +86,17 @@ def main(): else: config['toolchain'] = 'gcc' print 'Toolchain:', config['toolchain'] + + # + # Verify qmake + # + if not config['qmake']: + config['qmake'] = 'qmake' + else: + config['qmake'] = config['qmake'][0] + if not check_exit('which '+config['qmake']): + sys.exit('Cannot locate qmake') + print 'QMake:', config['qmake'] # # Determine optimization level @@ -93,7 +107,7 @@ def main(): # # Create speculative conf and clean # - config['omp'] = 'omp' + config['omp'] = True generate_conf(config) if not check_exit('make clean'): sys.stderr.write("Warning! Encountered errors when cleaning build environment!\n") @@ -102,8 +116,8 @@ def main(): # Check OpenMP support # if not check_exit('make omp_test'): - config['omp'] = 'no-omp' - print 'OpenMP Supported:', config['omp'] == 'omp' + config['omp'] = False + print 'OpenMP Supported:', config['omp'] # # Create final configuration @@ -137,12 +151,14 @@ def generate_conf(config): f = open( os.path.join(pwhome, Conf), 'w' ) f.write( 'PWHOME = %s\n' % pwhome ) + f.write( 'PWOS = %s\n' % config['os'] ) + f.write( 'PWTOOLCHAIN = %s\n' % config['toolchain'] ) + f.write( 'PWOMP = %s\n' % config['omp'] ) + f.write( 'PWOPT = %s\n' % config['optimization'] ) + f.write( 'PWQMAKE = %s\n' % config['qmake'] ) + f.write( 'CXX = %s\n' % config['cxx'] ) - confs = [config['os'], config['toolchain'], config['optimization'], config['omp'], 'common'] - for conf in confs: - f.write('include ${PWHOME}/etc/bld/Makefile.%s.conf\n' % conf) - - f.write('CXX = %s\n' % config['cxx']) + f.write( 'include ${PWHOME}/etc/bld/Makefile.conf\n' ) f.close() diff --git a/etc/bld/Makefile.common.conf b/etc/bld/Makefile.conf similarity index 61% rename from etc/bld/Makefile.common.conf rename to etc/bld/Makefile.conf index 477b23f..0f12806 100644 --- a/etc/bld/Makefile.common.conf +++ b/etc/bld/Makefile.conf @@ -1,8 +1,33 @@ ###################################################################### # -# Common System Configuration +# System Configuration # ###################################################################### +ifeq (${PWOS}, darwin) + SHARED_BASENAME = lib${1}.dylib + + SHARED_LDFLAGS += -dynamiclib + # Some of our libraries reference symbols that are defined in other libraries. + # For example, the main library references renderers, but those are defined in + # other libraries, and we don't know which library will provide the library at + # the time the main library is being built. + SHARED_LDFLAGS += -undefined dynamic_lookup + # We want the library to be searched for on the runtime load path. + SHARED_LDFLAGS += -Wl,-install_name,@rpath/$(shell basename ${target}) + + OPENGL_CXXFLAGS = -I/System/Library/Frameworks/OpenGL.framework/Headers + OPENGL_LIBS = -framework OpenGL +else + SHARED_BASENAME = lib${1}.so + + SHARED_LDFLAGS = -fPIC -shared + + OPENGL_CXXFLAGS = -I/usr/include/GL + OPENGL_LIBS = -lGL -lGLU +endif + +LD=${CXX} + CXXFLAGS += -g -std=c++11 -c -MMD -Wall # Flags required for linking to a library in ${PWLIB} @@ -12,6 +37,52 @@ DLOPEN_LIBS = -ldl GSL_LIBS = -lgsl -lgslcblas ZIP_LIBS = -lz +###################################################################### +# +# Optimization +# +###################################################################### +ifeq (${PWOPT}, optimized) + CXXFLAGS += -O2 +endif + +###################################################################### +# +# OpenMP +# +###################################################################### +ifeq (${PWOMP}, False) + OMP_CXXFLAGS = -Wno-unknown-pragmas +else + OMP_CXXFLAGS = -fopenmp + ifeq (${PWTOOLCHAIN}, gcc) + OMP_LIBS = -lgomp + endif +endif + +###################################################################### +# +# QMake Flags/Macros +# +###################################################################### +ifeq (${PWOS}, darwin) + # Command-line spec + QMAKE=${PWQMAKE} -spec macx-llvm + + # When we build a library, we want to specify it's on the runtime linker path. + QMAKE_LFLAGS_SONAME = -Wl,-install_name,@rpath/ + + # Make edits to the qmake-generated Makefile for cases where a convenient + # or reliable official mechanism isn't currently available. + FIXUP_QT_MAKEFILE = sed -e 's/-mmacosx-version-min=[[:digit:]\.]*//' -i "" ${1} ;\ + sed -e 's/export MACOSX_DEPLOYMENT_TARGET.*//' -i "" ${1} ; +else + QMAKE=${PWQMAKE} + + # no-op + FIXUP_QT_MAKEFILE = +endif + ###################################################################### # # Project Directory Structure diff --git a/etc/bld/Makefile.darwin.conf b/etc/bld/Makefile.darwin.conf deleted file mode 100644 index b3be676..0000000 --- a/etc/bld/Makefile.darwin.conf +++ /dev/null @@ -1,35 +0,0 @@ -###################################################################### -# -# System Configuration -# -###################################################################### -SHARED_BASENAME = lib${1}.dylib - -SHARED_LDFLAGS += -dynamiclib -# Some of our libraries reference symbols that are defined in other libraries. -# For example, the main library references renderers, but those are defined in -# other libraries, and we don't know which library will provide the library at -# the time the main library is being built. -SHARED_LDFLAGS += -undefined dynamic_lookup -# We want the library to be searched for on the runtime load path. -SHARED_LDFLAGS += -Wl,-install_name,@rpath/$(shell basename ${target}) - -OPENGL_CXXFLAGS = -I/System/Library/Frameworks/OpenGL.framework/Headers -OPENGL_LIBS = -framework OpenGL - -###################################################################### -# -# QMake Flags/Macros -# -###################################################################### - -# Command-line spec -QMAKE=qmake -spec macx-llvm - -# When we build a library, we want to specify it's on the runtime linker path. -QMAKE_LFLAGS_SONAME = -Wl,-install_name,@rpath/ - -# Make edits to the qmake-generated Makefile for cases where a convenient -# or reliable official mechanism isn't currently available. -FIXUP_QT_MAKEFILE = sed -e 's/-mmacosx-version-min=[[:digit:]\.]*//' -i "" ${1} ;\ - sed -e 's/export MACOSX_DEPLOYMENT_TARGET.*//' -i "" ${1} ; diff --git a/etc/bld/Makefile.debug.conf b/etc/bld/Makefile.debug.conf deleted file mode 100644 index ae6e561..0000000 --- a/etc/bld/Makefile.debug.conf +++ /dev/null @@ -1 +0,0 @@ -CXXFLAGS += -O0 \ No newline at end of file diff --git a/etc/bld/Makefile.gcc.conf b/etc/bld/Makefile.gcc.conf deleted file mode 100644 index 346dfaf..0000000 --- a/etc/bld/Makefile.gcc.conf +++ /dev/null @@ -1,3 +0,0 @@ -LD=${CXX} - -OMP_LIBS__PFM=-lgomp \ No newline at end of file diff --git a/etc/bld/Makefile.linux.conf b/etc/bld/Makefile.linux.conf deleted file mode 100644 index e02e168..0000000 --- a/etc/bld/Makefile.linux.conf +++ /dev/null @@ -1,22 +0,0 @@ -###################################################################### -# -# System Configuration -# -###################################################################### -SHARED_BASENAME = lib${1}.so - -SHARED_LDFLAGS = -fPIC -shared - -OPENGL_CXXFLAGS = -I/usr/include/GL -OPENGL_LIBS = -lGL -lGLU - -###################################################################### -# -# QMake Flags/Macros -# -###################################################################### - -QMAKE=qmake - -# no-op -FIXUP_QT_MAKEFILE = \ No newline at end of file diff --git a/etc/bld/Makefile.llvm.conf b/etc/bld/Makefile.llvm.conf deleted file mode 100644 index f641fc1..0000000 --- a/etc/bld/Makefile.llvm.conf +++ /dev/null @@ -1,5 +0,0 @@ -LD=${CXX} - - -# Not officially supported yet, but looks like omp won't require explicit library linking. -OMP_LIBS__PFM= \ No newline at end of file diff --git a/etc/bld/Makefile.no-omp.conf b/etc/bld/Makefile.no-omp.conf deleted file mode 100644 index e2363d3..0000000 --- a/etc/bld/Makefile.no-omp.conf +++ /dev/null @@ -1,2 +0,0 @@ -OMP_CXXFLAGS=-Wno-unknown-pragmas -OMP_LIBS= diff --git a/etc/bld/Makefile.omp.conf b/etc/bld/Makefile.omp.conf deleted file mode 100644 index be290a1..0000000 --- a/etc/bld/Makefile.omp.conf +++ /dev/null @@ -1,2 +0,0 @@ -OMP_CXXFLAGS=-fopenmp -OMP_LIBS=${OMP_LIBS__PFM} \ No newline at end of file diff --git a/etc/bld/Makefile.optimized.conf b/etc/bld/Makefile.optimized.conf deleted file mode 100644 index 02cf95b..0000000 --- a/etc/bld/Makefile.optimized.conf +++ /dev/null @@ -1 +0,0 @@ -CXXFLAGS += -O2 \ No newline at end of file