"Fossies" - the Fresh Open Source Software Archive

Member "nnn-4.2/Makefile" (21 Jul 2021, 8547 Bytes) of package /linux/misc/nnn-v4.2.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "Makefile": v4.1.1_vs_v4.2.

    1 VERSION = $(shell grep -m1 VERSION $(SRC) | cut -f 2 -d'"')
    2 
    3 PREFIX ?= /usr/local
    4 MANPREFIX ?= $(PREFIX)/share/man
    5 DESKTOPPREFIX ?= $(PREFIX)/share/applications
    6 DESKTOPICONPREFIX ?= $(PREFIX)/share/icons/hicolor
    7 STRIP ?= strip
    8 PKG_CONFIG ?= pkg-config
    9 INSTALL ?= install
   10 CP ?= cp
   11 
   12 CFLAGS_OPTIMIZATION ?= -O3
   13 
   14 O_DEBUG := 0  # debug binary
   15 O_NORL := 0  # no readline support
   16 O_PCRE := 0  # link with PCRE library
   17 O_NOLC := 0  # no locale support
   18 O_NOMOUSE := 0  # no mouse support
   19 O_NOBATCH := 0  # no built-in batch renamer
   20 O_NOFIFO := 0  # no FIFO previewer support
   21 O_CTX8 := 0  # enable 8 contexts
   22 O_ICONS := 0  # support icons-in-terminal
   23 O_NERD := 0  # support icons-nerdfont
   24 O_QSORT := 0  # use Alexey Tourbin's QSORT implementation
   25 O_BENCH := 0  # benchmark mode (stops at first user input)
   26 O_NOSSN := 0  # enable session support
   27 O_NOUG := 0  # disable user, group name in status bar
   28 O_NOX11 := 0  # disable X11 integration
   29 
   30 # User patches
   31 O_GITSTATUS := 0 # add git status to detail view
   32 O_NAMEFIRST := 0 # print file name first, add uid and guid to detail view
   33 
   34 # convert targets to flags for backwards compatibility
   35 ifneq ($(filter debug,$(MAKECMDGOALS)),)
   36 	O_DEBUG := 1
   37 endif
   38 ifneq ($(filter norl,$(MAKECMDGOALS)),)
   39 	O_NORL := 1
   40 endif
   41 ifneq ($(filter nolc,$(MAKECMDGOALS)),)
   42 	O_NORL := 1
   43 	O_NOLC := 1
   44 endif
   45 
   46 ifeq ($(strip $(O_DEBUG)),1)
   47 	CPPFLAGS += -DDEBUG
   48 	CFLAGS += -g
   49 endif
   50 
   51 ifeq ($(strip $(O_NORL)),1)
   52 	CPPFLAGS += -DNORL
   53 else ifeq ($(strip $(O_STATIC)),1)
   54 	CPPFLAGS += -DNORL
   55 else
   56 	LDLIBS += -lreadline
   57 endif
   58 
   59 ifeq ($(strip $(O_PCRE)),1)
   60 	CPPFLAGS += -DPCRE
   61 	LDLIBS += -lpcre
   62 endif
   63 
   64 ifeq ($(strip $(O_NOLC)),1)
   65 	ifeq ($(strip $(O_ICONS)),1)
   66 $(info *** Ignoring O_NOLC since O_ICONS is set ***)
   67 	else ifeq ($(strip $(O_NERD)),1)
   68 $(info *** Ignoring O_NOLC since O_NERD is set ***)
   69 	else
   70 		CPPFLAGS += -DNOLC
   71 	endif
   72 endif
   73 
   74 ifeq ($(strip $(O_NOMOUSE)),1)
   75 	CPPFLAGS += -DNOMOUSE
   76 endif
   77 
   78 ifeq ($(strip $(O_NOBATCH)),1)
   79 	CPPFLAGS += -DNOBATCH
   80 endif
   81 
   82 ifeq ($(strip $(O_NOFIFO)),1)
   83 	CPPFLAGS += -DNOFIFO
   84 endif
   85 
   86 ifeq ($(strip $(O_CTX8)),1)
   87 	CPPFLAGS += -DCTX8
   88 endif
   89 
   90 ifeq ($(strip $(O_ICONS)),1)
   91 	CPPFLAGS += -DICONS
   92 endif
   93 
   94 ifeq ($(strip $(O_NERD)),1)
   95 	CPPFLAGS += -DNERD
   96 endif
   97 
   98 ifeq ($(strip $(O_QSORT)),1)
   99 	CPPFLAGS += -DTOURBIN_QSORT
  100 endif
  101 
  102 ifeq ($(strip $(O_BENCH)),1)
  103 	CPPFLAGS += -DBENCH
  104 endif
  105 
  106 ifeq ($(strip $(O_NOSSN)),1)
  107 	CPPFLAGS += -DNOSSN
  108 endif
  109 
  110 ifeq ($(strip $(O_NOUG)),1)
  111 	CPPFLAGS += -DNOUG
  112 endif
  113 
  114 ifeq ($(strip $(O_NOX11)),1)
  115 	CPPFLAGS += -DNOX11
  116 endif
  117 
  118 ifeq ($(shell $(PKG_CONFIG) ncursesw && echo 1),1)
  119 	CFLAGS_CURSES ?= $(shell $(PKG_CONFIG) --cflags ncursesw)
  120 	LDLIBS_CURSES ?= $(shell $(PKG_CONFIG) --libs   ncursesw)
  121 else ifeq ($(shell $(PKG_CONFIG) ncurses && echo 1),1)
  122 	CFLAGS_CURSES ?= $(shell $(PKG_CONFIG) --cflags ncurses)
  123 	LDLIBS_CURSES ?= $(shell $(PKG_CONFIG) --libs   ncurses)
  124 else
  125 	LDLIBS_CURSES ?= -lncurses
  126 endif
  127 
  128 CFLAGS += -std=c11 -Wall -Wextra -Wshadow
  129 CFLAGS += $(CFLAGS_OPTIMIZATION)
  130 CFLAGS += $(CFLAGS_CURSES)
  131 
  132 LDLIBS += $(LDLIBS_CURSES) -lpthread
  133 
  134 # static compilation needs libgpm development package
  135 ifeq ($(strip $(O_STATIC)),1)
  136 	LDFLAGS += -static
  137 	LDLIBS += -lgpm
  138 endif
  139 
  140 DISTFILES = src nnn.1 Makefile README.md LICENSE
  141 SRC = src/nnn.c
  142 HEADERS = src/nnn.h
  143 BIN = nnn
  144 DESKTOPFILE = misc/desktop/nnn.desktop
  145 LOGOSVG = misc/logo/logo.svg
  146 LOGO64X64 = misc/logo/logo-64x64.png
  147 
  148 GITSTATUS = patches/gitstatus
  149 NAMEFIRST = patches/namefirst
  150 
  151 all: $(BIN)
  152 
  153 $(BIN): $(SRC) $(HEADERS)
  154 	@$(MAKE) --silent prepatch
  155 	$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS)
  156 	@$(MAKE) --silent postpatch
  157 
  158 # targets for backwards compatibility
  159 debug: $(BIN)
  160 norl: $(BIN)
  161 nolc: $(BIN)
  162 
  163 install-desktop: $(DESKTOPFILE)
  164 	$(INSTALL) -m 0755 -d $(DESTDIR)$(DESKTOPPREFIX)
  165 	$(INSTALL) -m 0644 $(DESKTOPFILE) $(DESTDIR)$(DESKTOPPREFIX)
  166 	$(INSTALL) -m 0755 -d $(DESTDIR)$(DESKTOPICONPREFIX)/scalable/apps
  167 	$(INSTALL) -m 0644 $(LOGOSVG) $(DESTDIR)$(DESKTOPICONPREFIX)/scalable/apps/nnn.svg
  168 	$(INSTALL) -m 0755 -d $(DESTDIR)$(DESKTOPICONPREFIX)/64x64/apps
  169 	$(INSTALL) -m 0644 $(LOGO64X64) $(DESTDIR)$(DESKTOPICONPREFIX)/64x64/apps/nnn.png
  170 
  171 uninstall-desktop:
  172 	$(RM) $(DESTDIR)$(DESKTOPPREFIX)/$(DESKTOPFILE)
  173 	$(RM) $(DESTDIR)$(DESKTOPICONPREFIX)/scalable/apps/nnn.svg
  174 	$(RM) $(DESTDIR)$(DESKTOPICONPREFIX)/64x64/apps/nnn.png
  175 
  176 install: all
  177 	$(INSTALL) -m 0755 -d $(DESTDIR)$(PREFIX)/bin
  178 	$(INSTALL) -m 0755 $(BIN) $(DESTDIR)$(PREFIX)/bin
  179 	$(INSTALL) -m 0755 -d $(DESTDIR)$(MANPREFIX)/man1
  180 	$(INSTALL) -m 0644 $(BIN).1 $(DESTDIR)$(MANPREFIX)/man1
  181 
  182 uninstall:
  183 	$(RM) $(DESTDIR)$(PREFIX)/bin/$(BIN)
  184 	$(RM) $(DESTDIR)$(MANPREFIX)/man1/$(BIN).1
  185 
  186 strip: $(BIN)
  187 	$(STRIP) $^
  188 
  189 upx: $(BIN)
  190 	$(STRIP) $^
  191 	upx -qqq $^
  192 
  193 static:
  194 	# regular static binary
  195 	make O_STATIC=1 strip
  196 	mv $(BIN) $(BIN)-static
  197 	# static binary with icons-in-terminal support
  198 	make O_STATIC=1 O_ICONS=1 strip
  199 	mv $(BIN) $(BIN)-icons-static
  200 	# static binary with patched nerd font support
  201 	make O_STATIC=1 O_NERD=1 strip
  202 	mv $(BIN) $(BIN)-nerd-static
  203 
  204 musl:
  205 	cp misc/musl/musl-static-ubuntu.sh .
  206 	./musl-static-ubuntu.sh 1
  207 	rm ./musl-static-ubuntu.sh
  208 
  209 dist:
  210 	mkdir -p nnn-$(VERSION)
  211 	$(CP) -r $(DISTFILES) nnn-$(VERSION)
  212 	tar -cf - nnn-$(VERSION) | gzip > nnn-$(VERSION).tar.gz
  213 	$(RM) -r nnn-$(VERSION)
  214 
  215 sign:
  216 	git archive -o nnn-$(VERSION).tar.gz --format tar.gz --prefix=nnn-$(VERSION)/ v$(VERSION)
  217 	gpg --detach-sign --yes nnn-$(VERSION).tar.gz
  218 	rm -f nnn-$(VERSION).tar.gz
  219 
  220 upload-local: sign static musl
  221 	$(eval ID=$(shell curl -s 'https://api.github.com/repos/jarun/nnn/releases/tags/v$(VERSION)' | jq .id))
  222 	# upload sign file
  223 	curl -XPOST 'https://uploads.github.com/repos/jarun/nnn/releases/$(ID)/assets?name=nnn-$(VERSION).tar.gz.sig' \
  224 	    -H 'Authorization: token $(NNN_SIG_UPLOAD_TOKEN)' -H 'Content-Type: application/pgp-signature' \
  225 	    --upload-file nnn-$(VERSION).tar.gz.sig
  226 	# upx compress all static binaries
  227 	upx -qqq $(BIN)-static
  228 	upx -qqq $(BIN)-icons-static
  229 	upx -qqq $(BIN)-nerd-static
  230 	# upload static binary
  231 	tar -zcf $(BIN)-static-$(VERSION).x86_64.tar.gz $(BIN)-static
  232 	curl -XPOST 'https://uploads.github.com/repos/jarun/nnn/releases/$(ID)/assets?name=$(BIN)-static-$(VERSION).x86_64.tar.gz' \
  233 	    -H 'Authorization: token $(NNN_SIG_UPLOAD_TOKEN)' -H 'Content-Type: application/x-sharedlib' \
  234 	    --upload-file $(BIN)-static-$(VERSION).x86_64.tar.gz
  235 	# upload icons-in-terminal compiled static binary
  236 	tar -zcf $(BIN)-icons-static-$(VERSION).x86_64.tar.gz $(BIN)-icons-static
  237 	curl -XPOST 'https://uploads.github.com/repos/jarun/nnn/releases/$(ID)/assets?name=$(BIN)-icons-static-$(VERSION).x86_64.tar.gz' \
  238 	    -H 'Authorization: token $(NNN_SIG_UPLOAD_TOKEN)' -H 'Content-Type: application/x-sharedlib' \
  239 	    --upload-file $(BIN)-icons-static-$(VERSION).x86_64.tar.gz
  240 	# upload patched nerd font compiled static binary
  241 	tar -zcf $(BIN)-nerd-static-$(VERSION).x86_64.tar.gz $(BIN)-nerd-static
  242 	curl -XPOST 'https://uploads.github.com/repos/jarun/nnn/releases/$(ID)/assets?name=$(BIN)-nerd-static-$(VERSION).x86_64.tar.gz' \
  243 	    -H 'Authorization: token $(NNN_SIG_UPLOAD_TOKEN)' -H 'Content-Type: application/x-sharedlib' \
  244 	    --upload-file $(BIN)-nerd-static-$(VERSION).x86_64.tar.gz
  245 	# upload musl static binary
  246 	tar -zcf $(BIN)-musl-static-$(VERSION).x86_64.tar.gz $(BIN)-musl-static
  247 	curl -XPOST 'https://uploads.github.com/repos/jarun/nnn/releases/$(ID)/assets?name=$(BIN)-musl-static-$(VERSION).x86_64.tar.gz' \
  248 	    -H 'Authorization: token $(NNN_SIG_UPLOAD_TOKEN)' -H 'Content-Type: application/x-sharedlib' \
  249 	    --upload-file $(BIN)-musl-static-$(VERSION).x86_64.tar.gz
  250 
  251 clean:
  252 	$(RM) -f $(BIN) nnn-$(VERSION).tar.gz *.sig $(BIN)-static $(BIN)-static-$(VERSION).x86_64.tar.gz $(BIN)-icons-static $(BIN)-icons-static-$(VERSION).x86_64.tar.gz $(BIN)-nerd-static $(BIN)-nerd-static-$(VERSION).x86_64.tar.gz $(BIN)-musl-static $(BIN)-musl-static-$(VERSION).x86_64.tar.gz
  253 
  254 prepatch:
  255 ifeq ($(strip $(O_NAMEFIRST)),1)
  256 	patch --forward --strip=1 --input=$(NAMEFIRST)/mainline.diff
  257 ifeq ($(strip $(O_GITSTATUS)),1)
  258 	patch --forward --strip=1 --input=$(GITSTATUS)/namefirst.diff
  259 endif
  260 else ifeq ($(strip $(O_GITSTATUS)),1)
  261 	patch --forward --strip=1 --input=$(GITSTATUS)/mainline.diff
  262 endif
  263 
  264 postpatch:
  265 ifeq ($(strip $(O_NAMEFIRST)),1)
  266 ifeq ($(strip $(O_GITSTATUS)),1)
  267 	patch --reverse --strip=1 --input=$(GITSTATUS)/namefirst.diff
  268 endif
  269 	patch --reverse --strip=1 --input=$(NAMEFIRST)/mainline.diff
  270 else ifeq ($(strip $(O_GITSTATUS)),1)
  271 	patch --reverse --strip=1 --input=$(GITSTATUS)/mainline.diff
  272 endif
  273 
  274 skip: ;
  275 
  276 .PHONY: all install uninstall strip static dist sign upload-local clean install-desktop uninstall-desktop