2011-08-05 08:25:00 -04:00
|
|
|
ifndef CPU
|
|
|
|
CPU=x86
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(CPU),x86)
|
|
|
|
CPUDEFINES=-DPLATFORM_X86
|
|
|
|
CPUFLAGS=-m32
|
|
|
|
CPULDFLAGS=-melf_i386
|
|
|
|
CPUASFLAGS=-32
|
|
|
|
CPUNASMFLAGS=-felf32
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(CPU),x64)
|
|
|
|
CPU=x64
|
|
|
|
CPUDEFINES=-DPLATFORM_X64
|
|
|
|
CPUFLAGS=-fPIC -m64
|
|
|
|
CPULDFLAGS=-melf_x86_64
|
|
|
|
CPUASFLAGS=-64
|
|
|
|
CPUNASMFLAGS=-felf64
|
2011-09-15 16:19:04 -04:00
|
|
|
LIBMAXSI_NO_SHARED=1 # This doesn't work yet
|
2011-08-05 08:25:00 -04:00
|
|
|
endif
|
|
|
|
|
|
|
|
DEFINES=-DLIBMAXSI_LIBRARY -DSORTIX $(CPUDEFINES)
|
|
|
|
FLAGSRELEASE=-O2
|
|
|
|
FLAGSDEBUG=-O2
|
|
|
|
FLAGS=$(CPUFLAGS) -std=gnu++0x -Wall -Wextra -nostdlib -fno-builtin -nostartfiles -nodefaultlibs -fno-exceptions -fno-stack-protector -nostdinc $(FLAGSRELEASE) $(DEFINES)
|
|
|
|
LDFLAGS=$(CPULDFLAGS)
|
|
|
|
ASFLAGS=$(CPUASFLAGS)
|
|
|
|
NASMFLAGS=$(CPUNASMFLAGS)
|
|
|
|
|
|
|
|
COBJS=c/file.o
|
|
|
|
CHEADERS=\
|
|
|
|
c/h/unistd.h \
|
|
|
|
c/h/stdlib.h \
|
|
|
|
c/h/wchar.h \
|
|
|
|
c/h/stddef.h \
|
|
|
|
c/h/fcntl.h \
|
|
|
|
c/h/stdarg.h \
|
|
|
|
c/h/wctype.h \
|
|
|
|
c/h/features.h \
|
|
|
|
c/h/string.h \
|
|
|
|
c/h/sys/stat.h \
|
|
|
|
c/h/sys/types.h \
|
2011-09-14 12:11:52 -04:00
|
|
|
c/h/stdio.h \
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2011-09-14 12:11:52 -04:00
|
|
|
COMMONOBJS=c++.o memory.o string.o error.o format.o
|
2011-08-05 08:25:00 -04:00
|
|
|
SORTIXOBJS:=$(addprefix sortix/,$(COMMONOBJS))
|
2011-09-14 12:11:52 -04:00
|
|
|
LIBMAXSIOBJS:=$(COMMONOBJS) \
|
|
|
|
sortix-vga.o \
|
|
|
|
sortix-keyboard.o \
|
|
|
|
sortix-sound.o \
|
|
|
|
process.o \
|
|
|
|
thread.o \
|
|
|
|
io.o \
|
|
|
|
init.o \
|
2011-09-15 16:19:04 -04:00
|
|
|
start.o \
|
2011-09-14 12:11:52 -04:00
|
|
|
|
2011-08-21 06:47:59 -04:00
|
|
|
HEADERS=\
|
|
|
|
error.h \
|
|
|
|
io.h \
|
|
|
|
memory.h \
|
|
|
|
platform.h \
|
|
|
|
string.h \
|
|
|
|
syscall.h \
|
|
|
|
thread.h \
|
2011-08-27 14:57:39 -04:00
|
|
|
process.h \
|
2011-08-21 06:47:59 -04:00
|
|
|
types.h \
|
|
|
|
format.h \
|
|
|
|
keyboard.h \
|
2011-10-25 12:21:06 -04:00
|
|
|
sortedlist.h \
|
2011-08-21 06:47:59 -04:00
|
|
|
sortix-vga.h \
|
2011-08-21 18:25:28 -04:00
|
|
|
sortix-keyboard.h \
|
|
|
|
sortix-sound.h \
|
2011-08-05 08:25:00 -04:00
|
|
|
|
|
|
|
OBJS:=$(LIBMAXSIOBJS)
|
2011-09-15 16:19:04 -04:00
|
|
|
BINS:=
|
|
|
|
|
|
|
|
ifndef LIBMAXSI_NO_SHARED
|
|
|
|
BINS:=$(BINS) libmaxsi.so
|
|
|
|
endif
|
2011-08-05 08:25:00 -04:00
|
|
|
|
|
|
|
ifndef LIBMAXSI_NO_STATIC
|
|
|
|
BINS:=$(BINS) libmaxsi.a
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifndef LIBMAXSI_NO_SORTIX
|
2011-09-15 16:19:04 -04:00
|
|
|
BINS:=$(BINS) libmaxsi-sortix.a
|
2011-08-05 08:25:00 -04:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifndef LIBMAXSI_NO_LIBC
|
|
|
|
OBJS:=$(OBJS) $(COBJS)
|
2011-09-15 16:19:04 -04:00
|
|
|
ifndef LIBMAXSI_NO_SHARED
|
|
|
|
BINS:=$(BINS) libc.so
|
|
|
|
endif
|
2011-08-05 08:25:00 -04:00
|
|
|
ifndef LIBMAXSI_NO_STATIC
|
|
|
|
BINS:=$(BINS) libc.a
|
|
|
|
endif
|
|
|
|
|
|
|
|
HEADERS:=$(HEADERS) $(CHEADERS)
|
|
|
|
|
|
|
|
else
|
|
|
|
DEFINES:=$(DEFINES) -DLIBMAXSI_NO_LIBC
|
|
|
|
endif
|
|
|
|
|
|
|
|
CFLAGS:=$(FLAGS) -std=c99 -Ic/h -I..
|
|
|
|
CXXFLAGS:=$(FLAGS) -nostdinc++ -fno-rtti -I.. -Ic/h
|
|
|
|
SORTIXFLAGS:=$(CXXFLAGS) -DSORTIX_KERNEL -I.. -I../..
|
|
|
|
|
|
|
|
all: $(BINS)
|
|
|
|
|
|
|
|
libmaxsi.a: $(OBJS)
|
|
|
|
ar rcs libmaxsi.a $(OBJS)
|
|
|
|
|
|
|
|
libmaxsi.so: $(OBJS)
|
|
|
|
ld $(LDFLAGS) -shared -o $@ $(OBJS)
|
|
|
|
|
|
|
|
libmaxsi-sortix.a: $(SORTIXOBJS)
|
|
|
|
ar rcs libmaxsi-sortix.a $(SORTIXOBJS)
|
|
|
|
|
|
|
|
libc.a: libmaxsi.a
|
|
|
|
ln -sf $< $@
|
|
|
|
|
|
|
|
libc.so: libmaxsi.so
|
|
|
|
ln -sf $< $@
|
|
|
|
|
2011-09-15 16:19:04 -04:00
|
|
|
start.o: $(CPU)/start.o
|
|
|
|
ln -sf $< $@
|
|
|
|
|
2011-08-05 08:25:00 -04:00
|
|
|
# libmaxsi
|
|
|
|
|
|
|
|
*.cpp: $(HEADERS)
|
|
|
|
|
|
|
|
%.o: %.cpp
|
|
|
|
g++ -c $< -o $@ $(CXXFLAGS)
|
|
|
|
|
|
|
|
%.h: hsrc/%.h
|
|
|
|
echo "/* WARNING: This header is generated - edits will be lost! */" > $@
|
|
|
|
mxmpp -I decl $< >> $@
|
|
|
|
|
|
|
|
%.o: %.s
|
|
|
|
as $(ASFLAGS) $< -o $@
|
|
|
|
|
|
|
|
%.o: %.asm
|
|
|
|
nasm $(CPUNASMFLAGS) $< -o $@
|
|
|
|
|
|
|
|
# libc
|
|
|
|
|
|
|
|
c/*.c: $(CHEADERS)
|
|
|
|
|
|
|
|
c/%.o: c/%.c
|
|
|
|
gcc -c $< -o $@ $(CFLAGS)
|
|
|
|
|
|
|
|
c/h/%.h: c/hsrc/%.h
|
2011-08-06 19:36:27 -04:00
|
|
|
mkdir -p c/h
|
2011-08-06 19:37:43 -04:00
|
|
|
mkdir -p c/h/sys
|
2011-08-05 08:25:00 -04:00
|
|
|
echo "/* WARNING: This header is generated - edits will be lost! */" > $@
|
|
|
|
mxmpp -I decl -I c/decl $< >> $@
|
|
|
|
|
|
|
|
# libmaxsi-sortix
|
|
|
|
|
|
|
|
sortix/*.cpp: $(HEADERS)
|
|
|
|
|
|
|
|
sortix/%.o: %.cpp $(HEADERS)
|
|
|
|
g++ -c $< -o $@ $(SORTIXFLAGS)
|
|
|
|
|
|
|
|
sortix/%.o: sortix/%.cpp
|
|
|
|
g++ -c $< -o $@ $(SORTIXFLAGS)
|
|
|
|
|
|
|
|
clean:
|
2011-09-15 16:19:04 -04:00
|
|
|
rm -f *.o sortix/*.o c/*.o x86/*.o x64/*.o *.a *.so $(CHEADERS) $(HEADERS)
|
2011-08-05 08:25:00 -04:00
|
|
|
|