better Makefile
This commit is contained in:
parent
2235d2f5b1
commit
1d6aa605fb
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,5 +1,7 @@
|
|||
**/.vscode/
|
||||
|
||||
*.o
|
||||
|
||||
fox32.rom
|
||||
fox32rom.h
|
||||
|
||||
|
|
55
Makefile
55
Makefile
|
@ -1,12 +1,27 @@
|
|||
TARGET = linux
|
||||
ifeq ($(TARGET),linux)
|
||||
# default is used for CC
|
||||
SDL2_CONFIG = sdl2-config
|
||||
CFLAGS = -g -Ofast -std=c99 -Wall -Wextra `$(SDL2_CONFIG) --cflags --libs`
|
||||
CC_WIN = x86_64-w64-mingw32-gcc
|
||||
CFLAGS_WIN = -g -Ofast -std=c99 -Wall -Wextra -lmingw32 -lSDL2main -lSDL2
|
||||
CC_WASM = emcc
|
||||
CFLAGS_WASM = -O3 -std=c99 -Wall -Wextra -s TOTAL_MEMORY=70057984 -sALLOW_MEMORY_GROWTH=1 -sUSE_SDL=2 --preload-file fox32os.img
|
||||
TARGET=fox32
|
||||
TARGET_WIN=fox32.exe
|
||||
TARGET_WASM=fox32.html
|
||||
CFLAGS += -g -Ofast -std=c99 -Wall -Wextra `$(SDL2_CONFIG) --cflags`
|
||||
LDFLAGS += `$(SDL2_CONFIG) --libs`
|
||||
else
|
||||
ifeq ($(TARGET),mingw)
|
||||
CC = x86_64-w64-mingw32-gcc
|
||||
CFLAGS += -g -Ofast -std=c99 -Wall -Wextra
|
||||
LDFLAGS += -lmingw32 -lSDL2main -lSDL2
|
||||
TARGET_FILE_EXTENSION = .exe
|
||||
else
|
||||
ifeq ($(TARGET),wasm)
|
||||
CC = emcc
|
||||
CFLAGS += -O3 -std=c99 -Wall -Wextra
|
||||
LDFLAGS += -s TOTAL_MEMORY=70057984 -sALLOW_MEMORY_GROWTH=1 -sUSE_SDL=2 --preload-file fox32os.img
|
||||
TARGET_EXTRADEPS = fox32os.img
|
||||
TARGET_FILE_EXTENSION = .html
|
||||
else
|
||||
$(error unknown TARGET)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
CFILES = src/main.c \
|
||||
src/bus.c \
|
||||
|
@ -19,23 +34,23 @@ CFILES = src/main.c \
|
|||
src/screen.c \
|
||||
src/serial.c
|
||||
|
||||
OBJS = $(addsuffix .o, $(basename $(CFILES)))
|
||||
|
||||
.PHONY: all
|
||||
all: fox32$(TARGET_FILE_EXTENSION)
|
||||
|
||||
FOX32ROM_IN = fox32.rom
|
||||
FOX32ROM_OUT = fox32rom.h
|
||||
|
||||
$(TARGET): $(CFILES) $(FOX32ROM_IN)
|
||||
$(FOX32ROM_OUT): $(FOX32ROM_IN)
|
||||
xxd -i $(FOX32ROM_IN) $(FOX32ROM_OUT)
|
||||
sed -i -e 's/fox32_rom/fox32rom/' fox32rom.h
|
||||
$(CC) -o $@ $(filter %.c, $^) $(CFLAGS)
|
||||
sed -i -e 's/fox32_rom/fox32rom/' $(FOX32ROM_OUT)
|
||||
|
||||
$(TARGET_WIN): $(CFILES)
|
||||
xxd -i $(FOX32ROM_IN) $(FOX32ROM_OUT)
|
||||
sed -i -e 's/fox32_rom/fox32rom/' fox32rom.h
|
||||
$(CC_WIN) -o $@ $(filter %.c, $^) $(CFLAGS_WIN)
|
||||
fox32$(TARGET_FILE_EXTENSION): $(TARGET_EXTRADEPS) $(OBJS)
|
||||
$(CC) -o $@ $(OBJS) $(LDFLAGS)
|
||||
|
||||
$(TARGET_WASM): $(CFILES) $(FOX32ROM_IN)
|
||||
xxd -i $(FOX32ROM_IN) $(FOX32ROM_OUT)
|
||||
sed -i -e 's/fox32_rom/fox32rom/' fox32rom.h
|
||||
$(CC_WASM) -o $@ $(filter %.c, $^) $(CFLAGS_WASM)
|
||||
%.o: %.c $(FOX32ROM_OUT)
|
||||
$(CC) -o $@ -c $< $(CFLAGS)
|
||||
|
||||
clean:
|
||||
rm -rf $(TARGET) $(TARGET_WIN) $(TARGET_WASM)
|
||||
rm -rf fox32 fox32.exe fox32.wasm fox32.html fox32.data fox32.js fox32rom.h $(OBJS)
|
||||
|
|
|
@ -17,7 +17,7 @@ Prebuilt Linux binaries of the latest commit are also available on the [GitHub A
|
|||
|
||||
### Building
|
||||
|
||||
Download the latest release or commit of [**fox32rom**](https://github.com/fox32-arch/fox32rom), and place the downloaded `fox32.rom` file into the root directory of this repo. Then simply run `make`. The resulting binary will be saved as `fox32`.
|
||||
Download the latest release or commit of [**fox32rom**](https://github.com/fox32-arch/fox32rom), and place the downloaded `fox32.rom` file into the root directory of this repo. Then simply run `make`. The resulting binary will be saved as `fox32`. Optionally you may build for a different target with `make TARGET=<target>`, see the Makefile for details.
|
||||
|
||||
### Usage
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user