Giter Site home page Giter Site logo

Папка build about stm8_samples HOT 2 CLOSED

eddyem avatar eddyem commented on August 26, 2024
Папка build

from stm8_samples.

Comments (2)

eddyem avatar eddyem commented on August 26, 2024

Вот пример заготовки Makefile, которая весь мусор в директорию mk сбрасывает:

run make DEF=... to add extra defines

PROGRAM :=
LDFLAGS := -fdata-sections -ffunction-sections -Wl,--gc-sections -Wl,--discard-all
SRCS := $(wildcard *.c)
DEFINES := $(DEF) -D_XOPEN_SOURCE=1111
OBJDIR := mk
CFLAGS += -O2 -Wall -Werror -Wextra -Wno-trampolines -std=gnu99
OBJS := $(addprefix $(OBJDIR)/, $(SRCS:%.c=%.o))
DEPS := $(OBJS:.o=.d)
CC = gcc
#CXX = g++

all : $(OBJDIR) $(PROGRAM)

$(PROGRAM) : $(OBJS)
@echo -e "\t\tLD $(PROGRAM)"
$(CC) $(LDFLAGS) $(OBJS) -o $(PROGRAM)

$(OBJDIR):
mkdir $(OBJDIR)

ifneq ($(MAKECMDGOALS),clean)
-include $(DEPS)
endif

$(OBJDIR)/%.o: %.c
@echo -e "\t\tCC $<"
$(CC) -MD -c $(LDFLAGS) $(CFLAGS) $(DEFINES) -o $@ $&lt;

clean:
@echo -e "\t\tCLEAN"
@rm -f $(OBJS) $(DEPS)
@rmdir $(OBJDIR) 2>/dev/null || true

xclean: clean
@rm -f $(PROGRAM)

gentags:
CFLAGS="$(CFLAGS) $(DEFINES)" geany -g $(PROGRAM).c.tags *[hc] 2>/dev/null

.PHONY: gentags clean xclean

from stm8_samples.

dzanis avatar dzanis commented on August 26, 2024

Спасибо это помогло.И вот что получилось

#Makefile for stm8 sdcc project
NAME=testproj
SDCC=sdcc
INCLUDES=-I../ -I/usr/share/sdcc/include 
DEFINES=-D STM8S103
CCFLAGS= -mstm8 --out-fmt-ihx
LDFLAGS= -mstm8 --out-fmt-ihx -lstm8
FLASHFLAGS=-c stlinkv2 -p stm8s103f3
OBJDIR=build
SRC=$(wildcard *.c)
OBJS= $(addprefix $(OBJDIR)/,$(SRC:%.c=%.rel))

all: $(OBJDIR) $(NAME).ihx 
	
$(OBJDIR):
	mkdir $(OBJDIR)	
clean:
	rm -Rrf $(OBJDIR)

flash: $(NAME).ihx
	stm8flash $(FLASHFLAGS) -w $(OBJDIR)/$(NAME).ihx

$(OBJDIR)/%.rel: %.c
	$(SDCC) $(CCFLAGS) $(INCLUDES) $(DEFINES) -o $@ -c  $<

$(NAME).ihx: $(OBJS)
	$(SDCC) $(LDFLAGS)  $(OBJS) -o $(OBJDIR)/$(NAME).ihx

.PHONY: all

from stm8_samples.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.