This is currently handled like this:
unzipped.shp: zipped.zip
@mkdir -p $(dir $@)
@# Extract .zip contents to temporary folder
@mkdir -p tmp
@unzip -q -o -d tmp $<
@for file in tmp/*.*; do \
fullfile=$$(basename "$$file") && \
fileextension="$${file##*.}" && \
cp "$$file" "$(dir $@)$*-extracted.$$fileextension" ; \
done
@# Delete temporary folder
@rm -rf tmp
This handles file names that have spaces, but it messes up when two files have the same root name, no matter if that has spaces or not.
For example, name.shp.xml and name.shp would get merged into a single name.xml output file. This function needs to be able to handle file names that contain periods other than the separator between its name and the file type extension.