mirror of
https://github.com/thepigeongenerator/mcaselector-lite.git
synced 2025-12-17 09:25:44 +01:00
seperate rust flags out of the rust compilation command
for consistency and able to specify a target now, which is still relevant for linking, despite not using the standard library
This commit is contained in:
12
makefile
12
makefile
@@ -13,23 +13,28 @@ CC := clang
|
|||||||
CLANG := c
|
CLANG := c
|
||||||
CSTD := c17
|
CSTD := c17
|
||||||
CFLAGS := -Wall -Wextra -Wpedantic -Wno-pointer-arith -static
|
CFLAGS := -Wall -Wextra -Wpedantic -Wno-pointer-arith -static
|
||||||
|
RSFLAGS := --crate-type=staticlib -C panic=abort
|
||||||
LDFLAGS :=
|
LDFLAGS :=
|
||||||
DEBUG ?= 0
|
DEBUG ?= 0
|
||||||
ARCH ?= 0
|
ARCH ?= 0
|
||||||
|
|
||||||
ifeq ($(DEBUG),1)
|
ifeq ($(DEBUG),1)
|
||||||
CFLAGS += -DDEBUG -g -Og
|
CFLAGS += -DDEBUG -g -Og
|
||||||
|
RSFLAGS += -C debuginfo=2
|
||||||
PROF := dbg
|
PROF := dbg
|
||||||
else
|
else
|
||||||
CFLAGS += -O2
|
CFLAGS += -O2
|
||||||
|
RSFLAGS += -D warnings
|
||||||
PROF := rel
|
PROF := rel
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifneq ($(MAKECMDGOALS),clean)
|
ifneq ($(MAKECMDGOALS),clean)
|
||||||
ifeq ($(ARCH),linux-x86_64)
|
ifeq ($(ARCH),linux-x86_64)
|
||||||
CFLAGS += -target x86_64-pc-linux-gnu
|
CFLAGS += -target x86_64-pc-linux-gnu
|
||||||
|
RSFLAGS += --target=x86_64-unknown-linux-gnu
|
||||||
else ifeq ($(ARCH),win-x86_64)
|
else ifeq ($(ARCH),win-x86_64)
|
||||||
CFLAGS += -target x86_64-pc-windows-gnu
|
CFLAGS += -target x86_64-pc-windows-gnu
|
||||||
|
RSFLAGS += --target=x86_64-pc-windows-gnu
|
||||||
EXT := .exe
|
EXT := .exe
|
||||||
else
|
else
|
||||||
$(error you must set the ARCH environment variable to one of these: 'linux-x86_64' 'win-x86_64')
|
$(error you must set the ARCH environment variable to one of these: 'linux-x86_64' 'win-x86_64')
|
||||||
@@ -64,6 +69,7 @@ $(TARGET): $(C_OBJ) $(RS_OBJ)
|
|||||||
@$(call wr_colour,"RUSTC: '$(RUSTC)'",94)
|
@$(call wr_colour,"RUSTC: '$(RUSTC)'",94)
|
||||||
@$(call wr_colour,"CC: '$(CC)'",94)
|
@$(call wr_colour,"CC: '$(CC)'",94)
|
||||||
@$(call wr_colour,"CFLAGS: '$(CFLAGS)'",94)
|
@$(call wr_colour,"CFLAGS: '$(CFLAGS)'",94)
|
||||||
|
@$(call wr_colour,"RSFLAGS: '$(RSFLAGS)'",94)
|
||||||
@$(call wr_colour,"LDFLAGS: '$(LDFLAGS)'",94)
|
@$(call wr_colour,"LDFLAGS: '$(LDFLAGS)'",94)
|
||||||
@$(call wr_colour,"linking to: '$@'",92)
|
@$(call wr_colour,"linking to: '$@'",92)
|
||||||
|
|
||||||
@@ -72,13 +78,13 @@ $(TARGET): $(C_OBJ) $(RS_OBJ)
|
|||||||
|
|
||||||
# create .o and .d files for C sources
|
# create .o and .d files for C sources
|
||||||
$(C_OBJ): $(C_SRC)
|
$(C_OBJ): $(C_SRC)
|
||||||
$(call wr_colour,"compiling $(notdir $@) from $(notdir $<)",92)
|
@$(call wr_colour,"compiling $(notdir $@) from $(notdir $<)",92)
|
||||||
@$(CC) $(CFLAGS) -c -MD -MP -std=$(CSTD) -x $(CLANG) -o $@ $<
|
@$(CC) $(CFLAGS) -c -MD -MP -std=$(CSTD) -x $(CLANG) -o $@ $<
|
||||||
|
|
||||||
# create .o files for RUST sources
|
# create .o files for RUST sources
|
||||||
$(RS_OBJ): $(RS_SRC)
|
$(RS_OBJ): $(RS_SRC)
|
||||||
$(call wr_colour,"compiling $(notdir $@) from $(notdir $<)",92)
|
@$(call wr_colour,"compiling $(notdir $@) from $(notdir $<)",92)
|
||||||
$(RUSTC) --crate-type=staticlib --emit=obj -C debuginfo=2 -C panic=abort -o $@ $<
|
@$(RUSTC) $(RSFLAGS) --emit=obj -o $@ $<
|
||||||
|
|
||||||
# create directories
|
# create directories
|
||||||
$(DIR):
|
$(DIR):
|
||||||
|
|||||||
Reference in New Issue
Block a user