Makefile: build all backends with optional HDR output
This commit is contained in:
1 parent
09923b9b18
commit
19f3a91b7f
5 files changed
+63
-32
No files matched your search
@@ -5,6 +5,7 @@ LDLIBS ?= -lm
|
||||
ENABLE_PNG ?= 1
|
||||
SPACETIME ?= minkowski
|
||||
BUILD_TYPE ?= Release
|
||||
ENABLE_HDR ?= 0
|
||||
|
||||
ifeq ($(BUILD_TYPE),Release)
|
||||
BUILD_CFLAGS := -O2 -DNDEBUG
|
||||
@@ -27,16 +28,16 @@ endif
|
||||
COMMON_SOURCES := $(filter-out src/main.c src/spacetime_minkowski.c src/spacetime_schwarzschild.c,$(wildcard src/*.c))
|
||||
PROVIDER_SOURCE := src/spacetime_$(SPACETIME).c
|
||||
BUILD_DIR := build/$(BUILD_TYPE)
|
||||
TARGET := $(BUILD_DIR)/$(SPACETIME)_sky
|
||||
TARGET_BASENAME := $(SPACETIME)_sky
|
||||
OBJECT_DIR := $(BUILD_DIR)/obj/$(SPACETIME)
|
||||
CORE_MINKOWSKI_SOURCES := $(COMMON_SOURCES) src/spacetime_minkowski.c
|
||||
TEST_TARGET := $(BUILD_DIR)/test_geodesic
|
||||
FRAME_TEST_TARGET := $(BUILD_DIR)/test_frame
|
||||
SCHWARZSCHILD_TEST_TARGET := $(BUILD_DIR)/test_schwarzschild
|
||||
OBSERVER_TRACK_TEST_TARGET := $(BUILD_DIR)/test_observer_track
|
||||
CATALOG_PREFETCH_TEST_TARGET := $(BUILD_DIR)/test_catalog_prefetch
|
||||
PSF_HDR_TEST_TARGET := $(BUILD_DIR)/minkowski_psf_hdr_test
|
||||
|
||||
.PHONY: all clean run test minkowski schwarzschild psf-hdr-test
|
||||
.PHONY: all backend clean run test minkowski schwarzschild FORCE
|
||||
|
||||
ifeq ($(SPACETIME),minkowski)
|
||||
BACKEND_CPPFLAGS := -DSPACETIME_MINKOWSKI
|
||||
@@ -46,10 +47,48 @@ else
|
||||
$(error Unknown SPACETIME '$(SPACETIME)'; choose minkowski or schwarzschild)
|
||||
endif
|
||||
|
||||
all: $(TARGET)
|
||||
ifeq ($(ENABLE_HDR),1)
|
||||
HDR_CPPFLAGS := -DENABLE_HDR_OUTPUT $(shell pkg-config --cflags cfitsio)
|
||||
HDR_LDLIBS := $(shell pkg-config --libs cfitsio)
|
||||
HDR_BUILD_TAG := hdr
|
||||
else ifeq ($(ENABLE_HDR),0)
|
||||
HDR_BUILD_TAG := standard
|
||||
else
|
||||
$(error Unknown ENABLE_HDR '$(ENABLE_HDR)'; choose 0 or 1)
|
||||
endif
|
||||
|
||||
$(TARGET): $(COMMON_SOURCES) $(PROVIDER_SOURCE) src/main.c | $(BUILD_DIR)
|
||||
$(CC) $(CPPFLAGS) $(BUILD_CPPFLAGS) $(BACKEND_CPPFLAGS) $(CFLAGS) $(BUILD_CFLAGS) $(OPENMP_FLAGS) -Isrc $^ $(LDLIBS) -o $@
|
||||
TARGET := $(BUILD_DIR)/$(TARGET_BASENAME)
|
||||
RENDER_SOURCES := $(COMMON_SOURCES) $(PROVIDER_SOURCE) src/main.c
|
||||
RENDER_OBJECTS := $(patsubst %.c,$(OBJECT_DIR)/$(HDR_BUILD_TAG)/%.o,$(RENDER_SOURCES))
|
||||
RENDER_DEPS := $(RENDER_OBJECTS:.o=.d)
|
||||
|
||||
# With no explicit backend choice, all means every currently supported
|
||||
# production spacetime backend. An explicit SPACETIME selects that backend,
|
||||
# so `make SPACETIME=schwarzschild` remains the direct build command.
|
||||
ifneq ($(filter command\ line environment environment\ override,$(origin SPACETIME)),)
|
||||
all: backend
|
||||
else
|
||||
all: minkowski schwarzschild
|
||||
endif
|
||||
|
||||
minkowski:
|
||||
$(MAKE) SPACETIME=minkowski ENABLE_HDR=$(ENABLE_HDR) backend
|
||||
|
||||
schwarzschild:
|
||||
$(MAKE) SPACETIME=schwarzschild ENABLE_HDR=$(ENABLE_HDR) backend
|
||||
|
||||
# Build exactly the selected backend/configuration, e.g.
|
||||
# make SPACETIME=schwarzschild ENABLE_HDR=1 backend
|
||||
backend: $(TARGET)
|
||||
|
||||
$(TARGET): $(RENDER_OBJECTS) FORCE | $(BUILD_DIR)
|
||||
$(CC) $(BUILD_CFLAGS) $(OPENMP_FLAGS) $(RENDER_OBJECTS) $(LDLIBS) $(HDR_LDLIBS) -o $@
|
||||
|
||||
FORCE:
|
||||
|
||||
$(OBJECT_DIR)/$(HDR_BUILD_TAG)/%.o: %.c
|
||||
@mkdir -p $(dir $@)
|
||||
$(CC) $(CPPFLAGS) $(BUILD_CPPFLAGS) $(BACKEND_CPPFLAGS) $(HDR_CPPFLAGS) $(CFLAGS) $(BUILD_CFLAGS) $(OPENMP_FLAGS) -Isrc -MMD -MP -c $< -o $@
|
||||
|
||||
$(BUILD_DIR):
|
||||
mkdir -p $@
|
||||
@@ -58,18 +97,6 @@ run: $(TARGET)
|
||||
mkdir -p output/imgs
|
||||
./$(TARGET) --catalog assets/sky_grid_5deg.csv --output output/imgs/$(SPACETIME)_sky.$(IMAGE_EXT)
|
||||
|
||||
minkowski:
|
||||
$(MAKE) SPACETIME=minkowski all
|
||||
|
||||
schwarzschild:
|
||||
$(MAKE) SPACETIME=schwarzschild all
|
||||
|
||||
# Deliberately separate from the production binary: enables --hdr-output FITS.
|
||||
$(PSF_HDR_TEST_TARGET): $(COMMON_SOURCES) src/spacetime_minkowski.c src/main.c | $(BUILD_DIR)
|
||||
$(CC) $(CPPFLAGS) $(BUILD_CPPFLAGS) -DENABLE_HDR_DEBUG -DSPACETIME_MINKOWSKI $(CFLAGS) $(BUILD_CFLAGS) $(OPENMP_FLAGS) -Isrc $^ $(LDLIBS) $(shell pkg-config --libs cfitsio) -o $@
|
||||
|
||||
psf-hdr-test: $(PSF_HDR_TEST_TARGET)
|
||||
|
||||
$(TEST_TARGET): tests/test_geodesic.c $(CORE_MINKOWSKI_SOURCES) | $(BUILD_DIR)
|
||||
$(CC) $(CPPFLAGS) $(BUILD_CPPFLAGS) $(CFLAGS) $(BUILD_CFLAGS) $(OPENMP_FLAGS) -Isrc $^ $(LDLIBS) -o $@
|
||||
|
||||
@@ -94,3 +121,5 @@ test: $(TEST_TARGET) $(FRAME_TEST_TARGET) $(SCHWARZSCHILD_TEST_TARGET) $(OBSERVE
|
||||
|
||||
clean:
|
||||
rm -rf build
|
||||
|
||||
-include $(RENDER_DEPS)
|
||||
@@ -253,11 +253,13 @@ count and each time slab's activation and terminal-ray summary.
|
||||
Movie renders always print one summary per time slab; `--verbose` also prints
|
||||
the ray counts before each slab is loaded.
|
||||
|
||||
For PSF validation only, `make psf-hdr-test` builds
|
||||
`build/minkowski_psf_hdr_test`, a separate binary with a `--hdr-output PATH`
|
||||
option. It writes the pre-tone-mapping RGB framebuffer as a three-plane,
|
||||
32-bit float FITS image. Values remain linear HDR at the renderer's arbitrary
|
||||
scale; no tone mapping or per-frame normalization is applied. The ordinary
|
||||
To preserve a render for later exposure and tone-mapping work, build the desired
|
||||
backend with `ENABLE_HDR=1`, for example `make SPACETIME=schwarzschild
|
||||
ENABLE_HDR=1`. This produces `build/Release/schwarzschild_sky`,
|
||||
which accepts `--hdr-output PATH`. It writes the pre-tone-mapping RGB
|
||||
framebuffer as a three-plane, 32-bit float FITS image. Values remain linear HDR
|
||||
at the renderer's arbitrary scale; no tone mapping or per-frame normalization
|
||||
is applied. The ordinary
|
||||
binaries do not contain this option or writer.
|
||||
|
||||
The FITS header describes a synthetic 8640-by-5760, 36-by-24 mm full-frame
|
||||
|
||||
+5
-5
@@ -31,7 +31,7 @@ typedef struct {
|
||||
const char *catalog_path;
|
||||
const char *all_sky_catalog_path;
|
||||
const char *output_path;
|
||||
#ifdef ENABLE_HDR_DEBUG
|
||||
#ifdef ENABLE_HDR_OUTPUT
|
||||
const char *hdr_output_path;
|
||||
#endif
|
||||
const char *observer_track_path;
|
||||
@@ -189,7 +189,7 @@ static int parse_args(int argc, char **argv, Settings *s,
|
||||
s->all_sky_catalog_path = argv[++i];
|
||||
else if (!strcmp(argv[i], "--output") && i + 1 < argc)
|
||||
s->output_path = argv[++i];
|
||||
#ifdef ENABLE_HDR_DEBUG
|
||||
#ifdef ENABLE_HDR_OUTPUT
|
||||
else if (!strcmp(argv[i], "--hdr-output") && i + 1 < argc)
|
||||
s->hdr_output_path = argv[++i];
|
||||
#endif
|
||||
@@ -449,7 +449,7 @@ static int render_observer_frame(const Settings *s, StarCatalog *catalog,
|
||||
&progress});
|
||||
if (s->draw_mesh)
|
||||
frame_draw_mesh(&mesh, hdr, s->width, s->height, 0.5, 0.5);
|
||||
#ifdef ENABLE_HDR_DEBUG
|
||||
#ifdef ENABLE_HDR_OUTPUT
|
||||
if (s->hdr_output_path != NULL &&
|
||||
write_hdr_fits(s->hdr_output_path, hdr, s->width, s->height,
|
||||
s->horizontal_fov_deg)) {
|
||||
@@ -666,7 +666,7 @@ int main(int argc, char **argv) {
|
||||
"[--psf-fwhm-pixels N] [--psf-moffat-beta N] "
|
||||
"[--max-magnification M] [--max-cache-psf-flux F] "
|
||||
"[--psf-direct] [--verbose] "
|
||||
#ifdef ENABLE_HDR_DEBUG
|
||||
#ifdef ENABLE_HDR_OUTPUT
|
||||
"[--hdr-output PATH] "
|
||||
#endif
|
||||
"[--coarse-cell-pixels N] [--refine-max-level N "
|
||||
@@ -692,7 +692,7 @@ int main(int argc, char **argv) {
|
||||
return write_minkowski_accel_track(&settings) == 0
|
||||
? 0
|
||||
: (perror(settings.write_minkowski_accel_track_path), 1);
|
||||
#ifdef ENABLE_HDR_DEBUG
|
||||
#ifdef ENABLE_HDR_OUTPUT
|
||||
if (settings.frames_dir != NULL && settings.hdr_output_path != NULL) {
|
||||
fputs("--hdr-output is available only for a single-frame render.\n", stderr);
|
||||
return 2;
|
||||
|
||||
+2
-2
@@ -8,7 +8,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef ENABLE_HDR_DEBUG
|
||||
#ifdef ENABLE_HDR_OUTPUT
|
||||
#include <fitsio.h>
|
||||
#endif
|
||||
|
||||
@@ -457,7 +457,7 @@ int write_tonemapped_image(const char *path, const double *hdr, int width, int h
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef ENABLE_HDR_DEBUG
|
||||
#ifdef ENABLE_HDR_OUTPUT
|
||||
int write_hdr_fits(const char *path, const double *hdr, int width, int height,
|
||||
double horizontal_fov_deg)
|
||||
{
|
||||
|
||||
+2
-2
@@ -58,8 +58,8 @@ int splat_moffat_cached(double *hdr, int width, int height, double x, double y,
|
||||
/* Writes PNG when built with libpng; non-libpng builds use PPM fallback. */
|
||||
int write_tonemapped_image(const char *path, const double *hdr, int width,
|
||||
int height);
|
||||
#ifdef ENABLE_HDR_DEBUG
|
||||
/* Test-build-only: writes the pre-tone-mapping framebuffer as 32-bit RGB FITS. */
|
||||
#ifdef ENABLE_HDR_OUTPUT
|
||||
/* Writes the pre-tone-mapping framebuffer as a 32-bit RGB FITS image. */
|
||||
int write_hdr_fits(const char *path, const double *hdr, int width, int height,
|
||||
double horizontal_fov_deg);
|
||||
#endif
|
||||
|
||||
Reference in new issue
Block a user