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) |
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/.mk b/src/.mk new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/src/.mk diff --git a/src/Makefile. b/src/Makefile. deleted file mode 100644 index baa0cf1c..00000000 --- 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 a9ef9791..00000000 --- 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 96a80ab9..00000000 --- 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 204325dd..00000000 --- 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 5f8ff569..00000000 --- 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 10f19865..00000000 --- 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 00000000..d3c96a65 --- /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 00000000..10f4fcb2 --- /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 00000000..947492c1 --- /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 00000000..b6826340 --- /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 2720e458..2720e458 100644 --- a/src/einfo.h +++ b/src/libeinfo/einfo.h diff --git a/src/einfo.map b/src/libeinfo/einfo.map index 428a8954..428a8954 100644 --- a/src/einfo.map +++ b/src/libeinfo/einfo.map diff --git a/src/libeinfo.c b/src/libeinfo/libeinfo.c index d80af9c0..d80af9c0 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 00000000..27ea942c --- /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 fe9509de..fe9509de 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 902d012f..902d012f 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 238f70d1..238f70d1 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 dcecc293..dcecc293 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 815c8370..815c8370 100644 --- a/src/librc-strlist.c +++ b/src/librc/librc-strlist.c diff --git a/src/librc.c b/src/librc/librc.c index 15309f87..15309f87 100644 --- a/src/librc.c +++ b/src/librc/librc.c diff --git a/src/librc.h b/src/librc/librc.h index cf61217a..cf61217a 100644 --- a/src/librc.h +++ b/src/librc/librc.h diff --git a/src/rc.h b/src/librc/rc.h index 0020764e..0020764e 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 00000000..f1df47f0 --- /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 00000000..6b8b56d9 --- /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 00000000..a9c961ed --- /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 00000000..1d0f013f --- /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 b079e320..b079e320 100644 --- a/src/_usage.c +++ b/src/rc/_usage.c diff --git a/src/_usage.h b/src/rc/_usage.h index e4a5fa3b..e4a5fa3b 100644 --- a/src/_usage.h +++ b/src/rc/_usage.h diff --git a/src/builtins.h b/src/rc/builtins.h index 43a4d9f9..43a4d9f9 100644 --- a/src/builtins.h +++ b/src/rc/builtins.h diff --git a/src/checkpath.c b/src/rc/checkpath.c index 612a0769..612a0769 100644 --- a/src/checkpath.c +++ b/src/rc/checkpath.c diff --git a/src/fstabinfo.c b/src/rc/fstabinfo.c index 5f8e469a..5f8e469a 100644 --- a/src/fstabinfo.c +++ b/src/rc/fstabinfo.c diff --git a/src/mountinfo.c b/src/rc/mountinfo.c index 05ce8dd7..05ce8dd7 100644 --- a/src/mountinfo.c +++ b/src/rc/mountinfo.c diff --git a/src/rc-depend.c b/src/rc/rc-depend.c index c5e9e662..c5e9e662 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 675a4d23..675a4d23 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 c15e73f8..c15e73f8 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 0d8b8c1f..0d8b8c1f 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 613f049e..613f049e 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 412a47e7..412a47e7 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 155192fa..155192fa 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 4f07503f..4f07503f 100644 --- a/src/rc-update.c +++ b/src/rc/rc-update.c diff --git a/src/rc.map b/src/rc/rc.map index e5f8ee34..e5f8ee34 100644 --- a/src/rc.map +++ b/src/rc/rc.map diff --git a/src/runscript.c b/src/rc/runscript.c index 1385bb02..1385bb02 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 bf03dbec..bf03dbec 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 860a3d52..860a3d52 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 00000000..7b5058db --- /dev/null +++ b/src/termcap.mk @@ -0,0 +1,3 @@ +LIBTERMCAP?= -ltermcap +CPPFLAGS+= -DHAVE_TERMCAP +LDADD+= ${LIBTERMCAP} |