Skip to content

Commit a827eb9

Browse files
committed
Merge branch '1.0rc1' of github.com:cschreib/egg into 1.0rc1
2 parents 14876b6 + 42cd7fd commit a827eb9

13 files changed

+259
-13
lines changed

cmake/FindLibDwarf.cmake

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# - Try to find libdwarf
2+
# Once done this will define
3+
#
4+
# LIBDWARF_FOUND - system has libdwarf
5+
# LIBDWARF_INCLUDE_DIRS - the libdwarf include directory
6+
# LIBDWARF_LIBRARIES - Link these to use libdwarf
7+
# LIBDWARF_DEFINITIONS - Compiler switches required for using libdwarf
8+
#
9+
10+
# Locate libelf library at first
11+
if (NOT LIBELF_FOUND)
12+
find_package (LibElf)
13+
endif (NOT LIBELF_FOUND)
14+
15+
if (LIBDWARF_LIBRARIES AND LIBDWARF_INCLUDE_DIRS)
16+
set (LibDwarf_FIND_QUIETLY TRUE)
17+
endif (LIBDWARF_LIBRARIES AND LIBDWARF_INCLUDE_DIRS)
18+
19+
find_path (DWARF_INCLUDE_DIR
20+
NAMES
21+
libdwarf.h dwarf.h
22+
PATHS
23+
/usr/include
24+
/usr/include/libdwarf
25+
/usr/local/include
26+
/usr/local/include/libdwarf
27+
/opt/local/include
28+
/sw/include
29+
ENV CPATH) # PATH and INCLUDE will also work
30+
31+
if (DWARF_INCLUDE_DIR)
32+
set (LIBDWARF_INCLUDE_DIRS ${DWARF_INCLUDE_DIR})
33+
endif ()
34+
35+
find_library (LIBDWARF_LIBRARIES
36+
NAMES
37+
dwarf libdwarf
38+
PATHS
39+
/usr/lib
40+
/usr/local/lib
41+
/opt/local/lib
42+
/sw/lib
43+
ENV LIBRARY_PATH # PATH and LIB will also work
44+
ENV LD_LIBRARY_PATH)
45+
include (FindPackageHandleStandardArgs)
46+
47+
48+
# handle the QUIETLY and REQUIRED arguments and set LIBDWARF_FOUND to TRUE
49+
# if all listed variables are TRUE
50+
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibDwarf DEFAULT_MSG
51+
LIBELF_FOUND
52+
LIBDWARF_LIBRARIES
53+
LIBDWARF_INCLUDE_DIRS)
54+
55+
if (LIBDWARF_LIBRARIES AND LIBDWARF_INCLUDE_DIRS)
56+
set(LIBDWARF_LIBRARIES ${LIBDWARF_LIBRARIES} ${LIBELF_LIBRARIES})
57+
set(LIBDWARF_INCLUDE_DIRS ${LIBDWARF_INCLUDE_DIRS} ${LIBELF_INCLUDE_DIRS})
58+
59+
set(CMAKE_REQUIRED_INCLUDES ${LIBDWARF_INCLUDE_DIRS})
60+
set(CMAKE_REQUIRED_LIBRARIES ${LIBDWARF_LIBRARIES} ${LIBELF_LIBRARIES})
61+
62+
# libdwarf makes breaking changes occasionally and doesn't provide an easy
63+
# way to test for them. The following checks should detect the changes and
64+
# pass that information on accordingly.
65+
INCLUDE(CheckCXXSourceCompiles)
66+
INCLUDE(CheckFunctionExists)
67+
68+
MACRO(CHECK_LIBDWARF_INIT init params var)
69+
# Check for the existence of this particular init function.
70+
unset(INIT_EXISTS CACHE)
71+
CHECK_FUNCTION_EXISTS(${init} INIT_EXISTS)
72+
if (INIT_EXISTS)
73+
set(LIBDWARF_USE_INIT_C ${var})
74+
75+
# Check to see if we can use a const name.
76+
unset(DW_CONST CACHE)
77+
78+
if (NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
79+
# -std=c++11 is already set in HPHPCompiler.cmake, don't
80+
# add -std=c++0x on top of that or clang will give errors
81+
set(CMAKE_REQUIRED_FLAGS "-std=c++0x")
82+
endif()
83+
84+
CHECK_CXX_SOURCE_COMPILES("
85+
#include <libdwarf.h>
86+
#include <cstddef>
87+
int dwarfCallback(const char * a, int b, Dwarf_Unsigned c,
88+
Dwarf_Unsigned d, Dwarf_Unsigned e, Dwarf_Unsigned f,
89+
Dwarf_Unsigned * g, Dwarf_Ptr h, int * i) {}
90+
int main() { ${init}(${params}); return 0; }" DW_CONST)
91+
if (DW_CONST)
92+
set(LIBDWARF_CONST_NAME 1)
93+
else()
94+
set(LIBDWARF_CONST_NAME 0)
95+
endif()
96+
endif()
97+
ENDMACRO(CHECK_LIBDWARF_INIT)
98+
99+
# Order is important, last one is used.
100+
CHECK_LIBDWARF_INIT("dwarf_producer_init"
101+
"0, dwarfCallback, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr" 0)
102+
CHECK_LIBDWARF_INIT("dwarf_producer_init_c" "0, dwarfCallback, nullptr, nullptr, nullptr, nullptr" 1)
103+
endif()
104+
105+
if(LIBDWARF_CONST_NAME)
106+
message(STATUS "libdwarf uses const char* type")
107+
else()
108+
message(STATUS "libdwarf uses char* type")
109+
endif()
110+
if(LIBDWARF_USE_INIT_C)
111+
message(STATUS "libdwarf has dwarf_producer_init_c")
112+
else()
113+
message(STATUS "libdwarf does not have dwarf_producer_init_c, using dwarf_producer_init")
114+
endif()
115+
116+
mark_as_advanced(LIBDW_INCLUDE_DIR DWARF_INCLUDE_DIR)
117+
mark_as_advanced(LIBDWARF_INCLUDE_DIRS LIBDWARF_LIBRARIES)
118+
mark_as_advanced(LIBDWARF_CONST_NAME LIBDWARF_USE_INIT_C)

cmake/FindLibElf.cmake

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# - Try to find libelf
2+
# Once done this will define
3+
#
4+
# LIBELF_FOUND - system has libelf
5+
# LIBELF_INCLUDE_DIRS - the libelf include directory
6+
# LIBELF_LIBRARIES - Link these to use libelf
7+
# LIBELF_DEFINITIONS - Compiler switches required for using libelf
8+
#
9+
# Copyright (c) 2008 Bernhard Walle <[email protected]>
10+
#
11+
# Redistribution and use is allowed according to the terms of the New
12+
# BSD license.
13+
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
14+
#
15+
16+
17+
if (LIBELF_LIBRARIES AND LIBELF_INCLUDE_DIRS)
18+
set (LibElf_FIND_QUIETLY TRUE)
19+
endif (LIBELF_LIBRARIES AND LIBELF_INCLUDE_DIRS)
20+
21+
find_path (LIBELF_INCLUDE_DIRS
22+
NAMES
23+
libelf.h
24+
PATHS
25+
/usr/include
26+
/usr/include/libelf
27+
/usr/local/include
28+
/usr/local/include/libelf
29+
/opt/local/include
30+
/opt/local/include/libelf
31+
/sw/include
32+
/sw/include/libelf
33+
ENV CPATH)
34+
35+
find_library (LIBELF_LIBRARIES
36+
NAMES
37+
elf
38+
PATHS
39+
/usr/lib
40+
/usr/local/lib
41+
/opt/local/lib
42+
/sw/lib
43+
ENV LIBRARY_PATH
44+
ENV LD_LIBRARY_PATH)
45+
46+
include (FindPackageHandleStandardArgs)
47+
48+
49+
# handle the QUIETLY and REQUIRED arguments and set LIBELF_FOUND to TRUE if all listed variables are TRUE
50+
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibElf DEFAULT_MSG
51+
LIBELF_LIBRARIES
52+
LIBELF_INCLUDE_DIRS)
53+
54+
SET(CMAKE_REQUIRED_LIBRARIES elf)
55+
INCLUDE(CheckCXXSourceCompiles)
56+
CHECK_CXX_SOURCE_COMPILES("#include <libelf.h>
57+
int main() {
58+
Elf *e = (Elf*)0;
59+
size_t sz;
60+
elf_getshdrstrndx(e, &sz);
61+
return 0;
62+
}" ELF_GETSHDRSTRNDX)
63+
64+
mark_as_advanced(LIBELF_INCLUDE_DIRS LIBELF_LIBRARIES ELF_GETSHDRSTRNDX)

cmake/FindLibUnwind.cmake

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Find the libunwind library
2+
#
3+
# LIBUNWIND_FOUND - True if libunwind was found.
4+
# LIBUNWIND_LIBRARIES - The libraries needed to use libunwind
5+
# LIBUNWIND_INCLUDE_DIR - Location of unwind.h and libunwind.h
6+
7+
FIND_PATH(LIBUNWIND_INCLUDE_DIR libunwind.h)
8+
if(NOT LIBUNWIND_INCLUDE_DIR)
9+
message(FATAL_ERROR "failed to find libunwind.h")
10+
elif(NOT EXISTS "${LIBUNWIND_INCLUDE_DIR}/unwind.h")
11+
message(FATAL_ERROR "libunwind.h was found, but unwind.h was not found in that directory.")
12+
SET(LIBUNWIND_INCLUDE_DIR "")
13+
endif()
14+
15+
FIND_LIBRARY(LIBUNWIND_GENERIC_LIBRARY "unwind")
16+
if(NOT LIBUNWIND_GENERIC_LIBRARY)
17+
MESSAGE(FATAL_ERROR "failed to find unwind generic library")
18+
endif()
19+
SET(LIBUNWIND_LIBRARIES ${LIBUNWIND_GENERIC_LIBRARY})
20+
21+
# For some reason, we have to link to two libunwind shared object files:
22+
# one arch-specific and one not.
23+
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
24+
SET(LIBUNWIND_ARCH "arm")
25+
elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "amd64")
26+
SET(LIBUNWIND_ARCH "x86_64")
27+
elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$")
28+
SET(LIBUNWIND_ARCH "x86")
29+
endif()
30+
31+
if(LIBUNWIND_ARCH)
32+
FIND_LIBRARY(LIBUNWIND_SPECIFIC_LIBRARY "unwind-${LIBUNWIND_ARCH}")
33+
if (NOT LIBUNWIND_SPECIFIC_LIBRARY)
34+
MESSAGE(FATAL_ERROR "failed to find unwind-${LIBUNWIND_ARCH}")
35+
endif()
36+
SET(LIBUNWIND_LIBRARIES ${LIBUNWIND_LIBRARIES} ${LIBUNWIND_SPECIFIC_LIBRARY})
37+
endif(LIBUNWIND_ARCH)
38+
39+
MARK_AS_ADVANCED(LIBUNWIND_LIBRARIES LIBUNWIND_INCLUDE_DIR)
40+
41+
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibUnwind DEFAULT_MSG
42+
LIBUNWIND_LIBRARIES LIBUNWIND_INCLUDE_DIR)

cmake/Findphypp.cmake

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ if(NOT PHYPP_FOUND)
8686
set(PHYPP_LIBRARIES ${PHYPP_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
8787

8888
# find optional libraries
89+
find_package(LibUnwind)
90+
find_package(LibDwarf)
8991
find_package(GSL)
9092
find_package(FFTW 3)
9193
find_package(GooglePerfTools)
@@ -128,6 +130,24 @@ if(NOT PHYPP_FOUND)
128130
set(PHYPP_LIBRARIES ${PHYPP_LIBRARIES} ${FFTW_LIBRARIES})
129131
endif()
130132

133+
# handle conditional LibUnwind support
134+
if (NOT LIBUNWIND_FOUND OR NO_LIBUNWIND)
135+
set(NO_UNWIND 1)
136+
add_definitions(-DNO_LIBUNWIND)
137+
else()
138+
set(NO_UNWIND 0)
139+
set(PHYPP_INCLUDE_DIRS ${PHYPP_INCLUDE_DIRS} ${LIBUNWIND_INCLUDE_DIR})
140+
set(PHYPP_LIBRARIES ${PHYPP_LIBRARIES} ${LIBUNWIND_LIBRARIES})
141+
endif()
142+
143+
# handle conditional LibDwarf support
144+
if (NO_UNWIND OR NOT LIBDWARF_FOUND OR NO_LIBDWARF)
145+
add_definitions(-DNO_LIBDWARF)
146+
else()
147+
set(PHYPP_INCLUDE_DIRS ${PHYPP_INCLUDE_DIRS} ${LIBDWARF_INCLUDE_DIRS})
148+
set(PHYPP_LIBRARIES ${PHYPP_LIBRARIES} ${LIBDWARF_LIBRARIES})
149+
endif()
150+
131151
# handle conditional Google perftools support
132152
if (TCMALLOC_LIBRARY)
133153
set(PHYPP_LIBRARIES ${PHYPP_LIBRARIES} ${TCMALLOC_LIBRARY})

share/psfs/README

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ Private communication
2727
Spitzer MIPS 24um
2828
=================
2929

30-
The PSF was built by Magnelli et al. (2009) by empirically stacking isolated objects in the observed GOODS-South map. It is provided at the standard map resolution of 1.2"/pixel, and is normalized to unit integral since MIPS maps are traditionally expressed in Jy/pixel (or MJy/sr).
31-
32-
Source:
33-
Private communication
34-
+ Magnelli et al. (2009)
30+
The PSF was built using a analytic radial model fitted to a bright source in GOODS South (a Gaussian core plus a Gaussian ring) at 1.2"/pixel resolution. It is normalized to unit integral since MIPS images are usually in Jy/pixel (or MJy/sr). The model is:
31+
exp(-r^2/(2.0*p[0]^2)) + p[1]*exp(-(r-p[2])^2/(2.0*p[3]^2))
32+
r: distance from center in pixels
33+
p[0]: width of the core (1.952 pixels)
34+
p[1]: relative amplitude of the ring (0.0485)
35+
p[2]: distance of the ring from center (7.756 pixels)
36+
p[3]: width of the ring (1.222 pixels)
3537

3638

3739
Herschel PACS

share/psfs/spitzer-mips24.fits

-22.5 KB
Binary file not shown.

src/egg-2skymaker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ void print_help();
77
// SkyMaker pixel type (see PIXTYPE in skymaker/src/fits/fitscat.h)
88
using SkyPixType = float;
99

10-
int main(int argc, char* argv[]) {
10+
int phypp_main(int argc, char* argv[]) {
1111
if (argc < 2) {
1212
print_help();
1313
return 1;

src/egg-buildmf.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ vec1d schechter2(vec1d m, double mstar1, double index1, double phistar1,
77
return log(10.0)*(exp(-tm1)*phistar1*pow(tm1, 1+index1) + exp(-tm2)*phistar2*pow(tm2, 1+index2));
88
}
99

10-
int main(int argc, char* argv[]) {
10+
int phypp_main(int argc, char* argv[]) {
1111
double mmin = 4.0, mmax = 13.0;
1212
double zmax = 10.5;
1313
double dm = 0.05;

src/egg-gencat.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const std::string filters_dir = filters_dir_env.empty() ?
77

88
void print_help();
99

10-
int main(int argc, char* argv[]) {
10+
int phypp_main(int argc, char* argv[]) {
1111
// Initialization
1212
// --------------
1313

src/egg-genmap.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const std::string egg_share_dir = file::directorize(EGG_SHARE_DIR);
44

55
void print_help();
66

7-
int main(int argc, char* argv[]) {
7+
int phypp_main(int argc, char* argv[]) {
88
// Name of the FITS table containing the mock catalog
99
std::string cat_file;
1010
// Name of the output FITS file in which to store the map

0 commit comments

Comments
 (0)