karllark / DIRTY_dustrt

DIRTY: 3D dust radiative transfer for dusty astrophysical sources
https://dirty-dustrt.readthedocs.io
5 stars 1 forks source link

Initial autotools integration #24

Closed jhunkeler closed 1 year ago

jhunkeler commented 1 year ago

Hi @karllark,

I recently helped someone compile DIRTY on their M1 laptop and ran into a few issues surrounding linkage to libcfitsio and finite (from math.h / libm) only being present on x86-based systems. On MacOS finite was superseded by isfinite. I'm not sure how prevalent this change is outside of Darwin, but it definitely broke the build in this case.

I've done the following:

  1. Integrated autoconf and automake (i.e. "autotools")
  2. Added automatic versioning based on tag information (see .build-aux/)
  3. Added auto-detection for cfitsio (via pkg-config). You can specify a custom path using --with-cfitsio=/path/here)
  4. Added --enable-debug to toggle all of the DEBUG_* defines. There are quite a few debug blocks with old code that don't work anymore. I tried to tidy up a few of them so they would compile. The ones that require additional defines are gated behind the --enable-debug-fixme option.
  5. Added auto-detection for sphinx. If found it will generate a man page (dirty.1).
  6. Added DIRTY/include/compat.h and included within the source files that were giving us trouble. This circumvents the finite issue.
  7. Added compilation instructions to docs/install.rst.
  8. I made a million assumptions about where things need to live. Here's what the installation prefix looks like after running make install...
$ ./configure --prefix=/tmp/dirty_test \
    && make -j20 \
    && make install \
    && find /tmp/dirty_test -type f
# ...
/tmp/dirty_test/share/man/man1/dirty.1
/tmp/dirty_test/share/dirty_dustrt/SEDs/redsg_kycyg_T3500_R2100.dat
/tmp/dirty_test/share/dirty_dustrt/SEDs/F98_p00_c_10.dat
/tmp/dirty_test/share/dirty_dustrt/SEDs/bluesg_T20000_R10.dat
/tmp/dirty_test/share/dirty_dustrt/pro/setup_ps_output.pro
/tmp/dirty_test/share/dirty_dustrt/pro/setup_colors.pro
/tmp/dirty_test/share/dirty_dustrt/pro/set_symbol.pro
/tmp/dirty_test/share/dirty_dustrt/pro/plot_rad_field_info.pro
/tmp/dirty_test/share/dirty_dustrt/pro/plot_model_grid_tau.pro
/tmp/dirty_test/share/dirty_dustrt/pro/plot_dirty_image_cut.pro
/tmp/dirty_test/share/dirty_dustrt/pro/plot_dirty_global_sed.pro
/tmp/dirty_test/share/dirty_dustrt/pro/plot_dirty_atten.pro
/tmp/dirty_test/share/dirty_dustrt/pro/krange.pro
/tmp/dirty_test/share/dirty_dustrt/pro/kplot.pro
/tmp/dirty_test/share/dirty_dustrt/pro/koplot.pro
/tmp/dirty_test/share/dirty_dustrt/pro/klegend.pro
/tmp/dirty_test/share/dirty_dustrt/pro/get_new_krange.pro
/tmp/dirty_test/share/dirty_dustrt/pro/generate_blackbody_input.pro
/tmp/dirty_test/share/dirty_dustrt/pro/find_uniq_rad_fields.pro
/tmp/dirty_test/share/dirty_dustrt/pro/create_wave_grid.pro
/tmp/dirty_test/share/dirty_dustrt/pro/comp_dirty_global_seds.pro
/tmp/dirty_test/share/dirty_dustrt/pro/close_ps_output.pro
/tmp/dirty_test/share/dirty_dustrt/pro/blackbody_dirtyv2.pro
/tmp/dirty_test/share/dirty_dustrt/licenses/LICENSE.rst
/tmp/dirty_test/share/dirty_dustrt/example/trust_slab/file_for_output_dir
/tmp/dirty_test/share/dirty_dustrt/example/trust_slab/full_grid.dat
/tmp/dirty_test/share/dirty_dustrt/example/trust_slab/DIRTY_bm1_neqgrain_tau_001.00_theta_090.drt
/tmp/dirty_test/share/dirty_dustrt/example/trust_slab/DIRTY_bm1_eqgrain_tau_001.00_theta_090.drt
/tmp/dirty_test/share/dirty_dustrt/example/trust_slab/DIRTY_bm1_effgrain_tau_001.00_theta_090.drt
/tmp/dirty_test/share/dirty_dustrt/example/trust_slab/BB_T10000_L100000.dat
/tmp/dirty_test/share/dirty_dustrt/example/trust_slab/basic_grid.dat
/tmp/dirty_test/share/dirty_dustrt/example/dmodel_test/standard_sphere_mwave_dmodel.param
/tmp/dirty_test/share/dirty_dustrt/example/test_sphere_tau3.param
/tmp/dirty_test/share/dirty_dustrt/example/standard_sphere.param
/tmp/dirty_test/share/dirty_dustrt/example/standard_sphere_multiwave.param
/tmp/dirty_test/share/dirty_dustrt/example/standard_sphere_diffuse.param
/tmp/dirty_test/share/dirty_dustrt/example/standard_slab.param
/tmp/dirty_test/share/dirty_dustrt/example/standard_shell.param
/tmp/dirty_test/share/dirty_dustrt/example/standard_shell_outputfailureadded.param
/tmp/dirty_test/share/dirty_dustrt/example/spherical_clumps.param
/tmp/dirty_test/share/dirty_dustrt/example/multiple_stars_sphere.param
/tmp/dirty_test/share/dirty_dustrt/example/cubical_clumps.param
/tmp/dirty_test/share/dirty_dustrt/README.rst
/tmp/dirty_test/bin/dirty

And finally -- to generate a release archive for your users:

# Generate a tag
git tag -a VERSION_TAG_HERE -m 'A worthy message'

# Purge all untracked files from the directory structure
git clean -ffxd

# Reinitialize autotools
./bootstrap
./configure

# Generate the archive
make distcheck

## on success: ./dirty_dustrt-VERSION_TAG_HERE.tar.gz
git push --tags

## on error: no archive
### remove local tag: 
### git checkout master
### git tag -d VERSION_TAG_HERE

#<<< fix the problems, commit, and repeat the steps above>>>

The distcheck target is nice because it tests the build process. You can upload the archive to the "release" associated with a tag on github.


I think that's about it.

karllark commented 1 year ago

This is awesome! Many thanks for helping out getting this working on Macs and then putting the pull request.

I will take a look at this soon (hopefully this week) and post any comments I have.

jhunkeler commented 1 year ago

No problem!

karllark commented 1 year ago

All looks great and my (limited) testing says it all works. Will merge.