hzmachine

Hiptop Z Machine
git clone http://frotz.net/git/hzmachine.git
Log | Files | Refs | LICENSE

hiptop.mk (3108B)


      1 
      2 # Set this to color or gray
      3 #
      4 SCREEN     ?= color
      5 
      6 # Use this line to build against the released SDK
      7 #
      8 #SDKHOME    := /home/swetland/sdk-40194
      9 
     10 # Use this line to build against a check out from 
     11 # revision control.  Not useful for non-Danger people.
     12 #
     13 #TREE       := /home/swetland/exp/platform
     14 
     15 
     16 # -----------------------------------------------------------------------
     17 #
     18 # Apps needed for the build.
     19 #
     20 MD5SUM     := md5sum
     21 JAVAC      := javac
     22 JAVA       := java
     23 
     24 # -----------------------------------------------------------------------
     25 #
     26 # The bits from here down should not need to be modified...
     27 #
     28 #
     29 ifneq ($(TREE),)
     30 LIBRARY    := $(TREE)/libdanger/classes
     31 TOOLS      := $(TREE)/bin
     32 LINK       := $(TREE)/target/libs/library.link
     33 else
     34 ERROR      := You must set SDKHOME
     35 endif
     36 
     37 ifneq ($(SDKHOME),)
     38 TOOLS      := $(SDKHOME)/tools/linux
     39 LIBRARY    := $(SDKHOME)/libs/library.jar
     40 LINK       := $(SDKHOME)/libs/library.link
     41 LIBS       := $(SDKHOME)/libs
     42 ERROR      :=
     43 endif
     44 
     45 MKBUNDLE   := $(TOOLS)/mkbundle
     46 DRC        := $(TOOLS)/drc 
     47 
     48 ifeq ($(APPNAME),)
     49 ERROR      := You must set APPNAME
     50 endif
     51 
     52 ifneq ($(ERROR),)
     53 all:
     54 	@echo "*** ERROR: $(ERROR)"
     55 else
     56 
     57 ifeq ($(SCREEN),color)
     58 SIMFLAGS   := -Dcom.danger.screen.color_space=color16
     59 else
     60 SIMFLAGS   := -Dcom.danger.screen.color_space=gray
     61 endif
     62 
     63 JFLAGS     := -classpath $(LIBRARY):. -d classes
     64 
     65 BUNDLE     := $(APPNAME).bndl
     66 RSRC_SRC   := $(APPNAME).rsrc
     67 RSRC_DB    := $(APPNAME)-$(SCREEN).rdb
     68 
     69 # SRCS must be all source files, including the INTERFACES
     70 # which may or may not exist in the filesystem when we
     71 # first do a build (because clean removes them)
     72 #
     73 SRCS       := $(shell find . -name \*.java) 
     74 SRCS       := $(filter-out $(addprefix ./, $(INTERFACES)),$(SRCS))
     75 SRCS       += $(INTERFACES)
     76 
     77 # javac likes to figure out its own depend stuff but invariably screws
     78 # stuff up for me -- let's just find all the java files and force a
     79 # rebuild if the list of files changes in any way (files added, removed,
     80 # etc).  When we build, we nuke the classes/ directory so that we don't
     81 # suffer when we remove a .java file and the .class file lingers
     82 #
     83 STAMP      := $(shell find . -name \*.java | $(MD5SUM) | sed 's/.\ .*//g')
     84 STAMPFILE  := stamp.$(STAMP)
     85 
     86 all: $(STAMPFILE) $(APPNAME).bndl
     87 
     88 $(STAMPFILE): $(SRCS) $(RSRC_DB)
     89 	@rm -rf classes stamp.* 
     90 	@mkdir -p classes
     91 	$(JAVAC) $(JFLAGS) $(SRCS)
     92 	$(MKBUNDLE) -o classes/application.dat $(RSRC_DB)
     93 	@touch $(STAMPFILE)
     94 
     95 $(INTERFACES): $(RSRC_SRC)
     96 	$(DRC) -i $<
     97 
     98 %-gray.rdb: %.rsrc
     99 	$(DRC) -i $< -o $@ 
    100 
    101 %-color.rdb: %.rsrc
    102 	$(DRC) -C -i $< -o $@ 
    103 
    104 ifneq ($(BUNDLENAME),)
    105 SIMFLAGS += -Dcom.danger.autoboot=$(BUNDLENAME)
    106 endif
    107 
    108 SIMCLASSPATH := -classpath $(LIBS)/simulator.jar:$(LIBS)/library.jar:classes
    109 
    110 run: $(STAMPFILE) 
    111 	$(JAVA) $(SIMFLAGS) $(SIMCLASSPATH) danger.Boot 
    112 
    113 run-gray: $(STAMPFILE) 
    114 	$(JAVA) -Dcom.danger.screen.color_space=gray $(SIMFLAGS) $(SIMCLASSPATH) danger.Boot 
    115 
    116 %.bndl: $(STAMPFILE) $(RSRC_DB)
    117 	$(MKBUNDLE) -o $@ $(LINK) classes $(RSRC_DB) -l $(APPNAME).lst 
    118 ifneq ($(TREE),)
    119 	cp -f $@ $(TREE)/target
    120 endif
    121 
    122 clean::
    123 	rm -rf classes $(INTERFACES) *~ *.rdb *.bndl *.lst stamp.* 
    124 
    125 endif