Multiple Projects: One Makefile? June 20, 2010 04:52AM | Registered: 15 years ago Posts: 118 |
Re: Multiple Projects: One Makefile? June 20, 2010 05:15AM | Moderator Registered: 16 years ago Posts: 441 |
Re: Multiple Projects: One Makefile? June 20, 2010 05:33AM | Registered: 15 years ago Posts: 118 |
Re: Multiple Projects: One Makefile? June 21, 2010 03:43AM | Registered: 15 years ago Posts: 444 |
Re: Multiple Projects: One Makefile? June 21, 2010 06:38AM | Registered: 15 years ago Posts: 118 |
Re: Multiple Projects: One Makefile? June 21, 2010 11:17AM | Registered: 15 years ago Posts: 379 |
TARGET := gb LDFLAGS := -lSDL CFLAGS := -Wall -Wextra -Wno-unused-parameter -O3 Q := @ CC := gcc CPP := g++ OBJDIR := .obj SRC_GB_GEN := gb_src/gb_gen.cpp SRC_GB := gb_src/cpu.cpp gb_src/link.cpp gb_src/sound.cpp gb_src/cpu_instruction.cpp gb_src/rom.cpp gb_src/timer.cpp gb_src/sgb.cpp gb_src/video.cpp SRC_CPP := main.cpp $(SRC_GB) SRC_C := OBJS := $(addprefix $(OBJDIR)/,$(subst .cpp,.o,$(SRC_CPP))) $(addprefix $(OBJDIR)/,$(subst .c,.o,$(SRC_C))) Q := @ all: $(TARGET) clean: rm -rf $(OBJDIR) rm -rf $(TARGET) .PHONY: all clean $(TARGET): $(OBJS) @echo "LD $(TARGET)" $(Q)$(CPP) -o $(TARGET) $(OBJS) $(LDFLAGS) -include $(OBJS:.o=.d) $(OBJDIR)/%.o: %.cpp @mkdir -p `dirname $(OBJDIR)/$*.o` @echo "CC $*.cpp" $(Q)$(CPP) -c $*.cpp -o $(OBJDIR)/$*.o $(CFLAGS) # @g++ -MM $(CFLAGS) $*.cpp > $(OBJDIR)/$*.d # @mv -f $(OBJDIR)/$*.d $(OBJDIR)/$*.d.tmp # @sed -e 's|.*:|$(OBJDIR)/$*.o:|' < $(OBJDIR)/$*.d.tmp > $(OBJDIR)/$*.d # @sed -e 's/.*://' -e 's/\\$$//' < $(OBJDIR)/$*.d.tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$/:/' >> $(OBJDIR)/$*.d # @rm -f $(OBJDIR)/$*.d.tmp @$(CPP) -MM $(CFLAGS) $*.cpp | sed -e 's|.*:|$(OBJDIR)/$*.o:|' > $(OBJDIR)/$*.d $(OBJDIR)/%.o: %.c @mkdir -p `dirname $(OBJDIR)/$*.o` @echo "CC $*.c" $(Q)$(CC) -c $*.c -o $(OBJDIR)/$*.o $(CFLAGS) @$(CC) -MM $(CFLAGS) $*.c | sed -e 's|.*:|$(OBJDIR)/$*.o:|' > $(OBJDIR)/$*.d #GB instruction table generator gb_src/cpu_gen_inst.h: gb_gen ./gb_gen gb_src/cpu_gen_inst_nm.h: gb_gen ./gb_gen gb_gen: $(OBJDIR)/gb_src/gb_gen.o @echo "LD gb_gen" g++ -o gb_gen $(OBJDIR)/gb_src/gb_gen.o
Re: Multiple Projects: One Makefile? June 23, 2010 11:38AM | Registered: 15 years ago Posts: 62 |
Re: Multiple Projects: One Makefile? July 05, 2010 02:07AM | Registered: 14 years ago Posts: 3 |
SUBDIRS:= `ls | egrep -v '^(CVS)$$'` DATESTRING := $(shell date +%Y)$(shell date +%m)$(shell date +%d) all: @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done; clean: @rm -f *.bz2 @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done; dist: clean @tar --exclude=.svn -cvjf wii-examples-$(DATESTRING).tar.bz2 *
Re: Multiple Projects: One Makefile? July 05, 2010 05:50AM | Registered: 15 years ago Posts: 118 |
Re: Multiple Projects: One Makefile? July 05, 2010 01:33PM | Registered: 14 years ago Posts: 39 |
Re: Multiple Projects: One Makefile? July 05, 2010 07:48PM | Registered: 15 years ago Posts: 118 |
Re: Multiple Projects: One Makefile? July 06, 2010 12:16PM | Registered: 15 years ago Posts: 161 |
#--------------------------------------------------------------------------------- # Clear the implicit built in rules #--------------------------------------------------------------------------------- .SUFFIXES: #--------------------------------------------------------------------------------- SystemName=$(shell uname) ifeq ($(strip $(DEVKITPPC)),) $(error "Please set DEVKITPPC in your environment. export DEVKITPPC=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 := source/exe BUILD := build SOURCES := source source/... $(TARGET) DATA := data INCLUDES := include #--------------------------------------------------------------------------------- # MS Visual Studio Style Fix #--------------------------------------------------------------------------------- STYLEFIX = 2>&1 | sed -e 's/\([a-zA-Z\.]\+\):\([0-9]\+\):\([0-9]\+:\)\?\(.\+\)/\1(\2):\4/' -e 's/undefined/error: undefined/' #--------------------------------------------------------------------------------- # 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 := -ltinyxml -lasnd -lwiiuse -lbte -logc -lm -lpngu -lpng -lfat -lfreetype -lmetaphrasis -lz #--------------------------------------------------------------------------------- # list of directories containing libraries, this must be the top level containing # include and lib #--------------------------------------------------------------------------------- LIBDIRS := $(PORTLIBS) #--------------------------------------------------------------------------------- # 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)/*.*))) EXEFILES := $(foreach dir,$(TARGET),$(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 := $(addsuffix .o,$(BINFILES)) \ $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \ $(sFILES:.s=.o) $(SFILES:.S=.o) export TARGETS := $(EXEFILES:.cpp=.dol) $(EXEFILES:.c=.dol) #--------------------------------------------------------------------------------- # 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 := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \ -L$(LIBOGC_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: $(OFILES) $(TARGETS) -include $(DEPENDS) #--------------------------------------------------------------------------------- # This rule links in binary data with the .* extension #--------------------------------------------------------------------------------- endif #---------------------------------------------------------------------------------
Re: Multiple Projects: One Makefile? July 07, 2010 08:51PM | Registered: 15 years ago Posts: 118 |
Re: Multiple Projects: One Makefile? July 09, 2010 03:51AM | Registered: 15 years ago Posts: 444 |
Re: Multiple Projects: One Makefile? July 09, 2010 09:19AM | Registered: 15 years ago Posts: 161 |
Re: Multiple Projects: One Makefile? July 10, 2010 11:01PM | Registered: 15 years ago Posts: 118 |
Re: Multiple Projects: One Makefile? July 12, 2010 09:58AM | Registered: 15 years ago Posts: 161 |
#--------------------------------------------------------------------------------- # Clear the implicit built in rules #--------------------------------------------------------------------------------- .SUFFIXES: #--------------------------------------------------------------------------------- SystemName=$(shell uname) ifeq ($(strip $(DEVKITPPC)),) $(error "Please set DEVKITPPC in your environment. export DEVKITPPC=devkitPPC") endif export LIBOGC_INC := $(DEVKITPRO)/libogc/include export LIBOGC_LIB := $(DEVKITPRO)/libogc/lib/wii MACHDEP = -DGEKKO -mrvl -mcpu=750 -meabi -mhard-float include $(DEVKITPPC)/base_rules #--------------------------------------------------------------------------------- %.dol: %.elf @echo output ... $(notdir $@) @elf2dol $< $@ #--------------------------------------------------------------------------------- %.tpl : %.scf @echo $(notdir $<) @gxtexconv -s $< -d $(DEPSDIR)/$*.d -o $@ #--------------------------------------------------------------------------------- %.elf: %.o @echo linking ... $(notdir $@) @$(LD) $^ $(LDFLAGS) $(LIBPATHS) $(LIBS) -o $@ #--------------------------------------------------------------------------------- # 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 := exe BUILD := build SOURCES := src/Lighting src/Simple DATA := data INCLUDES := include #--------------------------------------------------------------------------------- # MS Visual Studio Style Fix #--------------------------------------------------------------------------------- STYLEFIX = 2>&1 | sed -e 's/\([a-zA-Z\.]\+\):\([0-9]\+\):\([0-9]\+:\)\?\(.\+\)/\1(\2):\4/' -e 's/undefined/error: undefined/' #--------------------------------------------------------------------------------- # 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 := -lz -lfat -lwiiuse -lbte -logc -lm -lwiikeyboard #--------------------------------------------------------------------------------- # list of directories containing libraries, this must be the top level containing # include and lib #--------------------------------------------------------------------------------- LIBDIRS := $(PORTLIBS) #--------------------------------------------------------------------------------- # 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)/*.*))) EXEFILES := $(foreach dir,$(TARGET),$(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 := $(addsuffix .o,$(BINFILES)) \ $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \ $(sFILES:.s=.o) $(SFILES:.S=.o) export ELFFILES := $(OFILES:.o=.elf) export DOLFILES := $(OFILES:.o=.dol) export TARGETS := $(EXEFILES:.cpp=.dol) $(EXEFILES:.c=.dol) #--------------------------------------------------------------------------------- # build a list of include paths #--------------------------------------------------------------------------------- export INCLUDE := $(foreach dir,$(INCLUDES), -iquote $(CURDIR)/$(dir)) \ $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ -I$(CURDIR)/$(BUILD) \ -I$(CURDIR)/$(INCLUDES) \ -I$(LIBOGC_INC) #--------------------------------------------------------------------------------- # build a list of library paths #--------------------------------------------------------------------------------- export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \ -L$(LIBOGC_LIB) .PHONY: $(BUILD) clean #--------------------------------------------------------------------------------- $(BUILD): @[ -d $@ ] || mkdir -p $@ @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile #--------------------------------------------------------------------------------- clean: @echo clean ... @rm -fr $(BUILD) $(OUTPUT) #--------------------------------------------------------------------------------- run: wiiload $(TARGET).dol #--------------------------------------------------------------------------------- else DEPENDS := $(OFILES:.o=.d) #--------------------------------------------------------------------------------- # main targets #--------------------------------------------------------------------------------- $(OUTPUT): $(OFILES) $(DOLFILES) @mkdir -p $(OUTPUT) -include $(DEPENDS) #--------------------------------------------------------------------------------- # This rule links in binary data with the .* extension #--------------------------------------------------------------------------------- endif #---------------------------------------------------------------------------------
Re: Multiple Projects: One Makefile? July 12, 2010 09:19PM | Registered: 15 years ago Posts: 118 |
Re: Multiple Projects: One Makefile? July 25, 2010 12:27AM | Moderator Registered: 15 years ago Posts: 5,075 |
Re: Multiple Projects: One Makefile? July 25, 2010 03:50AM | Registered: 15 years ago Posts: 118 |