Skip to content

Commit

Permalink
Properly escape MAKE's pathname, which includes spaces and parens by …
Browse files Browse the repository at this point in the history
…default in GNUWin32. Close #485.
  • Loading branch information
travisgoodspeed committed Oct 11, 2016
1 parent 48ff875 commit 3ffa38f
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 62 deletions.
52 changes: 26 additions & 26 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,49 +13,49 @@ distclean: clean
rm -rf dist

clean: mostlyclean
$(MAKE) -C firmware clean
"${MAKE}" -C firmware clean

mostlyclean:
$(MAKE) -C patches/2.032 clean
$(MAKE) -C patches/3.020 clean
$(MAKE) -C patches/s13.020 clean
$(MAKE) -C patches/d13.020 clean
$(MAKE) -C applet clean
$(MAKE) -C db clean
"${MAKE}" -C patches/2.032 clean
"${MAKE}" -C patches/3.020 clean
"${MAKE}" -C patches/s13.020 clean
"${MAKE}" -C patches/d13.020 clean
"${MAKE}" -C applet clean
"${MAKE}" -C db clean
rm -f *~ *.pyc
rm -f data data.csv


#patches: firmwares
# $(MAKE) -C patches/2.032 all
# $(MAKE) -C patches/d13.020 all
# "${MAKE}" -C patches/2.032 all
# "${MAKE}" -C patches/d13.020 all

#applets: patches
# $(MAKE) -C applet all
# "${MAKE}" -C applet all

#firmwares:
# $(MAKE) -C firmware all
# "${MAKE}" -C firmware all

image_D02:
$(MAKE) -C applet FW=D02_032 all
"${MAKE}" -C applet FW=D02_032 all

image_D13:
$(MAKE) -C applet FW=D13_020 all
"${MAKE}" -C applet FW=D13_020 all

image_S13:
$(MAKE) -C applet FW=S13_020 all
"${MAKE}" -C applet FW=S13_020 all

flash:
$(MAKE) -C applet clean flash
"${MAKE}" -C applet clean flash

flash_d02.032:
$(MAKE) -C applet FW=D02_032 clean flash
"${MAKE}" -C applet FW=D02_032 clean flash

flash_s13.020:
$(MAKE) -C applet FW=S13_020 clean flash
"${MAKE}" -C applet FW=S13_020 clean flash

data:
$(MAKE) -C db
"${MAKE}" -C db
$(ICONV) db/users.csv | cut -d',' -f1-3,5-6 | sed 's/,\s+/,/g' > data.csv
wc -c < data.csv > data
cat data.csv >> data
Expand All @@ -67,13 +67,13 @@ dist:
rm -rf $(RELEASE) $(RELEASE).zip
mkdir -p $(RELEASE)/python
#Main release.
$(MAKE) mostlyclean image_D13
"${MAKE}" mostlyclean image_D13
cp applet/experiment.bin $(RELEASE)/firmware-`date "+%Y-%m-%d-NoGPS"`.bin
#For GPS radios.
$(MAKE) mostlyclean image_S13
"${MAKE}" mostlyclean image_S13
cp applet/experiment.bin $(RELEASE)/firmware-`date "+%Y-%m-%d-GPS"`.bin
#Older
$(MAKE) mostlyclean image_D02
"${MAKE}" mostlyclean image_D02
cp applet/experiment.bin $(RELEASE)/firmware-`date "+%Y-%m-%d-OLD"`.bin
#Include the Official Installer
cd $(RELEASE) && unzip ../../firmware/dl/D002.032.zip
Expand All @@ -91,15 +91,15 @@ doflash: image_D13

# or else make will fail.
#download:
# $(MAKE) -C firmware download
# "${MAKE}" -C firmware download

all_images:
$(MAKE) -C applet ci
"${MAKE}" -C applet ci

ci: mostlyclean
$(MAKE) -C applet ci
$(MAKE) -C db ci
$(MAKE) data
"${MAKE}" -C applet ci
"${MAKE}" -C db ci
"${MAKE}" data

check-ignore:
find -type f | git check-ignore -v --stdin | less
22 changes: 11 additions & 11 deletions applet/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,16 @@ OBJS = $(SRCS:.c=.o)
all: lib proj wrapped

experiment.img:
$(MAKE) -C ../patches/$(PATCHDIR) patched.bin
"${MAKE}" -C ../patches/$(PATCHDIR) patched.bin
cp ../patches/$(PATCHDIR)/patched.img ./experiment.img


lib: src/version.h config.h
$(MAKE) -C lib
"${MAKE}" -C lib

proj: $(PROJ_NAME).elf experiment.img
# use a fresh experiment.img
$(MAKE) -C ../patches/$(PATCHDIR) clean all
"${MAKE}" -C ../patches/$(PATCHDIR) clean all
cp ../patches/$(PATCHDIR)/patched.img ./experiment.img
python2 merge_$(SRCVERSION).py experiment.img $(PROJ_NAME).img $(MERGEBASE)

Expand All @@ -120,20 +120,20 @@ src/version.h: src/*.c
echo "#define GIT_VERSION \"$(GIT_VERSION)\"" >>src/version.h

clean:
$(MAKE) -C ../patches/$(PATCHDIR) clean
$(MAKE) -C lib clean
"${MAKE}" -C ../patches/$(PATCHDIR) clean
"${MAKE}" -C lib clean
rm -f *.img *.lst *.bin *.elf *.hex *.o *~ *.sym src/*~ src/version.h *.map

image_D02:
$(MAKE) FW=D02_032 all
"${MAKE}" FW=D02_032 all

image_D13:
$(MAKE) FW=D13_020 all
"${MAKE}" FW=D13_020 all

image_S13:
$(MAKE) FW=S13_020 all
"${MAKE}" FW=S13_020 all

ci:
$(MAKE) clean image_D02
$(MAKE) clean image_S13
$(MAKE) clean image_D13
"${MAKE}" clean image_D02
"${MAKE}" clean image_S13
"${MAKE}" clean image_D13
6 changes: 3 additions & 3 deletions applet/Makefile.d02.032
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ OBJS = $(SRCS:.c=.o)
all: lib proj wrapped

experiment.img:
cd ../patches/2.032 && $(MAKE) all
cd ../patches/2.032 && "${MAKE}" all
cp ../patches/2.032/patched.img ./experiment.img


lib: src/version.h config.h
$(MAKE) -C lib
"${MAKE}" -C lib

proj: $(PROJ_NAME).elf experiment.img
# use a fresh experiment.img
Expand All @@ -80,7 +80,7 @@ src/version.h: src/*.c
echo "#define GIT_VERSION \"$(GIT_VERSION)\"" >>src/version.h

clean:
$(MAKE) -C lib clean
"${MAKE}" -C lib clean
rm -f *.img *.bin *.elf *.hex *.o *~ *.sym src/*~ src/version.h


Expand Down
8 changes: 4 additions & 4 deletions applet/Makefile.s13.020
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,16 @@ OBJS = $(SRCS:.c=.o)
all: lib proj wrapped

experiment.img:
cd ../patches/$(SRCVERSION) && $(MAKE) all
cd ../patches/$(SRCVERSION) && "${MAKE}" all
cp ../patches/$(SRCVERSION)/patched.img ./experiment.img


lib: src/version.h config.h
$(MAKE) -C lib
"${MAKE}" -C lib

proj: $(PROJ_NAME).elf experiment.img
# use a fresh experiment.img
cd ../patches/$(SRCVERSION) && $(MAKE) all
cd ../patches/$(SRCVERSION) && "${MAKE}" all
cp ../patches/$(SRCVERSION)/patched.img ./experiment.img
python2 merge_$(SRCVERSION).py experiment.img $(PROJ_NAME).img 0x809c000

Expand All @@ -86,7 +86,7 @@ src/version.h: src/*.c
echo "#define VERSIONDATE L\"`date "+%Y-%m-%d"`\"" >src/version.h
echo "#define GIT_VERSION \"$(GIT_VERSION)\"" >>src/version.h
clean:
$(MAKE) -C lib clean
"${MAKE}" -C lib clean
rm -f *.img *.lst *.bin *.elf *.hex *.o *~ *.sym src/*~ src/version.h


Expand Down
8 changes: 4 additions & 4 deletions applet/Makefile_d13.020_original
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ OBJS = $(SRCS:.c=.o)
all: lib proj wrapped

experiment.img:
cd ../patches/$(SRCVERSION) && $(MAKE) all
cd ../patches/$(SRCVERSION) && "${MAKE}" all
cp ../patches/$(SRCVERSION)/patched.img ./experiment.img


lib: src/version.h config.h
$(MAKE) -C lib
"${MAKE}" -C lib

proj: $(PROJ_NAME).elf experiment.img
# use a fresh experiment.img
cd ../patches/$(SRCVERSION) && $(MAKE) all
cd ../patches/$(SRCVERSION) && "${MAKE}" all
cp ../patches/$(SRCVERSION)/patched.img ./experiment.img
python2 merge_$(SRCVERSION).py experiment.img $(PROJ_NAME).img 0x0809b000

Expand All @@ -86,7 +86,7 @@ src/version.h: src/*.c
echo "#define GIT_VERSION \"$(GIT_VERSION)\"" >>src/version.h

clean:
$(MAKE) -C lib clean
"${MAKE}" -C lib clean
rm -f *.img *.lst *.bin *.elf *.hex *.o *~ *.sym src/*~ src/version.h


Expand Down
12 changes: 6 additions & 6 deletions firmware/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ show:
echo $(MAKE_VERSION)

clean:
$(MAKE) -f Makefile_orig clean
"${MAKE}" -f Makefile_orig clean

download:
echo $(MAKE_VERSION)
$(MAKE) -f Makefile_orig download
"${MAKE}" -f Makefile_orig download

unwrapped/D002.032.img: $(OPT)
$(MAKE) -f Makefile_orig unwrapped/D002.032.img
"${MAKE}" -f Makefile_orig unwrapped/D002.032.img

unwrapped/S013.020.img: $(OPT)
$(MAKE) -f Makefile_orig unwrapped/S013.020.img
"${MAKE}" -f Makefile_orig unwrapped/S013.020.img

unwrapped/D013.020.img: $(OPT)
$(MAKE) -f Makefile_orig unwrapped/D013.020.img
"${MAKE}" -f Makefile_orig unwrapped/D013.020.img

2 changes: 1 addition & 1 deletion hooks/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ blhook: blhook.c
cc -std=c99 blhook.c -o blhook

images:
cd ../firmware && $(MAKE)
cd ../firmware && "${MAKE}"
test: all images
./blhook ../firmware/unwrapped/S013.020.img foo < testhooks

Expand Down
2 changes: 1 addition & 1 deletion patches/2.032/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ clean:
rm -f *~ *.bin *.img *.pyc

unwrapped.img:
cd ../../firmware && make unwrapped/D002.032.img
cd ../../firmware && "${MAKE}" unwrapped/D002.032.img
cp ../../firmware/unwrapped/D002.032.img $@

patched.img: unwrapped.img Makefile
Expand Down
2 changes: 1 addition & 1 deletion patches/3.020/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ clean:
rm -f *~ *.bin *.img

unwrapped.img:
cd ../../firmware && $(MAKE) unwrapped/D003.020.img
cd ../../firmware && "${MAKE}" unwrapped/D003.020.img
cp ../../firmware/unwrapped/D003.020.img $@

patched.img: unwrapped.img
Expand Down
2 changes: 1 addition & 1 deletion patches/d13.020/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ clean:
rm -f *~ *.bin *.img *.pyc

unwrapped.img:
cd ../../firmware && $(MAKE) unwrapped/D013.020.img
cd ../../firmware && "${MAKE}" unwrapped/D013.020.img
cp ../../firmware/unwrapped/D013.020.img $@

patched.img: unwrapped.img
Expand Down
4 changes: 1 addition & 3 deletions patches/s13.020/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ clean:
rm -f *~ *.bin *.img *.pyc

unwrapped.img:
cd ../../firmware && $(MAKE) unwrapped/S013.020.img
cd ../../firmware && "${MAKE}" unwrapped/S013.020.img
cp ../../firmware/unwrapped/S013.020.img $@

patched.img: unwrapped.img
./patch.py
../../md380-gfx --firmware=patched.img --gfx=replacement-font-big-latin.pbm fontreplace
../../md380-gfx --firmware=patched.img --gfx=replacement-font-small-latin.pbm fontreplace



patched.bin: patched.img
../../md380-fw --wrap patched.img patched.bin
Expand Down
2 changes: 1 addition & 1 deletion symbols/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ all: symgrate run
clean:
rm -f symgrate symbols_*
images:
cd ../firmware && $(MAKE) all
cd ../firmware && "${MAKE}" all

symgrate: symgrate.c
cc -std=c99 symgrate.c -o symgrate
Expand Down

11 comments on commit 3ffa38f

@sijskes
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yuk. clearly a make platform specific problem. maybe report upstream?

@travisgoodspeed
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I expect that it hits a lot of GNUWin32 projects, but it really is the script's fault and not Make's fault. Path names should always be escaped properly and all that jazz.

We might need to install GNUWin32 at the same, awkward address in our appveyor.yml file to prevent this error from slipping back in.

@sijskes
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sijskes
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is definitely a cygwin problem. I've renamed my directory 'Program Files' under linux, and everything works.

@travisgoodspeed
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In yesterday's build, or after this fix?

I reproduced the problem on OS X with GNU Make 4.1 by copying it to "/tmp/foo bar/gmake" and running it from there. The bug triggered reliably under the old code.

@sijskes
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

before this fix.

@sijskes
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make -C db
make[1]: Entering directory '/home/md380/ttt/Program Files (X86)/db'
...

@sijskes
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GNU Make 4.1
Built for x86_64-pc-linux-gnu

@sijskes
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error in make:

/tmp/Program\ Files\ (X86)/make clean
/tmp/Program Files (X86)/make -C patches/2.032 clean
/bin/sh: 1: Syntax error: "(" unexpected
Makefile:19: recipe for target 'mostlyclean' failed
make: *** [mostlyclean] Error 2

:(

@sijskes
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

http://savannah.gnu.org/bugs/?712

...
Sun 07 Jul 2002 05:24:17 PM UTC, comment #1:
...
I'll fix this for the next release.
...

@sijskes
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or not :)

the offending call:
21065 execve("/bin/sh", ["/bin/sh", "-c", "/tmp/Program Files (X86)/make -C patches/2.032 clean"], [/* 66 vars */]) = 0

fixable by installing cygwin with an escaped path.
bash -c '/tmp/Program\ Files\ (X86)/make -C patches/2.032 clean'

Please sign in to comment.