Update README.md
[sm64pc.git] / tools / Makefile
blobb8c84775ca9c2fb74c9c07ff942a2fc084fff5ff
1 UNAME := $(shell uname)
2 DEBUG ?= 0
4 ifeq ($(UNAME),Darwin)
5 OSX_BUILD := -DOSX_BUILD
6 endif
8 ifeq ($(DEBUG),1)
9 OPT_FLAG := -g
10 else
11 OPT_FLAG := -O2
12 endif
14 CC := gcc
15 CXX := g++
16 CFLAGS := -Llib -Iinclude -I../include -I . -Wall -Wextra -Wno-unused-parameter $(OSX_BUILD) -pedantic -std=c99 $(OPT_FLAG) -s
17 PROGRAMS := n64graphics n64graphics_ci mio0 n64cksum textconv patch_libultra_math iplfontutil aifc_decode aiff_extract_codebook vadpcm_enc tabledesign extract_data_for_mio skyconv
19 n64graphics_SOURCES := n64graphics.c utils.c
20 n64graphics_CFLAGS := -DN64GRAPHICS_STANDALONE
22 n64graphics_ci_SOURCES := n64graphics_ci_dir/n64graphics_ci.c n64graphics_ci_dir/exoquant/exoquant.c n64graphics_ci_dir/utils.c
23 n64graphics_ci_CFLAGS := $(OPT_FLAG)
25 mio0_SOURCES := libmio0.c
26 mio0_CFLAGS := -DMIO0_STANDALONE
28 n64cksum_SOURCES := n64cksum.c libmio0.c libsm64.c utils.c
30 textconv_SOURCES := textconv.c utf8.c hashtable.c
31 patch_libultra_math_SOURCES := patch_libultra_math.c
33 iplfontutil_SOURCES := iplfontutil.c
34 iplfontutil_CFLAGS := $(OPT_FLAG)
36 aifc_decode_SOURCES := aifc_decode.c
37 aifc_decode_CFLAGS := $(OPT_FLAG)
39 aiff_extract_codebook_SOURCES := aiff_extract_codebook.c
41 tabledesign_SOURCES := sdk-tools/tabledesign/codebook.c sdk-tools/tabledesign/estimate.c sdk-tools/tabledesign/print.c sdk-tools/tabledesign/tabledesign.c
42 tabledesign_CFLAGS := -Wno-uninitialized -Iaudiofile -Laudiofile -laudiofile -lstdc++ -lm
44 vadpcm_enc_SOURCES := sdk-tools/adpcm/vadpcm_enc.c sdk-tools/adpcm/vpredictor.c sdk-tools/adpcm/quant.c sdk-tools/adpcm/util.c sdk-tools/adpcm/vencode.c
45 vadpcm_enc_CFLAGS := -Wno-unused-result -Wno-uninitialized -Wno-sign-compare -Wno-absolute-value
47 extract_data_for_mio_SOURCES := extract_data_for_mio.c
48 extract_data_for_mio_CFLAGS := $(OPT_FLAG)
50 skyconv_SOURCES := skyconv.c n64graphics.c utils.c
51 skyconv_CFLAGS := $(OPT_FLAG) -lm
53 LIBAUDIOFILE := audiofile/libaudiofile.a
55 all: $(LIBAUDIOFILE) $(PROGRAMS)
57 $(LIBAUDIOFILE):
58 @$(MAKE) -C audiofile
60 clean:
61 $(RM) $(PROGRAMS)
62 $(RM) gen_asset_list
63 $(MAKE) -C audiofile clean
65 define COMPILE
66 $(1): $($1_SOURCES)
67 $(CC) $(CFLAGS) $(OSX_BUILD) $$^ -lm -o $$@ $($1_CFLAGS)
68 endef
70 # Separate build for debugging gen_asset_list.cpp
71 gen_asset_list:
72 $(CXX) -std=c++17 gen_asset_list.cpp -lstdc++fs $(OPT_FLAG) -Wall -o gen_asset_list
74 $(foreach p,$(PROGRAMS),$(eval $(call COMPILE,$(p))))