aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuncaen <mail@duncano.de>2017-03-06 23:32:31 +0100
committerDuncaen <mail@duncano.de>2017-03-06 23:32:31 +0100
commit78ce17ddcd7d19b6adde4ea02f5672a0a5114b47 (patch)
tree116422decb1bcc9af1c63aa61d11658dda443056
parentf775ceff014b779684d44542b467436b42106424 (diff)
downloadlobase-78ce17ddcd7d19b6adde4ea02f5672a0a5114b47.tar.gz
mk: updates
-rw-r--r--mk/bsd.lib.mk65
-rw-r--r--mk/bsd.man.mk0
-rw-r--r--mk/bsd.prog.mk24
-rw-r--r--mk/bsd.regress.mk5
-rw-r--r--mk/bsd.subdir.mk9
5 files changed, 56 insertions, 47 deletions
diff --git a/mk/bsd.lib.mk b/mk/bsd.lib.mk
index 0385bdb..2343c61 100644
--- a/mk/bsd.lib.mk
+++ b/mk/bsd.lib.mk
@@ -1,28 +1,23 @@
-include config.mk
-
STATICLIB = lib$(LIB).a
+LIBDIR=/lib
+BINOWN=root
+BINGRP=root
+LIBOWN=$(BINOWN)
+LIBGRP=$(BINGRP)
.CURDIR = .
-CLEANFILES += $(STATICLIB) *.o
-CPPFLAGS += -I$(TOPDIR)/libopenbsd -include openbsd.h -I$(TOPDIR) -include config.h
+CPPFLAGS += -I$(TOPDIR)/lib/libopenbsd -include openbsd.h -I$(TOPDIR)/include \
+ -I$(TOPDIR) -include config.h
LDFLAGS += $(LDADD)
-#find_src = $(wildcard $(src) $(.PATH:%=%/$(src)))
-#SRCS := $(foreach src,$(SRCS),$(find_src))
-ifneq (,$(.PATH))
- VPATH := $(.PATH)
-endif
-
CFILES = $(filter %.c,$(SRCS))
YFILES = $(filter %.y,$(SRCS))
LFILES = $(filter %.l,$(SRCS))
-OBJS = $(YFILES:.y=.o) $(LFILES:.l=.o) $(CFILES:.c=.o)
-
-ifneq (,$(findstring $(.DEFAULT_GOAL),install beforeinstall afterinstall))
- .DEFAULT_GOAL :=
-endif
+OBJS += $(YFILES:.y=.o)
+OBJS += $(LFILES:.l=.o)
+OBJS += $(CFILES:.c=.o)
.DEFAULT_GOAL :=
@@ -34,11 +29,6 @@ else
$(STATICLIB) : % : %.o
endif
-$(STATICLIB) : ../../libopenbsd/libopenbsd.a
-
-../../libopenbsd/libopenbsd.a:
- $(MAKE) -C ../../libopenbsd libopenbsd.a
-
y.tab.h y.tab.c:
$(YACC) -d $<
@@ -46,19 +36,40 @@ y.tab.h y.tab.c:
$(CC) $(CFLAGS) $(CPPFLAGS) -c y.tab.c -o $@
%.o: %.c
- $(CC) $(CFLAGS) $(CPPFLAGS) -c $<
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
$(STATICLIB):
- $(AR) rc $@ $^
+ rm -f $@
+ $(AR) rc $@ $(OBJS)
+ $(RANLIB) $@
-clean:
+clean: _SUBDIRUSE
+ rm -f $(STATICLIB) $(OBJS)
+ifdef CLEANFILES
rm -f $(CLEANFILES)
+endif
+
+cleandir: _SUBDIRUSE clean
-install: libinstall
+beforeinstall:
-libinstall:
+realinstall:
test -d "$(DESTDIR)$(LIBDIR)" || \
$(INSTALL) -d -m 755 $(DESTDIR)$(LIBDIR)
- $(INSTALL) $(STATICLIB) $(DESTDIR)$(LIBDIR)/$(STATICLIB)
+ $(INSTALL) -m 600 $(STATICLIB) \
+ $(DESTDIR)$(LIBDIR)
+
+install: maninstall _SUBDIRUSE
+maninstall: afterinstall
+afterinstall: realinstall
+realinstall: beforeinstall
+
-.PHONY: all clean install libinstall
+.PHONY: all clean cleandir install libinstall
+
+ifndef NOMAN
+include bsd.man.mk
+endif
+
+include bsd.subdir.mk
+include config.mk
diff --git a/mk/bsd.man.mk b/mk/bsd.man.mk
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/mk/bsd.man.mk
diff --git a/mk/bsd.prog.mk b/mk/bsd.prog.mk
index d0cc2fa..67321e7 100644
--- a/mk/bsd.prog.mk
+++ b/mk/bsd.prog.mk
@@ -3,14 +3,15 @@ include config.mk
.CURDIR = .
CLEANFILES += $(PROG) *.o
-CPPFLAGS += -I../../libopenbsd -include openbsd.h -I../.. -include config.h
-LDFLAGS += $(LDADD)
+CPPFLAGS += -I$(TOPDIR)/lib/libopenbsd -include openbsd.h -I$(TOPDIR) -include config.h
-#find_src = $(wildcard $(src) $(.PATH:%=%/$(src)))
-#SRCS := $(foreach src,$(SRCS),$(find_src))
-ifneq (,$(.PATH))
- VPATH := $(.PATH)
+LIBC ?= $(TOPDIR)/lib/libopenbsd/libopenbsd.a
+LIBUTIL ?= $(TOPDIR)/lib/libutil/libutil.a
+
+ifeq (-lutil,$(filter -lutil,$(LDADD)))
+ LDFLAGS+= -L$(TOPDIR)/lib/libutil
endif
+LDFLAGS += -L$(TOPDIR)/lib/libopenbsd $(LDADD) -lopenbsd
CFILES = $(filter %.c,$(SRCS))
YFILES = $(filter %.y,$(SRCS))
@@ -32,13 +33,8 @@ else
$(PROG) : % : %.o
endif
-$(PROG) : ../../libopenbsd/libopenbsd.a
-
-../../libopenbsd/libopenbsd.a:
- $(MAKE) -C ../../libopenbsd libopenbsd.a
-
y.tab.h y.tab.c:
- $(YACC) -d $<
+ $(YACC) -d $(YFILES)
%.o: %.y y.tab.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c y.tab.c -o $@
@@ -47,10 +43,10 @@ y.tab.h y.tab.c:
$(CC) $(CFLAGS) $(CPPFLAGS) -c $<
$(PROG):
- $(CC) $^ ../../libopenbsd/libopenbsd.a -o $@ $(LDFLAGS)
+ $(CC) $^ -o $@ $(LDFLAGS)
clean:
- rm -f $(CLEANFILES)
+ rm -f $(CLEANFILES) y.tab.h y.tab.c
install: proginstall install_links
diff --git a/mk/bsd.regress.mk b/mk/bsd.regress.mk
index cd7567c..8a95e91 100644
--- a/mk/bsd.regress.mk
+++ b/mk/bsd.regress.mk
@@ -1,5 +1,3 @@
-include ../../../config.mk
-
.CURDIR = .
.OBJDIR = $(shell pwd)
.DEFAULT_GOAL :=
@@ -20,3 +18,6 @@ ifneq (,$(CLEANFILES))
endif
.PHONY: all clean regress depend
+
+.SUFFIXES:
+include config.mk
diff --git a/mk/bsd.subdir.mk b/mk/bsd.subdir.mk
index 1ce7b9f..76f4021 100644
--- a/mk/bsd.subdir.mk
+++ b/mk/bsd.subdir.mk
@@ -1,5 +1,5 @@
SUBDIR_MFLAGS = -I$(TOPDIR) -I$(TOPDIR)/mk
-SUBDIR_TARGETS = all clean cleandir includes depend obj tags manlint
+SUBDIR_TARGETS = all install clean cleandir includes depend obj tags manlint
SKIPDIR ?=
$(SUBDIR_TARGETS): _SUBDIRUSE
@@ -10,9 +10,10 @@ ifneq (,$(SUBDIR))
skip=; for s in $(SKIPDIR); do \
[ "$$s" = "$$d" ] && skip=1; \
done; \
- [ "$$skip" ] && echo "($$d skipped)" && continue; \
- echo "===> $$d"; \
- $(MAKE) $(SUBDIR_MFLAGS) -C $$d $(MAKECMDGOALS) || exit 1; \
+ [ -n "$$_THISDIR_" ] && n="$$_THISDIR_/$$d" || n=$$d; \
+ [ "$$skip" ] && echo "($$n skipped)" && continue; \
+ echo "===> $$n"; \
+ $(MAKE) $(SUBDIR_MFLAGS) -C $$d _THISDIR_=$$n $(MAKECMDGOALS) || exit 1; \
done
$(SUBDIR):