Makefile 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. # POSIX-ish Makefile with extensions common to *BSD and GNU such as:
  2. # - Usage of backticks for shell evaluation
  3. # - Usage of ?= for defining variables when not already defined
  4. # - Usage of += for appending to a variable
  5. PACKAGE = Badwolf
  6. VERSION = 1.0.2
  7. VERSION_FULL = $(VERSION)`./version.sh`
  8. PREFIX ?= /usr/local
  9. BINDIR ?= $(PREFIX)/bin
  10. MANDIR ?= $(PREFIX)/share/man
  11. DOCDIR ?= $(PREFIX)/share/doc/badwolf-$(VERSION)
  12. DATADIR ?= $(PREFIX)/share/badwolf
  13. APPSDIR ?= $(PREFIX)/share/applications
  14. CC ?= cc
  15. CFLAGS ?= -g -Wall -Wextra -Wconversion -Wsign-conversion -O2
  16. DBG ?=
  17. PKGCONFIG ?= pkg-config
  18. MSGFMT ?= msgfmt
  19. INKSCAPE ?= inkscape
  20. # for i in 24 32 48 64 128 256; do echo icons/hicolor/${i}x${i}/apps/badwolf.png; done | tr '\n' ' '
  21. ICON_SIZES = icons/hicolor/24x24/apps/badwolf.png icons/hicolor/32x32/apps/badwolf.png icons/hicolor/48x48/apps/badwolf.png icons/hicolor/64x64/apps/badwolf.png icons/hicolor/128x128/apps/badwolf.png icons/hicolor/256x256/apps/badwolf.png
  22. DEPS = gtk+-3.0 webkit2gtk-4.0 libsoup-2.4 libconfig
  23. SRCS = config.c uri.c uri_test.c keybindings.c downloads.c badwolf.c
  24. OBJS = config.o uri.o keybindings.o downloads.o badwolf.o
  25. OBJS_test = uri_test.o
  26. EXE = badwolf
  27. EXE_test = uri_test
  28. TRANS = fr.mo pt_BR.mo tr.mo
  29. DOCS = usr.bin.badwolf README.md KnowledgeBase.md interface.txt badwolf.cfg
  30. CDEPS = -DDATADIR=\"$(DATADIR)\" -DPACKAGE=\"$(PACKAGE)\" -D_XOPEN_SOURCE=500 -D_POSIX_C_SOURCE=200809L -DVERSION=\"$(VERSION_FULL)\"
  31. CDEPS += `$(PKGCONFIG) --cflags $(DEPS)`
  32. LIBS = `$(PKGCONFIG) --libs $(DEPS)`
  33. all: $(EXE) $(TRANS) po/messages.pot
  34. icons: $(ICON_SIZES)
  35. icons/hicolor/scalable/apps/badwolf.svg: badwolf.svg
  36. mkdir -p icons/hicolor/scalable/apps
  37. scour --no-line-breaks --enable-id-stripping --remove-metadata $< $@
  38. icons/hicolor/%/apps/badwolf.png: icons/hicolor/scalable/apps/badwolf.svg
  39. mkdir -p `dirname $@`
  40. $(INKSCAPE) `echo $@ | cut -d/ -f3 | ./icons_size.sh` $< -o $@
  41. po/messages.pot: $(SRCS)
  42. xgettext --keyword=_ --language=C --from-code=UTF-8 -o $@ --add-comments --sort-output --copyright-holder="Badwolf Authors <https://hacktivis.me/projects/badwolf>" --package-name="$(PACKAGE)" --package-version="$(VERSION_FULL)" --msgid-bugs-address="contact+badwolf-msgid@hacktivis.me" $(SRCS)
  43. po/%.po: po/messages.pot
  44. msgmerge --update --backup=off $@ $<
  45. ${TRANS}: po/${@:.mo=.po}
  46. mkdir -p locale/${@:.mo=}/LC_MESSAGES
  47. $(MSGFMT) -o locale/${@:.mo=}/LC_MESSAGES/$(PACKAGE).mo po/${@:.mo=.po}
  48. badwolf: $(OBJS)
  49. $(CC) -std=c11 -o $@ $(OBJS) $(LDFLAGS) $(LIBS)
  50. .c:
  51. $(CC) -std=c11 $(CFLAGS) $(CDEPS) $(LDFLAGS) $(LIBS) -o $@ $<
  52. .c.o:
  53. $(CC) -std=c11 $(CFLAGS) $(CDEPS) -c -o $@ $<
  54. uri_test: uri.o uri_test.o
  55. $(CC) -std=c11 -o $@ uri.o uri_test.o $(LDFLAGS) $(LIBS)
  56. $(DBG) ./$@
  57. .PHONY: test
  58. test: $(EXE_test)
  59. .PHONY: install
  60. install: all
  61. mkdir -p $(DESTDIR)$(BINDIR)
  62. cp -p badwolf $(DESTDIR)$(BINDIR)/badwolf
  63. mkdir -p $(DESTDIR)$(MANDIR)/man1
  64. cp -p badwolf.1 $(DESTDIR)$(MANDIR)/man1
  65. mkdir -p $(DESTDIR)$(DATADIR)/locale
  66. cp -r locale/ $(DESTDIR)$(DATADIR)
  67. cp interface.css $(DESTDIR)$(DATADIR)
  68. mkdir -p $(DESTDIR)$(APPSDIR)
  69. cp -p badwolf.desktop $(DESTDIR)$(APPSDIR)/
  70. mkdir -p $(DESTDIR)$(DOCDIR)
  71. cp -p $(DOCS) $(DESTDIR)$(DOCDIR)/
  72. mkdir -p $(DESTDIR)$(PREFIX)/share
  73. cp -r icons $(DESTDIR)$(PREFIX)/share/
  74. @printf '\nNote: An example AppArmor profile has been installed at '$(DOCDIR)/usr.bin.badwolf'\n'
  75. .PHONY: clean
  76. clean:
  77. rm -fr locale $(OBJS) $(OBJS_test) $(EXE) $(EXE_test)
  78. format: *.c *.h
  79. clang-format -style=file -assume-filename=.clang-format -i *.c *.h