radareorg / acr

autoconf replacement
GNU General Public License v2.0
34 stars 10 forks source link

Implement SWITCH statements to avoid nested IFEQ/ELSE blocks #24

Open radare opened 4 years ago

radare commented 4 years ago

This is taken from r2's configure.acr:

IFEQ USEROSTYPE auto ; {
        IFEQ HOST_OS mingw32_nt-6.2 ; {
                USEROSTYPE = mingw32 ;
        }{
        IFEQ HOST_OS mingw32_nt ; {
                USEROSTYPE = mingw32 ;
        }{
        IFEQ HOST_OS wsl ; {
                USEROSTYPE =  wsl ;
        }{
        IFEQ HOST_OS linux ; {
                USEROSTYPE = gnulinux ;
        }{
        IFEQ HOST_OS gnu ; {
                (( GNU / HURD ))
                USEROSTYPE = gnulinux ;
                HAVE_LIB_DL = 1 ;
                DL_LIBS = -ldl ;
        }{
        IFEQ HOST_OS sunos ; {
                USEROSTYPE = solaris ;
        }{
        IFEQ HOST_OS gnu/kfreebsd ; {
                USEROSTYPE = bsd ;
        }{
        IFEQ HOST_OS netbsd ; {
                USEROSTYPE = bsd ;
        }{
        IFEQ HOST_OS freebsd ; {
                USEROSTYPE = bsd ;
        }{
        IFEQ HOST_OS openbsd ; {
                USEROSTYPE = bsd ;
        }{
        IFEQ HOST_OS darwin ; {
                USEROSTYPE = darwin ;
        } } } } } } } } } } }
}

That can be rewritten to:

SWITCH HOST_OS 
  darwin { USEROSTYPE = darwin; }
  openbsd { USEROSTYPE = bsd; }
  ..
}