Skip to content

Commit

Permalink
Fix Makefiles to pass mingw-64 builds
Browse files Browse the repository at this point in the history
Uniformize usage of EXESUFFIX instead of EXE in all makefiles; add setting of EXESUFFIX to a few Makefiles where it was missing and caused the build in mingw-32 to fail.

Add a crude rule to the top-level Makefile to build each of the bin/ tools if any of the *.c or *.h in the respective sources are out-of-date. This fixes the problem of working with out-of-date tools fetched from bin/.

Uniformize z80asm Makefile to build on the install: target, so that the top level Makefile only calls the z80asm one once.
  • Loading branch information
pauloscustodio committed Feb 17, 2019
1 parent 65b7bde commit eb7a4f5
Show file tree
Hide file tree
Showing 23 changed files with 233 additions and 120 deletions.
37 changes: 19 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#

# ---> Configurable parameters are below his point

# EXESUFFIX is passed when cross-compiling Win32 on Linux
ifeq ($(OS),Windows_NT)
EXESUFFIX := .exe
else
Expand Down Expand Up @@ -77,56 +79,55 @@ bin/zsdcc$(EXESUFFIX):
cd $(SDCC_PATH) && mv ./bin/sdcpp $(Z88DK_PATH)/bin/zsdcpp
$(RM) -fR $(SDCC_PATH)

bin/appmake$(EXESUFFIX):
bin/appmake$(EXESUFFIX): $(wildcard src/appmake/*.c src/appmake/*.h)
$(MAKE) -C src/appmake PREFIX=`pwd` install

bin/z88dk-copt$(EXESUFFIX):
bin/z88dk-copt$(EXESUFFIX): $(wildcard src/copt/*.c src/copt/*.h)
$(MAKE) -C src/copt PREFIX=`pwd` install

bin/z88dk-ucpp$(EXESUFFIX):
bin/z88dk-ucpp$(EXESUFFIX): $(wildcard src/ucpp/*.c src/ucpp/*.h)
$(MAKE) -C src/ucpp PREFIX=`pwd` install

bin/z88dk-zcpp$(EXESUFFIX):
bin/z88dk-zcpp$(EXESUFFIX): $(wildcard src/cpp/*.c src/cpp/*.h)
$(MAKE) -C src/cpp PREFIX=`pwd` install

bin/sccz80$(EXESUFFIX):
bin/sccz80$(EXESUFFIX): $(wildcard src/sccz80/*.c src/sccz80/*.h)
$(MAKE) -C src/sccz80 PREFIX=`pwd` install

bin/z80asm$(EXESUFFIX):
$(MAKE) -C src/z80asm
bin/z80asm$(EXESUFFIX): $(wildcard src/z80asm/*.c src/z80asm/*.h)
$(MAKE) -C src/z80asm PREFIX=`pwd` PREFIX_SHARE=`pwd` install

bin/zcc$(EXESUFFIX):
bin/zcc$(EXESUFFIX): $(wildcard src/zcc/*.c src/zcc/*.h)
$(MAKE) -C src/zcc PREFIX=`pwd` install

bin/z88dk-zpragma$(EXESUFFIX):
bin/z88dk-zpragma$(EXESUFFIX): $(wildcard src/zpragma/*.c src/zpragma/*.h)
$(MAKE) -C src/zpragma PREFIX=`pwd` install

bin/z88dk-zx7$(EXESUFFIX):
bin/z88dk-zx7$(EXESUFFIX): $(wildcard src/zx7/*.c src/zx7/*.h)
$(MAKE) -C src/zx7 PREFIX=`pwd` install

bin/z80nm$(EXESUFFIX):
bin/z80nm$(EXESUFFIX): $(wildcard src/z80nm/*.c src/z80nm/*.h)
$(MAKE) -C src/z80nm PREFIX=`pwd` install

bin/zobjcopy$(EXESUFFIX):
bin/zobjcopy$(EXESUFFIX): $(wildcard src/zobjcopy/*.c src/zobjcopy/*.h)
$(MAKE) -C src/zobjcopy PREFIX=`pwd` install

bin/z88dk-lstmanip$(EXESUFFIX):
bin/z88dk-lstmanip$(EXESUFFIX): $(wildcard src/lstmanip/*.c src/lstmanip/*.h)
$(MAKE) -C src/lstmanip PREFIX=`pwd` install

bin/z88dk-z80svg$(EXESUFFIX):
bin/z88dk-z80svg$(EXESUFFIX): $(wildcard support/graphics/*.c support/graphics/*.h)
$(MAKE) -C support/graphics PREFIX=`pwd` install

bin/z88dk-basck$(EXESUFFIX):
bin/z88dk-basck$(EXESUFFIX): $(wildcard support/basck/*.c support/basck/*.h)
$(MAKE) -C support/basck PREFIX=`pwd` install

bin/z88dk-font2pv1000$(EXESUFFIX):
bin/z88dk-font2pv1000$(EXESUFFIX): $(wildcard support/pv1000/*.c support/pv1000/*.h)
$(MAKE) -C support/pv1000 PREFIX=`pwd` install

bin/z88dk-ticks$(EXESUFFIX):
bin/z88dk-ticks$(EXESUFFIX): $(wildcard src/ticks/*.c src/ticks/*.h)
$(MAKE) -C src/ticks PREFIX=`pwd` install

bin/z88dk-lib$(EXESUFFIX):
bin/z88dk-lib$(EXESUFFIX): $(wildcard src/z88dk-lib/*.c src/z88dk-lib/*.h)
$(MAKE) -C src/z88dk-lib PREFIX=`pwd` install


Expand Down
6 changes: 3 additions & 3 deletions src/Make.common
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

# EXESUFFIX is passed when cross-compiling Win32 on Linux
ifeq ($(OS),Windows_NT)
EXE := .exe
EXESUFFIX := .exe
else
EXE := $(EXESUFFIX)
EXESUFFIX ?=
endif

# UNIXem is needed in both Windows_NT and in a MinGW build in Unix
ifeq ($(EXE),.exe)
ifeq ($(EXESUFFIX),.exe)
UNIXem_CFLAGS := -I../../ext/UNIXem/include
UNIXem_OBJS := ../../ext/UNIXem/src/glob.o \
../../ext/UNIXem/src/dirent.o
Expand Down
27 changes: 14 additions & 13 deletions src/appmake/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
#-----------------------------------------------------------------------------
PROJ := appmake

# EXESUFFIX is passed when cross-compiling Win32 on Linux
ifeq ($(OS),Windows_NT)
EXE := .exe
EXESUFFIX := .exe
else
EXE := $(EXESUFFIX)
EXESUFFIX ?=
endif

CC ?= gcc
Expand All @@ -26,36 +27,36 @@ DEPENDS := $(SRCS:.c=.d) $(T_SRCS:.c=.d)

#------------------------------------------------------------------------------
define MAKE_EXE
all: $(1)$(EXE)
all: $(1)$(EXESUFFIX)

$(1)$(EXE): $(2)
$(CC) $(CFLAGS) -o $(1)$(EXE) $(2) $(LDFLAGS)
$(1)$(EXESUFFIX): $(2)
$(CC) $(CFLAGS) -o $(1)$(EXESUFFIX) $(2) $(LDFLAGS)

clean::
$(RM) $(1)$(EXE) $(2)
$(RM) $(1)$(EXESUFFIX) $(2)

test:: $(1)$(EXE)
test:: $(1)$(EXESUFFIX)
ifeq ($(3),1)
./$(1)$(EXE)
./$(1)$(EXESUFFIX)
endif

valgrind:: $(1)$(EXE)
$(VALGRIND) $(1)$(EXE)
valgrind:: $(1)$(EXESUFFIX)
$(VALGRIND) $(1)$(EXESUFFIX)
endef

#------------------------------------------------------------------------------
$(eval $(call MAKE_EXE,$(PROJ),$(OBJS_ALL),0))

#------------------------------------------------------------------------------
test:: $(PROJ)$(EXE)
test:: $(PROJ)$(EXESUFFIX)
perl -S prove t/*.t

#------------------------------------------------------------------------------
clean::
$(RM) $(OBJS) $(DEPENDS) *.bak t/*.bak

#------------------------------------------------------------------------------
install: $(PROJ)$(EXE)
$(INSTALL) $(PROJ)$(EXE) $(PREFIX)/bin/$(PROJ)$(EXE)
install: $(PROJ)$(EXESUFFIX)
$(INSTALL) $(PROJ)$(EXESUFFIX) $(PREFIX)/bin/$(PROJ)$(EXESUFFIX)

-include $(DEPENDS)
20 changes: 14 additions & 6 deletions src/common/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
# Copyright (C) Paulo Custodio, 2011-2018
# License: http://www.perlfoundation.org/artistic_license_2_0
#-----------------------------------------------------------------------------

# EXESUFFIX is passed when cross-compiling Win32 on Linux
ifeq ($(OS),Windows_NT)
EXESUFFIX := .exe
else
EXESUFFIX ?=
endif

include ../Make.common

CC ?= gcc
Expand All @@ -26,10 +34,10 @@ CFLAGS += -DUNITY_EXCLUDE_SETJMP_H -I. -I../../ext/Unity/src \

DEPENDS := $(SRCS:.c=.d)

all: t/test$(EXE)
all: t/test$(EXESUFFIX)

t/test$(EXE): $(OBJS)
$(CC) $(CFLAGS) -o t/test$(EXE) $(OBJS) $(LDFLAGS)
t/test$(EXESUFFIX): $(OBJS)
$(CC) $(CFLAGS) -o t/test$(EXESUFFIX) $(OBJS) $(LDFLAGS)

t/test.o: t/test.c t/test1.hh t/test2.hh

Expand All @@ -41,11 +49,11 @@ t/test2.hh: $(wildcard t/*.c) Makefile
@grep -h -i '^void t_[a-z0-9_]*(void)' t/*.c | sed -e 's/void \(t_[a-z0-9_]*\).*/extern void \1(void); RUN_TEST(\1);/' > t/test2.hh
@echo Built t/test2.hh

test: t/test$(EXE)
t/test$(EXE)
test: t/test$(EXESUFFIX)
t/test$(EXESUFFIX)
t/run_tests.sh

clean:
$(RM) t/test$(EXE) $(OBJS) $(DEPENDS)
$(RM) t/test$(EXESUFFIX) $(OBJS) $(DEPENDS)

-include $(DEPENDS)
7 changes: 7 additions & 0 deletions src/copt/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@

# EXESUFFIX is passed when cross-compiling Win32 on Linux
ifeq ($(OS),Windows_NT)
EXESUFFIX := .exe
else
EXESUFFIX ?=
endif

INSTALL ?= install

INCLUDES += -I.
Expand Down
27 changes: 14 additions & 13 deletions src/cpp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
#-----------------------------------------------------------------------------
PROJ := z88dk-zcpp

# EXESUFFIX is passed when cross-compiling Win32 on Linux
ifeq ($(OS),Windows_NT)
EXE := .exe
EXESUFFIX := .exe
else
EXE := $(EXESUFFIX)
EXESUFFIX ?=
endif

CC ?= gcc
Expand All @@ -28,36 +29,36 @@ DEPENDS := $(SRCS:.c=.d) $(T_SRCS:.c=.d)

#------------------------------------------------------------------------------
define MAKE_EXE
all: $(1)$(EXE)
all: $(1)$(EXESUFFIX)

$(1)$(EXE): $(2)
$(CC) $(CFLAGS) -o $(1)$(EXE) $(2) $(LDFLAGS)
$(1)$(EXESUFFIX): $(2)
$(CC) $(CFLAGS) -o $(1)$(EXESUFFIX) $(2) $(LDFLAGS)

clean::
$(RM) $(1)$(EXE) $(2)
$(RM) $(1)$(EXESUFFIX) $(2)

test:: $(1)$(EXE)
test:: $(1)$(EXESUFFIX)
ifeq ($(3),1)
./$(1)$(EXE)
./$(1)$(EXESUFFIX)
endif

valgrind:: $(1)$(EXE)
$(VALGRIND) $(1)$(EXE)
valgrind:: $(1)$(EXESUFFIX)
$(VALGRIND) $(1)$(EXESUFFIX)
endef

#------------------------------------------------------------------------------
$(eval $(call MAKE_EXE,$(PROJ),$(OBJS_ALL),0))

#------------------------------------------------------------------------------
test:: $(PROJ)$(EXE)
test:: $(PROJ)$(EXESUFFIX)
perl -S prove t/*.t

#------------------------------------------------------------------------------
clean::
$(RM) $(OBJS) $(DEPENDS) *.bak t/*.bak

#------------------------------------------------------------------------------
install: $(PROJ)$(EXE)
$(INSTALL) $(PROJ)$(EXE) $(PREFIX)/bin/$(PROJ)$(EXE)
install: $(PROJ)$(EXESUFFIX)
$(INSTALL) $(PROJ)$(EXESUFFIX) $(PREFIX)/bin/$(PROJ)$(EXESUFFIX)

-include $(DEPENDS)
7 changes: 7 additions & 0 deletions src/lstmanip/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@

# EXESUFFIX is passed when cross-compiling Win32 on Linux
ifeq ($(OS),Windows_NT)
EXESUFFIX := .exe
else
EXESUFFIX ?=
endif

OBJS = lstmanip.o

INSTALL ?= install
Expand Down
7 changes: 7 additions & 0 deletions src/sccz80/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
# $Id: Makefile,v 1.17 2016-07-10 16:09:00 dom Exp $
#

# EXESUFFIX is passed when cross-compiling Win32 on Linux
ifeq ($(OS),Windows_NT)
EXESUFFIX := .exe
else
EXESUFFIX ?=
endif

INSTALL ?= install

OBJS = callfunc.o \
Expand Down
7 changes: 7 additions & 0 deletions src/ticks/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@

# EXESUFFIX is passed when cross-compiling Win32 on Linux
ifeq ($(OS),Windows_NT)
EXESUFFIX := .exe
else
EXESUFFIX ?=
endif

OBJS = ticks.o hook_console.o hook_io.o hook_misc.o hook.o debugger.o linenoise.o utf8.o syms.o disassembler_alg.o memory.o


Expand Down
27 changes: 14 additions & 13 deletions src/ucpp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
#-----------------------------------------------------------------------------
PROJ := z88dk-ucpp

# EXESUFFIX is passed when cross-compiling Win32 on Linux
ifeq ($(OS),Windows_NT)
EXE := .exe
EXESUFFIX := .exe
else
EXE := $(EXESUFFIX)
EXESUFFIX ?=
endif

CC ?= gcc
Expand All @@ -29,36 +30,36 @@ DEPENDS := $(SRCS:.c=.d) $(T_SRCS:.c=.d)

#------------------------------------------------------------------------------
define MAKE_EXE
all: $(1)$(EXE)
all: $(1)$(EXESUFFIX)

$(1)$(EXE): $(2)
$(CC) $(CFLAGS) -o $(1)$(EXE) $(2) $(LDFLAGS)
$(1)$(EXESUFFIX): $(2)
$(CC) $(CFLAGS) -o $(1)$(EXESUFFIX) $(2) $(LDFLAGS)

clean::
$(RM) $(1)$(EXE) $(2)
$(RM) $(1)$(EXESUFFIX) $(2)

test:: $(1)$(EXE)
test:: $(1)$(EXESUFFIX)
ifeq ($(3),1)
./$(1)$(EXE)
./$(1)$(EXESUFFIX)
endif

valgrind:: $(1)$(EXE)
$(VALGRIND) $(1)$(EXE)
valgrind:: $(1)$(EXESUFFIX)
$(VALGRIND) $(1)$(EXESUFFIX)
endef

#------------------------------------------------------------------------------
$(eval $(call MAKE_EXE,$(PROJ),$(OBJS_ALL),0))

#------------------------------------------------------------------------------
test:: $(PROJ)$(EXE)
test:: $(PROJ)$(EXESUFFIX)
perl -S prove t/*.t

#------------------------------------------------------------------------------
clean::
$(RM) $(OBJS) $(DEPENDS) *.bak t/*.bak

#------------------------------------------------------------------------------
install: $(PROJ)$(EXE)
$(INSTALL) $(PROJ)$(EXE) $(PREFIX)/bin/$(PROJ)$(EXE)
install: $(PROJ)$(EXESUFFIX)
$(INSTALL) $(PROJ)$(EXESUFFIX) $(PREFIX)/bin/$(PROJ)$(EXESUFFIX)

-include $(DEPENDS)

0 comments on commit eb7a4f5

Please sign in to comment.