# Makefile for unalf, by B. Watson. WTFPL. # Tested with GNU make, BSD make, makepp, and Schily's dmake. ### Override these variables as needed. Don't override CFLAGS; use # COPT instead. # C compiler to use. PATH is searched unless you give an absolute path. CC=cc # C compiler options (flags): COPT=-O3 # Path to the GNU or BSD 'install' program. INSTALL=install # Path to the rst2man command. Only needed if modifying/rebuilding the # man pages and/or windows HTML docs. RST2MAN=rst2man # These only affect the 'install' target (they don't get compiled # into the binary). PREFIX=/usr MANDIR=$(PREFIX)/man MAN1DIR=$(MANDIR)/man1 BINDIR=$(PREFIX)/bin DOCDIR=$(PREFIX)/doc/unalf-$(VERSION) DESTDIR= INSTALL_DATA=$(INSTALL) -m0644 INSTALL_PROGRAM=$(INSTALL) -m0755 GZIP=gzip -9 GZIP_MAN=yes STRIP=yes # ### No user-serviceable parts below. VERSION=0.1.0 CFLAGS=-DVERSION='"$(VERSION)"' -Wall -I../f65 $(COPT) UNALF_OBJS=unalf.o io.o listalf.o extract.o f65.o glob.o opts.o usage.o self.o asmcode.o ALFSUM_OBJS=alfsum.o self.o .PHONY: all clean install all: unalf unalf.1 alfsum alfsum.1 # unalf and alfsum need explicit rules for BSD make compatibility. # without them, bmake tries to run "cc -o unalf unalf.c" which ain't # gonna ever work. unalf: $(UNALF_OBJS) $(CC) $(LDFLAGS) -o $@ $(UNALF_OBJS) alfsum: alfsum.o self.o $(CC) $(LDFLAGS) -o $@ $(ALFSUM_OBJS) usage.o: usage.c f65.o: ../f65/f65.c ../f65/f65.h $(CC) $(CFLAGS) -c -o f65.o ../f65/f65.c usage.c: mkusage.pl unalf.rst perl mkusage.pl unalf.rst > usage.c unalf.o: unalf.c unalf.h ../f65/f65.h glob.o: glob.c unalf.h opts.o: opts.c unalf.h io.o: io.c unalf.h addrs.h ../f65/f65.h listalf.o: listalf.c addrs.h unalf.h ../f65/f65.h extract.o: extract.c addrs.h unalf.h ../f65/f65.h ver.rst: echo '.. |version| replace:: $(VERSION)' > ver.rst unalf.1: unalf.rst ver.rst manftr.rst $(RST2MAN) unalf.rst > unalf.1 alfsum.1: alfsum.rst ver.rst manftr.rst $(RST2MAN) alfsum.rst > alfsum.1 clean: rm -rf *.o unalf alfsum *.exe wintmp \ unalf.html alfsum.html *.aarch64.elf *.com.dbg # these are generated files, but they *are* checked into git. realclean: clean rm -f unalf.1 alfsum.1 usage.c install: all [ "$(STRIP)" = "yes" ] && strip unalf alfsum || true mkdir -p $(DESTDIR)$(BINDIR) $(DESTDIR)$(MAN1DIR) $(DESTDIR)$(DOCDIR) $(INSTALL_DATA) unalf.1 $(DESTDIR)$(MAN1DIR) $(INSTALL_DATA) alfsum.1 $(DESTDIR)$(MAN1DIR) [ "$(GZIP_MAN)" = "yes" ] && $(GZIP) $(DESTDIR)$(MAN1DIR)/unalf.1 || true [ "$(GZIP_MAN)" = "yes" ] && $(GZIP) $(DESTDIR)$(MAN1DIR)/alfsum.1 || true $(INSTALL_PROGRAM) unalf $(DESTDIR)$(BINDIR) $(INSTALL_PROGRAM) alfsum $(DESTDIR)$(BINDIR) cp -r ../README.txt ../LICENSE.txt ../TODO.txt ../doc ../examples $(DESTDIR)$(DOCDIR) crosswin: clean $(MAKE) CC=~/x-tools/x86_64-w64-mingw32/bin/x86_64-w64-mingw32-gcc html: alfsum.html unalf.html alfsum.html: alfsum.rst rst2html alfsum.rst > alfsum.html unalf.html: unalf.rst rst2html unalf.rst > unalf.html windows: crosswin html rm -rf wintmp ../unalf-$(VERSION)-win64.zip mkdir -p wintmp/{doc,examples} cp unalf.exe alfsum.exe wintmp cd .. ; for i in README.txt TODO.txt doc/*.txt doc/Arcinfo examples/*.txt; do perl -pe 's,\n,\r\n,;' $$i > src/wintmp/$$i; done perl -p -e 's,\n,\r\n,;' -e 's,\@VERSION\@,$(VERSION),g;' README_Windows.txt.in > wintmp/README_Windows.txt cp ../examples/*.alf wintmp/examples cp alfsum.html unalf.html wintmp cd wintmp ; zip -r ../../unalf-$(VERSION)-win64.zip *