1##############################################################################
2## Source-level Makefile for jzintv in Emscripten
3##
4## The whole make process is driven from the top-level Makefile.  In contrast
5## to the (poor) advice given in the Make documentation, I do _not_ call make
6## recursively to build the source of this project.
7##############################################################################
8
9##############################################################################
10## Project directory structure
11##############################################################################
12B=../bin
13L=../lib
14R=../rom
15
16##############################################################################
17## Project-wide build flags
18##############################################################################
19P           = export PATH;
20
21.SUFFIXES: .html
22
23SDL1_CFLAGS :=
24SDL1_LFLAGS := -lSDL
25
26SVN_REV := $(shell (svn info -R || :) | grep "Last Changed Rev:" | cut -d' ' -f4 | sort -n | tail -1)
27SVN_DTY := $(shell echo $$( (svn status || :) | grep -v '^?' | wc -l ) )
28
29# Set "X" to be the executable extension, and "O" to be the object extension.
30X = .html
31O = o
32
33# Set "RM" to be the remove/delete command
34RM = rm -f
35
36# Rely on mainstream targets for warning checks.
37 WARN    = -Wall -W -Wextra
38 WARNXX  = -Wall -W -Wextra
39
40 CC  = $(P) emcc -fwrapv
41 CXX = $(P) em++ --std=c++14 -fwrapv
42
43#DEF_FLAGS += -DDIRECT_INTV2PC
44#DEF_FLAGS += -DNEED_INOUT
45
46 LTO =
47
48 OPT_FLAGS =  $(LTO) -O3
49#OPT_FLAGS =  $(LTO) -g3
50
51CFLAGS   = $(OPT_FLAGS) $(WARN)   -I. -I.. $(DEF_FLAGS) $(EXTRA)
52CXXFLAGS = $(OPT_FLAGS) $(WARNXX) -I. -I.. $(DEF_FLAGS) $(EXTRA)
53
54CFLAGS   += -s NO_EXIT_RUNTIME=0 -s TOTAL_MEMORY=134217728
55CXXFLAGS += -s NO_EXIT_RUNTIME=0 -s TOTAL_MEMORY=134217728
56
57OBJS      = jzintv_em.$(O)
58PROG_SDL1 = $(B)/jzintv$(X)
59PROG_NULL = $(B)/jzintv_batch$(X)
60TOCLEAN  += $(PROG_SDL1)
61TOCLEAN  += $(PROG_NULL)
62TOCLEAN  += core
63
64CFLAGS += $(SDL1_CFLAGS)
65
66##############################################################################
67## Generic build-rules
68##############################################################################
69
70all: build
71
72$(PROG_SDL1): $(OBJS) $(OBJS_SDL1)
73	$(CXX) -o $(PROG_SDL1) $(OBJS) $(OBJS_SDL1) $(CFLAGS) $(SDL1_LFLAGS) $(LFLAGS)
74
75clean:
76	$(RM) $(OBJS)
77	$(RM) $(OBJS_SDL1)
78	$(RM) $(OBJS_NULL)
79	$(RM) $(TOCLEAN)
80
81%.$(O): %.c
82	$(CC) -o $@ $(CFLAGS) -c $<
83
84%.s: %.c
85	$(CC) -fverbose-asm -S -o $@ $(CFLAGS) -c $<
86
87##############################################################################
88## Emscripten-specific stuff
89##############################################################################
90
91pads/pads_intv2pc.$(O):
92	$(CC) -O3 -o pads/pads_intv2pc.$(O) $(CFLAGS) -c pads/pads_intv2pc.c
93
94OBJS_SDL1 += pads/pads_cgc_linux.$(O)
95OBJS += pads/pads_intv2pc.$(O)
96
97##############################################################################
98## Makefile.common includes all the subMakefiles and such
99##############################################################################
100include emscripten/subMakefile
101include Makefile.common
102build: jzIntv
103
104jzintv_em.$(O): config.h periph/periph.h cp1600/cp1600.h mem/mem.h
105jzintv_em.$(O): pads/pads.h debug/debug_.h cp1600/op_decode.h cp1600/op_exec.h
106jzintv_em.$(O): stic/stic.h speed/speed.h gfx/gfx.h snd/snd.h ay8910/ay8910.h
107jzintv_em.$(O): plat/plat.h plat/plat_lib.h event/event.h event/event_tbl.h
108jzintv_em.$(O): file/file.h ivoice/ivoice.h icart/icart.h cp1600/req_q.h
109jzintv_em.$(O): bincfg/legacy.h bincfg/bincfg.h pads/pads_intv2pc.h
110jzintv_em.$(O): demo/demo.h cfg/cfg.h cfg/mapping.h misc/jzprint.h avi/avi.h
111jzintv_em.$(O): name/name.h misc/file_crc32.h jlp/jlp.h locutus/locutus_adapt.h
112jzintv_em.$(O): emscripten/web_files.h
113
114