xaizek / tos (License: GPLv3 only) (since 2018-12-07)
This is an alternative version of sources presented as part of Write Your Own OS video tutorial by Viktor Engelmann.
<root> / Makefile (e81c3db921d5f449dc2d05bcc4ea88bc1744d7f9) (1,914B) (mode 100644) [raw]
CXX  := g++
AS   := gcc
LD   := gcc
QEMU := qemu-system-i386

CXXFLAGS  := -m32 -std=c++11 -g -MMD -Isrc/
CXXFLAGS  += -Wall -Wextra -Werror
CXXFLAGS  += -fno-use-cxa-atexit -fno-builtin -fno-rtti -fno-exceptions
CXXFLAGS  += -fno-threadsafe-statics
ASFLAGS   := -m32
LINKFLAGS := -g -m32 -nostartfiles -nostdlib
QEMUFLAGS := -netdev user,id=n0,hostfwd=udp::1234-:1234,hostfwd=tcp::1234-:1234
QEMUFLAGS += -device rtl8139,netdev=n0,mac=12:23:34:45:56:77
QEMUFLAGS += -drive file=./hda,index=0,media=disk,format=raw

# traverse directories ($1) recursively looking for patterns ($2) to make list
# of matching files
rwildcard = $(foreach d,$(wildcard $1*), \
              $(foreach p,$2, $(call rwildcard,$d/,$p) \
                              $(filter $(subst *,%,$p),$d)))

src     := $(call rwildcard, src/, *.cpp *.s *.S)
objects := $(patsubst src/%,obj/%.o,$(basename $(src)))
depends := $(objects:.o=.d)
dirs    := $(sort $(dir $(objects)))

obj/%.o: src/%.cpp | $(dirs)
	$(CXX) $(CXXFLAGS) -c -o $@ $<

obj/%.o: src/%.s | $(dirs)
	$(AS) $(ASFLAGS) -c -o $@ $<

obj/%.o: src/%.S | $(dirs)
	$(AS) $(ASFLAGS) -c -o $@ $<

kernel: linker.ld $(objects)
	$(CXX) $(LINKFLAGS) -Wl,-T $< -o $@ $(objects)

	mkdir -p $@

run: kernel
	$(QEMU) -kernel $< $(QEMUFLAGS) &

	@echo '[[[ Connecting to UDP server inside virtual machine... ]]]'
	nc -u 1234

	@echo '[[[ Opening UDP socket for kernel to connect to... ]]]'
	nc -u -lp 1235

	@echo '[[[ Connecting to TCP server inside virtual machine... ]]]'
	nc 1234

	@echo '[[[ Opening TCP socket for kernel to connect to... ]]]'
	nc -lp 1235

gdb: kernel
	@gdb -quiet -se=$< \
	     -ex 'target remote | exec $(QEMU) -gdb stdio -kernel $< $(QEMUFLAGS)'

	$(RM) -r kernel obj/

.PHONY: run udp-client udp-server tcp-client tcp-server gdb clean

-include $(depends)

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/tos

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/tos

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master