2014-03-06 22:32:24 +01:00
|
|
|
ifneq ($(shell echo),)
|
|
|
|
CMD_EXE = 1
|
|
|
|
endif
|
2014-02-05 22:31:46 +01:00
|
|
|
|
2022-04-25 14:58:38 +00:00
|
|
|
ifneq ($(V),1)
|
|
|
|
Q=@
|
|
|
|
else
|
|
|
|
Q=
|
|
|
|
endif
|
|
|
|
|
2016-03-27 19:09:00 +02:00
|
|
|
PROGS = ar65 \
|
|
|
|
ca65 \
|
|
|
|
cc65 \
|
|
|
|
chrcvt65 \
|
|
|
|
cl65 \
|
|
|
|
co65 \
|
|
|
|
da65 \
|
|
|
|
grc65 \
|
|
|
|
ld65 \
|
|
|
|
od65 \
|
|
|
|
sim65 \
|
2013-04-27 17:19:52 +02:00
|
|
|
sp65
|
|
|
|
|
2014-03-09 00:19:57 +01:00
|
|
|
.PHONY: all mostlyclean clean install zip avail unavail bin $(PROGS)
|
2014-03-06 23:42:44 +01:00
|
|
|
|
|
|
|
.SUFFIXES:
|
|
|
|
|
2017-07-22 16:38:50 +02:00
|
|
|
bindir := $(PREFIX)/bin
|
2022-04-27 16:17:04 +00:00
|
|
|
datadir := $(PREFIX)/share/cc65
|
2014-01-29 21:42:26 +01:00
|
|
|
|
|
|
|
CA65_INC = $(datadir)/asminc
|
|
|
|
CC65_INC = $(datadir)/include
|
2016-06-03 11:08:53 +02:00
|
|
|
CL65_TGT = $(datadir)/target
|
2014-01-29 21:42:26 +01:00
|
|
|
LD65_LIB = $(datadir)/lib
|
|
|
|
LD65_OBJ = $(datadir)/lib
|
|
|
|
LD65_CFG = $(datadir)/cfg
|
2013-04-27 17:19:52 +02:00
|
|
|
|
2014-03-27 21:40:28 +01:00
|
|
|
ifdef CMD_EXE
|
|
|
|
NULLDEV = nul:
|
|
|
|
DIRLIST = $(strip $(foreach dir,$1,$(wildcard $(dir))))
|
|
|
|
MKDIR = mkdir $(subst /,\,$1)
|
|
|
|
RMDIR = $(if $(DIRLIST),rmdir /s /q $(subst /,\,$(DIRLIST)))
|
|
|
|
else
|
2014-03-27 22:07:08 +01:00
|
|
|
NULLDEV = /dev/null
|
2014-03-27 21:40:28 +01:00
|
|
|
MKDIR = mkdir -p $1
|
|
|
|
RMDIR = $(RM) -r $1
|
|
|
|
endif
|
|
|
|
|
2014-03-06 22:32:24 +01:00
|
|
|
CC = $(CROSS_COMPILE)gcc
|
|
|
|
AR = $(CROSS_COMPILE)ar
|
|
|
|
|
2014-03-16 21:31:00 +01:00
|
|
|
ifdef CROSS_COMPILE
|
|
|
|
$(info CC: $(CC))
|
|
|
|
$(info AR: $(AR))
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifdef USER_CFLAGS
|
|
|
|
$(info USER_CFLAGS: $(USER_CFLAGS))
|
|
|
|
endif
|
|
|
|
|
2019-07-14 09:28:49 +02:00
|
|
|
ifndef BUILD_ID
|
2019-06-09 01:19:53 +02:00
|
|
|
BUILD_ID := Git $(shell git rev-parse --short HEAD 2>$(NULLDEV) || svnversion 2>$(NULLDEV))
|
|
|
|
ifneq ($(words $(BUILD_ID)),2)
|
|
|
|
BUILD_ID := N/A
|
2014-03-18 22:40:30 +01:00
|
|
|
endif
|
|
|
|
endif
|
2019-07-14 09:28:49 +02:00
|
|
|
$(info BUILD_ID: $(BUILD_ID))
|
2014-03-18 22:40:30 +01:00
|
|
|
|
2017-05-17 18:30:12 +02:00
|
|
|
CFLAGS += -MMD -MP -O3 -I common \
|
2014-03-09 15:17:51 +01:00
|
|
|
-Wall -Wextra -Wno-char-subscripts $(USER_CFLAGS) \
|
2022-04-25 16:52:46 +00:00
|
|
|
-DCA65_INC="\"$(CA65_INC)\"" -DCC65_INC="\"$(CC65_INC)\"" -DCL65_TGT="\"$(CL65_TGT)\"" \
|
|
|
|
-DLD65_LIB="\"$(LD65_LIB)\"" -DLD65_OBJ="\"$(LD65_OBJ)\"" -DLD65_CFG="\"$(LD65_CFG)\"" \
|
|
|
|
-DBUILD_ID="\"$(BUILD_ID)\""
|
2013-04-27 17:19:52 +02:00
|
|
|
|
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
|
|
|
|
|
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:
|
|
|
|
$(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
|
|
|
|
2014-03-09 00:19:57 +01:00
|
|
|
zip:
|
2014-03-09 01:20:39 +01:00
|
|
|
@cd .. && zip cc65 bin/*
|
2022-03-12 01:35:33 -05:00
|
|
|
@echo 'https://github.com/cc65/cc65/commits/'$(word 2,$(BUILD_ID))|zip -zq ../cc65
|
2014-03-09 00:19:57 +01: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 $<
|
2022-04-25 14:58:38 +00:00
|
|
|
$(Q)$(CC) -c $(CFLAGS) -o $@ $<
|
2013-04-27 17:19:52 +02:00
|
|
|
|
|
|
|
../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)
|