old-trainOS/Makefile

60 lines
2 KiB
Makefile
Raw Normal View History

2015-08-13 12:56:50 +00:00
SRCS = $(shell find . -regextype posix-egrep -regex '.*\.[cS]') src/cplusplus.cpp
2015-08-09 00:42:56 +00:00
OBJS = $(addsuffix .o,$(basename $(SRCS)))
CC = gcc
2015-08-13 12:56:50 +00:00
CXX = g++
2015-08-13 15:23:11 +00:00
LD = g++
2015-08-13 12:56:50 +00:00
LEX=flex
YACC=bison
2015-08-09 00:42:56 +00:00
# define nullptr, but not NULL.
CFLAGS = -m32 -Dnullptr=0
ASFLAGS =
2015-08-13 12:56:50 +00:00
CCFLAGS = -g -std=c11 -Wall -g -fno-stack-protector -ffreestanding -Iinclude
2015-08-13 15:23:11 +00:00
CXXFLAGS = -g -std=c++11 -Wall -g -fno-stack-protector -fno-use-cxa-atexit -nostdlib -fno-builtin -fno-rtti -fno-exceptions -fno-leading-underscore -Wall -Wextra -ffreestanding -Wno-unused-function -Iinclude
LDFLAGS = -g -m32 -Tkernel.ld
2015-08-09 00:42:56 +00:00
2015-08-13 15:23:11 +00:00
all: clean kernel
kernel: $(OBJS) obj/tsvm.o obj/lex.yy.o obj/trainscript.tab.o obj/vm.o
2015-08-09 00:42:56 +00:00
$(LD) $(LDFLAGS) -o $@ $(addprefix obj/, $(notdir $^))
%.o: %.c
$(CC) $(CFLAGS) $(CCFLAGS) -c -o $(addprefix obj/, $(notdir $@)) $^
%.o: %.S
$(CC) $(CFLAGS) $(ASFLAGS) -c -o $(addprefix obj/, $(notdir $@)) $^
2015-08-13 12:56:50 +00:00
%.o: %.cpp
$(CXX) $(CFLAGS) $(CXXFLAGS) -c -o $(addprefix obj/, $(notdir $@)) $^
2015-08-13 15:23:11 +00:00
obj/vm.o: src/vm.cpp trainscript/tsvm.hpp
g++ $(CFLAGS) $(CXXFLAGS) -c src/vm.cpp -o obj/vm.o
obj/tsvm.o: trainscript/tsvm.cpp trainscript/tsvm.hpp
2015-08-13 12:56:50 +00:00
g++ $(CFLAGS) $(CXXFLAGS) -c trainscript/tsvm.cpp -o obj/tsvm.o
2015-08-13 15:23:11 +00:00
obj/lex.yy.o: trainscript/lex.yy.cpp trainscript/tsvm.hpp
2015-08-13 12:56:50 +00:00
g++ $(CFLAGS) $(CXXFLAGS) -c trainscript/lex.yy.cpp -o obj/lex.yy.o
2015-08-13 15:23:11 +00:00
obj/trainscript.tab.o: trainscript/trainscript.tab.cpp trainscript/tsvm.hpp
2015-08-13 12:56:50 +00:00
g++ $(CFLAGS) $(CXXFLAGS) -c trainscript/trainscript.tab.cpp -o obj/trainscript.tab.o
trainscript/lex.yy.cpp: trainscript/trainscript.l
$(LEX) --header-file=trainscript/trainscript.l.h -o trainscript/lex.yy.cpp trainscript/trainscript.l
trainscript/trainscript.tab.cpp: trainscript/trainscript.y
$(YACC) -o trainscript/trainscript.tab.cpp -d trainscript/trainscript.y
2015-08-13 15:23:11 +00:00
obj/file01.o:
objcopy -I binary -O elf32-i386 --redefine-sym _binary_trainscript_file01_ts_start=file01_start --redefine-sym _binary_trainscript_file01_ts_end=file01_end --redefine-sym _binary_trainscript_file01_ts_size=file01_size trainscript/file01.ts obj/file01.o
2015-08-09 00:42:56 +00:00
clean:
2015-08-13 15:23:11 +00:00
rm obj/*.o
2015-08-09 00:42:56 +00:00
run:
qemu-system-i386 -kernel kernel
.PHONY: clean
.PHONY: run