diff options
author | Roy Marples <roy@marples.name> | 2008-01-05 19:25:55 +0000 |
---|---|---|
committer | Roy Marples <roy@marples.name> | 2008-01-05 19:25:55 +0000 |
commit | ac21d75300dabe83578e4373fcfd09d67c3a083b (patch) | |
tree | d5f8e2a16920add2277c79ff8a1b7e99ec2976df /src | |
parent | 112fbde453d55c49b7999d2e35496a8758aaa7b5 (diff) | |
download | openrc-ac21d75300dabe83578e4373fcfd09d67c3a083b.tar.gz openrc-ac21d75300dabe83578e4373fcfd09d67c3a083b.tar.bz2 openrc-ac21d75300dabe83578e4373fcfd09d67c3a083b.tar.xz |
Add some .mk stubs to impersonate bsk .mk files to make writing our Makefiles easier. libeinfo, librc and rc now have their own seperate directories. More work is needed to tidy this up though.
Diffstat (limited to 'src')
-rw-r--r-- | src/.mk | 0 | ||||
-rw-r--r-- | src/Makefile. | 4 | ||||
-rw-r--r-- | src/Makefile.BSD | 2 | ||||
-rw-r--r-- | src/Makefile.Linux | 2 | ||||
-rw-r--r-- | src/Makefile.ncurses | 2 | ||||
-rw-r--r-- | src/Makefile.pam | 2 | ||||
-rw-r--r-- | src/Makefile.termcap | 4 | ||||
-rw-r--r-- | src/cc.mk | 25 | ||||
-rw-r--r-- | src/default.mk | 34 | ||||
-rw-r--r-- | src/lib.mk | 55 | ||||
-rw-r--r-- | src/libeinfo/Makefile | 14 | ||||
-rw-r--r-- | src/libeinfo/einfo.h (renamed from src/einfo.h) | 0 | ||||
-rw-r--r-- | src/libeinfo/einfo.map (renamed from src/einfo.map) | 0 | ||||
-rw-r--r-- | src/libeinfo/libeinfo.c (renamed from src/libeinfo.c) | 0 | ||||
-rw-r--r-- | src/librc/Makefile | 14 | ||||
-rw-r--r-- | src/librc/librc-daemon.c (renamed from src/librc-daemon.c) | 0 | ||||
-rw-r--r-- | src/librc/librc-depend.c (renamed from src/librc-depend.c) | 0 | ||||
-rw-r--r-- | src/librc/librc-depend.h (renamed from src/librc-depend.h) | 0 | ||||
-rw-r--r-- | src/librc/librc-misc.c (renamed from src/librc-misc.c) | 0 | ||||
-rw-r--r-- | src/librc/librc-strlist.c (renamed from src/librc-strlist.c) | 0 | ||||
-rw-r--r-- | src/librc/librc.c (renamed from src/librc.c) | 0 | ||||
-rw-r--r-- | src/librc/librc.h (renamed from src/librc.h) | 0 | ||||
-rw-r--r-- | src/librc/rc.h (renamed from src/rc.h) | 0 | ||||
-rw-r--r-- | src/ncurses.mk | 3 | ||||
-rw-r--r-- | src/os.mk | 24 | ||||
-rw-r--r-- | src/pam.mk | 6 | ||||
-rw-r--r-- | src/prog.mk | 18 | ||||
-rw-r--r-- | src/rc/_usage.c (renamed from src/_usage.c) | 0 | ||||
-rw-r--r-- | src/rc/_usage.h (renamed from src/_usage.h) | 0 | ||||
-rw-r--r-- | src/rc/builtins.h (renamed from src/builtins.h) | 0 | ||||
-rw-r--r-- | src/rc/checkpath.c (renamed from src/checkpath.c) | 0 | ||||
-rw-r--r-- | src/rc/fstabinfo.c (renamed from src/fstabinfo.c) | 0 | ||||
-rw-r--r-- | src/rc/mountinfo.c (renamed from src/mountinfo.c) | 0 | ||||
-rw-r--r-- | src/rc/rc-depend.c (renamed from src/rc-depend.c) | 0 | ||||
-rw-r--r-- | src/rc/rc-logger.c (renamed from src/rc-logger.c) | 0 | ||||
-rw-r--r-- | src/rc/rc-logger.h (renamed from src/rc-logger.h) | 0 | ||||
-rw-r--r-- | src/rc/rc-misc.c (renamed from src/rc-misc.c) | 0 | ||||
-rw-r--r-- | src/rc/rc-plugin.c (renamed from src/rc-plugin.c) | 0 | ||||
-rw-r--r-- | src/rc/rc-plugin.h (renamed from src/rc-plugin.h) | 0 | ||||
-rw-r--r-- | src/rc/rc-status.c (renamed from src/rc-status.c) | 0 | ||||
-rw-r--r-- | src/rc/rc-update.c (renamed from src/rc-update.c) | 0 | ||||
-rw-r--r-- | src/rc/rc.c (renamed from src/rc.c) | 0 | ||||
-rw-r--r-- | src/rc/rc.map (renamed from src/rc.map) | 0 | ||||
-rw-r--r-- | src/rc/runscript.c (renamed from src/runscript.c) | 0 | ||||
-rw-r--r-- | src/rc/start-stop-daemon.c (renamed from src/start-stop-daemon.c) | 0 | ||||
-rw-r--r-- | src/rc/start-stop-daemon.pam (renamed from src/start-stop-daemon.pam) | 0 | ||||
-rw-r--r-- | src/termcap.mk | 3 |
47 files changed, 196 insertions, 16 deletions
diff --git a/src/Makefile. b/src/Makefile. deleted file mode 100644 index baa0cf1..0000000 --- a/src/Makefile. +++ /dev/null @@ -1,4 +0,0 @@ -# Empty Makefile so that we can do this -#include Makefile.$(FOO) -# where FOO is unset. -# This is needed as not all make implementations can optionally include a Makefile diff --git a/src/Makefile.BSD b/src/Makefile.BSD deleted file mode 100644 index a9ef979..0000000 --- a/src/Makefile.BSD +++ /dev/null @@ -1,2 +0,0 @@ -LDLIBS_LIBRC += -lkvm -LDLIBS_RC += -lkvm diff --git a/src/Makefile.Linux b/src/Makefile.Linux deleted file mode 100644 index 96a80ab..0000000 --- a/src/Makefile.Linux +++ /dev/null @@ -1,2 +0,0 @@ -LDLIBS_RC += -Wl,-Bdynamic -ldl -CPPFLAGS += -D_BSD_SOURCE -D_XOPEN_SOURCE=500 diff --git a/src/Makefile.ncurses b/src/Makefile.ncurses deleted file mode 100644 index 204325d..0000000 --- a/src/Makefile.ncurses +++ /dev/null @@ -1,2 +0,0 @@ -LIBTERMCAP = -lncurses -include Makefile.termcap diff --git a/src/Makefile.pam b/src/Makefile.pam deleted file mode 100644 index 5f8ff56..0000000 --- a/src/Makefile.pam +++ /dev/null @@ -1,2 +0,0 @@ -CPPFLAGS_SSD = -DHAVE_PAM -LDLIBS_RC += -lpam diff --git a/src/Makefile.termcap b/src/Makefile.termcap deleted file mode 100644 index 10f1986..0000000 --- a/src/Makefile.termcap +++ /dev/null @@ -1,4 +0,0 @@ -LIBTERMCAP ?= -ltermcap -CPPFLAGS_LIBEINFO = -DHAVE_TERMCAP -LDLIBS_LIBEINFO += $(LIBTERMCAP) -LDLIBS_RC += $(LIBTERMCAP) diff --git a/src/cc.mk b/src/cc.mk new file mode 100644 index 0000000..d3c96a6 --- /dev/null +++ b/src/cc.mk @@ -0,0 +1,25 @@ +# Copyright 2008 Roy Marples + +# Setup some good default CFLAGS + +CFLAGS ?= -O2 -pipe + +# GNU Make way of detecting gcc flags we can use +check_gcc=$(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \ + then echo "$(1)"; else echo "$(2)"; fi) + +# pmake check for extra cflags +WEXTRA != for x in -Wdeclaration-after-statement -Wsequence-point -Wextra; do \ + if $(CC) $$x -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \ + then echo -n "$$x "; fi \ + done + +# Loads of nice flags to ensure our code is good +CFLAGS += -pedantic -std=c99 \ + -Wall -Wunused -Wimplicit -Wshadow -Wformat=2 \ + -Wmissing-declarations -Wno-missing-prototypes -Wwrite-strings \ + -Wbad-function-cast -Wnested-externs -Wcomment -Winline \ + -Wchar-subscripts -Wcast-align -Wno-format-nonliteral \ + $(call check_gcc, -Wdeclaration-after-statement) \ + $(call check_gcc, -Wsequence-point) \ + $(call check_gcc, -Wextra) $(WEXTRA) diff --git a/src/default.mk b/src/default.mk new file mode 100644 index 0000000..10f4fcb --- /dev/null +++ b/src/default.mk @@ -0,0 +1,34 @@ +# Copyright 2007-2008 Roy Marples + +CC ?= gcc +AR ?= ar +RANLIB ?= ranlib +CFLAGS += -O2 -pipe +LDFLAGS += -L. +PICFLAG = -fPIC + +# GNU Make way of detecting gcc flags we can use +check_gcc=$(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \ + then echo "$(1)"; else echo "$(2)"; fi) + +# pmake check for extra cflags +WEXTRA != for x in -Wdeclaration-after-statement -Wsequence-point -Wextra; do \ + if $(CC) $$x -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \ + then echo -n "$$x "; fi \ + done + +# Loads of nice flags to ensure our code is good +CFLAGS += -pedantic -std=c99 \ + -Wall -Wunused -Wimplicit -Wshadow -Wformat=2 \ + -Wmissing-declarations -Wno-missing-prototypes -Wwrite-strings \ + -Wbad-function-cast -Wnested-externs -Wcomment -Winline \ + -Wchar-subscripts -Wcast-align -Wno-format-nonliteral \ + $(call check_gcc, -Wdeclaration-after-statement) \ + $(call check_gcc, -Wsequence-point) \ + $(call check_gcc, -Wextra) $(WEXTRA) + +# For debugging. -Werror is pointless due to ISO C issues with dlsym +#CFLAGS += -ggdb + +TOPDIR = .. +include $(TOPDIR)/default.mk diff --git a/src/lib.mk b/src/lib.mk new file mode 100644 index 0000000..947492c --- /dev/null +++ b/src/lib.mk @@ -0,0 +1,55 @@ +# rules to build a library +# based on FreeBSD's bsd.lib.mk + +# Copyright 2008 Roy Marples + +SHLIB_NAME= lib${LIB}.so.${SHLIB_MAJOR} +SHLIB_LINK= lib${LIB}.so +SHLIBDIR?= /lib +SONAME?= ${SHLIB_NAME} + +OBJS+= ${SRCS:.c=.o} +SOBJS+= ${OBJS:.o=.So} +_LIBS= lib${LIB}.a ${SHLIB_NAME} + +ECHO?= echo +AR?= ar +RANLIB?= ranlib +INSTALL?= install +LIBMODE?= 0444 + +PICFLAG?= -fPIC + +INCDIR?= /usr/include +INCMODE?= 0444 + +.SUFFIXES: .So + +.c.So: + ${CC} ${PICFLAG} -DPIC ${CFLAGS} ${CPPFLAGS} -c $< -o $@ + +all: ${_LIBS} + +lib${LIB}.a: ${OBJS} ${STATICOBJS} + @${ECHO} building static library $@ + ${AR} rc $@ $^ + ${RANLIB} $@ + + +${SHLIB_NAME}: ${SOBJS} + @${ECHO} building shared library $@ + @rm -f $@ ${SHLIB_LINK} + @ln -fs $@ ${SHLIB_LINK} + ${CC} ${LDFLAGS} -shared -Wl,-x \ + -o $@ -Wl,-soname,${SONAME} \ + ${SOBJS} ${LDADD} + +install: + ${INSTALL} -d ${DESTDIR}${SHLIBDIR} + ${INSTALL} -m ${LIBMODE} ${SHLIB_NAME} ${DESTDIR}${SHLIBDIR} + ln -fs ${SHLIB_NAME} ${DESTDIR}${SHLIBDIR}/${SHLIB_LINK} + ${INSTALL} -d ${DESTDIR}${INCDIR} + for x in ${INCS}; do ${INSTALL} -m ${INCMODE} $$x ${DESTDIR}${INCDIR}; done + +clean: + rm -f ${OBJS} ${SOBJS} ${_LIBS} ${SHLIB_LINK} diff --git a/src/libeinfo/Makefile b/src/libeinfo/Makefile new file mode 100644 index 0000000..b682634 --- /dev/null +++ b/src/libeinfo/Makefile @@ -0,0 +1,14 @@ +TOPDIR= .. +include $(TOPDIR)/os.mk + +LIB= einfo +SHLIB_MAJOR= 1 +SRCS= libeinfo.c +INCS= einfo.h + +SHLIBDIR= /${LIBNAME} + +include $(TOPDIR)/cc.mk +include $(TOPDIR)/lib.mk +include $(TOPDIR)/$(TERMCAP).mk + diff --git a/src/einfo.h b/src/libeinfo/einfo.h index 2720e45..2720e45 100644 --- a/src/einfo.h +++ b/src/libeinfo/einfo.h diff --git a/src/einfo.map b/src/libeinfo/einfo.map index 428a895..428a895 100644 --- a/src/einfo.map +++ b/src/libeinfo/einfo.map diff --git a/src/libeinfo.c b/src/libeinfo/libeinfo.c index d80af9c..d80af9c 100644 --- a/src/libeinfo.c +++ b/src/libeinfo/libeinfo.c diff --git a/src/librc/Makefile b/src/librc/Makefile new file mode 100644 index 0000000..27ea942 --- /dev/null +++ b/src/librc/Makefile @@ -0,0 +1,14 @@ +TOPDIR= .. +include $(TOPDIR)/os.mk + +LIB= rc +SHLIB_MAJOR= 1 +SRCS= librc.c librc-daemon.c librc-depend.c librc-misc.c librc-strlist.c +INCS= rc.h + +CPPFLAGS+= -DLIB=\"${LIBNAME}\" + +SHLIBDIR= /${LIBNAME} + +include $(TOPDIR)/cc.mk +include $(TOPDIR)/lib.mk diff --git a/src/librc-daemon.c b/src/librc/librc-daemon.c index fe9509d..fe9509d 100644 --- a/src/librc-daemon.c +++ b/src/librc/librc-daemon.c diff --git a/src/librc-depend.c b/src/librc/librc-depend.c index 902d012..902d012 100644 --- a/src/librc-depend.c +++ b/src/librc/librc-depend.c diff --git a/src/librc-depend.h b/src/librc/librc-depend.h index 238f70d..238f70d 100644 --- a/src/librc-depend.h +++ b/src/librc/librc-depend.h diff --git a/src/librc-misc.c b/src/librc/librc-misc.c index dcecc29..dcecc29 100644 --- a/src/librc-misc.c +++ b/src/librc/librc-misc.c diff --git a/src/librc-strlist.c b/src/librc/librc-strlist.c index 815c837..815c837 100644 --- a/src/librc-strlist.c +++ b/src/librc/librc-strlist.c diff --git a/src/librc.c b/src/librc/librc.c index 15309f8..15309f8 100644 --- a/src/librc.c +++ b/src/librc/librc.c diff --git a/src/librc.h b/src/librc/librc.h index cf61217..cf61217 100644 --- a/src/librc.h +++ b/src/librc/librc.h diff --git a/src/rc.h b/src/librc/rc.h index 0020764..0020764 100644 --- a/src/rc.h +++ b/src/librc/rc.h diff --git a/src/ncurses.mk b/src/ncurses.mk new file mode 100644 index 0000000..f1df47f --- /dev/null +++ b/src/ncurses.mk @@ -0,0 +1,3 @@ +LIBTERMCAP?= -lncurses +CPPFLAGS+= -DHAVE_TERMCAP +LDADD+= ${LIBTERMCAP} diff --git a/src/os.mk b/src/os.mk new file mode 100644 index 0000000..6b8b56d --- /dev/null +++ b/src/os.mk @@ -0,0 +1,24 @@ +# Copyright 2008 Roy Marples + +# Generic definitions + +_OS_SH= u=`uname -s`; case "$${u}" in *BSD|DragonFly) echo "BSD";; *) echo "$${u}";; esac +_OS!= $(_OS_SH) +OS?= $(_OS)$(shell $(_OS_SH)) + +_LIBNAME_SH= l=`readlink /lib`; case "$$l" in /lib64|lib64) echo "lib64";; *) echo "lib";; esac +_LIBNAME!= $(_LIBNAME_SH) +LIBNAME?= $(_LIBNAME)$(shell $(_LIBNAME_SH)) +RC_LIB= /$(LIB)/rc + +_DEF_SH= case `uname -s` in Linux) echo "-D_XOPEN_SOURCE=600 -D_BSD_SOURCE";; *) echo;; esac +_DEF!= $(_DEF_SH) +CPPFLAGS+= $(_DEF)$(shell $(_DEF_SH)) + +_LIBDL_SH= case `uname -s` in Linux) echo "-Wl,-Bdynamic -ldl";; *) echo;; esac +_LIBDL!= $(_LIBDL_SH) +LIBDL?= $(_LIBDL)$(shell $(_LIBDL_SH)) + +_LIBKVM_SH= case `uname -s` in *BSD) echo "-lkvm";; *) echo;; esac +_LIBKVM!= $(_LIBKVM_SH) +LIBKVM?= $(_LIBKVM)$(shell $(_LIBKVM_SH)) diff --git a/src/pam.mk b/src/pam.mk new file mode 100644 index 0000000..a9c961e --- /dev/null +++ b/src/pam.mk @@ -0,0 +1,6 @@ +LIBPAM?= -lpam +CPPFLAGS+= -DHAVE_PAM +LDADD+= ${LIBPAM} + +PAMDIR?= /etc/pam.d +PAMMODE?= 0644 diff --git a/src/prog.mk b/src/prog.mk new file mode 100644 index 0000000..1d0f013 --- /dev/null +++ b/src/prog.mk @@ -0,0 +1,18 @@ +# rules to build a library +# based on FreeBSD's bsd.prog.mk + +# Copyright 2008 Roy Marples + +BINDIR?= /sbin + +OBJS+= ${SRCS:.c=.o} + +INSTALL?= install + +all: ${PROG} + +${PROG}: ${SCRIPTS} ${OBJS} + ${CC} ${CFLAGS} ${LDFLAGS} ${PROGLDFLAGS} ${CPPFLAGS} -o $@ ${OBJS} ${LDADD} + +clean: + rm -f ${OBJS} ${PROG} ${CLEANFILES} diff --git a/src/_usage.c b/src/rc/_usage.c index b079e32..b079e32 100644 --- a/src/_usage.c +++ b/src/rc/_usage.c diff --git a/src/_usage.h b/src/rc/_usage.h index e4a5fa3..e4a5fa3 100644 --- a/src/_usage.h +++ b/src/rc/_usage.h diff --git a/src/builtins.h b/src/rc/builtins.h index 43a4d9f..43a4d9f 100644 --- a/src/builtins.h +++ b/src/rc/builtins.h diff --git a/src/checkpath.c b/src/rc/checkpath.c index 612a076..612a076 100644 --- a/src/checkpath.c +++ b/src/rc/checkpath.c diff --git a/src/fstabinfo.c b/src/rc/fstabinfo.c index 5f8e469..5f8e469 100644 --- a/src/fstabinfo.c +++ b/src/rc/fstabinfo.c diff --git a/src/mountinfo.c b/src/rc/mountinfo.c index 05ce8dd..05ce8dd 100644 --- a/src/mountinfo.c +++ b/src/rc/mountinfo.c diff --git a/src/rc-depend.c b/src/rc/rc-depend.c index c5e9e66..c5e9e66 100644 --- a/src/rc-depend.c +++ b/src/rc/rc-depend.c diff --git a/src/rc-logger.c b/src/rc/rc-logger.c index 675a4d2..675a4d2 100644 --- a/src/rc-logger.c +++ b/src/rc/rc-logger.c diff --git a/src/rc-logger.h b/src/rc/rc-logger.h index c15e73f..c15e73f 100644 --- a/src/rc-logger.h +++ b/src/rc/rc-logger.h diff --git a/src/rc-misc.c b/src/rc/rc-misc.c index 0d8b8c1..0d8b8c1 100644 --- a/src/rc-misc.c +++ b/src/rc/rc-misc.c diff --git a/src/rc-plugin.c b/src/rc/rc-plugin.c index 613f049..613f049 100644 --- a/src/rc-plugin.c +++ b/src/rc/rc-plugin.c diff --git a/src/rc-plugin.h b/src/rc/rc-plugin.h index 412a47e..412a47e 100644 --- a/src/rc-plugin.h +++ b/src/rc/rc-plugin.h diff --git a/src/rc-status.c b/src/rc/rc-status.c index 155192f..155192f 100644 --- a/src/rc-status.c +++ b/src/rc/rc-status.c diff --git a/src/rc-update.c b/src/rc/rc-update.c index 4f07503..4f07503 100644 --- a/src/rc-update.c +++ b/src/rc/rc-update.c diff --git a/src/rc.map b/src/rc/rc.map index e5f8ee3..e5f8ee3 100644 --- a/src/rc.map +++ b/src/rc/rc.map diff --git a/src/runscript.c b/src/rc/runscript.c index 1385bb0..1385bb0 100644 --- a/src/runscript.c +++ b/src/rc/runscript.c diff --git a/src/start-stop-daemon.c b/src/rc/start-stop-daemon.c index bf03dbe..bf03dbe 100644 --- a/src/start-stop-daemon.c +++ b/src/rc/start-stop-daemon.c diff --git a/src/start-stop-daemon.pam b/src/rc/start-stop-daemon.pam index 860a3d5..860a3d5 100644 --- a/src/start-stop-daemon.pam +++ b/src/rc/start-stop-daemon.pam diff --git a/src/termcap.mk b/src/termcap.mk new file mode 100644 index 0000000..7b5058d --- /dev/null +++ b/src/termcap.mk @@ -0,0 +1,3 @@ +LIBTERMCAP?= -ltermcap +CPPFLAGS+= -DHAVE_TERMCAP +LDADD+= ${LIBTERMCAP} |