3
0
mirror of https://github.com/XboxDev/nxdk.git synced 2026-02-04 15:35:39 +00:00

Makefile robustness.

This commit is contained in:
Matt Borgerson
2016-01-02 00:58:09 -07:00
parent ed508f56b0
commit 04d71a7be2
6 changed files with 105 additions and 36 deletions

View File

@ -1,3 +1,16 @@
ifeq ($(NXDK_DIR),)
NXDK_DIR = $(shell pwd)
endif
ifeq ($(XBE_TITLE),)
XBE_TITLE = nxdk_app
endif
ifeq ($(OUTPUT_DIR),)
OUTPUT_DIR = bin
endif
TARGET = $(OUTPUT_DIR)/default.xbe
LLDLINK = /usr/local/opt/llvm/bin/lld -flavor link
CC = /usr/local/opt/llvm/bin/clang
CXX = /usr/local/opt/llvm/bin/clang++
@ -7,50 +20,66 @@ VP20COMPILER = $(NXDK_DIR)/tools/vp20compiler/vp20compiler
FP20COMPILER = $(NXDK_DIR)/tools/fp20compiler/fp20compiler
EXTRACT_XISO = $(NXDK_DIR)/tools/extract-xiso/extract-xiso
TOOLS = cxbe vp20compiler fp20compiler extract-xiso
CFLAGS = -target i386-pc-win32 -march=pentium3 \
-ffreestanding -nostdlib -fno-builtin -fno-exceptions \
-I$(NXDK_DIR)/lib -I$(NXDK_DIR)/lib/xboxrt
ifeq ($(NXDK_DIR),)
NXDK_DIR = $(shell pwd)
endif
CFLAGS = -target i386-pc-win32 -march=pentium3 \
-ffreestanding -nostdlib -fno-builtin -fno-exceptions \
-I$(NXDK_DIR)/lib -I$(NXDK_DIR)/lib/xboxrt
include $(NXDK_DIR)/lib/Makefile
OBJS = $(SRCS:.c=.obj)
all: default.iso
ifneq ($(GEN_XISO),)
TARGET += $(GEN_XISO)
endif
default.iso: bin/default.xbe
$(EXTRACT_XISO) -c bin $@
V = 0
VE_0 := @
VE_1 :=
VE = $(VE_$(V))
bin/default.xbe: main.exe
mkdir -p bin
$(CXBE) -OUT:bin/default.xbe -TITLE:0ldskoo1 main.exe
ifeq ($(V),1)
STDOUT_TO_NULL=
else
STDOUT_TO_NULL=>/dev/null
endif
all: $(TARGET)
$(OUTPUT_DIR)/default.xbe: $(OUTPUT_DIR) main.exe
@echo "[ CXBE ] $@"
$(VE)$(CXBE) -OUT:$@ -TITLE:$(XBE_TITLE) $^ $(STDOUT_TO_NULL)
$(OUTPUT_DIR):
@mkdir -p $(OUTPUT_DIR);
ifneq ($(GEN_XISO),)
$(GEN_XISO): $(OUTPUT_DIR)/default.xbe
@echo "[ XISO ] $@"
$(VE) $(EXTRACT_XISO) -c $(OUTPUT_DIR) $(XISO_FLAGS) $@
endif
main.exe: $(OBJS)
$(LLDLINK) -subsystem:windows -dll -out:'$@' \
@echo "[ LLD ] $@"
$(VE) $(LLDLINK) -subsystem:windows -dll -out:'$@' \
-entry:XboxCRT $(NXDK_DIR)/lib/xboxkrnl/libxboxkrnl.lib $(OBJS)
%.obj: %.c $(INCLUDES)
$(CC) $(CFLAGS) -c -o '$@' '$<'
@echo "[ CC ] $@"
$(VE) $(CC) $(CFLAGS) -c -o '$@' '$<'
%.inl: %.vs.cg
$(CGC) -profile vp20 -o $@.$$$$ $< ; \
@echo "[ CG ] $@"
$(VE) $(CGC) -profile vp20 -o $@.$$$$ $< ; \
$(VP20COMPILER) $@.$$$$ > $@ ; \
rm -rf $@.$$$$
%.inl: %.ps.cg
$(CGC) -profile fp20 -o $@.$$$$ $< ; \
@echo "[ CG ] $@"
$(VE) $(CGC) -profile fp20 -o $@.$$$$ $< ; \
$(FP20COMPILER) $@.$$$$ > $@ ; \
rm -rf $@.$$$$
#
# Tools
#
tools: $(TOOLS)
.PHONY: tools $(TOOLS)
cxbe:
$(MAKE) -C $(NXDK_DIR)/tools/cxbe
@ -64,6 +93,17 @@ fp20compiler:
extract-xiso:
$(MAKE) -C $(NXDK_DIR)/tools/extract-xiso
.PHONY: clean tools cxbe vp20compiler fp20compiler extract-xiso
.PHONY: clean
clean:
rm -f default.iso bin/default.xbe main.exe main.exe.manifest $(OBJS) $(SHADEROBJ)
$(VE)rm -f $(TARGET) \
main.exe main.exe.manifest \
$(OBJS) $(SHADEROBJ) \
$(GEN_XISO)
.PHONY: distclean
distclean: clean
$(VE)$(MAKE) -C $(NXDK_DIR)/tools/extract-xiso clean
$(VE)$(MAKE) -C $(NXDK_DIR)/tools/fp20compiler distclean
$(VE)$(MAKE) -C $(NXDK_DIR)/tools/vp20compiler distclean
$(VE)$(MAKE) -C $(NXDK_DIR)/tools/cxbe clean
$(VE)bash -c "if [ -d $(OUTPUT_DIR) ]; then rmdir $(OUTPUT_DIR); fi"

View File

@ -2,7 +2,7 @@ NXDK - *the new open source xdk*
================================
**Note:** This is a custom fork of NXDK. The official NXDK repository can be found [here](https://github.com/xqemu/nxdk). Documentation below applies to this fork.
NXDK is a software development kit for the original Xbox, and compatible with the XQEMU emulator. NXDK is a revitalisation of [OpenXDK](http://opeNXDK.maturion.de/).
NXDK is a software development kit for the original Xbox, and compatible with the XQEMU emulator. NXDK is a revitalization of [OpenXDK](http://opeNXDK.maturion.de/).
Notable features:
- No complicated cross-compiling or big library dependencies! Builds with `make` and just needs standard tools and llvm.
@ -29,7 +29,6 @@ On OSX with [Homebrew](http://brew.sh/), this should do the job (XCode ships wit
### Download NXDK
git clone https://github.com/mborgerson/nxdk.git
git checkout mborgerson
cd nxdk
git submodule init
git submodule update
@ -42,12 +41,32 @@ To build the 0ldskoo1 sample, you can run:
cd samples/0ldskoo1
make
This will generate a single executable, default.xbe in the bin/ directory that
This will generate a single executable, default.xbe, in the bin/ directory which
can be executed on your Xbox (or XQEMU emulator).
Additionally, default.iso is generated. This can be burned to a disc, or passed
to the XQEMU emulator via the `-drive index=1,media=cdrom,file=default.iso`
parameter.
### Generate XISO
To generate an ISO file that can be burned to a disc, or passed to the XQEMU
emulator via the `-drive index=1,media=cdrom,file=/path/to/your.iso` parameter,
specify define the `GEN_XISO` variable with the name of the ISO to be created in
your project Makefile. For example:
GEN_XISO=$(XBE_TITLE).iso
You can include additional files in the ISO (they must reside in the output
directory) like this:
ISO_DEPS = bin/example.txt
$(GEN_XISO): $(ISO_DEPS)
bin/example.txt:
echo "Hello" > $@
clean: $(ISO_DEPS)
For easy ISO generation, you can also just specify it when you run `make`:
make -C samples/0ldskoo1 GEN_XISO=0ldskoo1.iso
Next Steps
----------
@ -62,15 +81,17 @@ Credits
- vp20compiler is based on nvvertparse.c from [Mesa](http://www.mesa3d.org/) (License: MIT)
- fp20compiler is based on nvparse from the [NVIDIA SDK 9.52](https://www.nvidia.com/object/sdk-9.html).
- A (Windows) copy of the NVIDIA Cg compiler 1.3 from the NVIDIA SDK is bundled.
- extract-xiso developed by in et al. (License: BSD)
Code Overview
-------------
* `lib/hal/` - Barebones Hardware Abstraction Layer for the Xbox, from OpenXDK.
* `lib/pbkit/` - A low level library for interfacing with the Xbox GPU.
* `lib/usb/` - USB support from OpenXDK. Hacked together parts of an old Linux OHCI stack.
* `lib/xboxkrnl` - stubs and import library for the interfacing with the Xbox kernel.
* `lib/xboxkrnl` - Stubs and import library for the interfacing with the Xbox kernel.
* `lib/xboxrt` - A very simple libc implementation.
* `tools/cxbe` - Simple converter for PE executables to the Xbox executable format, from OpenXDK.
* `tools/fp20compiler` - Translates register combiner descriptions to Xbox pushbuffer commands.
* `tools/vp20compiler` - Translates vertex program assembly to Xbox microcode.
* `tools/extract-xiso` - Generates and extracts ISO images compatible with the Xbox (and XQEMU).
* `samples/` - Sample applications to get started.

View File

@ -1,10 +1,9 @@
XBE_TITLE=0ldskoo1
SHADEROBJ = \
$(CURDIR)/vs.inl \
$(CURDIR)/ps.inl
INCLUDES = $(wildcard $(CURDIR)/*.h)
SRCS = $(wildcard $(CURDIR)/*.c)
NXDK_DIR = $(CURDIR)/../..
include $(NXDK_DIR)/Makefile
$(CURDIR)/graphics.obj : $(SHADEROBJ)

View File

@ -1,3 +1,4 @@
XBE_TITLE=hello
INCLUDES += $(wildcard $(CURDIR)/*.h)
SRCS += $(wildcard $(CURDIR)/*.c)
NXDK_DIR = $(CURDIR)/../..

View File

@ -55,4 +55,8 @@ clean:
rm -f _ps1.0_parser.cpp _ps1.0_parser.h _ps1.0_lexer.cpp
rm -f _rc1.0_parser.cpp _rc1.0_parser.h _rc1.0_lexer.cpp
rm -f _ts1.0_parser.cpp _ts1.0_parser.h _ts1.0_lexer.cpp
rm -f *.o
rm -f $(OBJS)
.PHONY: distclean
distclean: clean
rm -f $(MAIN)

View File

@ -16,4 +16,8 @@ $(MAIN): $(OBJS)
.PHONY: clean
clean:
rm -f *.o
rm -f $(OBJS)
.PHONY: distclean
distclean: clean
rm -f $(MAIN)