From 30125afcc1e35059a815852656e8ab27b62e1be8 Mon Sep 17 00:00:00 2001
From: Oliver Schmidt
Date: Thu, 6 Mar 2014 22:32:24 +0100
Subject: [PATCH] Moved from VS2013 to MinGW(-w64).
---
.gitignore | 1 +
.travis.yml | 2 +-
doc/Makefile | 26 ++++++++------
libsrc/Makefile | 77 +++++++++++++++++++--------------------
src/Makefile | 96 ++++++++++++++++++++++++++-----------------------
5 files changed, 105 insertions(+), 97 deletions(-)
diff --git a/.gitignore b/.gitignore
index 5de976c32..3e65003e4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,7 @@
/html/
/joy/
/lib/
+/libwrk/
/mou/
/ser/
/targetutil/
diff --git a/.travis.yml b/.travis.yml
index 3a0ee09a1..1ae62cd1c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,7 +4,7 @@ install:
- sudo apt-get install linuxdoc-tools linuxdoc-tools-info binutils-mingw-w64-i686 gcc-mingw-w64-i686
script:
- make all doc
- - make -C src clean all CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar PROGEXT=.exe
+ - make -C src clean all CROSS_COMPILE=i686-w64-mingw32-
after_success:
- make -C doc gh-pages
env:
diff --git a/doc/Makefile b/doc/Makefile
index 8c2bb902c..02028e66e 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -1,8 +1,18 @@
-.PHONY: all doc html info gh-pages mostlyclean clean install
+ifneq ($(shell echo),)
+ CMD_EXE = 1
+endif
+
+.PHONY: all mostlyclean clean install doc html info gh-pages
.SUFFIXES:
-ifeq ($(shell echo),)
+all mostlyclean install:
+
+ifdef CMD_EXE
+
+clean doc:
+
+else # CMD_EXE
SGMLS := $(wildcard *.sgml)
@@ -13,7 +23,8 @@ TOC_LEVEL = 2
GH_PAGES = ../../gh-pages
-all mostlyclean install:
+clean:
+ $(RM) -r ../html ../info
doc: html info
@@ -21,9 +32,6 @@ html: $(addprefix ../html/,$(SGMLS:.sgml=.html) doc.css doc.png)
info: $(addprefix ../info/,$(SGMLS:.sgml=.info))
-clean:
- $(RM) -r ../html ../info
-
../html ../info:
@mkdir $@
@@ -50,8 +58,4 @@ ifdef GH_TOKEN
git --work-tree=$(GH_PAGES) --git-dir=$(GH_PAGES)/.git push
endif
-else # cmd.exe
-
-all doc mostlyclean clean install:
-
-endif # cmd.exe
+endif # CMD_EXE
diff --git a/libsrc/Makefile b/libsrc/Makefile
index 0a8c844b6..24a958972 100644
--- a/libsrc/Makefile
+++ b/libsrc/Makefile
@@ -1,3 +1,11 @@
+ifneq ($(shell echo),)
+ CMD_EXE = 1
+endif
+
+.PHONY: all mostlyclean clean install lib $(TARGETS)
+
+.SUFFIXES:
+
CBMS = c128 \
c16 \
c64 \
@@ -29,6 +37,15 @@ DRVTYPES = emd \
ser \
tgi
+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
+
# Every target requires its individual vpath setting but the vpath directive
# acts globally. Therefore each target is built in a separate make instance.
@@ -38,45 +55,29 @@ ifeq ($(words $(MAKECMDGOALS)),1)
endif
endif
-DIRLIST = $(strip $(foreach dir,$1,$(wildcard $(dir))))
-
-ifeq ($(shell echo),)
- MKDIR = mkdir -p $1
- RMDIR = $(RM) -r $1
-else
- MKDIR = mkdir $(subst /,\,$1)
- RMDIR = $(if $(DIRLIST),rmdir /s /q $(subst /,\,$(DIRLIST)))
-endif
-
-.SUFFIXES:
-
-.PHONY: all lib $(TARGETS) mostlyclean clean install
-
ifndef TARGET
datadir = $(prefix)/share/cc65
-INSTALLDIRS = ../asminc ../cfg ../include \
- $(filter-out $(wildcard ../include/*.*),$(wildcard ../include/*)) \
- ../lib ../targetutil $(addprefix ../,$(DRVTYPES))
-
-INSTALL = install
-
all lib: $(TARGETS)
-$(TARGETS):
- @$(MAKE) --no-print-directory $@
-
mostlyclean:
$(call RMDIR,../libwrk)
clean:
$(call RMDIR,../libwrk ../lib ../targetutil $(addprefix ../,$(DRVTYPES)))
+ifdef CMD_EXE
+
install:
- $(foreach dir,$(INSTALLDIRS),$(INSTALL_recipe))
-##########
+else # CMD_EXE
+
+INSTALL = install
+
+INSTALLDIRS = ../asminc ../cfg ../include \
+ $(filter-out $(wildcard ../include/*.*),$(wildcard ../include/*)) \
+ ../lib ../targetutil $(addprefix ../,$(DRVTYPES))
define INSTALL_recipe
@@ -84,9 +85,15 @@ $(if $(prefix),,$(error variable `prefix' must be set))
$(INSTALL) -d $(subst ..,$(DESTDIR)$(datadir),$(dir))
$(INSTALL) -m644 $(dir)/*.* $(subst ..,$(DESTDIR)$(datadir),$(dir))
-endef
+endef # INSTALL_recipe
+
+install:
+ $(foreach dir,$(INSTALLDIRS),$(INSTALL_recipe))
+
+endif # CMD_EXE
-##########
+$(TARGETS):
+ @$(MAKE) --no-print-directory $@
else # TARGET
@@ -183,8 +190,6 @@ ifeq ($(TARGET),$(filter $(TARGET),$(TARGETUTIL)))
include $(SRCDIR)/targetutil/Makefile.inc
endif
-##########
-
define DRVTYPE_template
$1_SRCDIR = $$(SRCDIR)/$1
@@ -221,9 +226,7 @@ OBJS += $$($1_STCS)
DEPS += $$($1_OBJS:.o=.d)
-endef
-
-##########
+endef # DRVTYPE_template
$(foreach drvtype,$(DRVTYPES),$(eval $(call DRVTYPE_template,$(drvtype))))
@@ -235,16 +238,12 @@ LD65 := $(if $(wildcard ../bin/ld65*),../bin/ld65,ld65)
export CC65_HOME := $(abspath ..)
-##########
-
define ASSEMBLE_recipe
$(if $(TRAVIS),,@echo $(TARGET) - $<)
@$(CA65) -t $(TARGET) $(CA65FLAGS) --create-dep $(@:.o=.d) -o $@ $<
-endef
-
-##########
+endef # ASSEMBLE_recipe
define COMPILE_recipe
@@ -252,9 +251,7 @@ $(if $(TRAVIS),,@echo $(TARGET) - $<)
@$(CC65) -t $(TARGET) $(CC65FLAGS) --create-dep $(@:.o=.d) --dep-target $@ -o $(@:.o=.s) $<
@$(CA65) -t $(TARGET) -o $@ $(@:.o=.s)
-endef
-
-##########
+endef # COMPILE_recipe
../libwrk/$(TARGET)/%.o: %.s | ../libwrk/$(TARGET)
$(ASSEMBLE_recipe)
diff --git a/src/Makefile b/src/Makefile
index 844f81ca4..87548628b 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,8 +1,10 @@
-.SUFFIXES:
+ifneq ($(shell echo),)
+ CMD_EXE = 1
+endif
-.PHONY: all bin $(PROGS) mostlyclean clean install avail unavail
+.PHONY: all mostlyclean clean install avail unavail bin $(PROGS)
-ifeq ($(shell echo),)
+.SUFFIXES:
PROGS = ar65 \
ca65 \
@@ -25,6 +27,9 @@ LD65_LIB = $(datadir)/lib
LD65_OBJ = $(datadir)/lib
LD65_CFG = $(datadir)/cfg
+CC = $(CROSS_COMPILE)gcc
+AR = $(CROSS_COMPILE)ar
+
CFLAGS += -MMD -MP -O -I common $(USER_CFLAGS) \
-Wall -Wextra -Wno-char-subscripts \
-DCA65_INC=$(CA65_INC) -DCC65_INC=$(CC65_INC) \
@@ -34,44 +39,63 @@ CFLAGS += $(if $(TRAVIS),-Werror)
LDLIBS += -lm
-INSTALL = install
+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
all bin: $(PROGS)
mostlyclean:
- $(RM) -r ../wrk
+ $(call RMDIR,../wrk)
clean:
- $(RM) -r ../wrk ../bin
+ $(call RMDIR,../wrk ../bin)
-install:
- $(if $(prefix),,$(error variable `prefix' must be set))
- $(INSTALL) -d $(DESTDIR)$(bindir)
- $(INSTALL) ../bin/* $(DESTDIR)$(bindir)
+ifdef CMD_EXE
-avail:
- $(foreach prog,$(PROGS),$(AVAIL_recipe))
+install avail unavail:
-unavail:
- $(foreach prog,$(PROGS),$(UNAVAIL_recipe))
+else # CMD_EXE
-##########
+INSTALL = install
define AVAIL_recipe
ln -s $(abspath ../bin/$(prog)) /usr/local/bin/$(prog)
-endef
-
-##########
+endef # AVAIL_recipe
define UNAVAIL_recipe
$(RM) /usr/local/bin/$(prog)
-endef
+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))
-##########
+endif # CMD_EXE
define OBJS_template
@@ -80,53 +104,35 @@ $1_OBJS := $$(patsubst %.c,../wrk/%.o,$$(wildcard $1/*.c))
$$($1_OBJS): | ../wrk/$1
../wrk/$1:
- @mkdir -p $$@
+ @$$(call MKDIR,$$@)
DEPS += $$($1_OBJS:.o=.d)
-endef
-
-##########
+endef # OBJS_template
define PROG_template
$$(eval $$(call OBJS_template,$1))
-../bin/$1$(PROGEXT): $$($1_OBJS) ../wrk/common/common.a | ../bin
+../bin/$1$(EXE_SUFFIX): $$($1_OBJS) ../wrk/common/common.a | ../bin
$$(CC) $$(LDFLAGS) -o $$@ $$^ $$(LDLIBS)
-$1: ../bin/$1$(PROGEXT)
-
-endef
+$1: ../bin/$1$(EXE_SUFFIX)
-##########
+endef # PROG_template
../wrk/%.o: %.c
@echo $<
@$(CC) -c $(CFLAGS) -o $@ $<
../bin:
- @mkdir $@
+ @$(call MKDIR,$@)
$(eval $(call OBJS_template,common))
+
../wrk/common/common.a: $(common_OBJS)
$(AR) r $@ $?
$(foreach prog,$(PROGS),$(eval $(call PROG_template,$(prog))))
-include $(DEPS)
-
-else # cmd.exe
-
-all bin:
- 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:$@
-
-install avail unavail:
-
-endif # cmd.exe
--
2.39.5