Make freestanding and hosted LIBC
Posted: Fri Dec 02, 2011 6:39 am
Hi!
I'm quite new to OS Development, but my kernel already supports monotasking! Until now, everything went fine. But...
I want to make 2 versions of my C library: a hosted version, and a freestanding version. Using the preprocessor variable __STDC_HOSTED__ I can throw an error when a systemcall is called in the freestanding version, like:
Here is my original makefile. The problem is that I don't know how to make two "targets": libc.a (with __STDC_HOSTED 1) and libk.a (with __STDC_HOSTED 0) . Anyone knows a good solution for this?
Thanks in advance!
PS: sorry for my bad english
I'm quite new to OS Development, but my kernel already supports monotasking! Until now, everything went fine. But...
I want to make 2 versions of my C library: a hosted version, and a freestanding version. Using the preprocessor variable __STDC_HOSTED__ I can throw an error when a systemcall is called in the freestanding version, like:
Code: Select all
void syscall()
{
#if __STDC_HOSTED__ == 1
...
#else
#error System calls not allowed in kernel!
#endif
}
Code: Select all
CC=tcc -Wall -I../include
OBJS=$(patsubst %.c,%.o,$(wildcard *.c))
all : libc.a
.c.o:
$(CC) -D__STDC_HOSTED__=1 -c -o$@ $<
# Rules
libc.a: $(OBJS)
tiny_libmaker.exe libc.a $(OBJS)
PS: sorry for my bad english