[BusyBox] Autoconf

Neal H Walfield neal at cs.uml.edu
Sat Oct 6 17:07:56 UTC 2001


> Im not an expert at autoconf (it was a typo before), care to run through an
> example with me ?
>
> ./libbb/loop.c has
>
> extern int del_loop(const char *device)
> {
> 	int fd;
>
> 	if ((fd = open(device, O_RDONLY)) < 0) {
> 		perror_msg("%s", device);
> 		return (FALSE);
> 	}
> 	if (ioctl(fd, LOOP_CLR_FD, 0) < 0) {
> 		perror_msg("ioctl: LOOP_CLR_FD");
> 		return (FALSE);
> 	}
> 	close(fd);
> 	return (TRUE);
> }
>
> The values in the ioctl are OS dependenct (im pretty sure), so this code
> will only work under linux.

Well, we do not have loop devices under the Hurd; they are rendered
useless via translators.  For those not in the knowhow, a loop back
device is to a translator as a bicycle is to an amphibious vehicle
that can fly.

> autoconf generates a config.h with amoung other things
>
> /* Define if you have the <sys/ioctl.h> header file. */
> #define HAVE_SYS_IOCTL_H 1
>
> So under non linux systems would we have to change this to
> #define HAVE_SYS_IOCTL_H 0

This would be detected automatically by autoconf.

> and wrap the function in
>
> #ifdef HAVE_SYS_IOCTL_H
> extern int del_loop(const char *device)
> <code>
> #endif

Generally, we want to minimize the special case.  So, if this is the
minimum, then, yes, this is the right thing to do.  However, if the
question is, `do we have del_loop', checking HAVE_SYS_IOCTL_H is
wrong.  Rather, we should define HAVE_DEL_LOOP based on some configure
tests; one of them checking if HAVE_SYS_IOCTL_H is true.

> The del_loop function is used by the mount and umount applets, so we could
> also have defines that reflect back from libbb and generate a list of
> applets that could be compiled, the user could then manually edit this list
> to disable features they dont want, then run make.

I think that this is wrong.  You should edit the list before hand and
then configure would read that and determine the prerequisites for
each of the enabled applets.  If it could not do so, it would error
out.






More information about the busybox mailing list