commit 92c5012bc36e097cc3a28c848c90fcf9b8ef1c6f
parent e14f5927e5e5bc5d704fc507920786840e626b30
Author: sin <sin@2f30.org>
Date: Tue, 22 Mar 2016 16:13:30 +0000
simplify makefile, it was too generic
Diffstat:
M | Makefile | | | 61 | +++++++++++++++++++++++-------------------------------------- |
M | config.mk | | | 8 | ++++---- |
2 files changed, 27 insertions(+), 42 deletions(-)
diff --git a/Makefile b/Makefile
@@ -1,51 +1,36 @@
include config.mk
-NAME = stun
-VERSION = 0.1
+PREFIX = /usr/local
+MANPREFIX = $(PREFIX)/man
+
+DISTFILES = LICENSE Makefile README arg.h \
+ config.mk stun.8 stun.c
+OBJ = stun.o
BIN = stun
-SRC = ${BIN:=.c}
-MAN8 = ${BIN:=.8}
-HDR = arg.h
all: $(BIN)
-${BIN}: ${LIB} ${@:=.o}
-
-OBJ = ${SRC:.c=.o}
+$(BIN): $(OBJ)
+ $(CC) $(CFLAGS) -o $@ $(OBJ) $(LDLIBS)
-${OBJ}: config.mk ${HDR}
+stun.o: arg.h
-.o:
- ${CC} ${LDFLAGS} -o $@ $< ${LIB}
+install: all
+ mkdir -p $(DESTDIR)$(PREFIX)/bin
+ cp -f $(BIN) $(DESTDIR)$(PREFIX)/bin
+ mkdir -p $(DESTDIR)$(MANPREFIX)/man8
+ cp -f $(BIN).8 $(DESTDIR)$(MANPREFIX)/man8
-.c.o:
- ${CC} -c ${CFLAGS} ${CPPFLAGS} -o $@ -c $<
+uninstall:
+ rm -f $(DESTDIR)$(PREFIX)/bin/$(BIN)
+ rm -f $(DESTDIR)$(MANPREFIX)/man8/$(BIN).8
dist:
- mkdir -p stun-${VERSION}
- cp LICENSE Makefile README arg.h config.mk stun.8 stun.c stun-${VERSION}
- tar cf stun-${VERSION}.tar stun-${VERSION}
- gzip stun-${VERSION}.tar
- rm -rf stun-${VERSION}
+ mkdir -p stun-$(VERSION)
+ cp $(DISTFILES) stun-$(VERSION)
+ tar -cf stun-$(VERSION).tar stun-$(VERSION)
+ gzip stun-$(VERSION).tar
+ rm -rf stun-$(VERSION)
clean:
- rm -f ${BIN} ${OBJ} ${LIB}
-
-install: all
- # installing executable files.
- mkdir -p ${DESTDIR}${PREFIX}/bin
- cp -f ${BIN} ${DESTDIR}${PREFIX}/bin
- for f in $(BIN); do chmod 755 ${DESTDIR}${PREFIX}/bin/$$f; done
- # installing manual pages for tools.
- mkdir -p ${DESTDIR}${MANPREFIX}/man8
- cp -f ${MAN8} ${DESTDIR}${MANPREFIX}/man8
- for m in $(MAN8); do chmod 644 ${DESTDIR}${MANPREFIX}/man8/$$m; done
-
-uninstall:
- # removing executable files.
- for f in $(BIN); do rm -f ${DESTDIR}${PREFIX}/bin/$$f; done
- -rmdir ${DESTDIR}${PREFIX}/share/${NAME}
- # removing manual pages.
- for m in $(MAN8); do rm -f ${DESTDIR}${MANPREFIX}/man8/$$m; done
-
-.PHONY: all clean dist install uninstall
+ rm -f $(BIN) $(OBJ) stun-$(VERSION).tar.gz
diff --git a/config.mk b/config.mk
@@ -1,4 +1,4 @@
-# customize below to fit your system
+VERSION = 0.1
# paths
PREFIX = /usr/local
@@ -11,13 +11,13 @@ RANLIB = ranlib
# OpenBSD
CFLAGS = -O2 -std=c99
-LDFLAGS = -lcrypto -s
+LDLIBS = -lcrypto
# Linux
#CFLAGS = -O2 -std=c99
-#LDFLAGS = -lcrypto -lbsd -s
+#LDLIBS = -lcrypto -lbsd
#CPPFLAGS = -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -D_BSD_SOURCE
# DragonFly and FreeBSD
#CFLAGS = -O2 -std=c99
-#LDFLAGS = -lcrypto -s
+#LDLIBS = -lcrypto