From 823d0b763663d2148ef8fbf6c680607cd8be8b74 Mon Sep 17 00:00:00 2001 From: uz Date: Sun, 8 Feb 2009 17:19:45 +0000 Subject: [PATCH] Makefile cleanup. Among other things, allow use of the --as-needed linker flag by rearranging arguments for the linker. git-svn-id: svn://svn.cc65.org/cc65/trunk@3922 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/ar65/make/gcc.mak | 23 ++++++++++++++--------- src/ca65/make/gcc.mak | 29 +++++++++++++++++------------ src/cc65/make/gcc.mak | 4 ++-- src/cl65/make/gcc.mak | 24 ++++++++++++++---------- src/co65/make/gcc.mak | 23 ++++++++++++++--------- src/da65/make/gcc.mak | 26 +++++++++++++++----------- src/grc/make/gcc.mak | 25 +++++++++++++++---------- src/ld65/make/gcc.mak | 31 +++++++++++++++---------------- src/od65/make/gcc.mak | 19 ++++++++++++------- src/sim65/make/gcc.mak | 27 +++++++++++++++------------ 10 files changed, 133 insertions(+), 98 deletions(-) diff --git a/src/ar65/make/gcc.mak b/src/ar65/make/gcc.mak index 48238700f..665aa8f2c 100644 --- a/src/ar65/make/gcc.mak +++ b/src/ar65/make/gcc.mak @@ -2,6 +2,11 @@ # gcc Makefile for ar65 # +# ------------------------------------------------------------------------------ + +# The executable to build +EXE = ar65 + # Library dir COMMON = ../common @@ -27,28 +32,28 @@ OBJS = add.o \ LIBS = $(COMMON)/common.a -EXECS = ar65 +# ------------------------------------------------------------------------------ +# Makefile targets +# Main target - must be first .PHONY: all ifeq (.depend,$(wildcard .depend)) -all : $(EXECS) +all: $(EXE) include .depend else all: depend @$(MAKE) -f make/gcc.mak all endif - - -ar65: $(OBJS) $(LIBS) - $(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS) - @if [ $(OS2_SHELL) ] ; then $(EBIND) $@ ; fi +$(EXE): $(OBJS) $(LIBS) + $(CC) $^ $(LDFLAGS) -o $@ + @if [ $(OS2_SHELL) ] ; then $(EBIND) $(EXE) ; fi clean: - $(RM) *~ core + $(RM) *~ core.* *.map zap: clean - $(RM) *.o $(EXECS) .depend + $(RM) *.o $(EXE) .depend # ------------------------------------------------------------------------------ # Make the dependencies diff --git a/src/ca65/make/gcc.mak b/src/ca65/make/gcc.mak index 49d1a49a6..6030e9de3 100644 --- a/src/ca65/make/gcc.mak +++ b/src/ca65/make/gcc.mak @@ -2,6 +2,11 @@ # gcc Makefile for ca65 # +# ------------------------------------------------------------------------------ + +# The executable to build +EXE = ca65 + # Library dir COMMON = ../common @@ -55,43 +60,43 @@ OBJS = anonname.o \ symtab.o \ token.o \ toklist.o \ - ulabel.o + ulabel.o # ----------------------------------------------------------------------------- # List of all macro files INCS = atari.inc \ cbm.inc \ - cpu.inc \ - generic.inc \ + cpu.inc \ + generic.inc \ longbranch.inc -# ----------------------------------------------------------------------------- - LIBS = $(COMMON)/common.a -EXECS = ca65 +# ------------------------------------------------------------------------------ +# Makefile targets +# Main target - must be first .PHONY: all ifeq (.depend,$(wildcard .depend)) -all : $(EXECS) +all: $(EXE) include .depend else all: depend @$(MAKE) -f make/gcc.mak all endif -ca65: $(INCS) $(OBJS) $(LIBS) - $(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS) - @if [ $(OS2_SHELL) ] ; then $(EBIND) $@ ; fi +$(EXE): $(INCS) $(OBJS) $(LIBS) + $(CC) $(OBJS) $(LIBS) $(LDFLAGS) -o $@ + @if [ $(OS2_SHELL) ] ; then $(EBIND) $(EXE) ; fi inc: $(INCS) clean: - rm -f *~ core *.lst + $(RM) *~ core.* *.map zap: clean - rm -f *.o $(EXECS) $(INCS) .depend + $(RM) *.o $(EXE) $(INCS) .depend # ------------------------------------------------------------------------------ # Make the dependencies diff --git a/src/cc65/make/gcc.mak b/src/cc65/make/gcc.mak index 030189fd7..1752e1029 100644 --- a/src/cc65/make/gcc.mak +++ b/src/cc65/make/gcc.mak @@ -110,11 +110,11 @@ all: depend endif $(EXE): $(OBJS) $(LIBS) - $(CC) $(LDFLAGS) -o $(EXE) $(CFLAGS) $(OBJS) $(LIBS) + $(CC) $^ $(LDFLAGS) -o $@ @if [ $(OS2_SHELL) ] ; then $(EBIND) $(EXE) ; fi clean: - $(RM) *~ core *.map + $(RM) *~ core.* *.map zap: clean $(RM) *.o $(EXE) .depend diff --git a/src/cl65/make/gcc.mak b/src/cl65/make/gcc.mak index a7c02ae59..82bb4c259 100644 --- a/src/cl65/make/gcc.mak +++ b/src/cl65/make/gcc.mak @@ -2,6 +2,11 @@ # Makefile for the cl65 compile&link utility # +# ------------------------------------------------------------------------------ + +# The executable to build +EXE = cl65 + # Library dir COMMON = ../common @@ -23,29 +28,28 @@ OBJS = error.o \ LIBS = $(COMMON)/common.a -EXECS = cl65 - +# ------------------------------------------------------------------------------ +# Makefile targets +# Main target - must be first .PHONY: all ifeq (.depend,$(wildcard .depend)) -all : $(EXECS) +all: $(EXE) include .depend else all: depend @$(MAKE) -f make/gcc.mak all endif - -cl65: $(OBJS) $(LIBS) - $(CC) $(LDFLAGS) -o cl65 $(OBJS) $(LIBS) - @if [ $(OS2_SHELL) ] ; then $(EBIND) cl65 ; fi +$(EXE): $(OBJS) $(LIBS) + $(CC) $^ $(LDFLAGS) -o $@ + @if [ $(OS2_SHELL) ] ; then $(EBIND) $(EXE) ; fi clean: - $(RM) *~ core + $(RM) *~ core.* *.map zap: clean - $(RM) *.o $(EXECS) .depend - + $(RM) *.o $(EXE) .depend # ------------------------------------------------------------------------------ # Make the dependencies diff --git a/src/co65/make/gcc.mak b/src/co65/make/gcc.mak index 1fa07598c..7dbbe9506 100644 --- a/src/co65/make/gcc.mak +++ b/src/co65/make/gcc.mak @@ -2,6 +2,11 @@ # gcc Makefile for co65 # +# ------------------------------------------------------------------------------ + +# The executable to build +EXE = co65 + # Library dir COMMON = ../common @@ -20,28 +25,28 @@ OBJS = convert.o \ LIBS = $(COMMON)/common.a -EXECS = co65 +# ------------------------------------------------------------------------------ +# Makefile targets +# Main target - must be first .PHONY: all ifeq (.depend,$(wildcard .depend)) -all : $(EXECS) +all: $(EXE) include .depend else all: depend @$(MAKE) -f make/gcc.mak all endif - - -co65: $(OBJS) $(LIBS) - $(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS) - @if [ $(OS2_SHELL) ] ; then $(EBIND) $@ ; fi +$(EXE): $(OBJS) $(LIBS) + $(CC) $^ $(LDFLAGS) -o $@ + @if [ $(OS2_SHELL) ] ; then $(EBIND) $(EXE) ; fi clean: - $(RM) *~ core *.lst + $(RM) *~ core.* *.map zap: clean - $(RM) *.o $(EXECS) .depend + $(RM) *.o $(EXE) .depend # ------------------------------------------------------------------------------ # Make the dependencies diff --git a/src/da65/make/gcc.mak b/src/da65/make/gcc.mak index 7932d0e6c..35e2805c7 100644 --- a/src/da65/make/gcc.mak +++ b/src/da65/make/gcc.mak @@ -1,7 +1,12 @@ -# +# # gcc Makefile for da65 # +# ------------------------------------------------------------------------------ + +# The executable to build +EXE = da65 + # Library dir COMMON = ../common @@ -33,29 +38,28 @@ OBJS = asminc.o \ LIBS = $(COMMON)/common.a -EXECS = da65 +# ------------------------------------------------------------------------------ +# Makefile targets +# Main target - must be first .PHONY: all ifeq (.depend,$(wildcard .depend)) -all : $(EXECS) +all: $(EXE) include .depend else all: depend @$(MAKE) -f make/gcc.mak all endif - - -da65: $(OBJS) $(LIBS) - $(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS) - @if [ $(OS2_SHELL) ] ; then $(EBIND) $@ ; fi +$(EXE): $(OBJS) $(LIBS) + $(CC) $^ $(LDFLAGS) -o $@ + @if [ $(OS2_SHELL) ] ; then $(EBIND) $(EXE) ; fi clean: - $(RM) *~ core *.map + $(RM) *~ core.* *.map zap: clean - $(RM) *.o $(EXECS) .depend - + $(RM) *.o $(EXE) .depend # ------------------------------------------------------------------------------ # Make the dependencies diff --git a/src/grc/make/gcc.mak b/src/grc/make/gcc.mak index d86b3055b..e5d7c9eff 100644 --- a/src/grc/make/gcc.mak +++ b/src/grc/make/gcc.mak @@ -2,6 +2,11 @@ # gcc Makefile for grc # +# ------------------------------------------------------------------------------ + +# The executable to build +EXE = grc + COMMON = ../common CFLAGS = -g -O2 -Wall -W -std=c89 -I$(COMMON) @@ -11,30 +16,30 @@ EBIND = emxbind OBJS = grc.o -EXECS = grc - LIBS = $(COMMON)/common.a +# ------------------------------------------------------------------------------ +# Makefile targets + +# Main target - must be first .PHONY: all ifeq (.depend,$(wildcard .depend)) -all : $(EXECS) +all: $(EXE) include .depend else all: depend @$(MAKE) -f make/gcc.mak all endif - - -grc: $(OBJS) $(LIBS) - $(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS) - @if [ $(OS2_SHELL) ] ; then $(EBIND) $@ ; fi +$(EXE): $(OBJS) $(LIBS) + $(CC) $^ $(LDFLAGS) -o $@ + @if [ $(OS2_SHELL) ] ; then $(EBIND) $(EXE) ; fi clean: - $(RM) *~ core *.lst + $(RM) *~ core.* *.map zap: clean - $(RM) *.o $(EXECS) .depend + $(RM) *.o $(EXE) .depend # ------------------------------------------------------------------------------ # Make the dependencies diff --git a/src/ld65/make/gcc.mak b/src/ld65/make/gcc.mak index 94ff4a67c..7aed11bad 100644 --- a/src/ld65/make/gcc.mak +++ b/src/ld65/make/gcc.mak @@ -2,6 +2,11 @@ # gcc Makefile for ld65 # +# ------------------------------------------------------------------------------ + +# The executable to build +EXE = ld65 + # Library dir COMMON = ../common @@ -75,37 +80,31 @@ INCS = apple2.inc \ supervision.inc \ vic20.inc -# ----------------------------------------------------------------------------- -# - LIBS = $(COMMON)/common.a -EXECS = ld65 +# ------------------------------------------------------------------------------ +# Makefile targets +# Main target - must be first .PHONY: all ifeq (.depend,$(wildcard .depend)) -all : $(EXECS) +all: $(EXE) include .depend else all: depend @$(MAKE) -f make/gcc.mak all endif - - -ld65: $(INCS) $(OBJS) $(LIBS) - $(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS) - @if [ $(OS2_SHELL) ] ; then $(EBIND) $@ ; fi - -inc: $(INCS) +$(EXE): $(INCS) $(OBJS) $(LIBS) + $(CC) $(OBJS) $(LIBS) $(LDFLAGS) -o $@ + @if [ $(OS2_SHELL) ] ; then $(EBIND) $(EXE) ; fi clean: - $(RM) *~ core *.map - -zap: clean - $(RM) *.o $(INCS) $(EXECS) .depend + $(RM) *~ core.* *.map +zap: clean + $(RM) *.o $(INCS) $(EXE) .depend # ------------------------------------------------------------------------------ # Make the dependencies diff --git a/src/od65/make/gcc.mak b/src/od65/make/gcc.mak index 1c05b8193..da18ade97 100644 --- a/src/od65/make/gcc.mak +++ b/src/od65/make/gcc.mak @@ -3,6 +3,11 @@ # +# ------------------------------------------------------------------------------ + +# The executable to build +EXE = od65 + # Library dir COMMON = ../common @@ -19,25 +24,25 @@ OBJS = dump.o \ LIBS = $(COMMON)/common.a -EXE = od65 - +# ------------------------------------------------------------------------------ +# Makefile targets +# Main target - must be first .PHONY: all ifeq (.depend,$(wildcard .depend)) -all: $(EXE) +all: $(EXE) include .depend else all: depend @$(MAKE) -f make/gcc.mak all endif - -$(EXE): $(OBJS) - $(CC) $(LDFLAGS) -o $(EXE) $(CFLAGS) $(OBJS) $(LIBS) +$(EXE): $(OBJS) $(LIBS) + $(CC) $^ $(LDFLAGS) -o $@ @if [ $(OS2_SHELL) ] ; then $(EBIND) $(EXE) ; fi clean: - $(RM) *~ core *.map + $(RM) *~ core.* *.map zap: clean $(RM) *.o $(EXE) .depend diff --git a/src/sim65/make/gcc.mak b/src/sim65/make/gcc.mak index 7d7cf173f..16bdd0f29 100644 --- a/src/sim65/make/gcc.mak +++ b/src/sim65/make/gcc.mak @@ -2,6 +2,11 @@ # gcc Makefile for sim65 # +# ------------------------------------------------------------------------------ + +# The executable to build +EXE = sim65 + # Library dir COMMON = ../common @@ -28,34 +33,32 @@ OBJS = addrspace.o \ LIBS = $(COMMON)/common.a -EXECS = sim65 +# ------------------------------------------------------------------------------ +# Makefile targets +# Main target - must be first .PHONY: all ifeq (.depend,$(wildcard .depend)) -all: $(EXECS) chips +all: $(EXE) chips include .depend else all: depend @$(MAKE) -f make/gcc.mak all endif - -sim65: $(OBJS) $(LIBS) - $(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS) -ldl - @if [ $(OS2_SHELL) ] ; then $(EBIND) $@ ; fi +$(EXE): $(OBJS) $(LIBS) + $(CC) $^ $(LDFLAGS) -o $@ + @if [ $(OS2_SHELL) ] ; then $(EBIND) $(EXE) ; fi .PHONY: chips chips: @$(MAKE) -C chips -f make/gcc.mak - clean: - @$(MAKE) -C chips -f make/gcc.mak clean - $(RM) *~ core *.lst + $(RM) *~ core.* *.map -zap: clean - @$(MAKE) -C chips -f make/gcc.mak zap - $(RM) *.o $(EXECS) .depend +zap: clean + $(RM) *.o $(EXE) .depend # ------------------------------------------------------------------------------ # Make the dependencies