ref: 25251bab5307ad72727f0229f88c36fb2620ace7
parent: cd41a7859d9e011e006e4f328a288ae3b49a779f
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Thu May 19 18:57:16 EDT 2022
Makefile: make it run with BSD make as well
--- a/Makefile
+++ b/Makefile
@@ -1,12 +1,12 @@
TARGET=pc
DESTDIR?=
PREFIX?=/usr/local
-BIN=$(DESTDIR)$(PREFIX)/bin
-MAN=$(DESTDIR)$(PREFIX)/share/man/man1
+BIN=${DESTDIR}${PREFIX}/bin
+MAN=${DESTDIR}${PREFIX}/share/man/man1
CFLAGS?=-g -O2
CFLAGS+=-Iinclude -Wall -Wno-missing-braces -Wno-parentheses -Wno-incompatible-pointer-types
-OFILES=\
+OBJS=\
libc/dofmt.o\
libc/dorfmt.o\
libc/encodefmt.o\
@@ -74,26 +74,32 @@
libmp/mpvecsub.o\
libmp/mpvectscmp.o\
libmp/strtomp.o\
- $(TARGET).o\
+ ${TARGET}.o\
.PHONY: all default install uninstall clean
all: default
-default: $(TARGET)
+default: ${TARGET}
-install: $(TARGET)
- install -d $(BIN)
- install -m 755 $(TARGET) $(BIN)
- install -d $(MAN)
- install -m 644 $(TARGET).1 $(MAN)
+install: ${TARGET}
+ install -d ${BIN}
+ install -m 755 ${TARGET} ${BIN}
+ install -d ${MAN}
+ install -m 644 ${TARGET}.1 ${MAN}
uninstall:
- rm -f $(BIN)/$(TARGET) $(MAN)/$(TARGET).1
+ rm -f ${BIN}/${TARGET} ${MAN}/${TARGET}.1
clean:
- rm -f $(TARGET) $(OFILES) $(TARGET).c
+ rm -f ${TARGET} ${OBJS} ${TARGET}.c
-$(TARGET): $(OFILES)
+${TARGET}: ${OBJS}
+ ${CC} -o $@ ${OBJS}
-$(TARGET).c: $(TARGET).y
+pc.c: pc.y
+ yacc -o $@ $<
+
+.SUFFIXES: .c .o
+.c.o:
+ ${CC} -o $@ -c $< ${CFLAGS}