# Makefile for marsond. Should be fine with any make (GNU, BSD, etc). # Remember, all these assignments, you can override on the make # command line rather than editing this file. Examples: # make CC=clang CFLAGS=-O3 # make install PREFIX=/usr/local ### Project information. PROJ=marsond VERSION=0.3.0 ### Compile-time option. # If you change this, yse the full path. It changes the # default for the -k option. DEFAULT_KBD=/dev/input/by-id/usb-Marson_Marson_Keyboard_and_Mouse_Link_Ver:ps2120L-event-kbd # USB vendor and product IDs don't get baked into the binary, # they only affect the udev rule. VENDOR_ID=04b4 PRODUCT_ID=0101 ### Compiler and options. # C compiler. clang, pcc, and tcc also work. CC=gcc COPT=-O2 CWARN=-Wall CDEFS=-DVERSION='"$(VERSION)"' -D DEFAULT_KBD='"$(DEFAULT_KBD)"' CFLAGS=-std=c99 $(COPT) $(CWARN) $(CDEFS) ### Install paths. Not compiled into the binary. # These are appropriate for Slackware. Most other distros will need # MANDIR=$(PREFIX)/share/man, and DOCDIR=$(PREFIX)/share/doc/marsond. PREFIX=/usr SBINDIR=$(PREFIX)/sbin MANDIR=$(PREFIX)/man MAN8DIR=$(MANDIR)/man8 DOCDIR=/usr/doc/$(PROJ)-$(VERSION) UDEVDIR=/etc/udev/rules.d INSTALL=install INSTALL_FILE=$(INSTALL) -m0644 INSTALL_MAN=$(INSTALL_FILE) INSTALL_UDEV=$(INSTALL_FILE) INSTALL_DOC=$(INSTALL_FILE) INSTALL_BIN=$(INSTALL) -s -m0755 # Build with GZIP=false to avoid gzipping the man page. GZIP=gzip -9 # When building a Slackware package, use RULESUFFIX=.new RULESUFFIX= ### No user-serviceable parts below (I hope). all: $(PROJ) $(PROJ).8 99-$(PROJ).rules $(PROJ): $(PROJ).c usage.c usage.c: mkusage.pl $(PROJ).8 perl mkusage.pl $(PROJ).rst > usage.c ver.rst: Makefile echo '.. |version| replace:: $(VERSION)' > ver.rst $(PROJ).8: $(PROJ).rst ver.rst rst2man $(PROJ).rst > $(PROJ).8 99-$(PROJ).rules: sed -e 's,@SBINDIR@,$(SBINDIR),' \ -e 's,@VENDOR_ID@,$(VENDOR_ID),' \ -e 's,@PRODUCT_ID@,$(PRODUCT_ID),' \ < 99-$(PROJ).rules.in > 99-$(PROJ).rules clean: rm -f $(PROJ) core *.o realclean: clean rm -f $(PROJ).8 usage.c 99-marsond.rules # this is a "private" target, not expected to work on random systems. # It specifically works on Slackware 15.0, if the system/musl package # from SlackBuilds.org is installed. static: clean $(MAKE) CC=musl-gcc COPT="-Os -static -nostdinc -isystem /usr/include/musl -isystem /usr/include -Wl,-s" mv $(PROJ) $(PROJ).static install: all mkdir -p $(DESTDIR)/$(SBINDIR) $(DESTDIR)/$(MAN8DIR) $(DESTDIR)/$(UDEVDIR) $(DESTDIR)/$(DOCDIR) $(INSTALL_BIN) $(PROJ) $(DESTDIR)/$(SBINDIR) $(INSTALL_MAN) $(PROJ).8 $(DESTDIR)/$(MAN8DIR) $(GZIP) $(DESTDIR)/$(MAN8DIR)/$(PROJ).8 || true $(INSTALL_UDEV) 99-$(PROJ).rules $(DESTDIR)/$(UDEVDIR)/99-$(PROJ).rules$(RULESUFFIX) $(INSTALL_DOC) README TODO LICENSE CHANGES $(DESTDIR)/$(DOCDIR)