Makefile install flags incompatible with macOs version of `install`
## description
While trying to `sudo make install` under macOs the `-D` flag returns an error as it is not defined
While this is the linux behaviour ([docs](https://linux.die.net/man/1/install))
```
-D
create all leading components of DEST except the last, then copy SOURCE to DEST
```
Looks like there is no equivalent under macOs, closest is `-d`
From `man install`:
```
-d Create directories. Missing parent directories are created as required.
```
which still does not work with how the current Makefile is written
## working version
I ran a modified version with this and it worked:
```Makefile
PREFIX ?= /usr/local # just to mirror where Homebrew puts symlinks, not sure if the best option
BINARY_NAME=dynomark
all: build
build:
go build -o ${BINARY_NAME} .
run:
go build -o ${BINARY_NAME} .
./${BINARY_NAME}
install:
@install -m755 ${BINARY_NAME} $(DESTDIR)$(PREFIX)/bin/${BINARY_NAME} # removed -D flag
uninstall:
@rm -f $(DESTDIR)$(PREFIX)/bin/${BINARY_NAME}
clean:
go clean
rm ${BINARY_NAME}
```
## conclusion
I'm not sure if my version makes sense from a _best-practices_ point of view as I could not find resources to confirm it.
I still think it could be useful to add a warning in the README for this mismatch between operating systems.
关闭于 2024-10-14 3 条评论