NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

mk-configure: lightweight autoconf replacement written for/in bmake



A few days ago, I've started mk-configure, lightweight replacement for
GNU autoconf. This project was started only as proof-of-concept but
I think it is rather functional already and may be interesting
for NetBSD folks.

I share this code and hope that somebody of you will help me to improve
it. Yes, I need ideas, suggestions, any kind of feedback.
But note that, I'm at the very beginning...
Also note that mk-configure doesn't implement EVERYTHING
present in autoconf. Obviously this was not the goal.

http://mova.org/~cheusov/pub/mk-configure/mk-configure-0.5.0.tar.gz

This email is rather long, sorry :-)

============================================================================
                 Basic ideas behind mk-configure:

1) autohell is inconvenient, too complex, too big and too badly designed.
2) Code generation is bad idea.
3) Single top-level command, bmake in our case, is enough for making
   a project. And this is the goal because it saves developer's time.
   Two-step building (configure + make) is not so bad,
   but one-step building is much better
4) NetBSD make
        +
   bsd.*.mk scripts (or devel/mk-files)
        +
   mk-configure
        =
   very elegant and simple solution for cross-platform development.
5) mk-configure should care about cross-compiling.

============================================================================
  How it looks like (example).

MKC_COMMON_HEADERS=     unistd.h stdlib.h
MKC_COMMON_DEFINES=     -D_ALL_SOURCE -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64

MKC_CHECK_HEADERS+=     sys/time.h inttypes.h stdint.h zlib.h

#MKC_NOAUTO=            1 # for disabling automatic updates of LDADD/SRCS/...
#MKC_FUNCLIBS_NOAUTO=   1 # for disabling automatic updates of LDADD
MKC_CHECK_FUNCLIBS+=    crypt:crypt  dlopen:dl ftime:compat gettimeofday
MKC_FUNCLIBS_NOAUTO.ftime.compat = 1

MKC_SOURCE_FUNCLIBS+=   strlcat strlcpy

MKC_CHECK_DEFINES+=     RTLD_LAZY:dlfcn.h __GNUC__

MKC_CHECK_VARS+=        sys_errlist:errno.h
MKC_CHECK_FUNCS1+=      strerror:string.h

MKC_CHECK_FUNCS2+=      fgetln:stdio.h
MKC_CHECK_FUNCS3+=      getline:stdio.h

MKC_CHECK_FUNCS6+=      pselect:sys/select.h

MKC_CHECK_SIZEOF+=      int void*
MKC_CHECK_SIZEOF+=      long-long # - means space

MKC_CHECK_SIZEOF+=      size_t:string.h

MKC_CHECK_SIZEOF+=      off_t:sys/types.h

.include <bsd.own.mk>
.include <configure.mk>

.if !${HAVE_HEADER.sys.time_h}
MKC_ERR_MSG+= "Really?"
.endif

.if !${HAVE_HEADER.zlib_h}
MKC_ERR_MSG+= "zlib.h not found, install zlib library!"
.endif

.if ${HAVE_FUNCLIB.gettimeofday}
CFLAGS+=        -DUSE_GETTIMEOFDAY
.elif ${HAVE_FUNCLIB.ftime}
CFLAGS+=        -DUSE_FTIME
.elif ${HAVE_FUNCLIB.ftime.compat}
CFLAGS+=        -DUSE_FTIME
LDADD+=         -lcompat
.endif

.if ${HAVE_FUNCLIB.dlopen} || ${HAVE_FUNCLIB.dlopen.dl}
CFLAGS+=        -DPLUGINS_ENABLED=1
.else
CFLAGS+=        -DPLUGINS_ENABLED=0
.endif

#####################
# your real code here
#####################

.include <bsd.prog.mk>

============================================================================
                             How it works

0 mk-configure>env make -f EXAMPLE.Makefile list-vars VARS='SRCS CFLAGS LDADD'
checking for header sys/time.h... yes
checking for header inttypes.h... yes
checking for header stdint.h... yes
checking for header zlib.h... yes
checking for function crypt ( -lcrypt )... yes
checking for function crypt... no
checking for function dlopen ( -ldl )... no
checking for function dlopen... yes
checking for function ftime ( -lcompat )... yes
checking for function ftime... no
checking for function gettimeofday... yes
checking for function strlcat... yes
checking for function strlcpy... yes
checking for sizeof int... 4
checking for sizeof long long... 8
checking for sizeof void*... 4
checking for sizeof size_t... 4
checking for sizeof off_t... 8
checking for define RTLD_LAZY ( dlfcn.h )... yes
checking for define __GNUC__... yes
checking for variable sys_errlist ( errno.h )... yes
checking for func strerror ( string.h )... yes
checking for func fgetln ( stdio.h )... yes
checking for func getline ( stdio.h )... no
checking for func pselect ( sys/select.h )... yes
SRCS=
CFLAGS=-O2 -D_ALL_SOURCE -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 
-DHAVE_HEADER_SYS_TIME_H=1 -DHAVE_HEADER_INTTYPES_H=1 -DHAVE_HEADER_STDINT_H=1 
-DHAVE_HEADER_ZLIB_H=1 -DSIZEOF_INT=4 -DSIZEOF_LONG_LONG=8 -DSIZEOF_VOIDP=4 
-DSIZEOF_SIZE_T=4 -DSIZEOF_OFF_T=8 -DHAVE_DEFINE_RTLD_LAZY_DLFCN_H=1 
-DHAVE_DEFINE___GNUC__=1 -DHAVE_VAR_SYS_ERRLIST_ERRNO_H=1 
-DHAVE_FUNC1_STRERROR_STRING_H=1 -DHAVE_FUNC2_FGETLN_STDIO_H=1 
-DHAVE_FUNC3_GETLINE_STDIO_H=0 -DHAVE_FUNC6_PSELECT_SYS_SELECT_H=1 
-DUSE_GETTIMEOFDAY -DPLUGINS_ENABLED=1   -Werror
LDADD=-lcrypt
0 mk-configure>

============================================================================
                            Documentation

Look inside tarball and see mk-configure.mk.in and README files.

-- 
Best regards, Aleksey Cheusov.


Home | Main Index | Thread Index | Old Index