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-04-27 17:19:52 +02:00
|
|
|
all: $(PROGS)
|
|
|
|
|
|
|
|
mostlyclean:
|
|
|
|
$(RM) -r ../wrk
|
|
|
|
|
|
|
|
clean: mostlyclean
|
|
|
|
$(RM) -r ../bin
|
|
|
|
|
2013-04-28 22:30:18 +02:00
|
|
|
install: all
|
|
|
|
$(foreach prog,$(PROGS),$(INSTALL_recipe))
|
|
|
|
|
|
|
|
uninstall:
|
|
|
|
$(foreach prog,$(PROGS),$(UNINSTALL_recipe))
|
|
|
|
|
|
|
|
.PHONY: all $(PROGS) mostlyclean clean install uninstall
|
|
|
|
|
|
|
|
##########
|
|
|
|
|
2013-04-29 17:01:00 +03:00
|
|
|
define INSTALL_recipe
|
2013-04-28 22:30:18 +02:00
|
|
|
|
|
|
|
ln -s $(abspath ../bin/$(prog)) /usr/local/bin/$(prog)
|
|
|
|
|
|
|
|
endef
|
|
|
|
|
|
|
|
##########
|
|
|
|
|
2013-04-29 17:01:00 +03:00
|
|
|
define UNINSTALL_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
|
|
|
|
|
|
|
$(1)_OBJS := $$(addprefix ../wrk/,$$(addsuffix .o,$$(basename $$(wildcard $(1)/*.c))))
|
|
|
|
|
|
|
|
$$($(1)_OBJS): | ../wrk/$(1)
|
|
|
|
|
|
|
|
../wrk/$(1):
|
|
|
|
mkdir -p $$@
|
|
|
|
|
|
|
|
DEPS += $$($(1)_OBJS:.o=.d)
|
|
|
|
|
|
|
|
endef
|
|
|
|
|
|
|
|
##########
|
|
|
|
|
2013-04-29 17:01:00 +03:00
|
|
|
define PROG_template
|
2013-04-27 17:19:52 +02:00
|
|
|
|
|
|
|
$$(eval $$(call OBJS_template,$(1)))
|
|
|
|
|
|
|
|
../bin/$(1): $$($(1)_OBJS) ../wrk/common/common.a | ../bin
|
2013-04-29 17:03:14 +03:00
|
|
|
$$(CC) $$(LDFLAGS) $$(LDLIBS) -o $$@ $$^
|
2013-04-27 17:19:52 +02:00
|
|
|
|
|
|
|
$(1): ../bin/$(1)
|
|
|
|
|
|
|
|
endef
|
|
|
|
|
|
|
|
##########
|
|
|
|
|
|
|
|
../wrk/%.o: %.c
|
|
|
|
@echo $(CC) $<
|
|
|
|
@$(CC) -c $(CFLAGS) -o $@ $<
|
|
|
|
|
|
|
|
../bin:
|
|
|
|
mkdir $@
|
|
|
|
|
|
|
|
$(eval $(call OBJS_template,common))
|
|
|
|
../wrk/common/common.a: $(common_OBJS)
|
|
|
|
$(AR) r $@ $^
|
|
|
|
|
|
|
|
$(foreach prog,$(PROGS),$(eval $(call PROG_template,$(prog))))
|
|
|
|
|
|
|
|
-include $(DEPS)
|