summaryrefslogtreecommitdiff
path: root/examples/hello_libdeps
diff options
context:
space:
mode:
Diffstat (limited to 'examples/hello_libdeps')
-rw-r--r--examples/hello_libdeps/Makefile7
-rw-r--r--examples/hello_libdeps/expect.out127
-rw-r--r--examples/hello_libdeps/libs/libbar/Makefile9
-rw-r--r--examples/hello_libdeps/libs/libbar/bar.c8
-rw-r--r--examples/hello_libdeps/libs/libbar/bar.h6
-rw-r--r--examples/hello_libdeps/libs/libbaz/Makefile10
-rw-r--r--examples/hello_libdeps/libs/libbaz/baz.c8
-rw-r--r--examples/hello_libdeps/libs/libbaz/include/baz.h6
-rw-r--r--examples/hello_libdeps/libs/libbaz/linkme.mk5
-rw-r--r--examples/hello_libdeps/libs/libfoo/Makefile9
-rw-r--r--examples/hello_libdeps/libs/libfoo/foo.c8
-rw-r--r--examples/hello_libdeps/libs/libfoo/foo.h6
-rw-r--r--examples/hello_libdeps/libs/libfoo/linkme.mk1
-rw-r--r--examples/hello_libdeps/libs/libfooqux/Makefile9
-rw-r--r--examples/hello_libdeps/libs/libfooqux/fooqux.c9
-rw-r--r--examples/hello_libdeps/libs/libfooqux/fooqux.h8
-rw-r--r--examples/hello_libdeps/progs/foobaz/Makefile5
-rw-r--r--examples/hello_libdeps/progs/foobaz/foobaz.c11
-rw-r--r--examples/hello_libdeps/progs/fooquxfoobar/Makefile5
-rw-r--r--examples/hello_libdeps/progs/fooquxfoobar/fooquxfoobar.c12
-rw-r--r--examples/hello_libdeps/test.mk52
21 files changed, 321 insertions, 0 deletions
diff --git a/examples/hello_libdeps/Makefile b/examples/hello_libdeps/Makefile
new file mode 100644
index 0000000..40ea9d6
--- /dev/null
+++ b/examples/hello_libdeps/Makefile
@@ -0,0 +1,7 @@
+LIBDEPS += libs/libfoo:libs/libfooqux
+LIBDEPS += libs/libbar:progs/fooquxfoobar
+LIBDEPS += libs/libfooqux:progs/fooquxfoobar
+LIBDEPS += libs/libfoo:progs/foobaz libs/libbaz:progs/foobaz
+
+.include "test.mk"
+.include <mkc.mk>
diff --git a/examples/hello_libdeps/expect.out b/examples/hello_libdeps/expect.out
new file mode 100644
index 0000000..a80481d
--- /dev/null
+++ b/examples/hello_libdeps/expect.out
@@ -0,0 +1,127 @@
+=========== fooquxfoobar ============
+I am foo
+ and qux
+I am foo
+I am bar
+=========== foobaz ============
+I am foo
+I am baz
+=========== depends ============
+bar.o bar.o bar.o: bar.c bar.h
+baz.o baz.o baz.o: baz.c include/baz.h
+foo.o foo.o foo.o: foo.c foo.h
+foobaz.o foobaz.o foobaz.o: foobaz.c /objdir/libs/libfoo/foo.h /objdir/libs/libbaz/include/baz.h
+fooqux.o fooqux.o fooqux.o: fooqux.c fooqux.h /objdir/libs/libfoo/foo.h
+fooquxfoobar.o fooquxfoobar.o fooquxfoobar.o: fooquxfoobar.c /objdir/libs/libfooqux/fooqux.h /objdir/libs/libfoo/foo.h /objdir/libs/libbar/bar.h
+======= install ==========
+/objdir/prefix/bin/foobaz
+/objdir/prefix/bin/fooquxfoobar
+/objdir/prefix/include/bar.h
+/objdir/prefix/include/baz.h
+/objdir/prefix/include/foo.h
+/objdir/prefix/include/fooqux.h
+/objdir/prefix/lib/libbar.a
+/objdir/prefix/lib/libbar.so
+/objdir/prefix/lib/libbar.so.0
+/objdir/prefix/lib/libbar.so.0.0
+/objdir/prefix/lib/libbazbaz.a
+/objdir/prefix/lib/libfoo.a
+/objdir/prefix/lib/libfoo.so
+/objdir/prefix/lib/libfoo.so.0
+/objdir/prefix/lib/libfoo.so.0.0
+/objdir/prefix/lib/libfooqux.a
+/objdir/prefix/lib/libfooqux.so
+/objdir/prefix/lib/libfooqux.so.0
+/objdir/prefix/lib/libfooqux.so.0.0
+=========== all with STATICLIBS=... ============
+/objdir/Makefile
+/objdir/_mkc_compiler_type.err
+/objdir/_mkc_compiler_type.res
+/objdir/_mkc_prog_cc.err
+/objdir/_mkc_prog_cc.res
+/objdir/expect.out
+/objdir/hello_libdeps.test.out.tmp
+/objdir/libs/libbar/Makefile
+/objdir/libs/libbar/bar.c
+/objdir/libs/libbar/bar.h
+/objdir/libs/libbar/bar.o
+/objdir/libs/libbar/bar.os
+/objdir/libs/libbar/libbar.a
+/objdir/libs/libbar/libbar_pic.a
+/objdir/libs/libbaz/Makefile
+/objdir/libs/libbaz/baz.c
+/objdir/libs/libbaz/baz.o
+/objdir/libs/libbaz/include/baz.h
+/objdir/libs/libbaz/libbazbaz.a
+/objdir/libs/libbaz/linkme.mk
+/objdir/libs/libfoo/Makefile
+/objdir/libs/libfoo/foo.c
+/objdir/libs/libfoo/foo.h
+/objdir/libs/libfoo/foo.o
+/objdir/libs/libfoo/foo.os
+/objdir/libs/libfoo/libfoo.a
+/objdir/libs/libfoo/libfoo_pic.a
+/objdir/libs/libfoo/linkme.mk
+/objdir/libs/libfooqux/Makefile
+/objdir/libs/libfooqux/fooqux.c
+/objdir/libs/libfooqux/fooqux.h
+/objdir/libs/libfooqux/fooqux.o
+/objdir/libs/libfooqux/fooqux.os
+/objdir/libs/libfooqux/libfooqux.a
+/objdir/libs/libfooqux/libfooqux.so
+/objdir/libs/libfooqux/libfooqux.so.0
+/objdir/libs/libfooqux/libfooqux.so.0.0
+/objdir/progs/foobaz/Makefile
+/objdir/progs/foobaz/foobaz
+/objdir/progs/foobaz/foobaz.c
+/objdir/progs/foobaz/foobaz.o
+/objdir/progs/fooquxfoobar/Makefile
+/objdir/progs/fooquxfoobar/fooquxfoobar
+/objdir/progs/fooquxfoobar/fooquxfoobar.c
+/objdir/progs/fooquxfoobar/fooquxfoobar.o
+/objdir/test.mk
+========= install with STATICLIBS=... ==========
+/objdir/prefix
+/objdir/prefix/bin
+/objdir/prefix/bin/foobaz
+/objdir/prefix/bin/fooquxfoobar
+/objdir/prefix/include
+/objdir/prefix/include/bar.h
+/objdir/prefix/include/baz.h
+/objdir/prefix/include/foo.h
+/objdir/prefix/include/fooqux.h
+/objdir/prefix/lib
+/objdir/prefix/lib/libbar.a
+/objdir/prefix/lib/libbar_pic.a
+/objdir/prefix/lib/libbazbaz.a
+/objdir/prefix/lib/libfoo.a
+/objdir/prefix/lib/libfoo_pic.a
+/objdir/prefix/lib/libfooqux.a
+/objdir/prefix/lib/libfooqux.so
+/objdir/prefix/lib/libfooqux.so.0
+/objdir/prefix/lib/libfooqux.so.0.0
+symbol foo
+symbol fooqux
+======= distclean ==========
+/objdir/Makefile
+/objdir/expect.out
+/objdir/hello_libdeps.test.out.tmp
+/objdir/libs/libbar/Makefile
+/objdir/libs/libbar/bar.c
+/objdir/libs/libbar/bar.h
+/objdir/libs/libbaz/Makefile
+/objdir/libs/libbaz/baz.c
+/objdir/libs/libbaz/include/baz.h
+/objdir/libs/libbaz/linkme.mk
+/objdir/libs/libfoo/Makefile
+/objdir/libs/libfoo/foo.c
+/objdir/libs/libfoo/foo.h
+/objdir/libs/libfoo/linkme.mk
+/objdir/libs/libfooqux/Makefile
+/objdir/libs/libfooqux/fooqux.c
+/objdir/libs/libfooqux/fooqux.h
+/objdir/progs/foobaz/Makefile
+/objdir/progs/foobaz/foobaz.c
+/objdir/progs/fooquxfoobar/Makefile
+/objdir/progs/fooquxfoobar/fooquxfoobar.c
+/objdir/test.mk
diff --git a/examples/hello_libdeps/libs/libbar/Makefile b/examples/hello_libdeps/libs/libbar/Makefile
new file mode 100644
index 0000000..6514a70
--- /dev/null
+++ b/examples/hello_libdeps/libs/libbar/Makefile
@@ -0,0 +1,9 @@
+LIB = bar
+INCS = bar.h
+
+SHLIB_MAJOR = 0
+SHLIB_MINOR = 0
+
+WARNS = 4
+
+.include <mkc.mk>
diff --git a/examples/hello_libdeps/libs/libbar/bar.c b/examples/hello_libdeps/libs/libbar/bar.c
new file mode 100644
index 0000000..b8015fc
--- /dev/null
+++ b/examples/hello_libdeps/libs/libbar/bar.c
@@ -0,0 +1,8 @@
+#include "bar.h"
+
+#include <stdio.h>
+
+void bar (void)
+{
+ puts ("I am bar");
+}
diff --git a/examples/hello_libdeps/libs/libbar/bar.h b/examples/hello_libdeps/libs/libbar/bar.h
new file mode 100644
index 0000000..e1d9f28
--- /dev/null
+++ b/examples/hello_libdeps/libs/libbar/bar.h
@@ -0,0 +1,6 @@
+#ifndef _BAR_H_
+#define _BAR_H_
+
+void bar (void);
+
+#endif // _BAR_H_
diff --git a/examples/hello_libdeps/libs/libbaz/Makefile b/examples/hello_libdeps/libs/libbaz/Makefile
new file mode 100644
index 0000000..fb96ef1
--- /dev/null
+++ b/examples/hello_libdeps/libs/libbaz/Makefile
@@ -0,0 +1,10 @@
+LIB = bazbaz # LIB name is not equal to ${.CURDIR:T}!
+SRCS = baz.c
+INCS = baz.h
+INCSSRCDIR = include
+
+CPPFLAGS += ${INCSSRCDIR}
+
+WARNS = 4
+
+.include <mkc.mk>
diff --git a/examples/hello_libdeps/libs/libbaz/baz.c b/examples/hello_libdeps/libs/libbaz/baz.c
new file mode 100644
index 0000000..e9000dc
--- /dev/null
+++ b/examples/hello_libdeps/libs/libbaz/baz.c
@@ -0,0 +1,8 @@
+#include "baz.h"
+
+#include <stdio.h>
+
+void baz (void)
+{
+ puts ("I am baz");
+}
diff --git a/examples/hello_libdeps/libs/libbaz/include/baz.h b/examples/hello_libdeps/libs/libbaz/include/baz.h
new file mode 100644
index 0000000..3a8879c
--- /dev/null
+++ b/examples/hello_libdeps/libs/libbaz/include/baz.h
@@ -0,0 +1,6 @@
+#ifndef _BAZ_H_
+#define _BAZ_H_
+
+void baz (void);
+
+#endif // _BAZ_H_
diff --git a/examples/hello_libdeps/libs/libbaz/linkme.mk b/examples/hello_libdeps/libs/libbaz/linkme.mk
new file mode 100644
index 0000000..8127ebd
--- /dev/null
+++ b/examples/hello_libdeps/libs/libbaz/linkme.mk
@@ -0,0 +1,5 @@
+PATH.baz := ${.PARSEDIR:tA}
+
+DPINCDIRS += ${PATH.baz}/include # non-default dir for headers
+DPLIBDIRS += ${OBJDIR_libs_libbaz}
+DPLDADD += bazbaz # non-default library name
diff --git a/examples/hello_libdeps/libs/libfoo/Makefile b/examples/hello_libdeps/libs/libfoo/Makefile
new file mode 100644
index 0000000..747a9e6
--- /dev/null
+++ b/examples/hello_libdeps/libs/libfoo/Makefile
@@ -0,0 +1,9 @@
+LIB = foo
+INCS = foo.h
+
+SHLIB_MAJOR = 0
+SHLIB_MINOR = 0
+
+WARNS = 4
+
+.include <mkc.mk>
diff --git a/examples/hello_libdeps/libs/libfoo/foo.c b/examples/hello_libdeps/libs/libfoo/foo.c
new file mode 100644
index 0000000..fa86b30
--- /dev/null
+++ b/examples/hello_libdeps/libs/libfoo/foo.c
@@ -0,0 +1,8 @@
+#include "foo.h"
+
+#include <stdio.h>
+
+void foo (void)
+{
+ puts ("I am foo");
+}
diff --git a/examples/hello_libdeps/libs/libfoo/foo.h b/examples/hello_libdeps/libs/libfoo/foo.h
new file mode 100644
index 0000000..a5bf6dd
--- /dev/null
+++ b/examples/hello_libdeps/libs/libfoo/foo.h
@@ -0,0 +1,6 @@
+#ifndef _FOO_H_
+#define _FOO_H_
+
+void foo (void);
+
+#endif // _FOO_H_
diff --git a/examples/hello_libdeps/libs/libfoo/linkme.mk b/examples/hello_libdeps/libs/libfoo/linkme.mk
new file mode 100644
index 0000000..25e2e05
--- /dev/null
+++ b/examples/hello_libdeps/libs/libfoo/linkme.mk
@@ -0,0 +1 @@
+# empty linkme.mk is useless, this is a part of regression tests
diff --git a/examples/hello_libdeps/libs/libfooqux/Makefile b/examples/hello_libdeps/libs/libfooqux/Makefile
new file mode 100644
index 0000000..9157963
--- /dev/null
+++ b/examples/hello_libdeps/libs/libfooqux/Makefile
@@ -0,0 +1,9 @@
+LIB = fooqux
+INCS = fooqux.h
+
+SHLIB_MAJOR = 0
+SHLIB_MINOR = 0
+
+WARNS = 4
+
+.include <mkc.mk>
diff --git a/examples/hello_libdeps/libs/libfooqux/fooqux.c b/examples/hello_libdeps/libs/libfooqux/fooqux.c
new file mode 100644
index 0000000..27d5225
--- /dev/null
+++ b/examples/hello_libdeps/libs/libfooqux/fooqux.c
@@ -0,0 +1,9 @@
+#include "fooqux.h"
+
+#include <stdio.h>
+
+void fooqux (void)
+{
+ foo ();
+ puts (" and qux");
+}
diff --git a/examples/hello_libdeps/libs/libfooqux/fooqux.h b/examples/hello_libdeps/libs/libfooqux/fooqux.h
new file mode 100644
index 0000000..0c4f973
--- /dev/null
+++ b/examples/hello_libdeps/libs/libfooqux/fooqux.h
@@ -0,0 +1,8 @@
+#ifndef _FOOQUX_H_
+#define _FOOQUX_H_
+
+#include "foo.h"
+
+void fooqux (void);
+
+#endif // _FOOQUX_H_
diff --git a/examples/hello_libdeps/progs/foobaz/Makefile b/examples/hello_libdeps/progs/foobaz/Makefile
new file mode 100644
index 0000000..e24d1cf
--- /dev/null
+++ b/examples/hello_libdeps/progs/foobaz/Makefile
@@ -0,0 +1,5 @@
+PROG = foobaz
+
+WARNS = 4
+
+.include <mkc.mk>
diff --git a/examples/hello_libdeps/progs/foobaz/foobaz.c b/examples/hello_libdeps/progs/foobaz/foobaz.c
new file mode 100644
index 0000000..e2cf60b
--- /dev/null
+++ b/examples/hello_libdeps/progs/foobaz/foobaz.c
@@ -0,0 +1,11 @@
+#include "foo.h"
+#include "baz.h"
+
+#include <stdio.h>
+
+int main (int argc, char **argv)
+{
+ foo ();
+ baz ();
+ return 0;
+}
diff --git a/examples/hello_libdeps/progs/fooquxfoobar/Makefile b/examples/hello_libdeps/progs/fooquxfoobar/Makefile
new file mode 100644
index 0000000..5017e96
--- /dev/null
+++ b/examples/hello_libdeps/progs/fooquxfoobar/Makefile
@@ -0,0 +1,5 @@
+PROG = fooquxfoobar
+
+WARNS = 4
+
+.include <mkc.mk>
diff --git a/examples/hello_libdeps/progs/fooquxfoobar/fooquxfoobar.c b/examples/hello_libdeps/progs/fooquxfoobar/fooquxfoobar.c
new file mode 100644
index 0000000..3d154b6
--- /dev/null
+++ b/examples/hello_libdeps/progs/fooquxfoobar/fooquxfoobar.c
@@ -0,0 +1,12 @@
+#include "fooqux.h"
+#include "bar.h"
+
+#include <stdio.h>
+
+int main (int argc, char **argv)
+{
+ fooqux ();
+ foo ();
+ bar ();
+ return 0;
+}
diff --git a/examples/hello_libdeps/test.mk b/examples/hello_libdeps/test.mk
new file mode 100644
index 0000000..0c9daf4
--- /dev/null
+++ b/examples/hello_libdeps/test.mk
@@ -0,0 +1,52 @@
+run_nm := env NM=${NM:Q} OPSYS=${OPSTS:Q} mkc_test_nm
+
+.PHONY : test_output
+test_output:
+ @set -e; LC_ALL=C; export LC_ALL; \
+ LD_LIBRARY_PATH=${OBJDIR_libs_libfoo}:${OBJDIR_libs_libfooqux}:${OBJDIR_libs_libbar}:${OBJDIR_libs_libbaz}; \
+ DYLD_LIBRARY_PATH=$$LD_LIBRARY_PATH; \
+ LIBRARY_PATH=$$LIBRARY_PATH:$$LD_LIBRARY_PATH; \
+ export LD_LIBRARY_PATH DYLD_LIBRARY_PATH LIBRARY_PATH; \
+ echo =========== fooquxfoobar ============; \
+ ${OBJDIR_progs_fooquxfoobar}/fooquxfoobar; \
+ echo =========== foobaz ============; \
+ ${OBJDIR_progs_foobaz}/foobaz; \
+ rm -rf ${.OBJDIR}${PREFIX}; \
+ \
+ echo =========== depends ============; \
+ ${MAKE} ${MAKEFLAGS} -j4 depend > /dev/null; \
+ mkc_long_lines `find ${.CURDIR} -type f -name .depend` | \
+ awk '!/^#/ {for (i=1; i <= NF; ++i) if ($$i ~ /^\// && $$i !~ /mk-configure/) $$i = ""; print $$0; }' | \
+ awk '{$$1 = $$1; gsub(/[.]o[ps]/, ".o"); print $$0}' | sort | \
+ mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \
+ \
+ echo ======= install ==========; \
+ ${MAKE} ${MAKEFLAGS} install DESTDIR=${.OBJDIR} > /dev/null; \
+ find ${.OBJDIR}${PREFIX} -type f -o -type l | \
+ mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \
+ rm -rf ${.OBJDIR}${PREFIX} ${.OBJDIR}/usr ${.OBJDIR}/Users ${.OBJDIR}/home; \
+ \
+ echo =========== all with STATICLIBS=... ============; \
+ ${MAKE} ${MAKEFLAGS} distclean > /dev/null; \
+ env STATICLIBS='libfoo libbar' ${MAKE} ${MAKEFLAGS} -j4 all > /dev/null; \
+ find ${.OBJDIR} -type f -o -type l | \
+ mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \
+ \
+ echo ========= install with STATICLIBS=... ==========; \
+ env STATICLIBS='libfoo libbar' ${MAKE} ${MAKEFLAGS} install DESTDIR=${.OBJDIR} > /dev/null; \
+ find ${.OBJDIR}${PREFIX} -type f -o -type l -o -type d | \
+ mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \
+ case ${OPSYS} in \
+ *BSD|DragonFly|SunOS|Linux) \
+ ${run_nm} ${OBJDIR_libfooqux}/libfooqux.so;; \
+ *) \
+ printf 'symbol foo\nsymbol fooqux\n';; \
+ esac; \
+ rm -rf ${.OBJDIR}${PREFIX} ${.OBJDIR}/usr ${.OBJDIR}/home ${.OBJDIR}/Users; \
+ \
+ echo ======= distclean ==========; \
+ ${MAKE} ${MAKEFLAGS} distclean > /dev/null; \
+ find ${.OBJDIR} -type f | \
+ mkc_test_helper "${PREFIX}" "${.OBJDIR}"
+
+.include <mkc.minitest.mk>