Last active
December 29, 2017 00:17
-
-
Save cryptorick/c3c215dd0a4334fab074ff58bb3c7a33 to your computer and use it in GitHub Desktop.
This makefile was designed as a "drop in" replacement for the file GNUmakefile in repo https://github.com/ibara/mg. The idea is to have a common makefile that can be used by both gmake and BSD make. Two problems I ran into: one, versions of gmake before Apr 2011 do NOT support `!=`; two, NetBSD system make's implicit rule for `.c.o` puts all `.o…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Mg portable GNUmakefile | |
# This file written by Brian Callahan <bcallah@openbsd.org> | |
# and released into the Public Domain. | |
PROG = mg | |
PREFIX ?= /usr/local | |
MANDIR ?= ${PREFIX}/man | |
DOCDIR ?= ${PREFIX}/share/doc/mg | |
INSTALL = /usr/bin/install | |
# CFLAGS: | |
# -DREGEX -- Enable regex search commands | |
# -DSTARTUPFILE -- Look for and handle initialization file | |
CFLAGS ?= -O2 -pipe | |
CFLAGS += -Wall -DREGEX | |
LIBS = -lcurses | |
OBJS = autoexec.o basic.o bell.o buffer.o cinfo.o dir.o display.o \ | |
echo.o extend.o file.o fileio.o funmap.o help.o kbd.o keymap.o \ | |
line.o macro.o main.o match.o modes.o paragraph.o re_search.o \ | |
region.o search.o spawn.o tty.o ttyio.o ttykbd.o undo.o util.o \ | |
version.o window.o word.o yank.o | |
# | |
# More or less standalone extensions. | |
# | |
OBJS += cmode.o cscope.o dired.o grep.o tags.o | |
# | |
# Extensions unique to Mg portable. | |
# | |
OBJS += extensions.o | |
# | |
# Mg portable setup. | |
# | |
Linux_CFLAGS = -D_GNU_SOURCE -D__dead="__attribute__((__noreturn__))" -Dst_mtimespec=st_mtim | |
Linux_OBJS = portable/linux/fgetln.o portable/common/fparseln.o \ | |
portable/common/reallocarray.o portable/linux/strlcat.o \ | |
portable/linux/strlcpy.o portable/common/strtonum.o | |
Darwin_CFLAGS = -DMSG_NOSIGNAL=SO_NOSIGPIPE -DLOGIN_NAME_MAX=MAXLOGNAME | |
Darwin_OBJS = portable/common/fparseln.o portable/common/futimens.o \ | |
portable/common/reallocarray.o portable/common/strtonum.o | |
Darwin_LIBS = -lutil | |
FreeBSD_CFLAGS = -D__dead=__dead2 -DLOGIN_NAME_MAX=MAXLOGNAME | |
FreeBSD_OBJS = portable/common/reallocarray.o | |
FreeBSD_LIBS = -lutil | |
OpenBSD_LIBS = -lutil | |
NetBSD_OBJS = portable/common/reallocarray.o portable/common/strtonum.o | |
DragonFly_CFLAGS = -D__dead=__dead2 -DLOGIN_NAME_MAX=MAXLOGNAME | |
DragonFly_OBJS = portable/common/reallocarray.o | |
DragonFly_LIBS = -lutil | |
Bitrig_LIBS = -lutil | |
Cygwin_CFLAGS = -D_GNU_SOURCE -D__dead="__attribute__((__noreturn__))" -Dst_mtimespec=st_mtim | |
Cygwin_OBJS = portable/linux/fgetln.o portable/common/fparseln.o \ | |
portable/common/reallocarray.o portable/linux/strlcat.o \ | |
portable/linux/strlcpy.o portable/common/strtonum.o | |
UNAME_S != uname -s | sed 's/^CYGWIN.*$$/Cygwin/' | |
CFLAGS += $($(UNAME_S)_CFLAGS) | |
OBJS += $($(UNAME_S)_OBJS) | |
LIBS += $($(UNAME_S)_LIBS) | |
.c.o: | |
$(CC) $(CFLAGS) -c -o $@ $< | |
all: ${OBJS} | |
${CC} -o ${PROG} ${OBJS} ${LIBS} | |
install: all | |
${INSTALL} -d -m 755 ${DESTDIR}${PREFIX}/bin | |
${INSTALL} -d -m 755 ${DESTDIR}${MANDIR}/man1 | |
${INSTALL} -d -m 755 ${DESTDIR}${DOCDIR} | |
${INSTALL} -s -m 555 ${PROG} ${DESTDIR}${PREFIX}/bin | |
${INSTALL} -m 444 mg.1 ${DESTDIR}${MANDIR}/man1/${PROG}.1 | |
${INSTALL} -m 444 README.md ${DESTDIR}${DOCDIR} | |
${INSTALL} -m 444 README-Mg ${DESTDIR}${DOCDIR} | |
${INSTALL} -m 444 tutorial ${DESTDIR}${DOCDIR} | |
uninstall: | |
rm -f ${DESTDIR}${PREFIX}/bin/${PROG} \ | |
${DESTDIR}${MANDIR}/man1/${PROG}.1 | |
rm -rf ${DESTDIR}${DOCDIR} | |
clean: | |
rm -f ${PROG} ${OBJS} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment