Skip to content

Commit

Permalink
avoid hard-coded paths for utilities in build scripts
Browse files Browse the repository at this point in the history
These changes facilitate building Chez Scheme in environments where
utility commands are not available at their usual absolute paths,
such as Nix and GNU Guix.

Specific changes:
  - `cc` -> `$(CC)`
  - `/bin/rm` -> `rm`
  - `/bin/ln` -> `ln`
  - `/bin/cp` -> `cp`
  - `/bin/echo` -> `echo`
  - in `makefiles/installsh`, add a case to find `true`
    at an unusual path or as a shell builtin

Related to racket/racket#3707

Changes merged into Racket's fork of Chez Scheme as
racket@ade94d2
and
racket/racket@fdb2ad7

This commit incorporates further adjustments suggested by @akeep.

Co-authored-by: Andy Keep <[email protected]>
  • Loading branch information
LiberalArtist and akeep committed Mar 13, 2021
1 parent 5342bb3 commit 8f4633c
Show file tree
Hide file tree
Showing 40 changed files with 100 additions and 88 deletions.
11 changes: 11 additions & 0 deletions LOG
Original file line number Diff line number Diff line change
Expand Up @@ -2148,3 +2148,14 @@
primdata.ss primvars.ss
- sleep of negative durations now returns immediately
7.ss
- avoid hard-coded paths for utilities in build scripts
checkin csug/gifs/Makefile csug/math/Makefile examples/Makefile
makefiles/Makefile-csug.in makefiles/Makefile-release_notes.in
makefiles/Mf-install.in makefiles/installsh mats/6.ms mats/Mf-a6fb
mats/Mf-a6le mats/Mf-a6nb mats/Mf-a6ob mats/Mf-a6osx mats/Mf-arm32le
mats/Mf-i3fb mats/Mf-i3le mats/Mf-i3nb mats/Mf-i3ob mats/Mf-i3osx
mats/Mf-i3qnx mats/Mf-ppc32le mats/Mf-ta6fb mats/Mf-ta6le mats/Mf-ta6nb
mats/Mf-ta6ob mats/Mf-ta6osx mats/Mf-ti3fb mats/Mf-ti3le mats/Mf-ti3nb
mats/Mf-ti3ob mats/Mf-ti3osx mats/Mf-tppc32le mats/unix.ms newrelease
pkg/Makefile release_notes/gifs/Makefile release_notes/math/Makefile
s/Mf-base workarea
8 changes: 4 additions & 4 deletions csug/gifs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ density=-r90x90
${density} - |\
pnmcrop |\
ppmtogif -transparent white > $*.gif
/bin/rm -f $*.dvi $*.log *.aux
rm -f $*.dvi $*.log *.aux
test -f $*.gif && chmod 644 $*.gif

# translate ps file to gif w/o transparent white background
Expand All @@ -28,7 +28,7 @@ density=-r90x90
${density} - |\
pnmcrop |\
ppmtogif > $*.gif
/bin/rm -f $*.dvi $*.log *.aux
rm -f $*.dvi $*.log *.aux
test -f $*.gif && chmod 644 $*.gif

all: ${gifs}
Expand Down Expand Up @@ -57,7 +57,7 @@ ghostRightarrow.gif: Rightarrow.tex
giftrans -g '#000000=#ffffff' |\
giftopnm |\
ppmtogif -transparent white > $*.gif
/bin/rm -f Rightarrow.dvi Rightarrow.log Rightarrow.aux
rm -f Rightarrow.dvi Rightarrow.log Rightarrow.aux
test -f $*.gif && chmod 644 $*.gif

clean: ; /bin/rm -f *.gif Make.out
clean: ; rm -f *.gif Make.out
4 changes: 2 additions & 2 deletions csug/math/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ density=-r90x90
${density} - |\
pnmcrop |\
ppmtogif -transparent white > $*.gif
/bin/rm -f $*.dvi $*.log $*.aux
rm -f $*.dvi $*.log $*.aux
test -f $*.gif && chmod 644 $*.gif

all: ${gifs}

${gifs}: mathmacros

clean: ; /bin/rm -f *.gif Make.out
clean: ; rm -f *.gif Make.out
2 changes: 1 addition & 1 deletion examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ needed: ${obj}

all: ; echo "(time (for-each compile-file (map symbol->string '(${src}))))" | ${Scheme}

clean: ; /bin/rm -f $(obj) expr.md
clean: ; rm -f $(obj) expr.md
6 changes: 3 additions & 3 deletions makefiles/Makefile-csug.in
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ install: target
# thrice is not enough when starting from scratch
logcheck1: $(x).thirdrun
@if [ -n "`grep 'Warning: Label(s) may have changed' $(x).log`" ] ; then\
/bin/rm -f $(x).thirdrun ;\
rm -f $(x).thirdrun ;\
$(MAKE) $(x).thirdrun;\
fi

Expand All @@ -55,7 +55,7 @@ stexsrc = csug.stex title.stex copyright.stex contents.stex\
texsrc = ${stexsrc:%.stex=%.tex}

title.tex contents.tex bibliography.tex:
/bin/rm -f $*.tex
rm -f $*.tex
echo "%%% DO NOT EDIT THIS FILE" > $*.tex
echo "%%% Edit the .stex version instead" >> $*.tex
echo "" >> $*.tex
Expand Down Expand Up @@ -147,7 +147,7 @@ code: $(stexsrc)
echo '(load "code" pretty-print)' | $(Scheme) -q

$(x).clean:
-/bin/rm -f $(x).rfm $(x).sfm $(x).prefirstrun $(x).presecondrun\
-rm -f $(x).rfm $(x).sfm $(x).prefirstrun $(x).presecondrun\
$(x).prethirdrun $(x).ans\
$(x).hprefirstrun $(x).hpresecondrun $(x).hprethirdrun\
tspl.aux tspl.haux tspl.rfm tspl.idx in.hidx\
Expand Down
2 changes: 1 addition & 1 deletion makefiles/Makefile-release_notes.in
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ install: $x.pdf $x.html
$(INSTALL) -m 2755 -d $(installdir)/gifs
$(INSTALL) -m 0644 --ifdiff gifs/*.gif $(installdir)/gifs
$(INSTALL) -m 2755 -d $(installdir)/math
-/bin/rm -rf $(installdir)/$(mathdir)
-rm -rf $(installdir)/$(mathdir)
$(INSTALL) -m 2755 -d $(installdir)/$(mathdir)
if [ -e $(mathdir)/0.gif ] ; then $(INSTALL) -m 0644 $(mathdir)/*.gif $(installdir)/$(mathdir) ; fi

Expand Down
4 changes: 2 additions & 2 deletions makefiles/Mf-install.in
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ bininstall: ${Bin}
libbininstall: ${LibBin}
$I -m 444 ${PetiteBoot} ${LibBin}/petite.boot
if [ "${InstallPetiteName}" != "petite" ]; then\
/bin/rm -f ${LibBin}/${InstallPetiteName}.boot;\
rm -f ${LibBin}/${InstallPetiteName}.boot;\
ln -f ${LibBin}/petite.boot ${LibBin}/${InstallPetiteName}.boot;\
fi
$I -m 444 ${SchemeBoot} ${LibBin}/scheme.boot;\
if [ "${InstallSchemeName}" != "scheme" ]; then\
/bin/rm -f ${LibBin}/${InstallSchemeName}.boot;\
rm -f ${LibBin}/${InstallSchemeName}.boot;\
ln -f ${LibBin}/scheme.boot ${LibBin}/${InstallSchemeName}.boot;\
fi
ln -f ${LibBin}/scheme.boot ${LibBin}/${InstallScriptName}.boot;
Expand Down
3 changes: 2 additions & 1 deletion makefiles/installsh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#! /bin/sh
if [ -x /bin/true ]; then TRUE=/bin/true;
elif [ -x /usr/bin/true ]; then TRUE=/usr/bin/true;
else echo "Can't find /bin/true or /usr/bin/true" ; exit 1;
elif command -v true &> /dev/null; then TRUE=true;
else echo "Can't find /bin/true or /usr/bin/true and no true command" ; exit 1;
fi

while ${TRUE} ; do
Expand Down
2 changes: 1 addition & 1 deletion mats/6.ms
Original file line number Diff line number Diff line change
Expand Up @@ -2685,7 +2685,7 @@
(begin
(system "ln -s ../examples .")
(load "examples/fatfib.ss" compile)
(system "/bin/rm examples")
(system "rm -f examples")
#t))
(or (windows?) (embedded?)
(equal?
Expand Down
4 changes: 2 additions & 2 deletions mats/Mf-a6fb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fobj = foreign1.so
include Mf-base

foreign1.so: ${fsrc} ../boot/$m/scheme.h
cc -fPIC -shared -I${Include} -o foreign1.so ${fsrc}
$(CC) -fPIC -shared -I${Include} -o foreign1.so ${fsrc}

cat_flush: cat_flush.c
cc -o cat_flush cat_flush.c
$(CC) -o cat_flush cat_flush.c
4 changes: 2 additions & 2 deletions mats/Mf-a6le
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fobj = foreign1.so
include Mf-base

foreign1.so: ${fsrc} ../boot/$m/scheme.h
cc -m64 -fPIC -shared -I${Include} -o foreign1.so ${fsrc}
$(CC) -m64 -fPIC -shared -I${Include} -o foreign1.so ${fsrc}

cat_flush: cat_flush.c
cc -o cat_flush cat_flush.c
$(CC) -o cat_flush cat_flush.c
4 changes: 2 additions & 2 deletions mats/Mf-a6nb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fobj = foreign1.so
include Mf-base

foreign1.so: ${fsrc} ../boot/$m/scheme.h
cc -fPIC -shared -I${Include} -o foreign1.so ${fsrc}
$(CC) -fPIC -shared -I${Include} -o foreign1.so ${fsrc}

cat_flush: cat_flush.c
cc -o cat_flush cat_flush.c
$(CC) -o cat_flush cat_flush.c
4 changes: 2 additions & 2 deletions mats/Mf-a6ob
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fobj = foreign1.so
include Mf-base

foreign1.so: ${fsrc} ../boot/$m/scheme.h
cc -fPIC -shared -I${Include} -o foreign1.so ${fsrc}
$(CC) -fPIC -shared -I${Include} -o foreign1.so ${fsrc}

cat_flush: cat_flush.c
cc -o cat_flush cat_flush.c
$(CC) -o cat_flush cat_flush.c
4 changes: 2 additions & 2 deletions mats/Mf-a6osx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fobj = foreign1.so
include Mf-base

foreign1.so: ${fsrc} ../boot/$m/scheme.h
cc -m64 -dynamiclib -undefined dynamic_lookup -I${Include} -o foreign1.so ${fsrc}
$(CC) -m64 -dynamiclib -undefined dynamic_lookup -I${Include} -o foreign1.so ${fsrc}

cat_flush: cat_flush.c
cc -o cat_flush cat_flush.c
$(CC) -o cat_flush cat_flush.c
4 changes: 2 additions & 2 deletions mats/Mf-arm32le
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fobj = foreign1.so
include Mf-base

foreign1.so: ${fsrc} ../boot/$m/scheme.h
cc -fPIC -fomit-frame-pointer -shared -I${Include} -o foreign1.so ${fsrc}
$(CC) -fPIC -fomit-frame-pointer -shared -I${Include} -o foreign1.so ${fsrc}

cat_flush: cat_flush.c
cc -o cat_flush cat_flush.c
$(CC) -o cat_flush cat_flush.c
4 changes: 2 additions & 2 deletions mats/Mf-i3fb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fobj = foreign1.so
include Mf-base

foreign1.so: ${fsrc} ../boot/$m/scheme.h
cc -fPIC -shared -I${Include} -o foreign1.so ${fsrc}
$(CC) -fPIC -shared -I${Include} -o foreign1.so ${fsrc}

cat_flush: cat_flush.c
cc -o cat_flush cat_flush.c
$(CC) -o cat_flush cat_flush.c
4 changes: 2 additions & 2 deletions mats/Mf-i3le
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fobj = foreign1.so
include Mf-base

foreign1.so: ${fsrc} ../boot/$m/scheme.h
cc -m32 -fPIC -shared -I${Include} -o foreign1.so ${fsrc}
$(CC) -m32 -fPIC -shared -I${Include} -o foreign1.so ${fsrc}

cat_flush: cat_flush.c
cc -o cat_flush cat_flush.c
$(CC) -o cat_flush cat_flush.c
4 changes: 2 additions & 2 deletions mats/Mf-i3nb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fobj = foreign1.so
include Mf-base

foreign1.so: ${fsrc} ../boot/$m/scheme.h
cc -fPIC -shared -I${Include} -o foreign1.so ${fsrc}
$(CC) -fPIC -shared -I${Include} -o foreign1.so ${fsrc}

cat_flush: cat_flush.c
cc -o cat_flush cat_flush.c
$(CC) -o cat_flush cat_flush.c
4 changes: 2 additions & 2 deletions mats/Mf-i3ob
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fobj = foreign1.so
include Mf-base

foreign1.so: ${fsrc} ../boot/$m/scheme.h
cc -fPIC -shared -I${Include} -o foreign1.so ${fsrc}
$(CC) -fPIC -shared -I${Include} -o foreign1.so ${fsrc}

cat_flush: cat_flush.c
cc -o cat_flush cat_flush.c
$(CC) -o cat_flush cat_flush.c
4 changes: 2 additions & 2 deletions mats/Mf-i3osx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fobj = foreign1.so
include Mf-base

foreign1.so: ${fsrc} ../boot/$m/scheme.h
cc -m32 -dynamiclib -undefined dynamic_lookup -I${Include} -o foreign1.so ${fsrc}
$(CC) -m32 -dynamiclib -undefined dynamic_lookup -I${Include} -o foreign1.so ${fsrc}

cat_flush: cat_flush.c
cc -o cat_flush cat_flush.c
$(CC) -o cat_flush cat_flush.c
4 changes: 2 additions & 2 deletions mats/Mf-i3qnx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fobj = foreign1.so
include Mf-base

foreign1.so: ${fsrc} ../boot/$m/scheme.h
cc -m32 -fPIC -shared -I${Include} -o foreign1.so ${fsrc}
$(CC) -m32 -fPIC -shared -I${Include} -o foreign1.so ${fsrc}

cat_flush: cat_flush.c
cc -o cat_flush cat_flush.c
$(CC) -o cat_flush cat_flush.c
4 changes: 2 additions & 2 deletions mats/Mf-ppc32le
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fobj = foreign1.so
include Mf-base

foreign1.so: ${fsrc} ../boot/$m/scheme.h
cc -m32 -fPIC -shared -I${Include} -o foreign1.so ${fsrc}
$(CC) -m32 -fPIC -shared -I${Include} -o foreign1.so ${fsrc}

cat_flush: cat_flush.c
cc -o cat_flush cat_flush.c
$(CC) -o cat_flush cat_flush.c
4 changes: 2 additions & 2 deletions mats/Mf-ta6fb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fobj = foreign1.so
include Mf-base

foreign1.so: ${fsrc} ../boot/$m/scheme.h
cc -pthread -fPIC -shared -I${Include} -o foreign1.so ${fsrc}
$(CC) -pthread -fPIC -shared -I${Include} -o foreign1.so ${fsrc}

cat_flush: cat_flush.c
cc -o cat_flush cat_flush.c
$(CC) -o cat_flush cat_flush.c
4 changes: 2 additions & 2 deletions mats/Mf-ta6le
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fobj = foreign1.so
include Mf-base

foreign1.so: ${fsrc} ../boot/$m/scheme.h
cc -m64 -pthread -fPIC -shared -I${Include} -o foreign1.so ${fsrc}
$(CC) -m64 -pthread -fPIC -shared -I${Include} -o foreign1.so ${fsrc}

cat_flush: cat_flush.c
cc -o cat_flush cat_flush.c
$(CC) -o cat_flush cat_flush.c
4 changes: 2 additions & 2 deletions mats/Mf-ta6nb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fobj = foreign1.so
include Mf-base

foreign1.so: ${fsrc} ../boot/$m/scheme.h
cc -pthread -fPIC -shared -I${Include} -o foreign1.so ${fsrc}
$(CC) -pthread -fPIC -shared -I${Include} -o foreign1.so ${fsrc}

cat_flush: cat_flush.c
cc -o cat_flush cat_flush.c
$(CC) -o cat_flush cat_flush.c
4 changes: 2 additions & 2 deletions mats/Mf-ta6ob
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fobj = foreign1.so
include Mf-base

foreign1.so: ${fsrc} ../boot/$m/scheme.h
cc -pthread -fPIC -shared -I${Include} -o foreign1.so ${fsrc}
$(CC) -pthread -fPIC -shared -I${Include} -o foreign1.so ${fsrc}

cat_flush: cat_flush.c
cc -o cat_flush cat_flush.c
$(CC) -o cat_flush cat_flush.c
4 changes: 2 additions & 2 deletions mats/Mf-ta6osx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fobj = foreign1.so
include Mf-base

foreign1.so: ${fsrc} ../boot/$m/scheme.h
cc -m64 -pthread -dynamiclib -undefined dynamic_lookup -I${Include} -o foreign1.so ${fsrc}
$(CC) -m64 -pthread -dynamiclib -undefined dynamic_lookup -I${Include} -o foreign1.so ${fsrc}

cat_flush: cat_flush.c
cc -o cat_flush cat_flush.c
$(CC) -o cat_flush cat_flush.c
4 changes: 2 additions & 2 deletions mats/Mf-ti3fb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fobj = foreign1.so
include Mf-base

foreign1.so: ${fsrc} ../boot/$m/scheme.h
cc -pthread -fPIC -shared -I${Include} -o foreign1.so ${fsrc}
$(CC) -pthread -fPIC -shared -I${Include} -o foreign1.so ${fsrc}

cat_flush: cat_flush.c
cc -o cat_flush cat_flush.c
$(CC) -o cat_flush cat_flush.c
4 changes: 2 additions & 2 deletions mats/Mf-ti3le
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fobj = foreign1.so
include Mf-base

foreign1.so: ${fsrc} ../boot/$m/scheme.h
cc -m32 -pthread -fPIC -shared -I${Include} -o foreign1.so ${fsrc}
$(CC) -m32 -pthread -fPIC -shared -I${Include} -o foreign1.so ${fsrc}

cat_flush: cat_flush.c
cc -o cat_flush cat_flush.c
$(CC) -o cat_flush cat_flush.c
4 changes: 2 additions & 2 deletions mats/Mf-ti3nb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fobj = foreign1.so
include Mf-base

foreign1.so: ${fsrc} ../boot/$m/scheme.h
cc -pthread -fPIC -shared -I${Include} -o foreign1.so ${fsrc}
$(CC) -pthread -fPIC -shared -I${Include} -o foreign1.so ${fsrc}

cat_flush: cat_flush.c
cc -o cat_flush cat_flush.c
$(CC) -o cat_flush cat_flush.c
4 changes: 2 additions & 2 deletions mats/Mf-ti3ob
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fobj = foreign1.so
include Mf-base

foreign1.so: ${fsrc} ../boot/$m/scheme.h
cc -pthread -fPIC -shared -I${Include} -o foreign1.so ${fsrc}
$(CC) -pthread -fPIC -shared -I${Include} -o foreign1.so ${fsrc}

cat_flush: cat_flush.c
cc -o cat_flush cat_flush.c
$(CC) -o cat_flush cat_flush.c
4 changes: 2 additions & 2 deletions mats/Mf-ti3osx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fobj = foreign1.so
include Mf-base

foreign1.so: ${fsrc} ../boot/$m/scheme.h
cc -m32 -pthread -dynamiclib -undefined dynamic_lookup -I${Include} -o foreign1.so ${fsrc}
$(CC) -m32 -pthread -dynamiclib -undefined dynamic_lookup -I${Include} -o foreign1.so ${fsrc}

cat_flush: cat_flush.c
cc -o cat_flush cat_flush.c
$(CC) -o cat_flush cat_flush.c
4 changes: 2 additions & 2 deletions mats/Mf-tppc32le
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fobj = foreign1.so
include Mf-base

foreign1.so: ${fsrc} ../boot/$m/scheme.h
cc -m32 -pthread -fPIC -shared -I${Include} -o foreign1.so ${fsrc}
$(CC) -m32 -pthread -fPIC -shared -I${Include} -o foreign1.so ${fsrc}

cat_flush: cat_flush.c
cc -o cat_flush cat_flush.c
$(CC) -o cat_flush cat_flush.c
4 changes: 2 additions & 2 deletions mats/unix.ms
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@
(mat system
(eqv? (with-output-to-file "testfile.ss" void '(replace)) (void))
(begin
(system (format "~:[~;/pkg~]/bin/rm testfile.ss" (embedded?)))
(system (format "~:[~;/pkg~]/bin/echo hello > testfile.ss" (embedded?)))
(system "rm -f testfile.ss")
(system "echo hello > testfile.ss")
(let ([p (open-input-file "testfile.ss")])
(and (eq? (read p) 'hello)
(begin (close-input-port p) #t))))
Expand Down
Loading

0 comments on commit 8f4633c

Please sign in to comment.