aboutsummaryrefslogtreecommitdiffstats
path: root/mk
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-03-03 19:29:22 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-03 19:29:22 -0800
commitf7c5421560640d23fc10803b9d59a9ff1d83e467 (patch)
treed6ae69d0d3f4a4d760a3254ec326bca4a8afacfe /mk
parentd97c47cad830d00c9da685cc4ea157d6185f6c97 (diff)
downloadexternal_dhcpcd-f7c5421560640d23fc10803b9d59a9ff1d83e467.zip
external_dhcpcd-f7c5421560640d23fc10803b9d59a9ff1d83e467.tar.gz
external_dhcpcd-f7c5421560640d23fc10803b9d59a9ff1d83e467.tar.bz2
auto import from //depot/cupcake/@135843
Diffstat (limited to 'mk')
-rw-r--r--mk/cc.mk28
-rw-r--r--mk/depend.mk11
-rw-r--r--mk/dist.mk31
-rw-r--r--mk/files.mk9
-rw-r--r--mk/man.mk25
-rw-r--r--mk/os-BSD.mk5
-rw-r--r--mk/os-Darwin.mk5
-rw-r--r--mk/os-Linux.mk8
-rw-r--r--mk/os.mk7
-rw-r--r--mk/prog.mk68
-rw-r--r--mk/scripts.mk9
-rw-r--r--mk/sys.mk14
12 files changed, 220 insertions, 0 deletions
diff --git a/mk/cc.mk b/mk/cc.mk
new file mode 100644
index 0000000..fcf0535
--- /dev/null
+++ b/mk/cc.mk
@@ -0,0 +1,28 @@
+# Copyright 2008 Roy Marples <roy@marples.name>
+
+# Setup some good default CFLAGS
+CFLAGS?= -Os
+
+# Default to using the C99 standard
+CSTD?= c99
+_CSTD_SH= if test -n "${CSTD}"; then echo "-std=${CSTD}"; else echo ""; fi
+_CSTD!= ${_CSTD_SH}
+CFLAGS+= ${_CSTD}$(shell ${_CSTD_SH})
+
+# Try and use some good cc flags if we're building from git
+_CCFLAGS= -pedantic -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 \
+ -Wdeclaration-after-statement -Wsequence-point -Wextra
+_CC_FLAGS_SH= if ! test -d .git; then echo ""; else for f in ${_CCFLAGS}; do \
+ if ${CC} $$f -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
+ then printf "%s" "$$f "; fi \
+ done; fi
+_CC_FLAGS!= ${_CC_FLAGS_SH}
+CFLAGS+= ${_CC_FLAGS}$(shell ${_CC_FLAGS_SH})
+
+_GGDB_SH= if test "${DEBUG}" = "yes"; then echo "-ggdb -DDEBUG"; else echo ""; fi
+_GGDB!= ${_GGDB_SH}
+GGDB= ${_GGDB}$(shell ${_GGDB_SH})
+CFLAGS+= ${GGDB}
diff --git a/mk/depend.mk b/mk/depend.mk
new file mode 100644
index 0000000..a4d717a
--- /dev/null
+++ b/mk/depend.mk
@@ -0,0 +1,11 @@
+# This only works for make implementations that always include a .depend if
+# it exists. Only GNU make does not do this.
+
+# Copyright 2008 Roy Marples <roy@marples.name>
+
+CLEANFILES+= .depend
+
+.depend: ${SRCS}
+ ${CC} ${CFLAGS} -MM ${SRCS} > .depend
+
+depend: .depend
diff --git a/mk/dist.mk b/mk/dist.mk
new file mode 100644
index 0000000..3d9385b
--- /dev/null
+++ b/mk/dist.mk
@@ -0,0 +1,31 @@
+# rules to make a distribution tarball from a git repo
+# Copyright 2008 Roy Marples <roy@marples.name>
+
+GITREF?= HEAD
+DISTPREFIX?= ${PROG}-${VERSION}
+DISTFILE?= ${DISTPREFIX}.tar.bz2
+
+CLEANFILES+= *.tar.bz2
+
+_VERSION_SH= sed -n 's/\#define VERSION[[:space:]]*"\(.*\)".*/\1/p' config.h
+_VERSION!= ${_VERSION_SH}
+VERSION= ${_VERSION}$(shell ${_VERSION_SH})
+
+_SNAP_SH= date -u +%Y%m%d%H%M
+_SNAP!= ${_SNAP_SH}
+SNAP= ${_SNAP}$(shell ${_SNAP_SH})
+SNAPDIR= ${DISTPREFIX}-${SNAP}
+SNAPFILE= ${SNAPDIR}.tar.bz2
+
+dist:
+ git archive --prefix=${DISTPREFIX}/ ${GITREF} | bzip2 > ${DISTFILE}
+
+snapshot:
+ mkdir /tmp/${SNAPDIR}
+ cp -RPp * /tmp/${SNAPDIR}
+ (cd /tmp/${SNAPDIR}; make clean)
+ tar -cvjpf ${SNAPFILE} -C /tmp ${SNAPDIR}
+ rm -rf /tmp/${SNAPDIR}
+ ls -l ${SNAPFILE}
+
+snap: snapshot
diff --git a/mk/files.mk b/mk/files.mk
new file mode 100644
index 0000000..0682b03
--- /dev/null
+++ b/mk/files.mk
@@ -0,0 +1,9 @@
+# Quick and dirty files
+# Copyright 2008 Roy Marples <roy@marples.name>
+
+FILESDIR?= ${BINDIR}
+FILESMODE?= ${NONBINMODE}
+
+_filesinstall:
+ ${INSTALL} -d ${DESTDIR}${FILESDIR}
+ ${INSTALL} -m ${FILESMODE} ${FILES} ${DESTDIR}${FILESDIR}
diff --git a/mk/man.mk b/mk/man.mk
new file mode 100644
index 0000000..f1570bb
--- /dev/null
+++ b/mk/man.mk
@@ -0,0 +1,25 @@
+# rules to install manpages
+# Copyright 2008 Roy Marples <roy@marples.name>
+
+_MANPREFIX_SH= if [ -n "${PREFIX}" ]; then echo "${PREFIX}"; else echo "/usr/share"; fi
+_MANPREFIX!= ${_MANPREFIX_SH}
+MANPREFIX?= ${_MANPREFIX}$(shell ${_MANPREFIX_SH})
+
+MANDIR?= ${MANPREFIX}/man/man
+MANMODE?= 0444
+
+_MAN5_SH= for man in ${MAN}; do case $$man in *.5) echo $$man;; esac; done
+_MAN5!= ${_MAN5_SH}
+MAN5= ${_MAN5}$(shell ${_MAN5_SH})
+
+_MAN8_SH= for man in ${MAN}; do case $$man in *.8) echo $$man;; esac; done
+_MAN8!= ${_MAN8_SH}
+MAN8= ${_MAN8}$(shell ${_MAN8_SH})
+
+_man: ${MAN}
+
+_maninstall: _man
+ ${INSTALL} -d ${DESTDIR}${MANDIR}5
+ ${INSTALL} -m ${MANMODE} ${MAN5} ${DESTDIR}${MANDIR}5
+ ${INSTALL} -d ${DESTDIR}${MANDIR}8
+ ${INSTALL} -m ${MANMODE} ${MAN8} ${DESTDIR}${MANDIR}8
diff --git a/mk/os-BSD.mk b/mk/os-BSD.mk
new file mode 100644
index 0000000..f9d3397
--- /dev/null
+++ b/mk/os-BSD.mk
@@ -0,0 +1,5 @@
+# Setup OS specific variables
+# Copyright 2008 Roy Marples <roy@marples.name>
+
+SRC_PF= bpf.c
+SRC_IF= if-bsd.c
diff --git a/mk/os-Darwin.mk b/mk/os-Darwin.mk
new file mode 100644
index 0000000..f2c3104
--- /dev/null
+++ b/mk/os-Darwin.mk
@@ -0,0 +1,5 @@
+# Setup OS specific variables
+# Copyright 2008 Roy Marples <roy@marples.name>
+
+include ${MK}/os-BSD.mk
+LINK_RPATH= --rpath
diff --git a/mk/os-Linux.mk b/mk/os-Linux.mk
new file mode 100644
index 0000000..2d316b1
--- /dev/null
+++ b/mk/os-Linux.mk
@@ -0,0 +1,8 @@
+# Setup OS specific variables
+# Copyright 2008 Roy Marples <roy@marples.name>
+
+SRC_PF= lpf.c
+SRC_IF= if-linux.c
+
+CPPFLAGS+= -D_BSD_SOURCE -D_XOPEN_SOURCE=600
+LIBRT= -lrt
diff --git a/mk/os.mk b/mk/os.mk
new file mode 100644
index 0000000..f3426e4
--- /dev/null
+++ b/mk/os.mk
@@ -0,0 +1,7 @@
+# Setup OS specific variables
+# Copyright 2008 Roy Marples <roy@marples.name>
+
+_OS_SH= case `uname -s` in Linux) echo "Linux";; Darwin) echo "Darwin";; *) echo "BSD";; esac
+_OS!= ${_OS_SH}
+OS= ${_OS}$(shell ${_OS_SH})
+include ${MK}/os-${OS}.mk
diff --git a/mk/prog.mk b/mk/prog.mk
new file mode 100644
index 0000000..d970b2d
--- /dev/null
+++ b/mk/prog.mk
@@ -0,0 +1,68 @@
+# rules to build a program
+# based on FreeBSD's bsd.prog.mk
+
+# Copyright 2008 Roy Marples <roy@marples.name>
+
+include ${MK}/cc.mk
+
+OBJS+= ${SRCS:.c=.o}
+
+# If building for /, ensure we use the libc in / if different from
+# the default one in /usr/lib
+LINK_RPATH?= -Wl,-rpath
+_RPATH_SH= if test "${PREFIX}" = "" -o "${PREIX}" = "/"; then \
+ echo "${LINK_RPATH}=${PREFIX}/${LIBNAME}"; \
+ else \
+ echo ""; \
+ fi
+_RPATH!= ${_RPATH_SH}
+LDFLAGS+= ${_RPATH}$(shell ${_RPATH_SH})
+
+# If building for /, ensure we use the linker in /libexec if different from
+# the default one in /usr/libexec
+_DYNLINK_SH= if test "${PREFIX}" = "" -o "${PREFIX}" = "/" && test -e /libexec/ld.elf_so; then \
+ echo "-Wl,-dynamic-linker=/libexec/ld.elf_so"; \
+ else \
+ echo ""; \
+ fi
+_DYNLINK!= ${_DYNLINK_SH}
+LDFLAGS+= ${_DYNLINK}$(shell ${_DYNLINK_SH})
+
+all: ${PROG} ${SCRIPTS} _man
+
+.c.o:
+ ${CC} ${CFLAGS} ${CPPFLAGS} -c $< -o $@
+
+${PROG}: ${OBJS}
+ ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LDADD}
+
+# We could save about 600 bytes by building it like this
+# instead of the more traditional method above
+small: ${SRCS}
+ echo "" > _${PROG}.c
+ for src in ${SRCS}; do echo "#include \"$$src\"" >> _${PROG}.c; done
+ ${CC} ${CFLAGS} ${CPPFLAGS} -c _${PROG}.c -o _${PROG}.o
+ ${CC} ${LDFLAGS} -o ${PROG} _${PROG}.o ${LDADD}
+
+_proginstall: ${PROG}
+ ${INSTALL} -d ${DESTDIR}${BINDIR}
+ ${INSTALL} -m ${BINMODE} ${PROG} ${DESTDIR}${BINDIR}
+ ${INSTALL} -d ${DESTDIR}${DBDIR}
+
+include ${MK}/depend.mk
+include ${MK}/files.mk
+include ${MK}/scripts.mk
+include ${MK}/man.mk
+include ${MK}/dist.mk
+
+install: _proginstall _scriptsinstall _filesinstall _maninstall
+ for x in ${SUBDIRS}; do cd $$x; ${MAKE} $@; cd ..; done
+
+clean:
+ rm -f ${OBJS} ${PROG} _${PROG}.c _${PROG}.o ${PROG}.core ${CLEANFILES}
+
+LINTFLAGS?= -hx
+LINTFLAGS+= -X 159,247,352
+
+lint: ${SRCS:.c=.c}
+ ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} $^ ${.ALLSRC}
diff --git a/mk/scripts.mk b/mk/scripts.mk
new file mode 100644
index 0000000..d295163
--- /dev/null
+++ b/mk/scripts.mk
@@ -0,0 +1,9 @@
+# Quick and dirty scripts
+# Copyright 2008 Roy Marples <roy@marples.name>
+
+SCRIPTSDIR?= ${BINDIR}
+SCRIPTSMODE?= ${BINMODE}
+
+_scriptsinstall: ${SCRIPTS}
+ ${INSTALL} -d ${DESTDIR}${SCRIPTSDIR}
+ ${INSTALL} -m ${SCRIPTSMODE} ${SCRIPTS} ${DESTDIR}${SCRIPTSDIR}
diff --git a/mk/sys.mk b/mk/sys.mk
new file mode 100644
index 0000000..81882ab
--- /dev/null
+++ b/mk/sys.mk
@@ -0,0 +1,14 @@
+# Simple defaults
+
+BINDIR?= ${PREFIX}/usr/bin
+BINMODE?= 0755
+NONBINMODE?= 0644
+
+SYSCONFDIR?= ${PREFIX}/etc
+
+INSTALL?= install
+SED?= sed
+
+_LIBNAME_SH= case `readlink /lib` in "") echo "lib";; *) basename `readlink /lib`;; esac
+_LIBNAME!= ${_LIBNAME_SH}
+LIBNAME?= ${_LIBNAME}$(shell ${_LIBNAME_SH})