Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

Commit f25f77a

Browse files
ferdonlinepramodk
authored andcommitted
nrnivmodl prefer printf (#142)
- The install script string was not outputting quotes correctly. - We also changed `echo` to `printf` since it's a more portable command. - Using links instead of copying unmodified source files
1 parent 8fa8c48 commit f25f77a

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

extra/nrnivmodl-core

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ echo "#!/bin/bash
7777
set -e
7878
[ \$# -eq 1 ] || { echo 'Required install destination. Syntax: ' \$(basename \$0) '<directory>'; false; }
7979
set -x
80-
make -f \"${ROOTDIR}/share/coreneuron/nrnivmodl_core_makefile\" ${make_params[@]} DESTDIR=\$1 install
80+
make -f '${ROOTDIR}/share/coreneuron/nrnivmodl_core_makefile' " $(printf "'%s' " "${make_params[@]}") "DESTDIR=\$1 install
8181
" > nrnivmech_install.sh
8282
chmod 755 nrnivmech_install.sh
8383

extra/nrnivmodl_core_makefile.in

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,61 +66,60 @@ DESTDIR_RPATH = $(if $(DESTDIR),$(DESTDIR)/lib,$(_ORIGIN))
6666

6767
C_RESET := \033[0m
6868
C_GREEN := \033[32m
69-
ECHO := $(if $(filter Darwin,$(OS_NAME)),echo,echo -e)
7069

7170

7271
# ======== MAIN BUILD RULES ============
7372

7473
# Take the main and link with nrnmech.
7574
# RPATH is set for DESTDIR_RPATH and coreneuron lib
7675
$(special): $(coremech_lib)
77-
@$(ECHO) " => $(C_GREEN)LINKING$(C_RESET) executable $(special) "
76+
@printf " => $(C_GREEN)LINKING$(C_RESET) executable $(special)\n"
7877
$(CXX_LINK_EXE) -I $(incdir) $(datadir)/coreneuron.cpp -o $(special) \
7978
-L $(OUTPUT) -l$(coremech_libname) $(CORENRNLIB_FLAGS) -Wl,-rpath,'$(DESTDIR_RPATH)' -Wl,-rpath,$(libdir) $(LDFLAGS)
8079

8180

8281
$(coremech_lib): $(mod_func_o) $(dimplic_o) $(mod_objs)
83-
@$(ECHO) " => $(C_GREEN)LINKING$(C_RESET) library $(coremech_lib) Mod files: $(mod_files) (+ $(OPTMODS))"
82+
@printf " => $(C_GREEN)LINKING$(C_RESET) library $(coremech_lib) Mod files: $(mod_files) (+ $(OPTMODS))\n"
8483
$(CXX_LINK_SHARED) -I $(incdir) -DADDITIONAL_MECHS $(datadir)/enginemech.cpp -o ${coremech_lib} \
8584
$(mod_func_o) $(dimplic_o) $(mod_objs) $(datadir)/libscopmath.a $(CORENRNLIB_FLAGS) -Wl,-rpath,$(libdir) $(LDFLAGS)
8685

8786

8887
# Generic build cpp->o. Need PIC for shared lib
8988
$(OBJS_DIR)/%.o: $(MODC_DIR)/%.cpp $(kinderiv_h) | $(OBJS_DIR)
90-
@$(ECHO) " -> $(C_GREEN)Compiling$(C_RESET) $<"
89+
@printf " -> $(C_GREEN)Compiling$(C_RESET) $<\n"
9190
$(CXXCOMPILE) @CMAKE_CXX_COMPILE_OPTIONS_PIC@ -c $< -o $@
9291

9392

9493
# Build cpp files with mod2c
9594
$(MODC_DIR)/%.cpp: $(MODS_PATH)/%.mod | $(MODC_DIR)
96-
@$(ECHO) " -> $(C_GREEN)MOD2C$(C_RESET) $<"
95+
@printf " -> $(C_GREEN)MOD2C$(C_RESET) $<\n"
9796
MODLUNIT=$(datadir_mod2c)/nrnunits.lib \
9897
$(bindir)/mod2c_core $< -o $(MODC_DIR)/
9998

10099
# If .mod doesnt exist attempt from previously built opt mods in shared/
101100
$(MODC_DIR)/%.cpp: $(datadir_mod2c)/%.cpp | $(MODC_DIR)
102-
cp $< $@
101+
ln -s $< $@
103102

104103

105104
# Mod registration. Compiled by generic rule. Dont overwrite if not changed
106105
$(mod_func_c): build_always | $(MODC_DIR)
107-
@$(ECHO) " -> $(C_GREEN)Generating$(C_RESET) $(mod_func_c)"
106+
@printf " -> $(C_GREEN)Generating$(C_RESET) $(mod_func_c)\n"
108107
perl $(datadir)/mod_func.c.pl $(OPTMODS) $(mod_files) > $(mod_func_c).tmp
109108
diff -q $(mod_func_c).tmp $(mod_func_c) || echo "Replacing mod_func.c" && mv $(mod_func_c).tmp $(mod_func_c)
110109

111110

112111
# Header to avoid function callbacks using function pointers
113112
# Move all mods to temp and bring back only those required
114113
$(kinderiv_h): $(modc_files) build_always | $(MODC_DIR)
115-
@$(ECHO) " -> $(C_GREEN)Generating$(C_RESET) $(kinderiv_h)"
114+
@printf " -> $(C_GREEN)Generating$(C_RESET) $(kinderiv_h)\n"
116115
cd $(MODC_DIR) && mkdir -p _tmp && mv [^_]*.cpp _tmp/ && \
117116
mv $(addprefix _tmp/,$(notdir $(modc_files))) ./ || true
118117
rm -rf $(MODC_DIR)/_tmp
119118
cd $(MODC_DIR) && python $(datadir)/kinderiv.py
120119

121120

122121
$(dimplic_c): $(dimplic_src) | $(MODC_DIR)
123-
cp $(dimplic_src) $(dimplic_c)
122+
ln -s $(dimplic_src) $(dimplic_c)
124123

125124

126125
install: $(special) $(coremech_lib)

0 commit comments

Comments
 (0)