Makefile 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # Copyright (C) 2018-2023 Ruilin Peng (Nick) <[email protected]>.
  2. #
  3. # smartdns is free software: you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation, either version 3 of the License, or
  6. # (at your option) any later version.
  7. #
  8. # smartdns is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. PKG_CONFIG := pkg-config
  16. DESTDIR :=
  17. PREFIX := /usr
  18. SBINDIR := $(PREFIX)/sbin
  19. SYSCONFDIR := /etc
  20. RUNSTATEDIR := /var/run
  21. SYSTEMDSYSTEMUNITDIR := $(shell ${PKG_CONFIG} --variable=systemdsystemunitdir systemd)
  22. SMARTDNS_SYSTEMD = systemd/smartdns.service
  23. .PHONY: all clean install SMARTDNS_BIN
  24. all: SMARTDNS_BIN
  25. SMARTDNS_BIN: $(SMARTDNS_SYSTEMD)
  26. $(MAKE) $(MFLAGS) -C src all
  27. $(SMARTDNS_SYSTEMD): systemd/smartdns.service.in
  28. cp $< $@
  29. sed -i 's|@SBINDIR@|$(SBINDIR)|' $@
  30. sed -i 's|@SYSCONFDIR@|$(SYSCONFDIR)|' $@
  31. sed -i 's|@RUNSTATEDIR@|$(RUNSTATEDIR)|' $@
  32. clean:
  33. $(MAKE) $(MFLAGS) -C src clean
  34. $(RM) $(SMARTDNS_SYSTEMD)
  35. install: SMARTDNS_BIN
  36. install -v -m 0640 -D -t $(DESTDIR)$(SYSCONFDIR)/default etc/default/smartdns
  37. install -v -m 0755 -D -t $(DESTDIR)$(SYSCONFDIR)/init.d etc/init.d/smartdns
  38. install -v -m 0640 -D -t $(DESTDIR)$(SYSCONFDIR)/smartdns etc/smartdns/smartdns.conf
  39. install -v -m 0755 -D -t $(DESTDIR)$(SBINDIR) src/smartdns
  40. install -v -m 0644 -D -t $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR) systemd/smartdns.service