Makefile for Linux Kubuntu(Ubuntu)

Post Reply
User avatar
Pavel5750cz
Posts: 12
Joined: Tue Feb 14, 2023 9:34 pm

Makefile for Linux Kubuntu(Ubuntu)

Post by Pavel5750cz » Sun Apr 07, 2024 7:49 pm

the makefile from examples/template gives his error:

Code: Select all

linking ... Hra_Wii.elf
powerpc-eabi-g++: error: -E or -x required when input is from standard input
make[1]: *** [/opt/devkitpro/devkitPPC/wii_rules:31: /home/pavel/Documents/Hra_Wii/Hra_Wii.elf] Error 1
make: *** [Makefile:101: build] Error 2

Code: Select all

#---------------------------------------------------------------------------------
# Clear the implicit built in rules
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITPPC)),)
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
endif

include $(DEVKITPPC)/wii_rules

#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# INCLUDES is a list of directories containing extra header files
#---------------------------------------------------------------------------------
TARGET		:=	$(notdir $(CURDIR))
BUILD		:=	build
SOURCES		:=	zdroje
DATA		:=	data
INCLUDES	:=

#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------

CFLAGS	= -g -O2 -Wall $(MACHDEP) $(INCLUDE)
CXXFLAGS	=	$(CFLAGS)

LDFLAGS	=	-g $(MACHDEP) -Wl,-Map,$(notdir $@).map

#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS	:=	-lwiiuse -lbte -logc -lm

#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS	:=

#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------

export OUTPUT	:=	$(CURDIR)/$(TARGET)

export VPATH	:=	$(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
					$(foreach dir,$(DATA),$(CURDIR)/$(dir))

export DEPSDIR	:=	$(CURDIR)/$(BUILD)

#---------------------------------------------------------------------------------
# automatically build a list of object files for our project
#---------------------------------------------------------------------------------
CFILES		:=	$(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES	:=	$(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
sFILES		:=	$(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
SFILES		:=	$(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
BINFILES	:=	$(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))

#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
	export LD	:=	$(CC)
else
	export LD	:=	$(CXX)
endif

export OFILES_BIN	:=	$(addsuffix .o,$(BINFILES))
export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(sFILES:.s=.o) $(SFILES:.S=.o)
export OFILES := $(OFILES_BIN) $(OFILES_SOURCES)

export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES)))

#---------------------------------------------------------------------------------
# build a list of include paths
#---------------------------------------------------------------------------------
export INCLUDE	:=	$(foreach dir,$(INCLUDES), -iquote $(CURDIR)/$(dir)) \
					$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
					-I$(CURDIR)/$(BUILD) \
					-I$(LIBOGC_INC)

#---------------------------------------------------------------------------------
# build a list of library paths
#---------------------------------------------------------------------------------
export LIBPATHS	:= -L$(LIBOGC_LIB) $(foreach dir,$(LIBDIRS),-L$(dir)/lib)

export OUTPUT	:=	$(CURDIR)/$(TARGET)
.PHONY: $(BUILD) clean

#---------------------------------------------------------------------------------
$(BUILD):
	@[ -d $@ ] || mkdir -p $@
	@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile

#---------------------------------------------------------------------------------
clean:
	@echo clean ...
	@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).dol

#---------------------------------------------------------------------------------
run:
	wiiload $(TARGET).dol


#---------------------------------------------------------------------------------
else

DEPENDS	:=	$(OFILES:.o=.d)

#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT).dol: $(OUTPUT).elf
$(OUTPUT).elf: $(OFILES)

$(OFILES_SOURCES) : $(HFILES)

#---------------------------------------------------------------------------------
# This rule links in binary data with the .jpg extension
#---------------------------------------------------------------------------------
%.jpg.o	%_jpg.h :	%.jpg
#---------------------------------------------------------------------------------
	@echo $(notdir $<)
	$(bin2o)

-include $(DEPENDS)

#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------

devkitpro is setup according to bogus tutorial link removed

how to edit so i can buid on linux? I switched from windows coz i have linux on laptop and pc not always accessible.

How to configure template makefile to work on linux?
(meanwhile i am contining development for other platforms)
® Pavel5750cz

User avatar
Pavel5750cz
Posts: 12
Joined: Tue Feb 14, 2023 9:34 pm

Re: Makefile for Linux Kubuntu(Ubuntu)

Post by Pavel5750cz » Thu Apr 25, 2024 4:37 pm

After long time on wii developmengt i see clue to error i got and the error is:

powerpc-eabi-g++: error: -E or -x required when input is from standard input


clue story: i searched the error and i found solution for same error when it happened with gcc to someone. https://stackoverflow.com/questions/769 ... dard-input

I am attempting to paste it on line 101 where software is built. i dont yet understand makefile fully but it does something. It gives error that it doesnt find vpath variable which is in file. After resolution i post a solution.
® Pavel5750cz

User avatar
Pavel5750cz
Posts: 12
Joined: Tue Feb 14, 2023 9:34 pm

Re: Makefile for Linux Kubuntu(Ubuntu)

Post by Pavel5750cz » Thu Apr 25, 2024 7:45 pm

Problem was: some. source files had space in name like: Hello World.cpp(this is just example, not actual file in my project)

Solution: Rename file/s or move it/them from source folder or delete.


Example makefile works ok Linuxers(devkit installation and setup link i provided already in other post), just watch out to not have gap in file name because linux not tolerant like windows but windows may not tolerate also. Mac will also sure have solution. Bye
® Pavel5750cz

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 1 guest