From 9a539ebbe1ee0c8557fbcdf22e849534dcbd9b53 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Wed, 19 Oct 2011 21:30:39 -0400 Subject: [PATCH] further clean up OS differences in makefiles No need for if() logic. Signed-off-by: Mike Frysinger --- conf.d/Makefile | 27 +++++------ conf.d/{network.BSD => network.BSD.in} | 0 conf.d/{network.Linux => network.Linux.in} | 0 .../{staticroute.BSD => staticroute.BSD.in} | 0 ...staticroute.Linux => staticroute.Linux.in} | 0 doc/Makefile | 20 +------- etc/Makefile | 30 ++++++------ init.d.misc/Makefile | 9 +--- init.d/Makefile | 46 ++++++------------- mk/os-BSD.mk | 3 ++ mk/os-Linux.mk | 3 ++ mk/os.mk | 2 + net/Makefile | 28 ++++------- runlevels/Makefile | 35 +++++++------- sh/Makefile | 39 ++++++---------- 15 files changed, 93 insertions(+), 149 deletions(-) rename conf.d/{network.BSD => network.BSD.in} (100%) rename conf.d/{network.Linux => network.Linux.in} (100%) rename conf.d/{staticroute.BSD => staticroute.BSD.in} (100%) rename conf.d/{staticroute.Linux => staticroute.Linux.in} (100%) diff --git a/conf.d/Makefile b/conf.d/Makefile index 5af2592b..d5f85c30 100644 --- a/conf.d/Makefile +++ b/conf.d/Makefile @@ -1,5 +1,6 @@ DIR= ${CONFDIR} -CONF= bootmisc fsck hostname localmount network staticroute urandom +CONF= bootmisc fsck hostname localmount network staticroute urandom \ + ${CONF-${OS}} TARGETS+= network staticroute CLEANFILES+= network staticroute @@ -7,22 +8,16 @@ CLEANFILES+= network staticroute MK= ../mk include ${MK}/os.mk -ifeq (${OS},FreeBSD) -CONF+= ipfw moused powerd rarpd savecore syscons -else ifeq (${OS},Linux) -CONF+= consolefont dmesg hwclock keymaps killprocs modules -SOS= Linux -else ifeq (${OS},NetBSD) -CONF+= moused rarpd savecore -endif +CONF-FreeBSD= ipfw moused powerd rarpd savecore syscons + +CONF-Linux= consolefont dmesg hwclock keymaps killprocs modules + +CONF-NetBSD= moused rarpd savecore include ${MK}/scripts.mk -SOS?= BSD +network: network.in network${SFX} + cat $^ > $@ -network: network.in network.${SOS} - cp $@.in $@ - [ -e $@.${SOS} ] && cat $@.${SOS} >> $@ || true - -staticroute: staticroute.${SOS} - cp $@.${SOS} $@ +staticroute: staticroute${SFX} + cp $@${SFX} $@ diff --git a/conf.d/network.BSD b/conf.d/network.BSD.in similarity index 100% rename from conf.d/network.BSD rename to conf.d/network.BSD.in diff --git a/conf.d/network.Linux b/conf.d/network.Linux.in similarity index 100% rename from conf.d/network.Linux rename to conf.d/network.Linux.in diff --git a/conf.d/staticroute.BSD b/conf.d/staticroute.BSD.in similarity index 100% rename from conf.d/staticroute.BSD rename to conf.d/staticroute.BSD.in diff --git a/conf.d/staticroute.Linux b/conf.d/staticroute.Linux.in similarity index 100% rename from conf.d/staticroute.Linux rename to conf.d/staticroute.Linux.in diff --git a/doc/Makefile b/doc/Makefile index 4fbc99ce..81e621ba 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -1,27 +1,11 @@ DIR= ${DOCDIR}/openrc +SRCS= net.example.in INC= net.example MK= ../mk include ${MK}/os.mk -ifeq (${OS},FreeBSD) -SRCS+= net.example.in - -.SUFFIXES: .BSD.in -.BSD.in: +${SFX}: ${CP} $< $@ -else ifeq (${OS},Linux) -SRCS+= net.example.in - -.SUFFIXES: .Linux.in -.Linux.in: - ${CP} $< $@ -else ifeq (${OS},NetBSD) -SRCS+= net.example.in - -.SUFFIXES: .BSD.in -.BSD.in: - ${CP} $< $@ -endif include ${MK}/scripts.mk diff --git a/etc/Makefile b/etc/Makefile index a7976b6a..8bcf19ba 100644 --- a/etc/Makefile +++ b/etc/Makefile @@ -1,24 +1,26 @@ DIR= ${SYSCONFDIR} -CONF= rc.conf +SRCS= rc.conf.in rc.in rc.shutdown.in +BIN= ${BIN-${OS}} +CONF= rc.conf ${BIN-${OS}} CLEANFILES+= rc.conf MK= ../mk include ${MK}/os.mk -ifeq (${OS},FreeBSD) -SED_EXTRA= -e 's:@TERM@:cons25:g' -SRCS+= rc.conf.in rc.in rc.shutdown.in -CONF+= devd.conf -BIN+= rc rc.shutdown rc.devd -else ifeq (${OS},Linux) -SED_EXTRA= -e 's:@TERM@:wsvt25:g' -SRCS+= rc.conf.in rc.in rc.shutdown.in -else ifeq (${OS},NetBSD) -SED_EXTRA= -e 's:@TERM@:wsvt25:g' -SRCS+= rc.conf.in rc.in rc.shutdown.in -BIN+= rc rc.shutdown -endif +SED_EXTRA-FreeBSD= -e 's:@TERM@:cons25:g' +BIN-FreeBSD= rc rc.shutdown rc.devd +CONF-FreeBSD= devd.conf + +SED_EXTRA-Linux= -e 's:@TERM@:wsvt25:g' +BIN-Linux= +CONF-Linux= + +SED_EXTRA-NetBSD= -e 's:@TERM@:wsvt25:g' +BIN-NetBSD= rc rc.shutdown +CONF-NetBSD= + +SED_EXTRA= ${SED_EXTRA-${OS}} include ${MK}/scripts.mk diff --git a/init.d.misc/Makefile b/init.d.misc/Makefile index b44063cc..ce973c1b 100644 --- a/init.d.misc/Makefile +++ b/init.d.misc/Makefile @@ -7,12 +7,5 @@ MK= ../mk SED_EXTRA+= -e 's:@VARBASE@:/var:g' +include ${MK}/os.mk include ${MK}/scripts.mk - -ifeq ($(OS),FreeBSD) -PKG_PREFIX?= /usr/local -else ifeq ($(OS),Linux) -PKG_PREFIX?=/usr -else ifeq ($(OS),NetBSD) -PKG_PREFIX?= /usr/pkg -endif diff --git a/init.d/Makefile b/init.d/Makefile index 5fd33310..db681549 100644 --- a/init.d/Makefile +++ b/init.d/Makefile @@ -1,7 +1,7 @@ DIR= ${INITDIR} SRCS= bootmisc.in fsck.in hostname.in local.in localmount.in netmount.in \ network.in root.in savecache.in staticroute.in swap.in swclock.in \ - sysctl.in urandom.in + sysctl.in urandom.in ${SRCS-${OS}} BIN= ${OBJS} # Build our old net foo or not @@ -17,44 +17,28 @@ TARGETS+= ${_NET_LO} MK= ../mk include ${MK}/os.mk -ifeq ($(OS),FreeBSD) -NET_LO= net.lo0 - +NET_LO-FreeBSD= net.lo0 # Generic BSD scripts -SRCS+= hostid.in moused.in newsyslog.in pf.in rarpd.in rc-enabled.in \ - rpcbind.in savecore.in syslogd.in - +SRCS-FreeBSD= hostid.in moused.in newsyslog.in pf.in rarpd.in rc-enabled.in \ + rpcbind.in savecore.in syslogd.in # These are FreeBSD specific -SRCS+= adjkerntz.in devd.in dumpon.in ipfw.in mixer.in nscd.in \ - powerd.in syscons.in +SRCS-FreeBSD+= adjkerntz.in devd.in dumpon.in ipfw.in mixer.in nscd.in \ + powerd.in syscons.in -.SUFFIXES: .BSD.in -.BSD.in: - sed ${SED_REPLACE} ${SED_EXTRA} $< > $@ -else ifeq ($(OS),Linux) -NET_LO= net.lo - -SRCS+= devfs.in dmesg.in hwclock.in consolefont.in keymaps.in killprocs.in \ - modules.in mount-ro.in mtab.in numlock.in procfs.in sysfs.in \ - termencoding.in - -.SUFFIXES: .Linux.in -.Linux.in: - sed ${SED_REPLACE} ${SED_EXTRA} $< > $@ -else ifeq ($(OS),NetBSD) -NET_LO= net.lo0 +NET_LO-Linux= net.lo +SRCS-Linux= devfs.in dmesg.in hwclock.in consolefont.in keymaps.in \ + killprocs.in modules.in mount-ro.in mtab.in numlock.in \ + procfs.in sysfs.in termencoding.in +NET_LO-NetBSD= net.lo0 # Generic BSD scripts -SRCS+= hostid.in moused.in newsyslog.in pf.in rarpd.in rc-enabled.in \ - rpcbind.in savecore.in syslogd.in - +SRCS-NetBSD= hostid.in moused.in newsyslog.in pf.in rarpd.in rc-enabled.in \ + rpcbind.in savecore.in syslogd.in # These are NetBSD specific -SRCS+= devdb.in swap-blk.in ttys.in wscons.in +SRCS-NetBSD+= devdb.in swap-blk.in ttys.in wscons.in -.SUFFIXES: .BSD.in -.BSD.in: +${SFX}: sed ${SED_REPLACE} ${SED_EXTRA} $< > $@ -endif include ${MK}/scripts.mk diff --git a/mk/os-BSD.mk b/mk/os-BSD.mk index 0b19afb1..fbcd3710 100644 --- a/mk/os-BSD.mk +++ b/mk/os-BSD.mk @@ -3,4 +3,7 @@ # Generic definitions +PKG_PREFIX?= /usr/local +SFX= .BSD.in + LIBKVM?= -lkvm diff --git a/mk/os-Linux.mk b/mk/os-Linux.mk index 7da0ed9c..bdd12031 100644 --- a/mk/os-Linux.mk +++ b/mk/os-Linux.mk @@ -1,5 +1,8 @@ # Copyright (c) 2008 Roy Marples # Released under the 2-clause BSD license. +SFX= .Linux.in +PKG_PREFIX?= /usr + CPPFLAGS+= -D_BSD_SOURCE -D_XOPEN_SOURCE=600 LIBDL= -Wl,-Bdynamic -ldl diff --git a/mk/os.mk b/mk/os.mk index efa9a74e..4f5a954e 100644 --- a/mk/os.mk +++ b/mk/os.mk @@ -10,3 +10,5 @@ include ${MK}/os-${OS}.mk RC_LIB= /$(LIBNAME)/rc +SFX:= ${SFX_PFX}${SFX} +.SUFFIXES: ${SFX} diff --git a/net/Makefile b/net/Makefile index f783e40a..664800df 100644 --- a/net/Makefile +++ b/net/Makefile @@ -1,34 +1,24 @@ DIR= ${LIBEXECDIR}/net -SRCS= ifconfig.sh.in +SRCS= ifconfig.sh.in ${SRCS-${OS}} INC= dhclient.sh dhcpcd.sh ifconfig.sh macchanger.sh macnet.sh \ - ssidnet.sh system.sh wpa_supplicant.sh + ssidnet.sh system.sh wpa_supplicant.sh ${INC-${OS}} MK= ../mk include ${MK}/os.mk -ifeq (${OS},FreeBSD) -SRCS+= iwconfig.sh.in -INC+= iwconfig.sh +SRCS-FreeBSD= iwconfig.sh.in +INC-FreeBSD= iwconfig.sh -.SUFFIXES: .sh.BSD.in -.sh.BSD.in.sh: - ${CP} $< $@ -else ifeq (${OS},Linux) -SRCS+= iwconfig.sh.in -INC+= adsl.sh apipa.sh arping.sh bonding.sh br2684ctl.sh bridge.sh \ +SRCS-Linux= iwconfig.sh.in +INC-Linux= adsl.sh apipa.sh arping.sh bonding.sh br2684ctl.sh bridge.sh \ ccwgroup.sh clip.sh ethtool.sh iproute2.sh ifplugd.sh ip6to4.sh \ ipppd.sh iwconfig.sh netplugd.sh pppd.sh pump.sh tuntap.sh udhcpc.sh \ vlan.sh -.SUFFIXES: .sh.Linux.in -.sh.Linux.in.sh: - ${CP} $< $@ -else ifeq (${OS},NetBSD) -INC+= ifwatchd.sh +SRCS-NetBSD= +INC-NetBSD= ifwatchd.sh -.SUFFIXES: .sh.BSD.in -.sh.BSD.in.sh: +${SFX}.sh: ${CP} $< $@ -endif include ${MK}/scripts.mk diff --git a/runlevels/Makefile b/runlevels/Makefile index 1f9f9aaf..f454950d 100644 --- a/runlevels/Makefile +++ b/runlevels/Makefile @@ -1,7 +1,8 @@ BOOT= bootmisc fsck hostname localmount network \ - root staticroute swap sysctl urandom + root staticroute swap sysctl urandom ${BOOT-${OS}} DEFAULT= local netmount -SHUTDOWN= savecache +SHUTDOWN= savecache ${SHUTDOWN-${OS}} +SYSINIT= ${SYSINIT-${OS}} LEVELDIR= ${DESTDIR}/${SYSCONFDIR}/runlevels SYSINITDIR= ${LEVELDIR}/sysinit @@ -16,25 +17,25 @@ include ${MK}/sys.mk include ${MK}/os.mk include ${MK}/gitignore.mk -ifeq (${OS},BSD) -BOOT+= hostid newsyslog savecore syslogd swap-blk -else ifeq (${OS},FreeBSD) -# Generic BSD stuff -BOOT+= hostid net.lo0 newsyslog savecore syslogd +BOOT-${OS}= +SHUTDOWN-${OS}= +SYSINIT-${OS}= +BOOT-BSD= hostid newsyslog savecore syslogd swap-blk + +# Generic BSD stuff +BOOT-FreeBSD= hostid net.lo0 newsyslog savecore syslogd # FreeBSD specific stuff -BOOT+= adjkerntz dumpon syscons -else ifeq (${OS},Linux) -SYSINIT+= devfs dmesg -BOOT+= hwclock keymaps modules mtab procfs termencoding -SHUTDOWN+= killprocs mount-ro -else ifeq (${OS},NetBSD) -# Generic BSD stuff -BOOT+= hostid net.lo0 newsyslog savecore syslogd +BOOT-FreeBSD+= adjkerntz dumpon syscons +BOOT-Linux= hwclock keymaps modules mtab procfs termencoding +SHUTDOWN-Linux= killprocs mount-ro +SYSINIT-Linux= devfs dmesg + +# Generic BSD stuff +BOOT-NetBSD= hostid net.lo0 newsyslog savecore syslogd # NetBSD specific stuff -BOOT+= devdb swap-blk ttys wscons -endif +BOOT-NetBSD+= devdb swap-blk ttys wscons all: diff --git a/sh/Makefile b/sh/Makefile index c29462e3..c15c79e0 100644 --- a/sh/Makefile +++ b/sh/Makefile @@ -1,42 +1,29 @@ DIR= ${LIBEXECDIR}/sh -SRCS= functions.sh.in gendepends.sh.in init-common-post.sh.in \ - rc-functions.sh.in runscript.sh.in +SRCS= init.sh.in functions.sh.in gendepends.sh.in init-common-post.sh.in \ + rc-functions.sh.in runscript.sh.in ${SRCS-${OS}} INC= init-common-post.sh rc-mount.sh functions.sh rc-functions.sh -BIN= gendepends.sh init.sh runscript.sh +BIN= gendepends.sh init.sh runscript.sh ${BIN-${OS}} INSTALLAFTER= _installafter +SFX_PFX= .sh MK= ../mk include ${MK}/os.mk -ifeq (${OS},FreeBSD) -SRCS+= init.sh.in +SRCS-FreeBSD= +BIN-FreeBSD= -.SUFFIXES: .sh.BSD.in -.sh.BSD.in.sh: - ${SED} ${SED_REPLACE} ${SED_EXTRA} $< > $@ +SRCS-Linux= init-early.sh.in udhcpc-hook.sh.in +BIN-Linux= init-early.sh udhcpc-hook.sh -else ifeq (${OS},Linux) -SRCS+= init.sh.in init-early.sh.in udhcpc-hook.sh.in -BIN+= init-early.sh udhcpc-hook.sh - -.SUFFIXES: .sh.Linux.in -.sh.Linux.in.sh: - ${SED} ${SED_REPLACE} ${SED_EXTRA} $< > $@ - -else ifeq (${OS},NetBSD) -SRCS+= init.sh.in - -SRCS+= ifwatchd-carrier.sh.in ifwatchd-nocarrier.sh.in -BIN+= ifwatchd-carrier.sh ifwatchd-nocarrier.sh - -.SUFFIXES: .sh.BSD.in -.sh.BSD.in.sh: - ${SED} ${SED_REPLACE} ${SED_EXTRA} $< > $@ -endif +SRCS-NetBSD= ifwatchd-carrier.sh.in ifwatchd-nocarrier.sh.in +BIN-NetBSD= ifwatchd-carrier.sh ifwatchd-nocarrier.sh include ${MK}/scripts.mk +${SFX}.sh: + ${SED} ${SED_REPLACE} ${SED_EXTRA} $< > $@ + _installafter: ${INSTALL} -d ${DESTDIR}/${INITDIR} @# Put functions.sh into init for backwards compat