| 1 |
# Regular use |
| 2 |
CFLAGS=-O3 -s -flto |
| 3 |
|
| 4 |
# Common files used for everything |
| 5 |
CFILES=main_console.cpp nii_foreign.cpp nii_dicom.cpp jpg_0XC3.cpp ujpeg.cpp nifti1_io_core.cpp nii_ortho.cpp nii_dicom_batch.cpp -o dcm2niix |
| 6 |
|
| 7 |
# Universal files used for almost everything |
| 8 |
UFILES=$(CFILES) -DmyDisableOpenJPEG |
| 9 |
# Debugging |
| 10 |
#CFLAGS=-g |
| 11 |
|
| 12 |
# issue659: increase stack to 16mb |
| 13 |
#For Linux linker stacksize ignored: we must use setrlimit |
| 14 |
# LFLAGS=-Wl,-z -Wl,stack-size=16777216 |
| 15 |
LFLAGS= |
| 16 |
|
| 17 |
|
| 18 |
#Leak tests: |
| 19 |
# https://clang.llvm.org/docs/AddressSanitizer.html |
| 20 |
# clang++ -O1 -g -fsanitize=address -fno-omit-frame-pointer -I. main_console.cpp nii_foreign.cpp nii_dicom.cpp jpg_0XC3.cpp ujpeg.cpp nifti1_io_core.cpp nii_ortho.cpp nii_dicom_batch.cpp base64.c cJSON.c -o dcm2niix -DmyDisableOpenJPEG |
| 21 |
|
| 22 |
#run "ZLIB=1 make" for ZLIB build |
| 23 |
ifeq "$(ZLIB)" "1" |
| 24 |
CFILES += -DmyDisableMiniZ -lz |
| 25 |
endif |
| 26 |
|
| 27 |
#run "make" for default build |
| 28 |
#run "JPEGLS=1 make" for JPEGLS build |
| 29 |
JFLAGS= |
| 30 |
ifeq "$(JPEGLS)" "1" |
| 31 |
JFLAGS=-std=c++14 -DmyEnableJPEGLS charls/jpegls.cpp charls/jpegmarkersegment.cpp charls/interface.cpp charls/jpegstreamwriter.cpp charls/jpegstreamreader.cpp |
| 32 |
endif |
| 33 |
|
| 34 |
#run "JNIfTI=0 make" to disable JNIFTI build |
| 35 |
JSFLAGS= |
| 36 |
ifneq "$(JNIfTI)" "0" |
| 37 |
JSFLAGS=-DmyEnableJNIFTI base64.cpp cJSON.cpp |
| 38 |
endif |
| 39 |
|
| 40 |
ifneq ($(OS),Windows_NT) |
| 41 |
OS = $(shell uname) |
| 42 |
ifeq "$(OS)" "Darwin" |
| 43 |
#CFLAGS=-dead_strip -O3 |
| 44 |
#CFLAGS= -O3 |
| 45 |
CFLAGS=-O3 -flto -sectcreate __TEXT __info_plist Info.plist |
| 46 |
#Apple notarization requires a Info.plist |
| 47 |
# For .app bundles, the Info.plist is a separate file, for executables it is appended as a section |
| 48 |
#you can check that the Info.plist section has been inserted with either of these commands |
| 49 |
# otool -l ./dcm2niix | grep info_plist -B1 -A10 |
| 50 |
# launchctl plist ./dcm2niix |
| 51 |
#MacOS links g++ to clang++, for gcc install via homebrew and replace g++ with /usr/local/bin/gcc-9 |
| 52 |
#issue867 reduce stack pressure |
| 53 |
#LFLAGS=-Wl,-stack_size -Wl,0x1000000 |
| 54 |
endif |
| 55 |
endif |
| 56 |
all: |
| 57 |
g++ $(CFLAGS) -I. $(JSFLAGS) $(JFLAGS) $(LFLAGS) $(UFILES) |
| 58 |
@if [ "$$(uname)" = "Darwin" ]; then \ |
| 59 |
strip -x dcm2niix; \ |
| 60 |
fi |
| 61 |
|
| 62 |
sanitize: |
| 63 |
g++ -O1 -g -fsanitize=address -fno-omit-frame-pointer $(LFLAGS) $(UFILES) |
| 64 |
# -fstack-usage |
| 65 |
|
| 66 |
debug: |
| 67 |
g++ -O0 $(LFLAGS) $(UFILES) |
| 68 |
|
| 69 |
turbo: |
| 70 |
g++ -O0 $(LFLAGS) $(UFILES) -DmyTurboJPEG -I/opt/homebrew/include -L/opt/homebrew/lib -lturbojpeg |
| 71 |
|
| 72 |
jp2: |
| 73 |
g++ $(CFLAGS) $(LFLAGS) $(CFILES) $(JFLAGS) -I/opt/homebrew/Cellar/openjpeg/2.5.3/include/openjpeg-2.5/ -L/opt/homebrew/Cellar/openjpeg/2.5.3/lib/ -lopenjp2 |
| 74 |
|
| 75 |
noroi: |
| 76 |
g++ $(CFLAGS) -I. $(JSFLAGS) $(JFLAGS) $(LFLAGS) $(UFILES) -DmyNoRois |
| 77 |
|
| 78 |
wasm: |
| 79 |
emcc -O3 $(UFILES) -lz -s USE_ZLIB -s DEMANGLE_SUPPORT=1 -s EXPORTED_RUNTIME_METHODS='["callMain", "ccall", "cwrap", "FS", "FS_createDataFile", "FS_readFile", "FS_unlink", "allocateUTF8", "getValue", "stringToUTF8", "setValue"]' -s STACK_OVERFLOW_CHECK=2 -s STACK_SIZE=16MB -s ALLOW_MEMORY_GROWTH=1 -s WASM=1 -s EXPORT_ES6=1 -s MODULARIZE=1 -s EXPORTED_FUNCTIONS='["_main", "_malloc", "_free"]' -s FORCE_FILESYSTEM=1 -s INVOKE_RUN=0 -o ../js/src/dcm2niix.js |
| 80 |
# STACK_SIZE=16MB is the minimum value found to work with the current codebase when targeting WASM |
| 81 |
|
| 82 |
wasm-jpeg: |
| 83 |
emcc -O3 $(JFLAGS) $(CFILES) -DUSE_OPENJPEG -I${PIXI_PROJECT_ROOT}/openjpeg-2.5.3/src/lib/openjp2/ -I${PIXI_PROJECT_ROOT}/openjpeg-2.5.3/build/src/lib/openjp2/ -L${PIXI_PROJECT_ROOT}/openjpeg-2.5.3/build/bin/ -lopenjp2 -lz -s USE_ZLIB -s DEMANGLE_SUPPORT=1 -s EXPORTED_RUNTIME_METHODS='["callMain", "ccall", "cwrap", "FS", "FS_createDataFile", "FS_readFile", "FS_unlink", "allocateUTF8", "getValue", "stringToUTF8", "setValue"]' -s STACK_OVERFLOW_CHECK=2 -s STACK_SIZE=16MB -s ALLOW_MEMORY_GROWTH=1 -s WASM=1 -s EXPORT_ES6=1 -s MODULARIZE=1 -s EXPORTED_FUNCTIONS='["_main", "_malloc", "_free"]' -s FORCE_FILESYSTEM=1 -s INVOKE_RUN=0 -o ../js/src/dcm2niix.jpeg.js |
| 84 |
# STACK_SIZE=16MB is the minimum value found to work with the current codebase when targeting WASM |
| 85 |
|