rickjr/Makefile

203 lines
4.4 KiB
Makefile

#--------------------------------------------------------
#
# xrickjr GNU Makefile
#
# In config.h, I have temporarily disabled sound
#
SHELL = /bin/sh
MKDIR = mkdir
TARGET = rickjr
PROJROOT = .
#F256 = $(PROJROOT)/../f256
F256 = $(HOME)/code/f256
# Compiler needs to be in the PATH, before typing "Make"
# export PATH := $(F256)/llvm-mos/bin:$(PATH)
#
# I had to just add this to my path, before typing make
#
# I have a dumb script for this
# ". fixpath.sh"
#
# Global Defines
#SYSTEM = /usr
#SYSLIBDIR = $(SYSTEM)/lib
#SYSINCDIR = $(SYSTEM)/include
TMPFLAGS = -D F256=1 -Wno-unknown-pragmas
INCCMD = -I$(SYSINCDIR)
INCCMD += -I$(PROJROOT)/src
INCCMD += -I$(PROJROOT)/include
INCCMD += -I$(F256)/include
INCCMD += -I$(F256)/f256lib
OBJDIR = $(PROJROOT)/obj
DEPDIR = $(PROJROOT)/dep
LSTDIR = $(PROJROOT)/lst
#
# Special GnuMake Search Path Directive
#
VPATH = $(PROJROOT)/src
#
# Dedicated Search Paths for Specific Types
#
# Can be used to speed up compile by using this feature
# for each filetype (reducing the amount of searching)
#
vpath %.o $(OBJDIR)
vpath %.d $(DEPDIR)
#LIBCMD +=-lm -lpng
OBJS := xrick.o
OBJS += control.o
OBJS += data.o
OBJS += dat_ents.o
OBJS += dat_maps.o
OBJS += dat_screens.o
OBJS += dat_snd.o
OBJS += devtools.o
OBJS += draw.o
OBJS += e_bomb.o
OBJS += e_bonus.o
OBJS += e_box.o
OBJS += e_bullet.o
OBJS += ents.o
OBJS += e_rick.o
OBJS += e_sbonus.o
OBJS += e_them.o
OBJS += game.o
OBJS += maps.o
OBJS += rects.o
OBJS += scr_credit.o
OBJS += scr_gameover.o
OBJS += scr_getname.o
OBJS += scr_imain.o
OBJS += scr_imap.o
#OBJS += scr_joykey.o
OBJS += scroller.o
OBJS += scr_pause.o
OBJS += scr_xrick.o
OBJS += sysarg.o
OBJS += sysevt.o
OBJS += sysjoy.o
OBJS += syskbd.o
OBJS += syssnd.o
OBJS += system.o
OBJS += sysvid.o
OBJS += util.o
OBJS += f256.o
# change list of .o's into a list of .d's
DEPS := $(OBJS:%.o=%.d)
AS = merlin32
CC = mos-f256k-clang
LD = mos-f256k-clang
RM = /bin/rm -rfv
CFLAGS = -Os -Wall -Werror -Wa,-al -fno-common
CXXFLAGS = -Os -Wall -Werror -Wa,-al -fno-common
#ASFLAGS = -c -xassembler-with-cpp -Wa,-al
#LDFLAGS = -Wl,-Map,$(TARGET).map $(LIBCMD)
# Clear Default Suffixes
.SUFFIXES:
# Set my Own Suffixes
.SUFFIXES: .c .s .cc .d .o
all: $(TARGET)
$(TARGET): $(DEPS) $(OBJS) $(LIBS)
${CC} $(CFLAGS) $(TMPFLAGS) $(INCCMD) -c ${F256}/f256lib/f256.c -o $(OBJDIR)/f256.o > $(LSTDIR)/$*.lst
$(LD) -o $@ $(addprefix $(OBJDIR)/,$(OBJS)) $(LIBS) $(LDFLAGS)
# Object Rules
.s.o:
$(AS) $(ASFLAGS) $(TMPFLAGS) $(INCCMD) -o $(OBJDIR)/$@ $< > $(LSTDIR)/$*.lst
.c.o:
$(CC) $(CFLAGS) $(TMPFLAGS) $(INCCMD) -c $< -o $(OBJDIR)/$*.o > $(LSTDIR)/$*.lst
.cc.o:
$(CC) $(CXXFLAGS) $(TMPFLAGS) $(INCCMD) -c $< -o $(OBJDIR)/$*.o > $(LSTDIR)/$*.lst
# Dependencie Rules
#
# for now just touch, to create the file if its not defined
#
.s.d:
touch $(DEPDIR)/$*.d
.c.d:
set -e; $(CC) -M $(CFLAGS) $(TMPFLAGS) $(INCCMD) $< \
| sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $(DEPDIR)/$@; \
[ -s $(DEPDIR)/$@ ] || rm -f $(DEPDIR)/$@
.cc.d:
set -e; $(CC) -M $(CXXFLAGS) $(TMPFLAGS) $(INCCMD) $< \
| sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $(DEPDIR)/$@; \
[ -s $(DEPDIR)/$@ ] || rm -f $(DEPDIR)/$@
#.PHONY: install
#install: $(TARGET)
# cp $(TARGET).exe $(PROJROOT)/../bin
.PHONY: clean
clean:
$(RM) $(OBJDIR) *.o $(DEPDIR) *.map $(LSTDIR) $(TARGET) $(TARGET).elf $(TARGET).pgz
########################################
#
# HELPER TARGET RULES
#
########################################
#
# Target that forces all of the objects to be rebuilt if the makefile changes
#
$(OBJS) : Makefile
$(DEPS) : Makefile
#
# Targets that create the output object directory if it doesn't already exist
#
Makefile : $(OBJDIR) $(DEPDIR) $(LSTDIR)
$(OBJDIR) :
$(MKDIR) $(OBJDIR)
#
# Targets that create the output dependency directory if it doesn't already exist
#
$(DEPDIR) :
$(MKDIR) $(DEPDIR)
#
# Targets that create the output list directory if it doesn't already exist
#
$(LSTDIR) :
$(MKDIR) $(LSTDIR)
#
# Generated Dependencie Files
#
-include $(wildcard $(DEPDIR)/*.d)