build: add Makefile with standard targets
All checks were successful
CMake / build (push) Successful in 42s
All checks were successful
CMake / build (push) Successful in 42s
- Introduce Makefile supporting build, test, install, uninstall, clean - Add variables for PREFIX and DESTDIR - Update README.md with Makefile usage instructions
This commit is contained in:
parent
24adb7d618
commit
5e7fbf1895
38
Makefile
Normal file
38
Makefile
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
# Makefile for passwdgen
|
||||||
|
# Supports: build, test, install, uninstall, clean
|
||||||
|
# Vars: PREFIX=/usr/local make install
|
||||||
|
# DESTDIR=/tmp/staging make install
|
||||||
|
|
||||||
|
PREFIX ?= /usr/local
|
||||||
|
BUILD_DIR ?= build
|
||||||
|
JOBS ?= $(shell sysctl -n hw.ncpu 2>/dev/null || echo 4)
|
||||||
|
|
||||||
|
.PHONY: all build test clean install uninstall
|
||||||
|
|
||||||
|
all: build
|
||||||
|
|
||||||
|
build:
|
||||||
|
cmake -S . -B $(BUILD_DIR) -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release
|
||||||
|
cmake --build $(BUILD_DIR) -j$(JOBS)
|
||||||
|
|
||||||
|
test: build
|
||||||
|
ctest --test-dir $(BUILD_DIR) -V
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf $(BUILD_DIR)
|
||||||
|
|
||||||
|
install: build
|
||||||
|
mkdir -p $(DESTDIR)$(PREFIX)/bin
|
||||||
|
cp $(BUILD_DIR)/passwdgen $(DESTDIR)$(PREFIX)/bin/passwdgen
|
||||||
|
chmod 755 $(DESTDIR)$(PREFIX)/bin/passwdgen
|
||||||
|
mkdir -p $(DESTDIR)$(PREFIX)/lib
|
||||||
|
cp $(BUILD_DIR)/libpasswdgen_lib.a $(DESTDIR)$(PREFIX)/lib/libpasswdgen_lib.a
|
||||||
|
chmod 644 $(DESTDIR)$(PREFIX)/lib/libpasswdgen_lib.a
|
||||||
|
mkdir -p $(DESTDIR)$(PREFIX)/include
|
||||||
|
cp include/passwdgen.h $(DESTDIR)$(PREFIX)/include/passwdgen.h
|
||||||
|
chmod 644 $(DESTDIR)$(PREFIX)/include/passwdgen.h
|
||||||
|
|
||||||
|
uninstall:
|
||||||
|
rm -f $(DESTDIR)$(PREFIX)/bin/passwdgen
|
||||||
|
rm -f $(DESTDIR)$(PREFIX)/lib/libpasswdgen_lib.a
|
||||||
|
rm -f $(DESTDIR)$(PREFIX)/include/passwdgen.h
|
||||||
18
README.md
18
README.md
@ -36,3 +36,21 @@ or directly:
|
|||||||
```bash
|
```bash
|
||||||
./tests/passwdgen_test
|
./tests/passwdgen_test
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Makefile
|
||||||
|
|
||||||
|
Now supports standard targets via `Makefile`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
make # alias for build (Release)
|
||||||
|
make test # build + run tests
|
||||||
|
sudo make install # to /usr/local/bin, /lib, /include
|
||||||
|
make uninstall # remove installed files
|
||||||
|
make clean # rm -rf build/
|
||||||
|
```
|
||||||
|
|
||||||
|
Variables:
|
||||||
|
- `PREFIX=/opt/myprefix make install`
|
||||||
|
- `DESTDIR=/tmp/root PREFIX=/usr make install` (packaging)
|
||||||
Loading…
Reference in New Issue
Block a user