Here's the contents of the BCMSM Makefile file. It's 7 pages long in Word. I'll
post it today, and try to do some analysis later (tomorrow?).
Regards,
Al
========================================================
[root@localhost BCMSM-3.4.19]# ls
BCMSM-3.4.19.spec.template BCMSM-init-redhat INF2C* lkvi.h*
BCMSM.inf BCMSM_lib.o INF2C.c lkvi.o
BCMSM_inf.c BCMSM.o LastRPMBuildInfo Makefile
BCMSM_inf.o ChangeLog lkvi.c* README
[root@localhost BCMSM-3.4.19]# cat Makefile
#!make CC=gcc LD=ld C_FLAGS= -minline-all-stringops -D__KERNEL__ -DMODULE -I$(KERNEL_DIR)/include # # Linux Kernel Version Independent layer # Installation functions # Copyright (C) 2000 Broadcom Corporation. All rights reserved. #
# Modified Sat Apr 5 2003 Cengiz Gunay <cengiz@ull.edu>
# -Added the spec.template file as part of the source file distribution.
ifndef HOST_GCC
HOST_GCC=gcc
endif
#There are some functions declared inline in the kernel header
#files but not present on the kernel itself. If we dont use -O2
#the compiler will ignore the inline decl. and issue a call to
#a function that wont be present in the kernel. This will cause
#insmod to complain about unresolved symbols when loading the
#module.
LKVI_C_FLAGS = -O2
C_FLAGS += $(LKVI_C_FLAGS)
ifeq "$(KERNEL_DIR)" ""
NO_KERNEL_DIR_ERROR="ERROR: KERNEL_DIR environment variable is not set; Usually /usr/src/linux"
endif
ifeq "$(KERNEL_VERSION)" ""
KERNEL_VERSION = $(shell uname -r)
endif
RPM_NAME = BCMSM-3.4.19-6.i386.rpm
SRC_RPM_NAME = BCMSM-3.4.19-6.src.rpm
SRC_RPM_FILES = lkvi.c \
lkvi.h \
BCMSM_lib.o \
BCMSM-init-redhat \
BCMSM.inf \
INF2C.c \
Makefile \
ChangeLog \
BCMSM-3.4.19.spec.template \
README
RPMS = $(RPM_NAME) $(SRC_RPM_NAME)
RPM_DEPS = $(SRC_RPM_FILES)
RPMBUILD_FLAGS = -ba
RPMBUILD_NO_KERNEL_DIR_ERROR = $(NO_KERNEL_DIR_ERROR)
override RPM_KERNELS := $(subst rh72,2.4.7-10 2.4.7-10smp 2.4.7-10enterprise,$(RPM_KERNELS))
override RPM_KERNELS := $(subst rh73-3,2.4.18-3 2.4.18-3smp 2.4.18-3bigmem,$(RPM_KERNELS))
override RPM_KERNELS := $(subst rh73-4,2.4.18-4 2.4.18-4smp 2.4.18-4bigmem,$(RPM_KERNELS))
ifeq "$(RPM_KERNELS)" ""
RPMBUILD_FLAGS = -bs
RPMS = $(SRC_RPM_NAME)
RPMBUILD_NO_KERNEL_DIR_ERROR:=
endif
#To be able to rebuild the binary rpm if
#kernel versions or kernel header change
RPM_ID = $(sort $(RPM_KERNELS) $(KERNEL_DIR))
-include LastRPMBuildInfo
ifneq "$(LAST_RPM_ID)" "$(RPM_ID)"
#This file is built after rpms are built so including
#it as a dependency will force a rebuild of rpms.
RPM_DEPS += LastRPMBuildInfo
endif
ifeq "$(RPM_BUILD_ROOT)" ""
#Directory where rpm builds should take place.
RPM_BUILD_ROOT = $(shell pwd)/buildRPM
endif
ifndef RPM
define DEPMOD
@echo 'Rebuilding module dependencies..'; \
/sbin/depmod -a
endef
define RENAME_OLD_MODULES
@if [ "`echo $(INSTALL_ROOT)/lib/modules/$(KERNEL_VERSION)/*/BCMSM.o`" != '$(INSTALL_ROOT)/lib/modules/$(KERNEL_VERSION)/*/BCMSM.o' ]; then \
echo -n "Renaming old modem module(s):"; \
for OLDMOD in $(INSTALL_ROOT)/lib/modules/$(KERNEL_VERSION)/*/BCMSM.o; do \
echo -n " $$OLDMOD->"`dirname $$OLDMOD`/_`basename $$OLDMOD`.old; \
mv $$OLDMOD `dirname $$OLDMOD`/_`basename $$OLDMOD`.old; \
done; \
echo ''; \
fi
endef
define RENAME_OLD_INIT_SCRIPTS
@if [ -d $$INITDIR ]; then \
if [ "`echo $$INITDIR/BCMSM*`" != $$INITDIR/'BCMSM*' ]; then \
echo -n "Renaming old initilization script(s):"; \
for OLDINIT in $$INITDIR/BCMSM*; do \
echo -n " $$OLDINIT->"`dirname $$OLDINIT`/_`basename $$OLDINIT`.old; \
mv $$OLDINIT `dirname $$OLDINIT`/_`basename $$OLDINIT`.old; \
done; \
echo ''; \
fi ; \
fi
endef
define CREATE_RUNLEVEL_LINKS
@if [ -d $$INITDIR ]; then \
if [ "`echo $(INSTALL_ROOT)/etc/rc.d/rc[35].d`" != '$(INSTALL_ROOT)/etc/rc.d/rc[35].d' ]; then \
for RCDIR in $(INSTALL_ROOT)/etc/rc.d/rc[35].d; do \
RUNLEVEL=`echo $$RCDIR | sed 's,echo $(INSTALL_ROOT)/etc/rc.d/rc\([35]\).d,\1,'`; \
if [ "`echo $$RCDIR/S*BCMSM`" != $$RCDIR/'S*BCMSM' ]; then \
echo -n "Renaming old runlevel $$RUNLEVEL init script link(s):"; \
for OLDLINK in $$RCDIR/S*BCMSM; do \
echo -n " $$OLDLINK->"`dirname $$OLDLINK`/_`basename $$OLDLINK`.old; \
mv $$OLDLINK `dirname $$OLDLINK`/_`basename $$OLDLINK`.old; \
done; \
echo ''; \
fi; \
echo "Creating runlevel $$RUNLEVEL init script link.."; \
ln -s $(INSTALL_ROOT)/etc/rc.d/init.d/BCMSM $$RCDIR/S99BCMSM; \
done; \
fi ; \
fi ; \
if [ -d $$INITDIR ]; then \
if [ "`echo $(INSTALL_ROOT)/etc/rc.d/rc[06].d`" != '$(INSTALL_ROOT)/etc/rc.d/rc[06].d' ]; then \
for RCDIR in $(INSTALL_ROOT)/etc/rc.d/rc[06].d; do \
RUNLEVEL=`echo $$RCDIR | sed 's,echo $(INSTALL_ROOT)/etc/rc.d/rc\([06]\).d,\1,'`; \
if [ "`echo $$RCDIR/K*BCMSM`" != $$RCDIR/'K*BCMSM' ]; then \
echo -n "Renaming old runlevel $$RUNLEVEL init script link(s):"; \
for OLDLINK in $$RCDIR/K*BCMSM; do \
echo -n " $$OLDLINK->"`dirname $$OLDLINK`/_`basename $$OLDLINK`.old; \
mv $$OLDLINK `dirname $$OLDLINK`/_`basename $$OLDLINK`.old; \
done; \
echo ''; \
fi; \
echo "Creating runlevel $$RUNLEVEL init script link.."; \
ln -s $(INSTALL_ROOT)/etc/rc.d/init.d/BCMSM $$RCDIR/K01BCMSM; \
done; \
fi ; \
fi
endef
endif
copyright :
@echo 'BCM V.92 56K Modem Install'
@echo 'Copyright (C) 2000 Broadcom Corporation. All rights reserved.'
@echo ''
top : copyright BCMSM.o
@echo ''
@echo 'Run "make install" to install the modem on your system.'
@echo 'Run "make uninstall" to remove a previously installed modem.'
@echo ''
BCMSM.o : BCMSM_lib.o lkvi.o BCMSM_inf.o
@echo "Linking BCMSM.o modem module.."
@$(LD) -r -o BCMSM.o lkvi.o BCMSM_lib.o BCMSM_inf.o
lkvi.o : lkvi.c
ifneq "$(NO_KERNEL_DIR_ERROR)" ""
@echo $(NO_KERNEL_DIR_ERROR)
else
@echo "Building Linux Kernel Version Independent layer for this system.."
$(CC) $(C_FLAGS) -o lkvi.o -c lkvi.c
endif
INF2C : INF2C.c
@echo "Building INF to C Converter.."
$(HOST_GCC) -O2 -o $@ $^
BCMSM_inf.o : BCMSM.inf INF2C
@echo "Compiling hardware information.."
@./INF2C BCMSM.inf BCMSM_inf.c
@$(CC) $(C_FLAGS) -o BCMSM_inf.o -c BCMSM_inf.c
install : BCMSM.o
$(RENAME_OLD_MODULES)
@MODULE_DIR=`echo $(INSTALL_ROOT)/lib/modules/$(KERNEL_VERSION)`; \
echo "Installing BCMSM.o to $$MODULE_DIR/misc/BCMSM.o.."; \
mkdir -p $$MODULE_DIR/misc/; \
install --mode 644 BCMSM.o $$MODULE_DIR/misc/BCMSM.o
$(DEPMOD)
@set allow_null_glob_expansion; \
INITDIR=$(INSTALL_ROOT)/etc/rc.d/init.d;
$(RENAME_OLD_INIT_SCRIPTS)
@if [ -d $$INITDIR ]; then \
echo "Installing BCMSM-init-redhat to $(INSTALL_ROOT)/etc/rc.d/init.d/BCMSM"; \
mkdir -p $(INSTALL_ROOT)/etc/rc.d/init.d/ ; \
install --mode 755 BCMSM-init-redhat $(INSTALL_ROOT)/etc/rc.d/init.d/BCMSM; \
fi
$(CREATE_RUNLEVEL_LINKS)
@echo "Install complete!"
uninstall :
@INITDIR=/etc/rc.d/init.d; \
if [ -d $$INITDIR ]; then \
if [ "`echo /etc/rc.d/rc[35].d`" != '/etc/rc.d/rc[35].d' ]; then \
for RCDIR in /etc/rc.d/rc[35].d; do \
if [ "`echo $$RCDIR/S*BCMSM`" != '$$RCDIR/S*BCMSM' ]; then \
RUNLEVEL=`echo $$RCDIR | sed 's,echo /etc/rc.d/rc\([35]\).d,\1,'`; \
echo -n "Removing runlevel $$RUNLEVEL link(s) to init script:"; \
for LINK in $$RCDIR/S*BCMSM; do \
echo -n " $$LINK"; \
rm -f $$LINK; \
done; \
echo ''; \
fi; \
done; \
fi; \
if [ "`echo /etc/rc.d/rc[06].d`" != '/etc/rc.d/rc[06].d' ]; then \
for RCDIR in /etc/rc.d/rc[06].d; do \
if [ "`echo $$RCDIR/K*BCMSM`" != '$$RCDIR/K*BCMSM' ]; then \
RUNLEVEL=`echo $$RCDIR | sed 's,echo /etc/rc.d/rc\([06]\).d,\1,'`; \
echo -n "Removing runlevel $$RUNLEVEL link(s) to init script:"; \
for LINK in $$RCDIR/K*BCMSM; do \
echo -n " $$LINK"; \
rm -f $$LINK; \
done; \
echo ''; \
fi; \
done; \
fi; \
if [ "`echo $$INITDIR/BCMSM*`" != $$INITDIR/'BCMSM*' ]; then \
echo -n "Removing init script(s):"; \
for INIT in $$INITDIR/BCMSM*; do \
echo -n " $$INIT"; \
rm -f $$INIT; \
done; \
echo ''; \
fi; \
fi
@MODULE_DIR=`echo /lib/modules/$(KERNEL_VERSION)`; \
if [ "`echo $$MODULE_DIR/misc/BCMSM.o*`" != $$MODULE_DIR/misc/'BCMSM.o*' ]; then \
echo -n "Removing modem modules:"; \
for MOD in $$MODULE_DIR/misc/BCMSM.o*; do \
echo -n " $$MOD"; \
rm -f $$MOD; \
done; \
echo ''; \
fi
@echo 'Rebuilding module dependencies..'; \
/sbin/depmod -a
@echo "Uninstall complete!"
.PHONY: rpm
rpm : $(RPMS)
ifneq "$(RPMBUILD_NO_KERNEL_DIR_ERROR)" ""
@echo $(RPMBUILD_NO_KERNEL_DIR_ERROR)
endif
LastRPMBuildInfo:
touch LastRPMBuildInfo
$(RPMS) : $(RPM_DEPS)
ifeq "$(RPMBUILD_NO_KERNEL_DIR_ERROR)" ""
#Prepare rpm build root directory
@rm -fr $(RPM_BUILD_ROOT) ; \
mkdir -p $(RPM_BUILD_ROOT)
#Prepare the sources and the spec file
@mkdir -p $(RPM_BUILD_ROOT)/BCMSM-3.4.19 ; \
cp $(SRC_RPM_FILES) $(RPM_BUILD_ROOT)/BCMSM-3.4.19 ; \
tar -C$(RPM_BUILD_ROOT) -czf $(RPM_BUILD_ROOT)/BCMSM-3.4.19.tar.gz BCMSM-3.4.19 ; \
awk '{ \
gsub(/%RPM_KERNELS%/,"$(RPM_KERNELS)"); \
gsub(/%KERNEL_DIR%/,"$(KERNEL_DIR)"); \
if (/%RPM_MODULES%/) \
print "$(foreach RPM_KERNEL_VERSION,$(RPM_KERNELS),/lib/modules/$(RPM_KERNEL_VERSION)/misc/BCMSM.o\n)"; \
else \
print; \
} ' < BCMSM-3.4.19.spec.template > $(RPM_BUILD_ROOT)/BCMSM-3.4.19.spec;
#Build the rpm
@rpmbuild --target=i386 \
--define='_topdir $(RPM_BUILD_ROOT)' \
--define='_sourcedir %{_topdir}' \
--define='_specdir %{_topdir}' \
--define='_rpmdir %{_topdir}' \
--define='_srcrpmdir %{_topdir}' \
--define='_builddir %{_topdir}' \
--buildroot=$(RPM_BUILD_ROOT) \
$(RPMBUILD_FLAGS) $(RPM_BUILD_ROOT)/BCMSM-3.4.19.spec
#Rename the resulting rpms and copy them to bin directory
@if [ -e $(RPM_BUILD_ROOT)/i386/BCMSM-3.4.19-6.i386.rpm ] ; then \
cp $(RPM_BUILD_ROOT)/i386/BCMSM-3.4.19-6.i386.rpm $(RPM_NAME) ; \
sleep 2 ; \
echo "LAST_RPM_ID = $(RPM_ID)" > LastRPMBuildInfo ; \
echo "$(RPM_NAME) successfully built" ; \
fi
@if [ -e $(RPM_BUILD_ROOT)/BCMSM-3.4.19-6.src.rpm ] ; then \
cp $(RPM_BUILD_ROOT)/BCMSM-3.4.19-6.src.rpm $(SRC_RPM_NAME) ; \
echo "$(SRC_RPM_NAME) successfully built" ; \
fi
@echo ""
endif
clean :
rm -f lkvi.o INF2C.o BCMSM.o BCMSM_inf.o BCMSM_inf.c *.rpm
[root@localhost BCMSM-3.4.19]#
======================================================