Skip to content

Commit

Permalink
Source reorganized, product renamed to galstar
Browse files Browse the repository at this point in the history
  • Loading branch information
mjuric committed Jul 19, 2010
1 parent 0bcdbeb commit b9c238a
Show file tree
Hide file tree
Showing 12 changed files with 387 additions and 14 deletions.
22 changes: 22 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Files that will not show up in git status listings
#
*.[oa]
*~
# For Joe editor lovers
DEADJOE
# For SM users
.smhist
# staging subdirectory
/staging
# Other stuff
workspace/*
# CMake build system directories/files
/Makefile
/optimized
/debug
/build
/.cpackignore
/.version
/.version.fn
/Debug
/Release
10 changes: 5 additions & 5 deletions .kdev4/galfit.kdev4 → .kdev4/galstar.kdev4
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
BuildItems=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x01\x00\x00\x00\x0b\x00\x00\x00\x00\x01\x00\x00\x00\x0c\x00g\x00a\x00l\x00f\x00i\x00t)

[CMake]
BuildDirs=/home/mjuric/projects/galfit/build
BuildDirs=/home/mjuric/projects/galstar/build
CMakeDir=/usr/share/cmake-2.8/Modules
Current CMake Binary=file:///usr/bin/cmake
CurrentBuildDir=file:///home/mjuric/projects/galfit/build
CurrentBuildDir=file:///home/mjuric/projects/galstar/build
CurrentBuildType=Release
CurrentInstallDir=file:///usr/local
ProjectRootRelative=./
Expand All @@ -16,16 +16,16 @@ Launch Configurations=Launch Configuration 0
[Launch][Launch Configuration 0]
Configured Launch Modes=execute
Configured Launchers=nativeAppLauncher
Name=galfit run
Name=galstar run
Type=Native Application

[Launch][Launch Configuration 0][Data]
Arguments=
Dependencies=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x00)
Dependency Action=Nothing
EnvironmentGroup=default
Executable=file:///home/mjuric/projects/galfit/build/galfit
Working Directory=file:///home/mjuric/projects/galfit
Executable=file:///home/mjuric/projects/galstar/build/galstar
Working Directory=file:///home/mjuric/projects/galstar
isExecutable=true

[MakeBuilder]
Expand Down
42 changes: 35 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 2.6)
PROJECT(galfit)
PROJECT(galstar)

# cmake -Dlibpeyton_ROOT=/home/mjuric/projects/libpeyton/debug ..

Expand All @@ -25,12 +25,40 @@ find_package(Boost REQUIRED COMPONENTS regex iostreams thread program_options)
include_directories(${Boost_INCLUDE_DIRS})


#
# Data Directories
#
set(DATADIRSUFFIX "share/${CMAKE_PROJECT_NAME}")
set(DATADIR "${CMAKE_INSTALL_PREFIX}/${DATADIRSUFFIX}")

#
# configure a header file to pass some of the CMake settings to the source
# code
#
configure_file(
"${PROJECT_SOURCE_DIR}/src/galstar_config.h.in"
"${PROJECT_BINARY_DIR}/src/galstar_config.h"
ESCAPE_QUOTES
)
include_directories("${PROJECT_BINARY_DIR}/src")

ADD_EXECUTABLE(galfit src/main.cpp src/sampler.cpp)
#
# galstar executable
#
add_executable(galstar src/main.cpp src/sampler.cpp)

target_link_libraries(galstar dl)
target_link_libraries(galstar ${Boost_LIBRARIES})
target_link_libraries(galstar ${CFITSIO_LIBRARIES})
target_link_libraries(galstar ${GSL_LIBRARIES})
target_link_libraries(galstar ${libpeyton_LIBRARIES})

target_link_libraries(galfit dl)
#
# install info
#
install (TARGETS galstar DESTINATION bin)
install(FILES
data/MrLF.MSandRGB_v1.0.dat
data/MSandRGBcolors_v1.3.dat
DESTINATION ${DATADIRSUFFIX})

target_link_libraries(galfit ${Boost_LIBRARIES})
target_link_libraries(galfit ${CFITSIO_LIBRARIES})
target_link_libraries(galfit ${GSL_LIBRARIES})
target_link_libraries(galfit ${libpeyton_LIBRARIES})
13 changes: 13 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
galstar
=======

Setup and Build
===============

./configure --with-libpeyton=../libpeyton/optimized --optimized --prefix=`pwd`/staging
make -j install

This will configure and build an optimized version of galstar in
./optimized and install it in directory ./staging linking against
an optimized version of libpeyton from ../libpeyton/optimized

221 changes: 221 additions & 0 deletions configure
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
#!/bin/bash
#
# A configure stub for people used to that syntax
# Do ./configure --help for usage instructions
#

usage()
{
tee -a $CONFIGLOG <<-EOF
Configure and prepare the source code for building.
Usage:
$0 [flags] [CMAKE_VAR1=VALUE [CMAKE_VAR2=VALUE2 [...]]]
Available flags:
--prefix=<prefix> # will install the code into <prefix>
--optimized # configure the 'Release' build
--debug # configure the 'Debug' build
--env=<VAR=VALUE> # set VAR=VALUE environment variable
# before running CMAKE
--with-gcc=<gcc_root> # use gcc from <gcc_root> directory
--with-cuda=<cuda_root> # use CUDA toolkit from <cuda_root>
--with-boost=<boost_root> # use boost from <boost_root> directory
--with-libpeyton=<lp_root> # use libpeyton from <lp_root> directory
--devemu # target CUDA code for device emulation
If ran from the top level source directory, it will configure the build
directory in build/optimized/debug (depending on whether --optimized or
--debug flags were present), as well as generate a simple Makefile to
allowing the user to build the code directly from the top-level directory.
Otherwise, it will configure the source in the current directory (assuming
it's meant to be the build directory).
This build system uses CMake. If your CMake executable is in
nonstandard location, you may specify it via the CMAKE environment
variable.
Written by Mario Juric <[email protected]>
EOF
}

xecho()
{
echo "== $@" | tee -a $CONFIGLOG
}

oecho()
{
echo "** $@" >> $CONFIGLOG
}

configlog()
{
CONFIGLOG_FINAL="$CONFIGLOG"
CONFIGLOG="$CONFIGLOG.tmp"
cat > $CONFIGLOG <<-EOF
This file contains any messages produced by CMake while
running configure, to aid debugging if configure makes a mistake.
It was created by configure, an Autoconf-like script for CMake
written by Mario Juric <[email protected]>. Invocation command line
was:
\$ $0 $@
## --------- ##
## Platform. ##
## --------- ##
hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
uname -m = `(uname -m) 2>/dev/null || echo unknown`
uname -r = `(uname -r) 2>/dev/null || echo unknown`
uname -s = `(uname -s) 2>/dev/null || echo unknown`
uname -v = `(uname -v) 2>/dev/null || echo unknown`
CMAKE = $CMAKE
which \$CMAKE = `(which "$CMAKE") 2>/dev/null || echo not found`
\$CMAKE --version = `("$CMAKE" --version) 2>/dev/null || echo not found`
## ------------------ ##
## Configuration log. ##
## ------------------ ##
EOF
# If CONFIGLOG_FINAL is defined, move $CONFIGLOG to $CONFIGLOG_FINAL (and delete $CONFIGLOG)
# In case you're wondering, CONFIGLOG_FINAL becomes undefined if --help was given on the command line
trap "{ test \"x\$CONFIGLOG_FINAL\" != x && mv '$CONFIGLOG' '$CONFIGLOG_FINAL'; rm -f '$CONFIGLOG'; }" EXIT
}

# Defaults
CMAKE=${CMAKE:-cmake}
ENV=${env}

# Store invocation information
CONFIGLOG="`pwd`/config.log"
configlog "$@"

# Quick check for CMake
which $CMAKE 2>&1 > /dev/null || {
CML=`dirname $0`"/CMakeLists.txt"
xecho "No usable CMake found (tried looking for executable \`$CMAKE')"
test -f "$CML" && {
CMV=`grep -i cmake_minimum_required "$CML" | perl -e '$_=<>; ($v) = /^cmake_minimum_required\s*\(\s*version\s+([0-9.]+)\s*\)/i; print $v'`;
test "x$CMV" != "x" && xecho "CMake $CMV or greater is needed to build this code.";
} || {
xecho "CMake is needed to build this code.";
}
xecho "If your CMake executable is in nonstandard location, you may specify"
xecho "it via the CMAKE environment variable."
exit -1;
}

BUILDDIR='build'

#
# Project-specific command-line argument parsing
#
TEMP=`getopt -o hp: -l help,prefix:,debug,optimized,devemu,env:,with-gcc:,with-cuda:,with-boost:,with-libpeyton: -- "$@"` || { xecho "Try $0 --help"; exit $?; }
eval set -- "$TEMP"
while true ; do
case "$1" in
-p|--prefix)
xecho "Setting install path to '$2'"
CMAKE="$CMAKE -DCMAKE_INSTALL_PREFIX='$2'"
shift 2 ;;
--env)
xecho "Setting environment variable '$2'"
ENV="$ENV '$2'"
shift 2 ;;
--devemu)
xecho "Targeting CUDA code for device emulation"
CMAKE="$CMAKE -DCUDA_BUILD_EMULATION=ON"
shift 1 ;;
--debug)
xecho "Setting build type to 'Debug'"
BUILDDIR='debug'
CMAKE="$CMAKE -DCMAKE_BUILD_TYPE='Debug'"
shift 1 ;;
--optimized)
xecho "Setting build type to 'Release'"
BUILDDIR='optimized'
CMAKE="$CMAKE -DCMAKE_BUILD_TYPE='Release'"
shift 1 ;;
--with-boost)
xecho "Using Boost from '$2'"
CMAKE="$CMAKE -DBOOST_ROOT='$2'"
shift 2 ;;
--with-cuda)
xecho "Using CUDA Toolkit from '$2'"
CMAKE="$CMAKE -DCUDA_TOOLKIT_ROOT_DIR='$2'"
shift 2 ;;
--with-gcc)
xecho "Using gcc suite from '$2'"
CMAKE="$CMAKE -DCMAKE_CXX_COMPILER='$2/bin/g++'"
CMAKE="$CMAKE -DCMAKE_C_COMPILER='$2/bin/gcc'"
CMAKE="$CMAKE -DGCC_ROOT='$2'"
ENV="$ENV LDFLAGS='-L$2/lib -L$2/lib64'"
shift 2 ;;
--with-libpeyton)
xecho "Using libpeyton from '$2'"
CMAKE="$CMAKE -Dlibpeyton_ROOT='$2'"
shift 2 ;;
-h|--help)
usage;
CONFIGLOG_FINAL=
exit 0 ;;
--) shift ; break ;;
*) xecho "Internal error!" ; exit 1 ;;
esac
done

# Figure out the build dir -- if we're in the same directory as the
# configure script, make a subdirectory based on the choice of BUILD_TYPE
test -x ./configure && {
mkdir -p "$BUILDDIR" && cd "$BUILDDIR" && SOURCEDIR=".." || {
xecho "Error creating build directory."; exit -1;
}

# A flag meaning we're configuring from in-source
BDSET=1

xecho "Build directory is '$BUILDDIR'"
} || {
BUILDDIR="."
SOURCEDIR=`dirname $0`
}

# Assume all extra arguments are CMAKE variable definitions
for arg do
CMAKE="$CMAKE '-D$arg'"
done
CMAKE="$CMAKE $SOURCEDIR"

# Delete old CMakeCache.txt if it exists
test -f CMakeCache.txt && rm -f CMakeCache.txt

# Run cmake
xecho "Invoking CMake to configure the source"
oecho "$ENV $CMAKE"
eval $ENV $CMAKE | tee -a $CONFIGLOG;
test "x${PIPESTATUS[0]}" == "x0" && {
if [ "$BDSET" == "1" ]; then
# Generate a stub makefile that will hand-off compilation to the real makefile
# This happens only when configure is run in-source
cat > ../Makefile <<EOT
all:
tidy:
@ rm -rf $BUILDDIR
%:
@ test -f $BUILDDIR/Makefile || { echo "$BUILDDIR directory not configured. Run configure first." && false; }
@ cd $BUILDDIR && \$(MAKE) \$@
EOT
fi;
xecho "Source configured in directory '$BUILDDIR'. Run \`make' to compile."
} || {
xecho "Error configuring source."
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions scripts/make_plots.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

../scripts/plotpdf.py prob_ArMr.txt A_r M_r prob_ArMr.png
../scripts/plotpdf.py prob_MrFeH.txt M_r "[Fe/H]" prob_MrFeH.png
../scripts/plotpdf.py prob_DMAr.txt DM "A_r" prob_DMAr.png
Loading

0 comments on commit b9c238a

Please sign in to comment.