From 561a13ee5e1e3ad09a5dabb18cf621070825da35 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Sun, 7 Feb 2010 00:22:31 +0000 Subject: [PATCH] Move some configuration stuff from build-kernel into configure.ac. --- build-kernel | 41 ++++++++++++++++++----------------------- build-win32 | 2 +- configure.ac | 39 ++++++++++++++++++++++++++------------- kernel/klibc.h | 6 +++++- 4 files changed, 50 insertions(+), 38 deletions(-) diff --git a/build-kernel b/build-kernel index 323f6b6..05abd8e 100755 --- a/build-kernel +++ b/build-kernel @@ -6,59 +6,54 @@ set -x set -e -CFLAGS="-fno-builtin -O0 -I. -I.. -I../caca/ -Wall -D__KERNEL__ -fno-stack-protector -m32" -LDFLAGS="-nostdlib -Wl,-N -Wl,-Ttext -Wl,100000" +MYCFLAGS="-fno-builtin -O0 -I. -I.. -I../caca/ -Wall -D__KERNEL__ -fno-stack-protector -m32" -./configure --disable-slang --disable-ncurses --disable-win32 \ - --disable-conio --disable-x11 --disable-gl --disable-network \ - --enable-vga --disable-imlib2 --disable-doc \ - --host i386 +./configure --enable-kernel --disable-doc --host i386 # Compile cacademo, leave it as an object cd caca && make && cd .. cd examples && make dithering.o && cd .. - cd kernel # Bootsector nasm -f bin -o bootsect.bin boot/bootsect.asm # Interruption handlers -nasm -f elf -o int.o boot/int.asm +nasm -f elf -o int.o boot/int.asm ##### Boot (x86) # Stage2, loads GDT, PIC, IDT, interrupts, then calls kmain() -gcc $CFLAGS boot/stage2.c -c +gcc $MYCFLAGS boot/stage2.c -c # GDT installation, called by stage2 -gcc $CFLAGS boot/gdt.c -c +gcc $MYCFLAGS boot/gdt.c -c # PIC installation, called by stage2 -gcc $CFLAGS boot/pic.c -c +gcc $MYCFLAGS boot/pic.c -c # IDT installation, called by stage2 -gcc $CFLAGS boot/idt.c -c +gcc $MYCFLAGS boot/idt.c -c # Interruptions installation, called by stage2 -gcc $CFLAGS boot/interruptions.c -c +gcc $MYCFLAGS boot/interruptions.c -c -##### Drivers +##### Drivers # Floppy driver -gcc $CFLAGS drivers/floppy.c -c +gcc $MYCFLAGS drivers/floppy.c -c # Processor driver -gcc $CFLAGS drivers/processor.c -c +gcc $MYCFLAGS drivers/processor.c -c # Keyboard handler -gcc $CFLAGS drivers/keyboard.c -c +gcc $MYCFLAGS drivers/keyboard.c -c # Memory driver -gcc $CFLAGS drivers/memory.c -c +gcc $MYCFLAGS drivers/memory.c -c # Programmable Interval Timer driver -gcc $CFLAGS drivers/timer.c -c +gcc $MYCFLAGS drivers/timer.c -c # Minimalistic libc -gcc $CFLAGS klibc.c -c +gcc $MYCFLAGS klibc.c -c # Kernel by itself, contains cmain() which calls main() -gcc $CFLAGS kernel.c -c +gcc $MYCFLAGS kernel.c -c # Link everything but bootsector, kernel.o MUST be at the very end -ld --oformat binary -Ttext 1000 stage2.o gdt.o pic.o int.o idt.o interruptions.o keyboard.o memory.o timer.o floppy.o processor.o klibc.o kernel.o ../caca/.libs/libcaca.a -Map kernel.map -o kern.bin - +ld --oformat binary -Ttext 1000 stage2.o gdt.o pic.o int.o idt.o interruptions.o keyboard.o memory.o timer.o floppy.o processor.o klibc.o kernel.o ../caca/.libs/libcaca.a -Map kernel.map -o kern.bin + ls -ail kern.bin cd .. diff --git a/build-win32 b/build-win32 index f8331d6..97a1858 100755 --- a/build-win32 +++ b/build-win32 @@ -20,7 +20,7 @@ make distclean || true cd "${BUILDDIR}" # Build for win32 -"${SRCDIR}/configure" --host=i586-mingw32msvc --prefix=/ --bindir=/bin --libdir=/lib --disable-imlib2 --disable-doc "$@" +"${SRCDIR}/configure" --host=i586-mingw32msvc --prefix=/ --bindir=/bin --libdir=/lib --disable-imlib2 --disable-java --disable-doc "$@" make pkglibdir=/lib pkgdatadir=/data bindir=/bin # Install into our private directory make install DESTDIR="${INSTALLDIR}" pkglibdir=/lib/ pkgdatadir=/ bindir=/bin/ diff --git a/configure.ac b/configure.ac index dff7a7b..da2148d 100644 --- a/configure.ac +++ b/configure.ac @@ -55,6 +55,10 @@ esac AC_MSG_RESULT($LT_SUFFIX) AC_SUBST(LT_SUFFIX) +dnl global configuration features +AC_ARG_ENABLE(kernel, + [ --enable-kernel kernel mode (default no)]) + dnl output driver features AC_ARG_ENABLE(slang, [ --enable-slang slang graphics support (autodetected)]) @@ -71,9 +75,9 @@ AC_ARG_ENABLE(gl, AC_ARG_ENABLE(cocoa, [ --enable-cocoa Cocoa support (autodetected)]) AC_ARG_ENABLE(network, - [ --enable-network Network support (autodetected)]) + [ --enable-network network support (autodetected)]) AC_ARG_ENABLE(vga, - [ --enable-vga VGA support (default disabled)]) + [ --enable-vga VGA support for kernel mode (autodetected)]) dnl language bindings AC_ARG_ENABLE(csharp, @@ -103,6 +107,17 @@ AC_ARG_ENABLE(cppunit, AC_ARG_ENABLE(zzuf, [ --enable-zzuf use zzuf for fuzzing tests (autodetected)]) +ac_cv_my_have_kernel="no" +if test "${enable_kernel}" = "yes"; then + ac_cv_my_have_kernel="yes" + CPPFLAGS="${CPPFLAGS} -I. -D__KERNEL__ -nostdinc -include kernel/klibc.h -fno-stack-protector" + CCASFLAGS="${CCASFLAGS} -I. -fno-stack-protector" + CFLAGS="${CFLAGS} -fno-builtin -O0 -I. -I.. -I../caca/ -Wall -D__KERNEL__ -fno-stack-protector -m32" + LDFLAGS="${LDFLAGS} -nostdlib -Wl,-N -Wl,-Ttext -Wl,100000 -fno-stack-protector" + AC_DEFINE(USE_KERNEL, 1, Define to 1 to activate kernel mode) +fi +AM_CONDITIONAL(USE_KERNEL, test "${ac_cv_my_have_kernel}" = "yes") + AC_CHECK_HEADERS(stdio.h stdarg.h signal.h sys/ioctl.h sys/time.h endian.h unistd.h arpa/inet.h netinet/in.h winsock2.h errno.h locale.h getopt.h dlfcn.h termios.h) AC_CHECK_FUNCS(signal ioctl snprintf vsnprintf getenv putenv strcasecmp htons) AC_CHECK_FUNCS(usleep gettimeofday atexit) @@ -308,16 +323,14 @@ if test "${enable_ncurses}" != "no"; then fi fi -if test "${enable_vga}" = "yes"; then - ac_cv_my_have_vga="yes" - CPPFLAGS="${CPPFLAGS} -I. -D__KERNEL__ -nostdinc -include kernel/klibc.h -fno-stack-protector" - CFLAGS="${CFLAGS} -fno-builtin -O2 -Wall -fno-stack-protector" - CCASFLAGS="${CCASFLAGS} -I. -fno-stack-protector" - LDFLAGS="${LDFLAGS} -nostdlib -Wl,-N -Wl,-Ttext -Wl,100000 -fno-stack-protector" - AC_DEFINE(USE_VGA, 1, Define to 1 to activate the VGA backend driver) - CACA_DRIVERS="${CACA_DRIVERS} vga" +if test "${enable_vga}" != "no"; then + if test "${ac_cv_my_have_kernel}" = "yes"; then + AC_DEFINE(USE_VGA, 1, Define to 1 to activate the VGA backend driver) + CACA_DRIVERS="${CACA_DRIVERS} vga" + elif test "${enable_vga}" = "yes"; then + AC_MSG_ERROR([--enable-vga requires --enable-kernel]) + fi fi -AM_CONDITIONAL(USE_KERNEL, test "${ac_cv_my_have_vga}" = "yes") if test "${enable_debug}" = "yes"; then AC_DEFINE(DEBUG, 1, Define to 1 to activate debug) @@ -358,7 +371,7 @@ AC_SUBST(GL_LIBS) # How to get the C99 types. See caca/caca_types.h.in for details about # the CACA_TYPES variable -if test "${ac_cv_my_have_vga}" = "yes"; then +if test "${ac_cv_my_have_kernel}" = "yes"; then CACA_TYPES=0 else AC_CHECK_HEADERS(stdint.h, @@ -412,7 +425,7 @@ AM_CONDITIONAL(USE_CSHARP, test "${ac_cv_my_have_csharp}" = "yes") # Build the Java bindings? ac_cv_my_have_java="no" -if test "${enable_java}" != "no"; then +if test "${enable_java}" != "no" -a "${ac_cv_my_have_kernel}" != "yes"; then AC_PATH_PROG(JAVAC, javac, no) AC_PATH_PROG(JAVAH, javah, no) AC_PATH_PROG(JAR, jar, no) diff --git a/kernel/klibc.h b/kernel/klibc.h index 3b0b6f2..f68b837 100644 --- a/kernel/klibc.h +++ b/kernel/klibc.h @@ -1,5 +1,4 @@ /* - * libcaca * libcaca Colour ASCII-Art library * Copyright (c) 2006 Sam Hocevar * 2009 Jean-Yves Lamoureux @@ -19,6 +18,8 @@ * that must be used when building libcaca and libcaca into a kernel. */ +#if !defined HAVE_KLIBC_H +#define HAVE_KLIBC_H /* Various typedefs -- some are x86-specific */ #define CUSTOM_INTTYPES @@ -146,3 +147,6 @@ unsigned int htonl(unsigned int hostlong); unsigned short htons(unsigned short hostlong); void print(char *str); + +#endif /* HAVE_KLIBC_H */ +