mirror of
https://github.com/GRRLIB/GRRLIB.git
synced 2024-11-22 06:52:20 +00:00
Make Makefile more similar to template
This commit is contained in:
parent
7ced58bf9a
commit
ac5d9581b2
2 changed files with 185 additions and 56 deletions
|
@ -1,13 +1,10 @@
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
|
# Clear the implicit built in rules
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
.SUFFIXES:
|
.SUFFIXES:
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
|
|
||||||
ifeq ($(strip $(DEVKITPPC)),)
|
ifeq ($(strip $(DEVKITPPC)),)
|
||||||
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC)
|
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(strip $(DEVKITPRO)),)
|
|
||||||
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPro)
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(PLATFORM),cube)
|
ifeq ($(PLATFORM),cube)
|
||||||
|
@ -15,41 +12,105 @@ include $(DEVKITPPC)/gamecube_rules
|
||||||
|
|
||||||
MACHDEP += -DHW_DOL
|
MACHDEP += -DHW_DOL
|
||||||
|
|
||||||
INSTALL_INC := $(DEVKITPRO)/portlibs/gamecube/include
|
# Installation directory
|
||||||
INSTALL_LIB := $(DEVKITPRO)/portlibs/gamecube/lib
|
DESTDIR := $(PORTLIBS_PATH)/gamecube
|
||||||
else
|
else
|
||||||
include $(DEVKITPPC)/wii_rules
|
include $(DEVKITPPC)/wii_rules
|
||||||
|
|
||||||
MACHDEP += -DHW_RVL
|
MACHDEP += -DHW_RVL
|
||||||
|
|
||||||
INSTALL_INC := $(DEVKITPRO)/portlibs/wii/include
|
# Installation directory
|
||||||
INSTALL_LIB := $(DEVKITPRO)/portlibs/wii/lib
|
DESTDIR := $(PORTLIBS_PATH)/wii
|
||||||
endif
|
endif
|
||||||
|
|
||||||
NULLSTR :=
|
#---------------------------------------------------------------------------------
|
||||||
PWD := $(subst $(NULLSTR) ,\ ,$(shell pwd))
|
# 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 := grrlib
|
||||||
|
BUILD := build
|
||||||
|
SOURCES := .
|
||||||
|
INCLUDES := . ../lib/pngu
|
||||||
|
|
||||||
INCLUDE := -I../lib/pngu -I$(PWD) -I$(LIBOGC_INC) -I$(DEVKITPRO)/portlibs/ppc/include -I$(DEVKITPRO)/portlibs/ppc/include/freetype2
|
HDR := $(TARGET).h $(wildcard $(TARGET)/*.h)
|
||||||
CFLAGS := -O2 -Wall $(MACHDEP) $(INCLUDE)
|
|
||||||
|
|
||||||
LIB := grrlib
|
#---------------------------------------------------------------------------------
|
||||||
CFILES := $(wildcard *.c)
|
# options for code generation
|
||||||
OFILES := $(CFILES:.c=.o)
|
#---------------------------------------------------------------------------------
|
||||||
DEPENDS := $(OFILES:.o=.d)
|
|
||||||
ARC := lib$(LIB).a
|
|
||||||
HDR := $(LIB).h
|
|
||||||
INL := $(wildcard $(LIB)/*.h)
|
|
||||||
|
|
||||||
export DEPSDIR := $(CURDIR)
|
CFLAGS = -g -O2 -Wall $(MACHDEP) $(INCLUDE) `$(PREFIX)pkg-config freetype2 --cflags`
|
||||||
|
CXXFLAGS = $(CFLAGS)
|
||||||
|
|
||||||
all : $(OFILES)
|
LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map
|
||||||
$(AR) -r $(ARC) $(OFILES)
|
|
||||||
|
|
||||||
clean :
|
#---------------------------------------------------------------------------------
|
||||||
rm -f $(OFILES) $(DEPENDS) $(ARC)
|
# list of directories containing libraries, this must be the top level containing
|
||||||
|
# include and lib
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
LIBDIRS :=
|
||||||
|
|
||||||
install :
|
#---------------------------------------------------------------------------------
|
||||||
mkdir -p $(INSTALL_LIB) $(INSTALL_INC) $(INSTALL_INC)/grrlib
|
# no real need to edit anything past this point unless you need to add additional
|
||||||
cp -f $(ARC) $(INSTALL_LIB)/
|
# rules for different file extensions
|
||||||
cp -f $(HDR) $(INSTALL_INC)/
|
#---------------------------------------------------------------------------------
|
||||||
cp -f $(INL) $(INSTALL_INC)/grrlib
|
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
export OUTPUT := $(CURDIR)/lib$(TARGET).a
|
||||||
|
|
||||||
|
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir))
|
||||||
|
|
||||||
|
export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
# automatically build a list of object files for our project
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||||
|
|
||||||
|
export OFILES_SOURCES := $(CFILES:.c=.o)
|
||||||
|
export OFILES := $(OFILES_SOURCES)
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
# build a list of include paths
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
export INCLUDE := $(foreach dir,$(INCLUDES), -I$(CURDIR)/$(dir)) \
|
||||||
|
-I$(LIBOGC_INC)
|
||||||
|
|
||||||
|
.PHONY: $(BUILD) clean
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
all: $(BUILD)
|
||||||
|
|
||||||
|
$(BUILD):
|
||||||
|
@[ -d $@ ] || mkdir -p $@
|
||||||
|
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
clean:
|
||||||
|
@echo clean ...
|
||||||
|
@rm -fr $(BUILD) $(OUTPUT)
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
install:
|
||||||
|
@cp --force $(OUTPUT) $(DESTDIR)/lib
|
||||||
|
@cp --force --parents $(HDR) $(DESTDIR)/include
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
else
|
||||||
|
|
||||||
|
DEPENDS := $(OFILES:.o=.d)
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
# main targets
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
$(OUTPUT) : $(OFILES)
|
||||||
|
|
||||||
|
$(OFILES_SOURCES) : $(HFILES)
|
||||||
|
|
||||||
|
-include $(DEPENDS)
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
endif
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
|
|
@ -1,40 +1,108 @@
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
|
# Clear the implicit built in rules
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
.SUFFIXES:
|
.SUFFIXES:
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
|
|
||||||
ifeq ($(strip $(DEVKITPPC)),)
|
ifeq ($(strip $(DEVKITPPC)),)
|
||||||
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC)
|
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(strip $(DEVKITPRO)),)
|
|
||||||
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPro)
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
include $(DEVKITPPC)/base_rules
|
include $(DEVKITPPC)/base_rules
|
||||||
|
|
||||||
|
# Extra rules for PPC
|
||||||
|
export PATH := $(PORTLIBS_PATH)/ppc/bin:$(PATH)
|
||||||
MACHDEP = -DGEKKO -mcpu=750 -meabi -mhard-float
|
MACHDEP = -DGEKKO -mcpu=750 -meabi -mhard-float
|
||||||
|
|
||||||
INSTALL_INC := $(DEVKITPRO)/portlibs/ppc/include
|
# Installation directory
|
||||||
INSTALL_LIB := $(DEVKITPRO)/portlibs/ppc/lib
|
DESTDIR := $(PORTLIBS_PATH)/ppc
|
||||||
|
|
||||||
INCLUDE := -I$(DEVKITPRO)/portlibs/ppc/include
|
#---------------------------------------------------------------------------------
|
||||||
CFLAGS := -O2 -Wall $(MACHDEP) $(INCLUDE)
|
# 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 := .
|
||||||
|
INCLUDES :=
|
||||||
|
|
||||||
LIB := pngu
|
HDR := $(TARGET).h
|
||||||
CFILES := $(wildcard *.c)
|
|
||||||
OFILES := $(CFILES:.c=.o)
|
|
||||||
DEPENDS := $(OFILES:.o=.d)
|
|
||||||
ARC := lib$(LIB).a
|
|
||||||
HDR := $(LIB).h
|
|
||||||
|
|
||||||
export DEPSDIR := $(CURDIR)
|
#---------------------------------------------------------------------------------
|
||||||
|
# options for code generation
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
|
||||||
all : $(OFILES)
|
CFLAGS = -g -O2 -Wall $(MACHDEP) $(INCLUDE) `$(PREFIX)pkg-config libpng --cflags`
|
||||||
$(AR) -r $(ARC) $(OFILES)
|
CXXFLAGS = $(CFLAGS)
|
||||||
|
|
||||||
clean :
|
LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map
|
||||||
rm -f $(OFILES) $(DEPENDS) $(ARC)
|
|
||||||
|
|
||||||
install :
|
#---------------------------------------------------------------------------------
|
||||||
mkdir -p $(INSTALL_LIB) $(INSTALL_INC)
|
# list of directories containing libraries, this must be the top level containing
|
||||||
cp -f $(ARC) $(INSTALL_LIB)/
|
# include and lib
|
||||||
cp -f $(HDR) $(INSTALL_INC)
|
#---------------------------------------------------------------------------------
|
||||||
|
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)/lib$(TARGET).a
|
||||||
|
|
||||||
|
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir))
|
||||||
|
|
||||||
|
export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
# automatically build a list of object files for our project
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||||
|
|
||||||
|
export OFILES_SOURCES := $(CFILES:.c=.o)
|
||||||
|
export OFILES := $(OFILES_SOURCES)
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
# build a list of include paths
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
export INCLUDE := $(foreach dir,$(INCLUDES), -iquote $(CURDIR)/$(dir))
|
||||||
|
|
||||||
|
.PHONY: $(BUILD) clean
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
all: $(BUILD)
|
||||||
|
|
||||||
|
$(BUILD):
|
||||||
|
@[ -d $@ ] || mkdir -p $@
|
||||||
|
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
clean:
|
||||||
|
@echo clean ...
|
||||||
|
@rm -fr $(BUILD) $(OUTPUT)
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
install:
|
||||||
|
@cp --force $(OUTPUT) $(DESTDIR)/lib
|
||||||
|
@cp --force --parents $(HDR) $(DESTDIR)/include
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
else
|
||||||
|
|
||||||
|
DEPENDS := $(OFILES:.o=.d)
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
# main targets
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
$(OUTPUT) : $(OFILES)
|
||||||
|
|
||||||
|
$(OFILES_SOURCES) : $(HFILES)
|
||||||
|
|
||||||
|
-include $(DEPENDS)
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
endif
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in a new issue