aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cc.mk1
-rw-r--r--src/depend.mk10
-rw-r--r--src/lib.mk6
-rw-r--r--src/libeinfo/Makefile2
-rw-r--r--src/libeinfo/libeinfo.c2
-rw-r--r--src/librc/Makefile2
-rw-r--r--src/librc/librc.h6
-rw-r--r--src/prog.mk6
-rw-r--r--src/rc/rc-update.c6
-rw-r--r--subdir.mk2
10 files changed, 32 insertions, 11 deletions
diff --git a/src/cc.mk b/src/cc.mk
index 1dc1b3fe..8b65627c 100644
--- a/src/cc.mk
+++ b/src/cc.mk
@@ -23,3 +23,4 @@ CFLAGS += -pedantic -std=c99 \
$(call check_gcc, -Wdeclaration-after-statement) \
$(call check_gcc, -Wsequence-point) \
$(call check_gcc, -Wextra) $(WEXTRA)
+
diff --git a/src/depend.mk b/src/depend.mk
new file mode 100644
index 00000000..5b2da6d2
--- /dev/null
+++ b/src/depend.mk
@@ -0,0 +1,10 @@
+# This only works for make implementations that always include a .depend if
+# it exists. Only GNU make does not do this.
+
+.depend: ${SCRIPTS} ${SRCS}
+ $(CC) $(CFLAGS) -MM ${SRCS} > .depend
+
+depend: .depend
+
+clean-depend:
+ rm -f .depend
diff --git a/src/lib.mk b/src/lib.mk
index 574fd383..c1b4558c 100644
--- a/src/lib.mk
+++ b/src/lib.mk
@@ -32,7 +32,7 @@ LIBMODE?= 0444
.c.So:
${CC} ${PICFLAG} -DPIC ${CFLAGS} -c $< -o $@
-all: ${_LIBS}
+all: depend ${_LIBS}
lib${LIB}.a: ${OBJS} ${STATICOBJS}
@${ECHO} building static library $@
@@ -59,5 +59,7 @@ install: all
${INSTALL} -d ${DESTDIR}${INCDIR}
for x in ${INCS}; do ${INSTALL} -m ${INCMODE} $$x ${DESTDIR}${INCDIR}; done
-clean:
+clean: clean-depend
rm -f ${OBJS} ${SOBJS} ${_LIBS} ${SHLIB_LINK}
+
+include $(TOPDIR)/depend.mk
diff --git a/src/libeinfo/Makefile b/src/libeinfo/Makefile
index 5cace0cc..de96f7f7 100644
--- a/src/libeinfo/Makefile
+++ b/src/libeinfo/Makefile
@@ -9,6 +9,8 @@ VERSION_MAP= einfo.map
SHLIBDIR= /${LIBNAME}
+CFLAGS+= -I$(TOPDIR)
+
include $(TOPDIR)/cc.mk
include $(TOPDIR)/lib.mk
include $(TOPDIR)/$(TERMCAP).mk
diff --git a/src/libeinfo/libeinfo.c b/src/libeinfo/libeinfo.c
index 14f254eb..8dfe13f2 100644
--- a/src/libeinfo/libeinfo.c
+++ b/src/libeinfo/libeinfo.c
@@ -50,7 +50,7 @@ const char libeinfo_copyright[] = "Copyright (c) 2007-2008 Roy Marples";
#include <unistd.h>
#include "einfo.h"
-#include "../hidden-visibility.h"
+#include "hidden-visibility.h"
hidden_proto(ecolor)
hidden_proto(ebegin)
hidden_proto(ebeginv)
diff --git a/src/librc/Makefile b/src/librc/Makefile
index e510b1f4..741545e1 100644
--- a/src/librc/Makefile
+++ b/src/librc/Makefile
@@ -11,6 +11,8 @@ VERSION_MAP= rc.map
CFLAGS+= -DLIB=\"${LIBNAME}\"
LDADD+= ${LIBKVM}
+CFLAGS+= -I$(TOPDIR)
+
SHLIBDIR= /${LIBNAME}
include $(TOPDIR)/cc.mk
diff --git a/src/librc/librc.h b/src/librc/librc.h
index 491462b8..d70ffa17 100644
--- a/src/librc/librc.h
+++ b/src/librc/librc.h
@@ -65,10 +65,10 @@
#include "librc-depend.h"
#include "rc.h"
-#include "../rc-misc.h"
-#include "../strlist.h"
+#include "rc-misc.h"
+#include "strlist.h"
-#include "../hidden-visibility.h"
+#include "hidden-visibility.h"
#define librc_hidden_proto(x) hidden_proto(x)
#define librc_hidden_def(x) hidden_def(x)
diff --git a/src/prog.mk b/src/prog.mk
index ea7f4fc7..9a222e7d 100644
--- a/src/prog.mk
+++ b/src/prog.mk
@@ -8,10 +8,12 @@ OBJS+= ${SRCS:.c=.o}
INSTALL?= install
-all: ${PROG}
+all: depend ${PROG}
${PROG}: ${SCRIPTS} ${OBJS}
${CC} ${CFLAGS} ${LDFLAGS} ${PROGLDFLAGS} -o $@ ${OBJS} ${LDADD}
-clean:
+clean: clean-depend
rm -f ${OBJS} ${PROG} ${CLEANFILES}
+
+include $(TOPDIR)/depend.mk
diff --git a/src/rc/rc-update.c b/src/rc/rc-update.c
index bbf23af0..4f07503f 100644
--- a/src/rc/rc-update.c
+++ b/src/rc/rc-update.c
@@ -39,10 +39,10 @@
#include <unistd.h>
#include "builtins.h"
-#include "../libeinfo/einfo.h"
+#include "einfo.h"
#include "rc.h"
-#include "../rc-misc.h"
-#include "../strlist.h"
+#include "rc-misc.h"
+#include "strlist.h"
static const char *applet = NULL;
diff --git a/subdir.mk b/subdir.mk
index 03bec8c3..1933c529 100644
--- a/subdir.mk
+++ b/subdir.mk
@@ -23,3 +23,5 @@ clean:
$(_SUBDIR)
install:
$(_SUBDIR)
+depend:
+ $(_SUBDIR)