2014-03-06 22:32:24 +01:00
|
|
|
ifneq ($(shell echo),)
|
|
|
|
CMD_EXE = 1
|
|
|
|
endif
|
2014-02-05 22:31:46 +01:00
|
|
|
|
2013-04-27 17:19:52 +02:00
|
|
|
PROGS = ar65 \
|
|
|
|
ca65 \
|
|
|
|
cc65 \
|
|
|
|
cl65 \
|
|
|
|
co65 \
|
|
|
|
da65 \
|
|
|
|
grc65 \
|
|
|
|
ld65 \
|
|
|
|
od65 \
|
2013-05-20 20:20:14 +02:00
|
|
|
sim65 \
|
2013-04-27 17:19:52 +02:00
|
|
|
sp65
|
|
|
|
|
2014-03-06 23:42:44 +01:00
|
|
|
.PHONY: all mostlyclean clean install avail unavail bin $(PROGS)
|
|
|
|
|
|
|
|
.SUFFIXES:
|
|
|
|
|
2014-01-29 21:42:26 +01:00
|
|
|
bindir := $(prefix)/bin
|
|
|
|
datadir := $(if $(prefix),$(prefix)/share/cc65,$(abspath ..))
|
|
|
|
|
|
|
|
CA65_INC = $(datadir)/asminc
|
|
|
|
CC65_INC = $(datadir)/include
|
|
|
|
LD65_LIB = $(datadir)/lib
|
|
|
|
LD65_OBJ = $(datadir)/lib
|
|
|
|
LD65_CFG = $(datadir)/cfg
|
2013-04-27 17:19:52 +02:00
|
|
|
|
2014-03-06 22:32:24 +01:00
|
|
|
CC = $(CROSS_COMPILE)gcc
|
|
|
|
AR = $(CROSS_COMPILE)ar
|
|
|
|
|
2014-03-05 13:03:33 +01:00
|
|
|
CFLAGS += -MMD -MP -O -I common $(USER_CFLAGS) \
|
|
|
|
-Wall -Wextra -Wno-char-subscripts \
|
2013-04-27 17:19:52 +02:00
|
|
|
-DCA65_INC=$(CA65_INC) -DCC65_INC=$(CC65_INC) \
|
2013-12-19 09:17:41 +01:00
|
|
|
-DLD65_LIB=$(LD65_LIB) -DLD65_OBJ=$(LD65_OBJ) -DLD65_CFG=$(LD65_CFG)
|
2013-04-27 17:19:52 +02:00
|
|
|
|
2014-02-09 19:48:30 +01:00
|
|
|
CFLAGS += $(if $(TRAVIS),-Werror)
|
|
|
|
|
2013-04-29 17:03:14 +03:00
|
|
|
LDLIBS += -lm
|
|
|
|
|
2014-03-06 22:32:24 +01:00
|
|
|
ifdef CMD_EXE
|
|
|
|
EXE_SUFFIX=.exe
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifdef CROSS_COMPILE
|
|
|
|
EXE_SUFFIX=.exe
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifdef CMD_EXE
|
|
|
|
DIRLIST = $(strip $(foreach dir,$1,$(wildcard $(dir))))
|
|
|
|
MKDIR = mkdir $(subst /,\,$1)
|
|
|
|
RMDIR = $(if $(DIRLIST),rmdir /s /q $(subst /,\,$(DIRLIST)))
|
|
|
|
else
|
|
|
|
MKDIR = mkdir -p $1
|
|
|
|
RMDIR = $(RM) -r $1
|
|
|
|
endif
|
2014-01-29 21:42:26 +01:00
|
|
|
|
2013-05-07 17:49:35 +02:00
|
|
|
all bin: $(PROGS)
|
2013-04-27 17:19:52 +02:00
|
|
|
|
|
|
|
mostlyclean:
|
2014-03-06 22:32:24 +01:00
|
|
|
$(call RMDIR,../wrk)
|
2013-04-27 17:19:52 +02:00
|
|
|
|
2013-05-05 22:34:04 +02:00
|
|
|
clean:
|
2014-03-06 22:32:24 +01:00
|
|
|
$(call RMDIR,../wrk ../bin)
|
2013-04-27 17:19:52 +02:00
|
|
|
|
2014-03-06 22:32:24 +01:00
|
|
|
ifdef CMD_EXE
|
2014-01-29 21:42:26 +01:00
|
|
|
|
2014-03-06 22:32:24 +01:00
|
|
|
install avail unavail:
|
2013-04-28 22:30:18 +02:00
|
|
|
|
2014-03-06 22:32:24 +01:00
|
|
|
else # CMD_EXE
|
2013-04-28 22:30:18 +02:00
|
|
|
|
2014-03-06 22:32:24 +01:00
|
|
|
INSTALL = install
|
2013-04-28 22:30:18 +02:00
|
|
|
|
2013-05-15 11:59:51 +02:00
|
|
|
define AVAIL_recipe
|
2013-04-28 22:30:18 +02:00
|
|
|
|
|
|
|
ln -s $(abspath ../bin/$(prog)) /usr/local/bin/$(prog)
|
|
|
|
|
2014-03-06 22:32:24 +01:00
|
|
|
endef # AVAIL_recipe
|
2013-04-28 22:30:18 +02:00
|
|
|
|
2013-05-15 11:59:51 +02:00
|
|
|
define UNAVAIL_recipe
|
2013-04-28 22:30:18 +02:00
|
|
|
|
|
|
|
$(RM) /usr/local/bin/$(prog)
|
|
|
|
|
2014-03-06 22:32:24 +01:00
|
|
|
endef # UNAVAIL_recipe
|
|
|
|
|
|
|
|
install:
|
|
|
|
$(if $(prefix),,$(error variable `prefix' must be set))
|
|
|
|
$(INSTALL) -d $(DESTDIR)$(bindir)
|
|
|
|
$(INSTALL) ../bin/* $(DESTDIR)$(bindir)
|
|
|
|
|
|
|
|
avail:
|
|
|
|
$(foreach prog,$(PROGS),$(AVAIL_recipe))
|
|
|
|
|
|
|
|
unavail:
|
|
|
|
$(foreach prog,$(PROGS),$(UNAVAIL_recipe))
|
2013-04-27 17:19:52 +02:00
|
|
|
|
2014-03-06 22:32:24 +01:00
|
|
|
endif # CMD_EXE
|
2013-04-27 17:19:52 +02:00
|
|
|
|
2013-04-29 17:01:00 +03:00
|
|
|
define OBJS_template
|
2013-04-27 17:19:52 +02:00
|
|
|
|
2013-05-04 11:59:42 +02:00
|
|
|
$1_OBJS := $$(patsubst %.c,../wrk/%.o,$$(wildcard $1/*.c))
|
2013-04-27 17:19:52 +02:00
|
|
|
|
2013-05-04 11:59:42 +02:00
|
|
|
$$($1_OBJS): | ../wrk/$1
|
2013-04-27 17:19:52 +02:00
|
|
|
|
2013-05-04 11:59:42 +02:00
|
|
|
../wrk/$1:
|
2014-03-06 22:32:24 +01:00
|
|
|
@$$(call MKDIR,$$@)
|
2013-04-27 17:19:52 +02:00
|
|
|
|
2013-05-04 11:59:42 +02:00
|
|
|
DEPS += $$($1_OBJS:.o=.d)
|
2013-04-27 17:19:52 +02:00
|
|
|
|
2014-03-06 22:32:24 +01:00
|
|
|
endef # OBJS_template
|
2013-04-27 17:19:52 +02:00
|
|
|
|
2013-04-29 17:01:00 +03:00
|
|
|
define PROG_template
|
2013-04-27 17:19:52 +02:00
|
|
|
|
2013-05-04 11:59:42 +02:00
|
|
|
$$(eval $$(call OBJS_template,$1))
|
2013-04-27 17:19:52 +02:00
|
|
|
|
2014-03-06 22:32:24 +01:00
|
|
|
../bin/$1$(EXE_SUFFIX): $$($1_OBJS) ../wrk/common/common.a | ../bin
|
2013-05-02 15:06:02 +03:00
|
|
|
$$(CC) $$(LDFLAGS) -o $$@ $$^ $$(LDLIBS)
|
2013-04-27 17:19:52 +02:00
|
|
|
|
2014-03-06 22:32:24 +01:00
|
|
|
$1: ../bin/$1$(EXE_SUFFIX)
|
2013-04-27 17:19:52 +02:00
|
|
|
|
2014-03-06 22:32:24 +01:00
|
|
|
endef # PROG_template
|
2013-04-27 17:19:52 +02:00
|
|
|
|
|
|
|
../wrk/%.o: %.c
|
2013-05-05 22:34:04 +02:00
|
|
|
@echo $<
|
2013-04-27 17:19:52 +02:00
|
|
|
@$(CC) -c $(CFLAGS) -o $@ $<
|
|
|
|
|
|
|
|
../bin:
|
2014-03-06 22:32:24 +01:00
|
|
|
@$(call MKDIR,$@)
|
2013-04-27 17:19:52 +02:00
|
|
|
|
|
|
|
$(eval $(call OBJS_template,common))
|
2014-03-06 22:32:24 +01:00
|
|
|
|
2013-04-27 17:19:52 +02:00
|
|
|
../wrk/common/common.a: $(common_OBJS)
|
2013-04-29 17:14:08 +03:00
|
|
|
$(AR) r $@ $?
|
2013-04-27 17:19:52 +02:00
|
|
|
|
|
|
|
$(foreach prog,$(PROGS),$(eval $(call PROG_template,$(prog))))
|
|
|
|
|
|
|
|
-include $(DEPS)
|