linux和windows makefile之间的区别?

时间:2017-10-03 16:28:54

标签: c linux windows makefile

已在Windows环境中构建C程序并制作此makefile

# project name (generate executable with this name)
TARGET   = Orga_L1_MATURANA

CC       = gcc
# compiling flags here
CFLAGS   = -Wall -I.

LINKER   = gcc
# linking flags here
LFLAGS   = -Wall -I. -lm

# change these to proper directories where each file should be
SRCDIR   = src
OBJDIR   = obj
BINDIR   = bin

SOURCES  := $(wildcard $(SRCDIR)/main.c)
OBJECTS  := $(SOURCES:$(SRCDIR)/%.c=$(OBJDIR)/%.o)
rm       = rm -f


$(BINDIR)/$(TARGET): $(OBJECTS)
    @$(LINKER) $(OBJECTS) $(LFLAGS) -o $@
    @echo "Linking complete!"

$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.c
    @$(CC) $(CFLAGS) -c $< -o $@
    @echo "Compiled "$<" successfully!"

并且这棵树看到了代码

.
├── bin
│   ├── lineasControl2.txt
│   ├── mipsEjemplo2.asm
│   └── Orga_L1_MATURANA
├── makefile
├── obj
│   └── main.o
├── README.md
└── src
    ├── 2EnlazadasCursor.c
    ├── cons.c
    ├── cons.h
    ├── funciones.c
    ├── funciones.h
    ├── main.c
    ├── operaciones.c
    └── structs.h

它对于我为两个操作系统执行makefile的方式都很好吗?此外,我听说ubuntu不需要makefile,是吗?我不这么认为。

0 个答案:

没有答案