Our build chain now works with GNU and BSD make implementations

This commit is contained in:
Roy Marples 2007-11-19 13:48:43 +00:00
parent 2ef9c5c520
commit 5f8cf73b22
20 changed files with 91 additions and 104 deletions

View File

@ -3,25 +3,14 @@
# Distributed under the terms of the GNU General Public License v2
NAME = openrc
VERSION = 1.0pre1
VERSION = 1.0
PKG = $(NAME)-$(VERSION)
SUBDIRS = etc conf.d init.d man net sh src
ifeq ($(OS),)
OS=$(shell uname -s)
ifneq ($(OS),Linux)
OS=BSD
endif
endif
NET_LO = net.lo0
ifeq ($(OS),Linux)
NET_LO = net.lo
endif
SUBDIR = conf.d etc init.d man net sh src
TOPDIR = .
include $(TOPDIR)/default.mk
include $(TOPDIR)/Makefile.$(OS)
install::
# Don't install runlevels if they already exist

1
Makefile.BSD Normal file
View File

@ -0,0 +1 @@
NET_LO = net.lo0

1
Makefile.Linux Normal file
View File

@ -0,0 +1 @@
NET_LO = net.lo

View File

@ -1,5 +1,5 @@
DIR = /etc/conf.d
FILES = localmount net.example
CONF = localmount net.example
TOPDIR = ..
include $(TOPDIR)/default.mk

View File

@ -1,7 +1,6 @@
DIR = /etc/conf.d
FILES = net.example
FILES_APPEND = clock rc
FILES_NOEXIST = consolefont keymaps
CONF = consolefont keymaps net.example
CONF_APPEND = clock rc
TOPDIR = ..
include $(TOPDIR)/default.mk

View File

@ -1,5 +1,6 @@
DIR = /etc/conf.d
FILES_NOEXIST = $(filter-out Makefile,$(wildcard *))
DIR = /etc/conf.d
CONF = bootmisc checkfs clock env_whitelist hostname local.start local.stop \
net rc urandom
TOPDIR = ..
include $(TOPDIR)/default.mk

View File

@ -6,50 +6,51 @@ ROOT = /
LIB = lib
RC_LIB = /$(LIB)/rc
INSTALL ?= install
_OS_SH = u=`uname -s`; case "$${u}" in *BSD|DragonFly) echo "BSD";; *) echo "$${u}";; esac
_OS != $(_OS_SH)
OS ?= $(_OS)$(shell $(_OS_SH))
#
# Recursive rules
# Adapted from FreeBSDs bsd.subdir.mk
#
ECHODIR ?= true
_SUBDIR = \
@for x in $(SUBDIR); do \
if test -d $$x; then \
${ECHODIR} "===> ${DIRPRFX}$$x ($@)"; \
${MAKE} -C $$x $@ DIRPRFX=${DIRPRFX}$$x/; \
fi; \
if test -d $$x.${OS}; then \
${ECHODIR} "===> ${DIRPRFX}$$x.${OS} ($@)"; \
${MAKE} -C $$x.${OS} $@ DIRPRFX=${DIRPRFX}$$x/; \
fi; \
done
SUBDIRS_ALL = $(patsubst %,%_all,$(SUBDIRS))
SUBDIRS_CLEAN = $(patsubst %,%_clean,$(SUBDIRS))
SUBDIRS_INSTALL = $(patsubst %,%_install,$(SUBDIRS))
all:
$(_SUBDIR)
clean::
$(_SUBDIR)
install::
$(_SUBDIR)
all:: $(SUBDIRS_ALL)
clean:: $(SUBDIRS_CLEAN)
install:: $(SUBDIRS_INSTALL)
# Hmm ... possible to combine these three and not be ugly ?
%_all:
if test -d $(patsubst %_all,%,$@); then $(MAKE) -C $(patsubst %_all,%,$@).$(OS) all; fi
if test -d $(patsubst %_all,%,$@).$(OS); then $(MAKE) -C $(patsubst %_all,%,$@).$(OS) all; fi
%_clean:
if test -d $(patsubst %_clean,%,$@) ; then $(MAKE) -C $(patsubst %_clean,%,$@) clean ; fi
if test -d $(patsubst %_clean,%,$@).$(OS) ; then $(MAKE) -C $(patsubst %_clean,%,$@).$(OS) clean ; fi
%_install:
if test -d $(patsubst %_install,%,$@) ; then $(MAKE) -C $(patsubst %_install,%,$@) install ; fi
if test -d $(patsubst %_install,%,$@).$(OS) ; then $(MAKE) -C $(patsubst %_install,%,$@).$(OS) install ; fi
#
# Install rules
#
INSTALL_DIR = install -m 0755 -d
INSTALL_EXE = install -m 0755
INSTALL_FILE = install -m 0644
INSTALL_SECURE = install -m 0600
install:: $(EXES) $(FILES) $(FILES_NOEXIST) $(MANS)
test -n $(DIR) && $(INSTALL_DIR) $(DESTDIR)$(DIR)
for x in $(EXES) ; do $(INSTALL_EXE) $$x $(DESTDIR)$(DIR) || exit $$? ; done
for x in $(FILES) ; do $(INSTALL_FILE) $$x $(DESTDIR)$(DIR) || exit $$? ; done
for x in $(FILES_APPEND) ; do if test -e $(DESTDIR)$(DIR)/$$x ; then cat $$x >> $(DESTDIR)$(DIR)/$$x || exit $$? ; else $(INSTALL_FILE) $$x $(DESTDIR)$(DIR) || exit $$? ; fi ; done
for x in $(FILES_NOEXIST) ; do if ! test -e $(DESTDIR)$(DIR)/$$x ; then $(INSTALL_FILE) $$x $(DESTDIR)$(DIR) || exit $$? ; fi ; done
for x in $(FILES_SECURE) ; do $(INSTALL_SECURE) $$x $(DESTDIR)$(DIR) || exit $$? ; done
for x in $(MANS) ; do \
ext=`echo $$x | sed -e 's/^.*\\.//'` ; \
$(INSTALL_DIR) $(DESTDIR)$(DIR)/man$$ext || exit $$? ; \
$(INSTALL_FILE) $$x $(DESTDIR)$(DIR)/man$$ext || exit $$? ; \
install:: $(BIN) $(CONF) $(CONF_APPEND) $(MAN8)
if test -n "$(DIR)" ; then $(INSTALL) -d $(DESTDIR)$(DIR) || exit $$?; fi
if test -n "$(BIN)" ; then $(INSTALL) $(BIN) $(DESTDIR)$(DIR) || exit $$?; fi
if test -n "$(CONF)" ; then $(INSTALL) -m 0644 $(CONF) $(DESTDIR)$(DIR) || exit $$?; fi
for x in $(CONF_APPEND) ; do \
if ! test -e $(DESTDIR)$(DIR)/$$x; then \
$(INSTALL) -m 0644 $$x $(DESTDIR)$(DIR) || exit $$?; \
fi; \
done
for x in $(CONF_APPEND) ; do \
if test -e $(DESTDIR)$(DIR)/$$x; then \
cat $$x >> $(DESTDIR)$(DIR)/$$x || exit $$?; \
else \
$(INSTALL) -m 0644 $$x $(DESTDIR)$(DIR) || exit $$?; \
fi; \
done
.PHONY: all clean install

View File

@ -1,5 +1,5 @@
DIR = /etc/init.d
EXES = clock
DIR = /etc/init.d
BIN = clock
TOPDIR = ..
include $(TOPDIR)/default.mk

View File

@ -1,5 +1,5 @@
DIR = /etc/init.d
EXES = clock consolefont keymaps modules numlock
DIR = /etc/init.d
BIN = clock consolefont keymaps modules numlock
TOPDIR = ..
include $(TOPDIR)/default.mk

View File

@ -1,6 +1,6 @@
DIR = /etc/init.d
EXES = bootmisc checkfs checkroot hostname local localmount \
netmount rmnologin urandom halt.sh
DIR = /etc/init.d
BIN = bootmisc checkfs checkroot hostname local localmount \
netmount rmnologin urandom halt.sh
TOPDIR = ..
include $(TOPDIR)/default.mk

View File

@ -1,5 +1,5 @@
DIR = /usr/share/man
MANS = rc-status.8 rc-update.8 start-stop-daemon.8
DIR = /usr/share/man/man8
CONF = rc-status.8 rc-update.8 start-stop-daemon.8
TOPDIR = ..
include $(TOPDIR)/default.mk

View File

@ -1,5 +1,5 @@
DIR = $(RC_LIB)/net
FILES = ifconfig.sh iwconfig.sh
DIR = $(RC_LIB)/net
CONF = ifconfig.sh iwconfig.sh
TOPDIR = ..
include $(TOPDIR)/default.mk

View File

@ -1,8 +1,8 @@
DIR = $(RC_LIB)/net
FILES = adsl.sh apipa.sh arping.sh bonding.sh br2684ctl.sh bridge.sh \
ccwgroup.sh clip.sh ifconfig.sh ifplugd.sh ip6to4.sh ipppd.sh \
iproute2.sh iwconfig.sh netplugd.sh pppd.sh pump.sh tuntap.sh \
udhcpc.sh vlan.sh
DIR = $(RC_LIB)/net
CONF = adsl.sh apipa.sh arping.sh bonding.sh br2684ctl.sh bridge.sh \
ccwgroup.sh clip.sh ifconfig.sh ifplugd.sh ip6to4.sh ipppd.sh \
iproute2.sh iwconfig.sh netplugd.sh pppd.sh pump.sh tuntap.sh \
udhcpc.sh vlan.sh
TOPDIR = ..
include $(TOPDIR)/default.mk

View File

@ -1,6 +1,6 @@
DIR = $(RC_LIB)/net
FILES = dhclient.sh dhcpcd.sh macchanger.sh macnet.sh ssidnet.sh system.sh \
wpa_supplicant.sh
DIR = $(RC_LIB)/net
CONF = dhclient.sh dhcpcd.sh macchanger.sh macnet.sh ssidnet.sh system.sh \
wpa_supplicant.sh
TOPDIR = ..
include $(TOPDIR)/default.mk

View File

@ -2,10 +2,10 @@ BOOT = consolefont keymaps modules net.lo
DEFAULT = hdparm
install:
install -d -m 0755 $(DESTDIR)/etc/runlevels/boot || exit $$? ; \
for x in $(BOOT) ; do ln -snf ../../init.d/"$$x" $(DESTDIR)/etc/runlevels/boot/"$$x" || exit $$? ; done ; \
install -d -m 0755 $(DESTDIR)/etc/runlevels/default || exit $$? ; \
for x in $(DEFAULT) ; do ln -snf ../../init.d/"$$x" $(DESTDIR)/etc/runlevels/default/"$$x" || exit $$? ; done ; \
install -d -m 0755 $(DESTDIR)/etc/runlevels/boot || exit $$?
for x in $(BOOT) ; do ln -snf ../../init.d/"$$x" $(DESTDIR)/etc/runlevels/boot/"$$x" || exit $$? ; done
install -d -m 0755 $(DESTDIR)/etc/runlevels/default || exit $$?
for x in $(DEFAULT) ; do ln -snf ../../init.d/"$$x" $(DESTDIR)/etc/runlevels/default/"$$x" || exit $$? ; done
.PHONY: all clean

View File

@ -2,10 +2,10 @@ BOOT = bootmisc checkroot checkfs clock hostname localmount rmnologin urandom
DEFAULT = local netmount
install:
install -d -m 0755 $(DESTDIR)/etc/runlevels/boot || exit $$? ; \
for x in $(BOOT) ; do ln -snf ../../init.d/"$$x" $(DESTDIR)/etc/runlevels/boot/"$$x" || exit $$? ; done ; \
install -d -m 0755 $(DESTDIR)/etc/runlevels/default || exit $$? ; \
for x in $(DEFAULT) ; do ln -snf ../../init.d/"$$x" $(DESTDIR)/etc/runlevels/default/"$$x" || exit $$? ; done ; \
install -d -m 0755 $(DESTDIR)/etc/runlevels/boot || exit $$?
for x in $(BOOT) ; do ln -snf ../../init.d/"$$x" $(DESTDIR)/etc/runlevels/boot/"$$x" || exit $$? ; done
install -d -m 0755 $(DESTDIR)/etc/runlevels/default || exit $$?
for x in $(DEFAULT) ; do ln -snf ../../init.d/"$$x" $(DESTDIR)/etc/runlevels/default/"$$x" || exit $$? ; done
.PHONY: all clean

View File

@ -1,5 +1,5 @@
DIR = $(RC_LIB)/sh
EXES = init.sh
DIR = $(RC_LIB)/sh
BIN = init.sh
TOPDIR = ..
include $(TOPDIR)/default.mk

View File

@ -1,5 +1,5 @@
DIR = $(RC_LIB)/sh
EXES = init.sh init-early.sh
DIR = $(RC_LIB)/sh
BIN = init.sh init-early.sh
TOPDIR = ..
include $(TOPDIR)/default.mk

View File

@ -1,7 +1,7 @@
DIR = $(RC_LIB)/sh
FILES = functions.sh init-functions.sh init-common-post.sh \
rc-functions.sh rc-mount.sh
EXES = gendepends.sh net.sh rc-mount.sh rc-help.sh runscript.sh
DIR = $(RC_LIB)/sh
CONF = functions.sh init-functions.sh init-common-post.sh \
rc-functions.sh rc-mount.sh
BIN = gendepends.sh net.sh rc-mount.sh rc-help.sh runscript.sh
TOPDIR = ..
include $(TOPDIR)/default.mk

View File

@ -10,7 +10,7 @@
# that works with GNU make and vice versa. NetBSD and OpenBSD makes do.
# You can get a patch from
# http://www.freebsd.org/cgi/query-pr.cgi?pr=standards/116081
# to fix this. We include this patch with Gentoo/FreeBSD :)
# to fix this.
CC ?= gcc
CFLAGS += -O2 -pipe
@ -39,10 +39,6 @@ CFLAGS += -pedantic -std=c99 \
# For debugging. -Werror is pointless due to ISO C issues with dlsym
#CFLAGS += -ggdb
DESTDIR =
LIB = lib
RC_LIB = /$(LIB)/rc
# Set PAM = pam for pam support
PAM =
@ -98,9 +94,8 @@ CPPFLAGS += -DLIB=\"$(LIB)\"
LDFLAGS += -Wl,-rpath .
# Load an optional OS Makefile
_OS_SH = u=`uname -s`; case "$${u}" in *BSD|DragonFly) echo "BSD";; *) echo "$${u}";; esac
_OS != $(_OS_SH)
OS ?= $(_OS)$(shell $(_OS_SH))
TOPDIR = ..
include $(TOPDIR)/default.mk
include Makefile.$(OS)
include Makefile.$(PAM)
@ -137,7 +132,7 @@ $(ALL_LINKS): rc
ln -sf rc $@
links: $(ALL_LINKS)
install: $(TARGET)
install:: $(TARGET)
install -m 0755 -d $(DESTDIR)/$(LIB)
install -m 0755 $(LIB_TARGETS) $(DESTDIR)/$(LIB)
install -m 0755 -d $(DESTDIR)/usr/$(LIB)
@ -165,7 +160,7 @@ install: $(TARGET)
clean-links:
rm -f $(ALL_LINKS)
clean: clean-links
clean::
echo > .depend
touch -r Makefile .depend
rm -f $(TARGET)