Add Makefile, gitignore and (empty-ish) source files
This commit is contained in:
47
Makefile
Normal file
47
Makefile
Normal file
@@ -0,0 +1,47 @@
|
||||
DIR_SRC := src
|
||||
DIR_BLD := build
|
||||
DIR_BIN := $(DIR_BLD)/bin
|
||||
|
||||
OBJS := $(DIR_BLD)/tests.o \
|
||||
$(DIR_BLD)/constants.o \
|
||||
$(DIR_BLD)/core.o \
|
||||
$(DIR_BLD)/console.o \
|
||||
$(DIR_BLD)/string.o \
|
||||
$(DIR_BLD)/convert.o
|
||||
OBJS_LST := false
|
||||
SRCS := $(patsubst $(DIR_BLD)/%.o,$(SRC_DIR)/%.asm,$(OBJS))
|
||||
|
||||
COMPILER := nasm
|
||||
COMPILER_FLAGS := -f elf64
|
||||
COMPILER_FLAGS_D := -f elf64 -g -F dwarf
|
||||
LINKER := ld
|
||||
LINKER_FLAGS := -no-pie -z noexecstack -Ox
|
||||
|
||||
.PHONY: all clean debug
|
||||
|
||||
all: $(DIR_BIN)/tests
|
||||
|
||||
$(DIR_BIN)/tests: $(OBJS)
|
||||
@mkdir -p $(DIR_BIN)
|
||||
$(LINKER) $^ -o $@ $(LINKER_FLAGS)
|
||||
ln -sf $@ tests
|
||||
$(DIR_BLD)/%.o: $(DIR_SRC)/%.asm
|
||||
@mkdir -p $(DIR_BLD)
|
||||
@LST=$(basename $@).lst; \
|
||||
if [ "$(OBJS_LST)" = "true" ]; then \
|
||||
$(COMPILER) $< $(COMPILER_FLAGS) -l $$LST -o $@; \
|
||||
echo $(COMPILER) $< $(COMPILER_FLAGS) -l $$LST -o $@; \
|
||||
else \
|
||||
$(COMPILER) $< $(COMPILER_FLAGS) -o $@; \
|
||||
echo $(COMPILER) $< $(COMPILER_FLAGS) -o $@; \
|
||||
fi
|
||||
|
||||
clean:
|
||||
rm -rf $(DIR_BLD) tests
|
||||
|
||||
debug: COMPILER_FLAGS = $(COMPILER_FLAGS_D)
|
||||
debug: OBJS_LST := true
|
||||
debug: clean $(OBJS)
|
||||
@mkdir -p $(DIR_BIN)
|
||||
$(LINKER) $(OBJS) -o $(DIR_BIN)/tests $(LINKER_FLAGS)
|
||||
ln -sf $(DIR_BIN)/tests tests
|
Reference in New Issue
Block a user