# fss-0002
# TODO: --with-moddir=/modules/

main:
  ./configure $CONF --enable-zlib=/lib --with-moddir=/modules
  sed -i -e "s|ptr = index(line, ':');|ptr = strchr(line, ':');|" modprobe.c
  sed -i -e 's|\-static||g' Makefile build/Makefile
  sed -i -e 's|/lib/modules|/modules|g' depmod.c modinfo.c modprobe.c # may not be needed anymore now that --with-moddir= exists
  sed -i -e 's|^DOCBOOKTOMAN|& = echo|' build/Makefile
  #make insmod_static_LDFLAGS='-shared'
  #make insmod_static_LDFLAGS='-shared' install
  make 
  make install
  cp -vR ${PR}modprobe.conf.d /etc/modprobe.conf.d
  chmod u+rw-x,g+r-wx,o-rwx -R /etc/modprobe.conf.d
  chgrp e_module -R /etc/modprobe.conf.d
  find /etc/modprobe.conf.d -type d -exec chmod g+s '{}' ';'
  mv -v /bin/lsmod /sbin/lsmod
  chgrp e_module /sbin/{lsmod,rmmod,insmod,modinfo,modprobe,depmod}
  chmod o-rx /sbin/{lsmod,rmmod,insmod,modinfo,modprobe,depmod}
  #setcap cap_sys_module=ep /sbin/modprobe
  #setcap cap_sys_module=ep /sbin/insmod
  #setcap cap_sys_module=ep /sbin/rmmod
  #setcap cap_sys_module=ep /sbin/depmod
  chmod +s /sbin/{modprobe,insmod,rmmod,depmod}
  rm -Rf /sbin/insmod.static /usr /sbin/generate-modprobe.conf
