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 # Distributed under the terms of the GNU General Public License v2
NAME = openrc NAME = openrc
VERSION = 1.0pre1 VERSION = 1.0
PKG = $(NAME)-$(VERSION) PKG = $(NAME)-$(VERSION)
SUBDIRS = etc conf.d init.d man net sh src SUBDIR = conf.d etc 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
TOPDIR = . TOPDIR = .
include $(TOPDIR)/default.mk include $(TOPDIR)/default.mk
include $(TOPDIR)/Makefile.$(OS)
install:: install::
# Don't install runlevels if they already exist # 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 DIR = /etc/conf.d
FILES = localmount net.example CONF = localmount net.example
TOPDIR = .. TOPDIR = ..
include $(TOPDIR)/default.mk include $(TOPDIR)/default.mk

View File

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

View File

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

View File

@ -6,50 +6,51 @@ ROOT = /
LIB = lib LIB = lib
RC_LIB = /$(LIB)/rc 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 # 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)) all:
SUBDIRS_CLEAN = $(patsubst %,%_clean,$(SUBDIRS)) $(_SUBDIR)
SUBDIRS_INSTALL = $(patsubst %,%_install,$(SUBDIRS)) clean::
$(_SUBDIR)
install::
$(_SUBDIR)
all:: $(SUBDIRS_ALL) install:: $(BIN) $(CONF) $(CONF_APPEND) $(MAN8)
clean:: $(SUBDIRS_CLEAN) if test -n "$(DIR)" ; then $(INSTALL) -d $(DESTDIR)$(DIR) || exit $$?; fi
install:: $(SUBDIRS_INSTALL) if test -n "$(BIN)" ; then $(INSTALL) $(BIN) $(DESTDIR)$(DIR) || exit $$?; fi
if test -n "$(CONF)" ; then $(INSTALL) -m 0644 $(CONF) $(DESTDIR)$(DIR) || exit $$?; fi
# Hmm ... possible to combine these three and not be ugly ? for x in $(CONF_APPEND) ; do \
%_all: if ! test -e $(DESTDIR)$(DIR)/$$x; then \
if test -d $(patsubst %_all,%,$@); then $(MAKE) -C $(patsubst %_all,%,$@).$(OS) all; fi $(INSTALL) -m 0644 $$x $(DESTDIR)$(DIR) || exit $$?; \
if test -d $(patsubst %_all,%,$@).$(OS); then $(MAKE) -C $(patsubst %_all,%,$@).$(OS) all; fi fi; \
%_clean: done
if test -d $(patsubst %_clean,%,$@) ; then $(MAKE) -C $(patsubst %_clean,%,$@) clean ; fi for x in $(CONF_APPEND) ; do \
if test -d $(patsubst %_clean,%,$@).$(OS) ; then $(MAKE) -C $(patsubst %_clean,%,$@).$(OS) clean ; fi if test -e $(DESTDIR)$(DIR)/$$x; then \
%_install: cat $$x >> $(DESTDIR)$(DIR)/$$x || exit $$?; \
if test -d $(patsubst %_install,%,$@) ; then $(MAKE) -C $(patsubst %_install,%,$@) install ; fi else \
if test -d $(patsubst %_install,%,$@).$(OS) ; then $(MAKE) -C $(patsubst %_install,%,$@).$(OS) install ; fi $(INSTALL) -m 0644 $$x $(DESTDIR)$(DIR) || exit $$?; \
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 $$? ; \
done done
.PHONY: all clean install .PHONY: all clean install

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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