File Makefile and .Mak + CodeBlocks and VStudio

Hi guys, I'm a little new to the whole makefile concept, so I have some questions regarding this.

I am creating a project using CodeBlocks in linux, I used the cbp2mak tool to create a .make file from the CodeBlocks project (if anyone knows the best tool, let me know).

Now I'm not sure what the difference is between .mak and .makefile, can anyone tell me? I can compile .mak using "make -C.mak", but what is the difference?

The reason I'm trying to use it is because I want to provide the source code for my project and I want it to be buildable on both Linux and Windows, so I don't want to give them my codeblocks project file . So I thought I could use a makefile that can be used to create on both Linux and Windows.

I would also like to check on Windows if both the MinGW and VC ++ compiler exist, and built a source with both compilers, on Linux it will only be with GNU GCC.

There are also several macros in the .mak file to determine what needs to be created depending on whether it runs on Windows or Linux, since there are platform-specific files.

So the questions are:

-What is the difference between .mak and .makefile

-Can I run the .mak file in windows? say using a visual studio?

- , ? ( cpb2mak, .mak, , , make )

- .

EDIT:

.mak

, , . .mak , ifdef "shell, uname"

# project performer-1.0


export PATH := /opt/wx/2.8/bin:$(PATH)
export LD_LIBRARY_PATH := /opt/wx/2.8/lib:$(LD_LIBRARY_PATH)

_WX = /home/gr/projects/gui/codeblocks/wx
_WX.LIB = $(_WX)/lib
_WX.INCLUDE = $(_WX)/include

_CB = /home/gr/projects/gui/codeblocks/cb/src
_CB.INCLUDE = $(_CB)/include
_CB.LIB = $(_CB)/devel



CFLAGS_C = $(filter-out -include "sdk.h",$(CFLAGS))

# -----------------------------------------

# MAKE_DEP = -MMD -MT $@ -MF $(@:.o=.d)

CFLAGS = -Wall 
INCLUDES = -I../performer-1.0 
LDFLAGS =  -s
RCFLAGS = 
LDLIBS = $(T_LDLIBS) -lrt -lboost_regex-gcc43-mt -lxerces-c  -lstdc++

LINK_exe = gcc -o $@ $^ $(LDFLAGS) $(LDLIBS)
LINK_con = gcc -o $@ $^ $(LDFLAGS) $(LDLIBS)
LINK_dll = gcc -o $@ $^ $(LDFLAGS) $(LDLIBS) -shared
LINK_lib = rm -f $@ && ar rcs $@ $^
COMPILE_c = gcc $(CFLAGS_C) -o $@ -c $< $(MAKEDEP) $(INCLUDES)
COMPILE_cpp = g++ $(CFLAGS) -o $@ -c $< $(MAKEDEP) $(INCLUDES)
COMPILE_rc = windres $(RCFLAGS) -J rc -O coff -i $< -o $@ -I$(dir $<)

%.o : %.c ; $(COMPILE_c)
%.o : %.cpp ; $(COMPILE_cpp)
%.o : %.cxx ; $(COMPILE_cpp)
%.o : %.rc ; $(COMPILE_rc)
.SUFFIXES: .o .d .c .cpp .cxx .rc

all: all.before all.targets all.after

all.before :
    -
all.after : $(FIRST_TARGET)

# -----------------------------------------------------------
ifeq "$(shell uname)" "Linux"
# -----------------------------------------------------------

all.targets : Linux_Dynamic_target Linux_Static_target 

# -----------------------------------------------------------
else
# -----------------------------------------------------------

all.targets : Windows_Dynamic_target

# -----------------------------------------------------------
endif
# -----------------------------------------------------------

clean :
    rm -fv $(clean.OBJ)
    rm -fv $(DEP_FILES)

.PHONY: all clean distclean

# -----------------------------------------------------------
ifeq "$(shell uname)" "Linux"
# -----------------------------------------------------------

# -----------------------------------------
# Linux_Dynamic_target

Linux_Dynamic_target.BIN = libs/libperformer-1.so
Linux_Dynamic_target.OBJ = src/analysis/analyzer.o src/analysis/comparer.o src/analysis/paverage.o src/analysis/pfunctor.o src/analysis/pmax.o src/analysis/pmin.o src/config/configfile.o src/data_collection/datacollector.o src/data_collection/linux/linfactory.o src/data_collection/linux/linmemprof.o src/data_collection/linux/lintimer.o src/data_collection/linux/procsmaps.o src/data_collection/linux/procstatus.o src/data_collection/pstructs.o src/data_collection/resultxml.o 
DEP_FILES += src/analysis/analyzer.d src/analysis/comparer.d src/analysis/paverage.d src/analysis/pfunctor.d src/analysis/pmax.d src/analysis/pmin.d src/config/configfile.d src/data_collection/datacollector.d src/data_collection/linux/linfactory.d src/data_collection/linux/linmemprof.d src/data_collection/linux/lintimer.d src/data_collection/linux/procsmaps.d src/data_collection/linux/procstatus.d src/data_collection/pstructs.d src/data_collection/resultxml.d 
clean.OBJ += $(Linux_Dynamic_target.BIN) $(Linux_Dynamic_target.OBJ)

Linux_Dynamic_target : Linux_Dynamic_target.before $(Linux_Dynamic_target.BIN) Linux_Dynamic_target.after_always
Linux_Dynamic_target : CFLAGS += -Wall -g  -Os
Linux_Dynamic_target : INCLUDES += 
Linux_Dynamic_target : RCFLAGS += 
Linux_Dynamic_target : LDFLAGS +=  $(CREATE_LIB) $(CREATE_DEF)
Linux_Dynamic_target : T_LDLIBS = 
ifdef LMAKE
Linux_Dynamic_target : CFLAGS -= -O1 -O2 -g -pipe
endif

Linux_Dynamic_target.before :


Linux_Dynamic_target.after_always : $(Linux_Dynamic_target.BIN)

$(Linux_Dynamic_target.BIN) : $(Linux_Dynamic_target.OBJ)
    $(LINK_dll)

# -----------------------------------------
# Linux_Static_target

Linux_Static_target.BIN = libs/libperformer-1.a
Linux_Static_target.OBJ = src/analysis/analyzer.o src/analysis/comparer.o src/analysis/paverage.o src/analysis/pfunctor.o src/analysis/pmax.o src/analysis/pmin.o src/config/configfile.o src/data_collection/datacollector.o src/data_collection/linux/linfactory.o src/data_collection/linux/linmemprof.o src/data_collection/linux/lintimer.o src/data_collection/linux/procsmaps.o src/data_collection/linux/procstatus.o src/data_collection/pstructs.o src/data_collection/resultxml.o 
DEP_FILES += src/analysis/analyzer.d src/analysis/comparer.d src/analysis/paverage.d src/analysis/pfunctor.d src/analysis/pmax.d src/analysis/pmin.d src/config/configfile.d src/data_collection/datacollector.d src/data_collection/linux/linfactory.d src/data_collection/linux/linmemprof.d src/data_collection/linux/lintimer.d src/data_collection/linux/procsmaps.d src/data_collection/linux/procstatus.d src/data_collection/pstructs.d src/data_collection/resultxml.d 
clean.OBJ += $(Linux_Static_target.BIN) $(Linux_Static_target.OBJ)

Linux_Static_target : Linux_Static_target.before $(Linux_Static_target.BIN) Linux_Static_target.after_always
Linux_Static_target : CFLAGS += -Wall -g  -Os
Linux_Static_target : INCLUDES += 
Linux_Static_target : RCFLAGS += 
Linux_Static_target : LDFLAGS +=   $(CREATE_DEF)
Linux_Static_target : T_LDLIBS = 
ifdef LMAKE
Linux_Static_target : CFLAGS -= -O1 -O2 -g -pipe
endif

Linux_Static_target.before :


Linux_Static_target.after_always : $(Linux_Static_target.BIN)

$(Linux_Static_target.BIN) : $(Linux_Static_target.OBJ)
    $(LINK_lib)


# -----------------------------------------

# -----------------------------------------------------------
else
# -----------------------------------------------------------   

# -----------------------------------------
# Windows_Dynamic_target

Windows_Dynamic_target.BIN = libs/performer-1.so
Windows_Dynamic_target.OBJ = src/analysis/analyzer.o src/analysis/comparer.o src/analysis/paverage.o src/analysis/pfunctor.o src/analysis/pmax.o src/analysis/pmin.o src/config/configfile.o src/data_collection/datacollector.o src/data_collection/pstructs.o src/data_collection/resultxml.o src/data_collection/windows/winfactory.o src/data_collection/windows/wintimer.o 
DEP_FILES += src/analysis/analyzer.d src/analysis/comparer.d src/analysis/paverage.d src/analysis/pfunctor.d src/analysis/pmax.d src/analysis/pmin.d src/config/configfile.d src/data_collection/datacollector.d src/data_collection/pstructs.d src/data_collection/resultxml.d src/data_collection/windows/winfactory.d src/data_collection/windows/wintimer.d 
clean.OBJ += $(Windows_Dynamic_target.BIN) $(Windows_Dynamic_target.OBJ)

Windows_Dynamic_target : Windows_Dynamic_target.before $(Windows_Dynamic_target.BIN) Windows_Dynamic_target.after_always
Windows_Dynamic_target : CFLAGS += -Wall -g  -Os
Windows_Dynamic_target : INCLUDES += 
Windows_Dynamic_target : RCFLAGS += 
Windows_Dynamic_target : LDFLAGS +=  $(CREATE_LIB) $(CREATE_DEF)
Windows_Dynamic_target : T_LDLIBS = 
ifdef LMAKE
Windows_Dynamic_target : CFLAGS -= -O1 -O2 -g -pipe
endif

Windows_Dynamic_target.before :


Windows_Dynamic_target.after_always : $(Windows_Dynamic_target.BIN)

$(Windows_Dynamic_target.BIN) : $(Windows_Dynamic_target.OBJ)
    $(LINK_dll)

ifdef MAKE_DEP
-include $(DEP_FILES)
endif

# -----------------------------------------------------------
endif
#
+3
2

, . make .

.mak, ,

+1

, , mak mk (make) . , , .

mak microsoft, :

nmake /f NAMEOFfile.mak

nmake Visual Studio, / mak mk (make).

make mk Linux Cross Platform ( , Dev Windows). mk Autotools, CMake ( Windows, Linux). mk script, make, mak/nmake.

0

Source: https://habr.com/ru/post/1717921/


All Articles