Update more Makefiles
This commit is contained in:
parent
a18511cdc1
commit
27d7c68dd7
2 changed files with 169 additions and 55 deletions
|
@ -12,6 +12,19 @@
|
||||||
# To rebuild project do "make clean" and "make all".
|
# To rebuild project do "make clean" and "make all".
|
||||||
#
|
#
|
||||||
|
|
||||||
|
##############################################################################################
|
||||||
|
# Start of make control
|
||||||
|
#
|
||||||
|
|
||||||
|
# Verbose compiling?
|
||||||
|
USE_VERBOSE_COMPILE=no
|
||||||
|
|
||||||
|
# Generate listing files?
|
||||||
|
USE_LISTING=no
|
||||||
|
|
||||||
|
# Your project name and executable file name - Optional, defaults to the project directory name
|
||||||
|
#PROJECT=uGFX
|
||||||
|
|
||||||
##############################################################################################
|
##############################################################################################
|
||||||
# Start of default section
|
# Start of default section
|
||||||
#
|
#
|
||||||
|
@ -33,7 +46,7 @@ DINCDIR =
|
||||||
DLIBDIR =
|
DLIBDIR =
|
||||||
|
|
||||||
# List all default libraries here
|
# List all default libraries here
|
||||||
DLIBS = -lX11 -pthread -lrt
|
DLIBS = -lrt
|
||||||
|
|
||||||
#
|
#
|
||||||
# End of default section
|
# End of default section
|
||||||
|
@ -43,8 +56,10 @@ DLIBS = -lX11 -pthread -lrt
|
||||||
# Start of user section
|
# Start of user section
|
||||||
#
|
#
|
||||||
|
|
||||||
# Define project name here
|
# Default project name is the project directory name
|
||||||
PROJECT = ugfx
|
ifeq ($(PROJECT),)
|
||||||
|
PROJECT := $(notdir $(patsubst %/,%,$(dir $(abspath $(firstword $(MAKEFILE_LIST))))))
|
||||||
|
endif
|
||||||
|
|
||||||
# Imported source files and paths for uGFX
|
# Imported source files and paths for uGFX
|
||||||
GFXLIB = ../ugfx
|
GFXLIB = ../ugfx
|
||||||
|
@ -87,15 +102,38 @@ OPT = -ggdb -O0 -fomit-frame-pointer
|
||||||
# End of user defines
|
# End of user defines
|
||||||
##############################################################################################
|
##############################################################################################
|
||||||
|
|
||||||
|
I# Output directory and files
|
||||||
|
ifeq ($(MAKECMDGOALS),Debug)
|
||||||
|
BUILDDIR = bin/Debug
|
||||||
|
else ifeq ($(MAKECMDGOALS),Release)
|
||||||
|
BUILDDIR = bin/Release
|
||||||
|
else ifeq ($(BUILDDIR),)
|
||||||
|
BUILDDIR = .build
|
||||||
|
else ifeq ($(BUILDDIR),.)
|
||||||
|
BUILDDIR = .build
|
||||||
|
endif
|
||||||
|
|
||||||
|
OBJDIR = $(BUILDDIR)/obj
|
||||||
|
LSTDIR = $(BUILDDIR)/lst
|
||||||
|
MAPDIR = $(BUILDDIR)/map
|
||||||
|
DEPDIR = .dep
|
||||||
|
|
||||||
INCDIR = $(patsubst %,-I%,$(DINCDIR) $(UINCDIR))
|
INCDIR = $(patsubst %,-I%,$(DINCDIR) $(UINCDIR))
|
||||||
LIBDIR = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR))
|
LIBDIR = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR))
|
||||||
DEFS = $(DDEFS) $(UDEFS)
|
DEFS = $(DDEFS) $(UDEFS)
|
||||||
ADEFS = $(DADEFS) $(UADEFS)
|
ADEFS = $(DADEFS) $(UADEFS)
|
||||||
OBJS = $(ASRC:.s=.o) $(SRC:.c=.o)
|
COBJ = $(addprefix $(OBJDIR)/, $(subst ../,_dot_dot/,$(SRC:.c=.o)))
|
||||||
|
AOBJ = $(addprefix $(OBJDIR)/, $(subst ../,_dot_dot/,$(ASRC:.s=.o)))
|
||||||
|
OBJS = $(AOBJ) $(COBJ)
|
||||||
LIBS = $(DLIBS) $(ULIBS)
|
LIBS = $(DLIBS) $(ULIBS)
|
||||||
|
|
||||||
ASFLAGS = -Wa,-amhls=$(<:.s=.lst) $(ADEFS)
|
ASFLAGS = $(ADEFS)
|
||||||
CPFLAGS = $(OPT) -Wall -Wextra -Wstrict-prototypes -fverbose-asm $(DEFS)
|
CPFLAGS = $(OPT) -Wall -Wextra -Wstrict-prototypes -fverbose-asm $(DEFS)
|
||||||
|
LDFLAGS = -Wl,-Map=$(MAPDIR)/$(PROJECT).map,--cref,--no-warn-mismatch $(LIBDIR)
|
||||||
|
ifeq ($(USE_LISTING),yes)
|
||||||
|
ASFLAGS += -Wa,-amhls=$(LSTDIR)/$(subst ../,_dot_dot/,$(<:.s=.lst))
|
||||||
|
CPFLAGS += -Wa,-alms=$(LSTDIR)/$(subst ../,_dot_dot/,$(<:.c=.lst))
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(HOST_OSX),yes)
|
ifeq ($(HOST_OSX),yes)
|
||||||
ifeq ($(OSX_SDK),)
|
ifeq ($(OSX_SDK),)
|
||||||
|
@ -105,29 +143,54 @@ ifeq ($(HOST_OSX),yes)
|
||||||
OSX_ARCH = -mmacosx-version-min=10.3 -arch i386
|
OSX_ARCH = -mmacosx-version-min=10.3 -arch i386
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CPFLAGS += -isysroot $(OSX_SDK) $(OSX_ARCH)
|
|
||||||
LDFLAGS = -Wl -Map=$(PROJECT).map,-syslibroot,$(OSX_SDK),$(LIBDIR)
|
|
||||||
LIBS += $(OSX_ARCH)
|
LIBS += $(OSX_ARCH)
|
||||||
|
CPFLAGS += -isysroot $(OSX_SDK) $(OSX_ARCH)
|
||||||
|
LDFLAGS = -Wl -Map=$(MAPDIR)/$(PROJECT).map,-syslibroot,$(OSX_SDK),$(LIBDIR)
|
||||||
else
|
else
|
||||||
# Linux, or other
|
# Linux, or other
|
||||||
CPFLAGS += -m32 -Wa,-alms=$(<:.c=.lst)
|
CPFLAGS += -m32
|
||||||
LDFLAGS = -m32 -Wl,-Map=$(PROJECT).map,--cref,--no-warn-mismatch $(LIBDIR)
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Generate dependency information
|
# Generate dependency information
|
||||||
CPFLAGS += -MD -MP -MF .dep/$(@F).d
|
CPFLAGS += -MD -MP -MF $(DEPDIR)/$(@F).d
|
||||||
|
|
||||||
#
|
#
|
||||||
# makefile rules
|
# makefile rules
|
||||||
#
|
#
|
||||||
|
|
||||||
all: $(OBJS) $(PROJECT)
|
all: $(BUILDDIR) $(OBJS) $(PROJECT)
|
||||||
|
|
||||||
%.o : %.c
|
$(BUILDDIR) $(OBJDIR) $(LSTDIR) $(MAPDIR):
|
||||||
$(CC) -c $(CPFLAGS) -I . $(INCDIR) $< -o $@
|
mkdir -p $(OBJDIR)
|
||||||
|
mkdir -p $(MAPDIR)
|
||||||
|
ifeq ($(USE_LISTING),yes)
|
||||||
|
mkdir -p $(LSTDIR)
|
||||||
|
endif
|
||||||
|
ifneq ($(USE_VERBOSE_COMPILE),yes)
|
||||||
|
@echo Compiler Options - $(CC) -c $(CPFLAGS) -I. $(INCDIR) main.c -o $(OBJDIR)/main.o
|
||||||
|
@echo
|
||||||
|
endif
|
||||||
|
|
||||||
%.o : %.s
|
.SECONDEXPANSION:
|
||||||
$(AS) -c $(ASFLAGS) $< -o $@
|
$(OBJDIR)/%.o : $$(subst _dot_dot/,../,%.c)
|
||||||
|
@mkdir -p $(dir $@)
|
||||||
|
ifeq ($(USE_VERBOSE_COMPILE),yes)
|
||||||
|
@echo
|
||||||
|
$(CC) -c $(CPFLAGS) -I. $(INCDIR) $< -o $@
|
||||||
|
else
|
||||||
|
@echo Compiling $<
|
||||||
|
@$(CC) -c $(CPFLAGS) -I. $(INCDIR) $< -o $@
|
||||||
|
endif
|
||||||
|
|
||||||
|
$(OBJDIR)/%.o : $$(subst _dot_dot/,../,%.s)
|
||||||
|
@mkdir -p $(dir $@)
|
||||||
|
ifeq ($(USE_VERBOSE_COMPILE),yes)
|
||||||
|
@echo
|
||||||
|
$(AS) -c $(ASFLAGS) -I. $(INCDIR) $< -o $@
|
||||||
|
else
|
||||||
|
@echo Compiling $<
|
||||||
|
@$(AS) -c $(ASFLAGS) -I. $(INCDIR) $< -o $@
|
||||||
|
endif
|
||||||
|
|
||||||
$(PROJECT): $(OBJS)
|
$(PROJECT): $(OBJS)
|
||||||
$(CC) $(OBJS) $(LDFLAGS) $(LIBS) -o $@
|
$(CC) $(OBJS) $(LDFLAGS) $(LIBS) -o $@
|
||||||
|
@ -138,18 +201,12 @@ gcov:
|
||||||
-mv *.gcov ./gcov
|
-mv *.gcov ./gcov
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
-rm -f $(OBJS)
|
-rm -f $(BUILDDIR)
|
||||||
-rm -f $(PROJECT)
|
-rm -fR $(DEPDIR)
|
||||||
-rm -f $(PROJECT).map
|
|
||||||
-rm -f $(SRC:.c=.c.bak)
|
|
||||||
-rm -f $(SRC:.c=.lst)
|
|
||||||
-rm -f $(ASRC:.s=.s.bak)
|
|
||||||
-rm -f $(ASRC:.s=.lst)
|
|
||||||
-rm -fR .dep
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Include the dependency files, should be the last of the makefile
|
# Include the dependency files, should be the last of the makefile
|
||||||
#
|
#
|
||||||
-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
|
-include $(shell mkdir $(DEPDIR) 2>/dev/null) $(wildcard $(DEPDIR)/*)
|
||||||
|
|
||||||
# *** EOF ***
|
# *** EOF ***
|
||||||
|
|
|
@ -12,6 +12,19 @@
|
||||||
# To rebuild project do "make clean" and "make all".
|
# To rebuild project do "make clean" and "make all".
|
||||||
#
|
#
|
||||||
|
|
||||||
|
##############################################################################################
|
||||||
|
# Start of make control
|
||||||
|
#
|
||||||
|
|
||||||
|
# Verbose compiling?
|
||||||
|
USE_VERBOSE_COMPILE=no
|
||||||
|
|
||||||
|
# Generate listing files?
|
||||||
|
USE_LISTING=no
|
||||||
|
|
||||||
|
# Your project name and executable file name - Optional, defaults to the project directory name
|
||||||
|
#PROJECT=uGFX
|
||||||
|
|
||||||
##############################################################################################
|
##############################################################################################
|
||||||
# Start of default section
|
# Start of default section
|
||||||
#
|
#
|
||||||
|
@ -43,8 +56,10 @@ DLIBS = -lX11 -pthread -lrt
|
||||||
# Start of user section
|
# Start of user section
|
||||||
#
|
#
|
||||||
|
|
||||||
# Define project name here
|
# Default project name is the project directory name
|
||||||
PROJECT = ugfx
|
ifeq ($(PROJECT),)
|
||||||
|
PROJECT := $(notdir $(patsubst %/,%,$(dir $(abspath $(firstword $(MAKEFILE_LIST))))))
|
||||||
|
endif
|
||||||
|
|
||||||
# Imported source files and paths for uGFX
|
# Imported source files and paths for uGFX
|
||||||
GFXLIB = ../ugfx
|
GFXLIB = ../ugfx
|
||||||
|
@ -87,15 +102,38 @@ OPT = -ggdb -O0 -fomit-frame-pointer
|
||||||
# End of user defines
|
# End of user defines
|
||||||
##############################################################################################
|
##############################################################################################
|
||||||
|
|
||||||
|
# Output directory and files
|
||||||
|
ifeq ($(MAKECMDGOALS),Debug)
|
||||||
|
BUILDDIR = bin/Debug
|
||||||
|
else ifeq ($(MAKECMDGOALS),Release)
|
||||||
|
BUILDDIR = bin/Release
|
||||||
|
else ifeq ($(BUILDDIR),)
|
||||||
|
BUILDDIR = .build
|
||||||
|
else ifeq ($(BUILDDIR),.)
|
||||||
|
BUILDDIR = .build
|
||||||
|
endif
|
||||||
|
|
||||||
|
OBJDIR = $(BUILDDIR)/obj
|
||||||
|
LSTDIR = $(BUILDDIR)/lst
|
||||||
|
MAPDIR = $(BUILDDIR)/map
|
||||||
|
DEPDIR = .dep
|
||||||
|
|
||||||
INCDIR = $(patsubst %,-I%,$(DINCDIR) $(UINCDIR))
|
INCDIR = $(patsubst %,-I%,$(DINCDIR) $(UINCDIR))
|
||||||
LIBDIR = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR))
|
LIBDIR = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR))
|
||||||
DEFS = $(DDEFS) $(UDEFS)
|
DEFS = $(DDEFS) $(UDEFS)
|
||||||
ADEFS = $(DADEFS) $(UADEFS)
|
ADEFS = $(DADEFS) $(UADEFS)
|
||||||
OBJS = $(ASRC:.s=.o) $(SRC:.c=.o)
|
COBJ = $(addprefix $(OBJDIR)/, $(subst ../,_dot_dot/,$(SRC:.c=.o)))
|
||||||
|
AOBJ = $(addprefix $(OBJDIR)/, $(subst ../,_dot_dot/,$(ASRC:.s=.o)))
|
||||||
|
OBJS = $(AOBJ) $(COBJ)
|
||||||
LIBS = $(DLIBS) $(ULIBS)
|
LIBS = $(DLIBS) $(ULIBS)
|
||||||
|
|
||||||
ASFLAGS = -Wa,-amhls=$(<:.s=.lst) $(ADEFS)
|
ASFLAGS = $(ADEFS)
|
||||||
CPFLAGS = $(OPT) -Wall -Wextra -Wstrict-prototypes -fverbose-asm $(DEFS)
|
CPFLAGS = $(OPT) -Wall -Wextra -Wstrict-prototypes -fverbose-asm $(DEFS)
|
||||||
|
LDFLAGS = -Wl,-Map=$(MAPDIR)/$(PROJECT).map,--cref,--no-warn-mismatch $(LIBDIR)
|
||||||
|
ifeq ($(USE_LISTING),yes)
|
||||||
|
ASFLAGS += -Wa,-amhls=$(LSTDIR)/$(subst ../,_dot_dot/,$(<:.s=.lst))
|
||||||
|
CPFLAGS += -Wa,-alms=$(LSTDIR)/$(subst ../,_dot_dot/,$(<:.c=.lst))
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(HOST_OSX),yes)
|
ifeq ($(HOST_OSX),yes)
|
||||||
ifeq ($(OSX_SDK),)
|
ifeq ($(OSX_SDK),)
|
||||||
|
@ -105,29 +143,54 @@ ifeq ($(HOST_OSX),yes)
|
||||||
OSX_ARCH = -mmacosx-version-min=10.3 -arch i386
|
OSX_ARCH = -mmacosx-version-min=10.3 -arch i386
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CPFLAGS += -isysroot $(OSX_SDK) $(OSX_ARCH)
|
|
||||||
LDFLAGS = -Wl -Map=$(PROJECT).map,-syslibroot,$(OSX_SDK),$(LIBDIR)
|
|
||||||
LIBS += $(OSX_ARCH)
|
LIBS += $(OSX_ARCH)
|
||||||
|
CPFLAGS += -isysroot $(OSX_SDK) $(OSX_ARCH)
|
||||||
|
LDFLAGS = -Wl -Map=$(MAPDIR)/$(PROJECT).map,-syslibroot,$(OSX_SDK),$(LIBDIR)
|
||||||
else
|
else
|
||||||
# Linux, or other
|
# Linux, or other
|
||||||
CPFLAGS += -m32 -Wa,-alms=$(<:.c=.lst)
|
CPFLAGS += -m32
|
||||||
LDFLAGS = -m32 -Wl,-Map=$(PROJECT).map,--cref,--no-warn-mismatch $(LIBDIR)
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Generate dependency information
|
# Generate dependency information
|
||||||
CPFLAGS += -MD -MP -MF .dep/$(@F).d
|
CPFLAGS += -MD -MP -MF $(DEPDIR)/$(@F).d
|
||||||
|
|
||||||
#
|
#
|
||||||
# makefile rules
|
# makefile rules
|
||||||
#
|
#
|
||||||
|
|
||||||
all: $(OBJS) $(PROJECT)
|
all: $(BUILDDIR) $(OBJS) $(PROJECT)
|
||||||
|
|
||||||
%.o : %.c
|
$(BUILDDIR) $(OBJDIR) $(LSTDIR) $(MAPDIR):
|
||||||
$(CC) -c $(CPFLAGS) -I . $(INCDIR) $< -o $@
|
mkdir -p $(OBJDIR)
|
||||||
|
mkdir -p $(MAPDIR)
|
||||||
|
ifeq ($(USE_LISTING),yes)
|
||||||
|
mkdir -p $(LSTDIR)
|
||||||
|
endif
|
||||||
|
ifneq ($(USE_VERBOSE_COMPILE),yes)
|
||||||
|
@echo Compiler Options - $(CC) -c $(CPFLAGS) -I. $(INCDIR) main.c -o $(OBJDIR)/main.o
|
||||||
|
@echo
|
||||||
|
endif
|
||||||
|
|
||||||
%.o : %.s
|
.SECONDEXPANSION:
|
||||||
$(AS) -c $(ASFLAGS) $< -o $@
|
$(OBJDIR)/%.o : $$(subst _dot_dot/,../,%.c)
|
||||||
|
@mkdir -p $(dir $@)
|
||||||
|
ifeq ($(USE_VERBOSE_COMPILE),yes)
|
||||||
|
@echo
|
||||||
|
$(CC) -c $(CPFLAGS) -I. $(INCDIR) $< -o $@
|
||||||
|
else
|
||||||
|
@echo Compiling $<
|
||||||
|
@$(CC) -c $(CPFLAGS) -I. $(INCDIR) $< -o $@
|
||||||
|
endif
|
||||||
|
|
||||||
|
$(OBJDIR)/%.o : $$(subst _dot_dot/,../,%.s)
|
||||||
|
@mkdir -p $(dir $@)
|
||||||
|
ifeq ($(USE_VERBOSE_COMPILE),yes)
|
||||||
|
@echo
|
||||||
|
$(AS) -c $(ASFLAGS) -I. $(INCDIR) $< -o $@
|
||||||
|
else
|
||||||
|
@echo Compiling $<
|
||||||
|
@$(AS) -c $(ASFLAGS) -I. $(INCDIR) $< -o $@
|
||||||
|
endif
|
||||||
|
|
||||||
$(PROJECT): $(OBJS)
|
$(PROJECT): $(OBJS)
|
||||||
$(CC) $(OBJS) $(LDFLAGS) $(LIBS) -o $@
|
$(CC) $(OBJS) $(LDFLAGS) $(LIBS) -o $@
|
||||||
|
@ -138,18 +201,12 @@ gcov:
|
||||||
-mv *.gcov ./gcov
|
-mv *.gcov ./gcov
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
-rm -f $(OBJS)
|
-rm -f $(BUILDDIR)
|
||||||
-rm -f $(PROJECT)
|
-rm -fR $(DEPDIR)
|
||||||
-rm -f $(PROJECT).map
|
|
||||||
-rm -f $(SRC:.c=.c.bak)
|
|
||||||
-rm -f $(SRC:.c=.lst)
|
|
||||||
-rm -f $(ASRC:.s=.s.bak)
|
|
||||||
-rm -f $(ASRC:.s=.lst)
|
|
||||||
-rm -fR .dep
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Include the dependency files, should be the last of the makefile
|
# Include the dependency files, should be the last of the makefile
|
||||||
#
|
#
|
||||||
-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
|
-include $(shell mkdir $(DEPDIR) 2>/dev/null) $(wildcard $(DEPDIR)/*)
|
||||||
|
|
||||||
# *** EOF ***
|
# *** EOF ***
|
||||||
|
|
Loading…
Add table
Reference in a new issue