2013-05-05 23:46:12 +02:00
|
|
|
ifeq ($(shell echo),)
|
|
|
|
|
2013-04-27 17:19:52 +02:00
|
|
|
PROGS = ar65 \
|
|
|
|
ca65 \
|
|
|
|
cc65 \
|
|
|
|
cl65 \
|
|
|
|
co65 \
|
|
|
|
da65 \
|
|
|
|
grc65 \
|
|
|
|
ld65 \
|
|
|
|
od65 \
|
|
|
|
sp65
|
|
|
|
|
|
|
|
CA65_INC := $(abspath ../asminc)
|
|
|
|
CC65_INC := $(abspath ../include)
|
|
|
|
LD65_LIB := $(abspath ../lib)
|
|
|
|
LD65_OBJ := $(abspath ../lib)
|
|
|
|
LD65_CFG := $(abspath ../cfg)
|
|
|
|
|
|
|
|
CFLAGS += -MMD -MP -O -std=c89 -I common \
|
|
|
|
-Wall -Wextra -Wno-char-subscripts -Werror \
|
|
|
|
-DCA65_INC=$(CA65_INC) -DCC65_INC=$(CC65_INC) \
|
|
|
|
-DLD65_LIB=$(LD65_LIB) -DLD65_OBJ=$(LD65_OBJ) -DLD65_CFG=$(LD65_CFG)
|
|
|
|
|
2013-04-29 17:03:14 +03:00
|
|
|
LDLIBS += -lm
|
|
|
|
|
2013-05-05 22:34:04 +02:00
|
|
|
.SUFFIXES:
|
|
|
|
|
2013-05-15 11:59:51 +02:00
|
|
|
.PHONY: all bin $(PROGS) mostlyclean clean avail unavail
|
2013-05-05 22:34:04 +02:00
|
|
|
|
2013-05-07 17:49:35 +02:00
|
|
|
all bin: $(PROGS)
|
2013-04-27 17:19:52 +02:00
|
|
|
|
|
|
|
mostlyclean:
|
|
|
|
$(RM) -r ../wrk
|
|
|
|
|
2013-05-05 22:34:04 +02:00
|
|
|
clean:
|
|
|
|
$(RM) -r ../wrk ../bin
|
2013-04-27 17:19:52 +02:00
|
|
|
|
2013-05-17 16:21:05 +02:00
|
|
|
avail:
|
2013-05-15 11:59:51 +02:00
|
|
|
$(foreach prog,$(PROGS),$(AVAIL_recipe))
|
2013-04-28 22:30:18 +02:00
|
|
|
|
2013-05-15 11:59:51 +02:00
|
|
|
unavail:
|
|
|
|
$(foreach prog,$(PROGS),$(UNAVAIL_recipe))
|
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)
|
|
|
|
|
|
|
|
endef
|
|
|
|
|
|
|
|
##########
|
|
|
|
|
2013-05-15 11:59:51 +02:00
|
|
|
define UNAVAIL_recipe
|
2013-04-28 22:30:18 +02:00
|
|
|
|
|
|
|
$(RM) /usr/local/bin/$(prog)
|
|
|
|
|
|
|
|
endef
|
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:
|
2013-05-05 22:34:04 +02:00
|
|
|
@mkdir -p $$@
|
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
|
|
|
|
|
|
|
endef
|
|
|
|
|
|
|
|
##########
|
|
|
|
|
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
|
|
|
|
2013-05-04 11:59:42 +02:00
|
|
|
../bin/$1: $$($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
|
|
|
|
2013-05-04 11:59:42 +02:00
|
|
|
$1: ../bin/$1
|
2013-04-27 17:19:52 +02:00
|
|
|
|
|
|
|
endef
|
|
|
|
|
|
|
|
##########
|
|
|
|
|
|
|
|
../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:
|
2013-05-05 22:34:04 +02:00
|
|
|
@mkdir $@
|
2013-04-27 17:19:52 +02:00
|
|
|
|
|
|
|
$(eval $(call OBJS_template,common))
|
|
|
|
../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)
|
2013-05-05 23:46:12 +02:00
|
|
|
|
|
|
|
else # cmd.exe
|
|
|
|
|
|
|
|
.SUFFIXES:
|
|
|
|
|
2013-05-07 17:49:35 +02:00
|
|
|
.PHONY: all bin mostlyclean clean
|
2013-05-05 23:46:12 +02:00
|
|
|
|
2013-05-07 17:49:35 +02:00
|
|
|
all bin:
|
2013-05-05 23:46:12 +02:00
|
|
|
msbuild cc65.sln /p:configuration=release /consoleloggerparameters:disableconsolecolor
|
|
|
|
|
|
|
|
mostlyclean:
|
|
|
|
$(if $(wildcard ../wrk),rmdir /s /q ..\wrk)
|
|
|
|
|
|
|
|
clean:
|
|
|
|
msbuild cc65.sln /p:configuration=release /consoleloggerparameters:disableconsolecolor /target:$@
|
|
|
|
|
|
|
|
endif # cmd.exe
|