17 .PHONY: all mostlyclean clean install zip avail unavail bin $(PROGS)
21 bindir := $(prefix)/bin
22 datadir := $(if $(prefix),$(prefix)/share/cc65,$(abspath ..))
24 CA65_INC = $(datadir)/asminc
25 CC65_INC = $(datadir)/include
26 LD65_LIB = $(datadir)/lib
27 LD65_OBJ = $(datadir)/lib
28 LD65_CFG = $(datadir)/cfg
30 CC = $(CROSS_COMPILE)gcc
31 AR = $(CROSS_COMPILE)ar
33 CFLAGS += -MMD -MP -O -I common \
34 -Wall -Wextra -Wno-char-subscripts $(USER_CFLAGS) \
35 -DCA65_INC=$(CA65_INC) -DCC65_INC=$(CC65_INC) \
36 -DLD65_LIB=$(LD65_LIB) -DLD65_OBJ=$(LD65_OBJ) -DLD65_CFG=$(LD65_CFG)
38 CFLAGS += $(if $(TRAVIS),-Werror)
51 DIRLIST = $(strip $(foreach dir,$1,$(wildcard $(dir))))
52 MKDIR = mkdir $(subst /,\,$1)
53 RMDIR = $(if $(DIRLIST),rmdir /s /q $(subst /,\,$(DIRLIST)))
65 $(call RMDIR,../wrk ../bin)
69 install avail unavail:
77 ln -s $(abspath ../bin/$(prog)) /usr/local/bin/$(prog)
83 $(RM) /usr/local/bin/$(prog)
85 endef # UNAVAIL_recipe
88 $(if $(prefix),,$(error variable `prefix' must be set))
89 $(INSTALL) -d $(DESTDIR)$(bindir)
90 $(INSTALL) ../bin/* $(DESTDIR)$(bindir)
93 $(foreach prog,$(PROGS),$(AVAIL_recipe))
96 $(foreach prog,$(PROGS),$(UNAVAIL_recipe))
101 @cd .. && zip cc65 bin/*
105 $1_OBJS := $$(patsubst %.c,../wrk/%.o,$$(wildcard $1/*.c))
107 $$($1_OBJS): | ../wrk/$1
112 DEPS += $$($1_OBJS:.o=.d)
114 endef # OBJS_template
118 $$(eval $$(call OBJS_template,$1))
120 ../bin/$1$(EXE_SUFFIX): $$($1_OBJS) ../wrk/common/common.a | ../bin
121 $$(CC) $$(LDFLAGS) -o $$@ $$^ $$(LDLIBS)
123 $1: ../bin/$1$(EXE_SUFFIX)
125 endef # PROG_template
129 @$(CC) -c $(CFLAGS) -o $@ $<
134 $(eval $(call OBJS_template,common))
136 ../wrk/common/common.a: $(common_OBJS)
139 $(foreach prog,$(PROGS),$(eval $(call PROG_template,$(prog))))