Skip to content

Commit

Permalink
Upgrade Makefile for better compability with manpath
Browse files Browse the repository at this point in the history
  • Loading branch information
FelipeFTN committed Jun 13, 2024
1 parent 83630f5 commit 7917067
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ PACKAGES = x11 xcomposite xfixes xdamage xrender
LIBS = `pkg-config --libs ${PACKAGES}` -lm
INCS = `pkg-config --cflags ${PACKAGES}`
CFLAGS = -Wall -O3 -flto
PREFIX = /usr/local
MANDIR = ${PREFIX}/share/man/man1
BIN = /usr/local/bin

# This should get all the possible man possible paths
# And split the char ':' into a new line
MANPATH = $(shell manpath | tr ':' '\n')

OBJS=fastcompmgr.o comp_rect.o

Expand All @@ -14,13 +17,29 @@ fastcompmgr: $(OBJS)
$(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS)

install: fastcompmgr
@cp -t ${PREFIX}/bin fastcompmgr
@[ -d "${MANDIR}" ] \
&& cp -t "${MANDIR}" fastcompmgr.1
@echo "[=] Installing fastcompmgr"
@cp -t ${BIN} fastcompmgr
@echo "[+] fastcompmgr copied to bin!"
@for dir in $(MANPATH); do \
MANDIR=$$(find "$$dir" -type d -path "*/man/man1"); \
if [ -n "$$MANDIR" ]; then \
echo "[=] Creating fastcompmgr man: $$MANDIR"; \
cp -t "$$MANDIR" fastcompmgr.1; \
echo "[+] fastcompmgr man created!"; \
break; \
fi \
done
@echo "[!] fastcompmgr sucessfully installed!"

uninstall:
@rm -f ${PREFIX}/fastcompmgr
@rm -f ${MANDIR}/fastcompmgr.1
@rm -f ${BIN}/fastcompmgr
@for dir in $(MANPATH); do \
MANDIR=$$(find "$$dir" -type d -path "*/man/man1"); \
if [ -n "$$MANDIR" ]; then \
rm -f "$${MANDIR}/fastcompmgr.1"; \
break; \
fi \
done

clean:
rm -f $(OBJS) fastcompmgr
Expand Down

0 comments on commit 7917067

Please sign in to comment.