Skip to content

Commit

Permalink
Begin unify gcc build for far & plugins
Browse files Browse the repository at this point in the history
The number of warnings will be humongous, but that's ok for now.
  • Loading branch information
alabuzhev committed May 11, 2021
1 parent f4c07cf commit 14b80a0
Show file tree
Hide file tree
Showing 25 changed files with 51 additions and 100 deletions.
8 changes: 4 additions & 4 deletions far/makefile_gcc
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ FORCEINCLUDE_DISABLED_WARNINGS=-include disabled_warnings.hpp
FORCEINCLUDE=$(FORCEINCLUDE_DISABLED_WARNINGS) -include headers.hpp -include memcheck.hpp

CFLAGS += $(FORCEINCLUDE_DISABLED_WARNINGS)
CCFLAGS += $(ADDINCLUDE) $(FORCEINCLUDE)
CPPFLAGS += $(ADDINCLUDE) $(FORCEINCLUDE)

.PHONY: all
all:
Expand Down Expand Up @@ -254,11 +254,11 @@ $(OBJDIR)%.o: %.c

$(OBJDIR)%.o: %.cpp
@echo $<
$(CXX) -c -include $(OBJDIR)headers $(CCFLAGS) -o $@ $<
$(CXX) -c -include $(OBJDIR)headers $(CPPFLAGS) -o $@ $<

$(OBJDIR)headers.gch: headers.cpp headers.hpp
@echo Making precompiled headers
$(CXX) -x c++-header -c $(CCFLAGS) -o $@ $<
$(CXX) -x c++-header -c $(CPPFLAGS) -o $@ $<

$(OBJS): $(OBJDIR)headers.gch

Expand All @@ -272,7 +272,7 @@ $(OBJDIR)api_test_c.testobj: $(FARINCLUDE)plugin.hpp $(FARINCLUDE)farcolor.hpp a

$(OBJDIR)api_test_c++.testobj: $(FARINCLUDE)plugin.hpp $(FARINCLUDE)farcolor.hpp api_test.c
@echo Testing C++ plugin API
$(CXX) $(CCFLAGS) -c -x c++ -o $@ api_test.c
$(CXX) $(CPPFLAGS) -c -x c++ -o $@ api_test.c

MSG=@echo Generating $@

Expand Down
2 changes: 1 addition & 1 deletion far/makefile_gcc_common
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ CFLAGS += \
-Wno-unused-parameter \
-Wno-missing-field-initializers \

CCFLAGS = $(CFLAGS)\
CPPFLAGS = $(CFLAGS)\
-std=gnu++17 \
-fvisibility=hidden \
-Werror=old-style-cast \
Expand Down
3 changes: 0 additions & 3 deletions plugins/align/makefile_gcc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@ NAME = Align

SRCS = Align.cpp

include ../../far/makefile_gcc_common

include ../makefile_gcc_def_inc

include ../makefile_gcc_target_inc
18 changes: 12 additions & 6 deletions plugins/arclite/makefile_gcc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
.SILENT:

include ../../far/makefile_gcc_common
THIS_MAKE = $(TOP_MAKEFILE)

include project.ini
Expand All @@ -9,7 +8,7 @@ include ../makefile_gcc_def_inc
OUTDIR = $(BASEDIR)
BOOTSTRAPDIR=$(OBJDIR)/include/bootstrap/

CCFLAGS += -fexceptions -std=c++17 -I $(BOOTSTRAPDIR) -I 7z/h
CPPFLAGS += -fexceptions -std=c++17 -I $(BOOTSTRAPDIR) -I 7z/h

DEPFILE = $(OBJDIR)/$(MODULE).dep

Expand Down Expand Up @@ -121,14 +120,21 @@ $(OBJDIR)/version.rc.o: $(BOOTSTRAPDIR)version.rc

$(OBJDIR)/%.o: %.cpp
@echo $<
$(CXX) $(CCFLAGS) -c -include $(OBJDIR)/headers -include headers.hpp -o $@ $<
$(CXX) -c -include $(OBJDIR)/headers -include headers.hpp $(CPPFLAGS) -o $@ $<

$(OBJS): $(OBJDIR)/headers.gch

$(OBJDIR)/headers.gch: headers.cpp headers.hpp
@echo Making precompiled headers
$(CXX) -x c++-header -c $(CCFLAGS) -o $@ $<
$(CXX) -x c++-header -c $(CPPFLAGS) -o $@ $<

$(DLLFULLNAME): $(OBJS) plugin.gcc.def
ifeq ($(DIRBIT),32)
DEFFILE = plugin.gcc.def
else
#for x64 vc.def is good enough
DEFFILE = plugin.def
endif

$(DLLFULLNAME): $(OBJS) $(DEFFILE)
@echo linking $@
$(CXX) -o $@ plugin.gcc.def $(OBJS) $(LNKFLAGS) -Wl,--kill-at -shared -Xlinker -Map=$(MAPFULLNAME)
$(CXX) -o $@ $(DEFFILE) $(OBJS) $(LNKFLAGS) -Wl,--kill-at -shared -Xlinker -Map=$(MAPFULLNAME)
3 changes: 0 additions & 3 deletions plugins/autowrap/makefile_gcc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@ NAME = AutoWrap

SRCS = AutoWrap.cpp

include ../../far/makefile_gcc_common

include ../makefile_gcc_def_inc

include ../makefile_gcc_target_inc
3 changes: 0 additions & 3 deletions plugins/brackets/makefile_gcc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@ NAME = Brackets

SRCS = Brackets.cpp

include ../../far/makefile_gcc_common

include ../makefile_gcc_def_inc

include ../makefile_gcc_target_inc
3 changes: 0 additions & 3 deletions plugins/compare/makefile_gcc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@ NAME = Compare

SRCS = Compare.cpp

include ../../far/makefile_gcc_common

include ../makefile_gcc_def_inc

include ../makefile_gcc_target_inc
3 changes: 0 additions & 3 deletions plugins/drawline/makefile_gcc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@ NAME = DrawLine

SRCS = DrawLine.cpp

include ../../far/makefile_gcc_common

include ../makefile_gcc_def_inc

include ../makefile_gcc_target_inc
3 changes: 0 additions & 3 deletions plugins/editcase/makefile_gcc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@ NAME = EditCase

SRCS = EditCase.cpp

include ../../far/makefile_gcc_common

include ../makefile_gcc_def_inc

include ../makefile_gcc_target_inc
5 changes: 0 additions & 5 deletions plugins/emenu/makefile_gcc
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,5 @@ SRCS = \
Pidl.cpp \
Plugin.cpp

USERLIBS= -luuid

include ../../far/makefile_gcc_common

include ../makefile_gcc_def_inc

include ../makefile_gcc_target_inc
5 changes: 0 additions & 5 deletions plugins/farcmds/makefile_gcc
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,5 @@ SRCS = \
Mix.cpp \
OpenCmd.cpp

USERLIBS = -lole32 -luuid -lrpcrt4

include ../../far/makefile_gcc_common

include ../makefile_gcc_def_inc

include ../makefile_gcc_target_inc
3 changes: 0 additions & 3 deletions plugins/helloworld/makefile_gcc
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
NAME = HelloWorld
SRCS = HelloWorld.cpp

include ../../far/makefile_gcc_common

include ../makefile_gcc_def_inc

include ../makefile_gcc_target_inc
5 changes: 0 additions & 5 deletions plugins/hlfviewer/makefile_gcc
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,5 @@ NAME = HlfViewer

SRCS = HlfViewer.cpp

USERLIBS = -lrpcrt4

include ../../far/makefile_gcc_common

include ../makefile_gcc_def_inc

include ../makefile_gcc_target_inc
15 changes: 7 additions & 8 deletions plugins/luamacro/makefile_gcc
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
include ../../far/makefile_gcc_common

NAME = luamacro
LUAVER=51

ifndef FAR_WORKDIR
FAR_WORKDIR := $(FARDIR)$(DIRNAME).$(DIRBIT).gcc
endif
LUALIB = $(FAR_WORKDIR)/luafar3.dll
LUALIB = $(OBJDIR)/luafar3.lib

SRCS = luafar/luaplug.c

DOCS = luamacro.example.ini

USERCPP = -Iluasdk/include -DEXPORT_OPEN -DEXPORT_CONFIGURE \
USERC = -Iluasdk/include -DEXPORT_OPEN -DEXPORT_CONFIGURE \
-DEXPORT_PROCESSEDITOREVENT -DEXPORT_PROCESSVIEWEREVENT \
-DEXPORT_PROCESSDIALOGEVENT -DEXPORT_PROCESSEDITORINPUT -DEXPORT_PROCESSCONSOLEINPUT \
-DEXPORT_ANALYSE -DEXPORT_CLOSEPANEL -DEXPORT_COMPARE -DEXPORT_DELETEFILES \
-DEXPORT_GETFILES -DEXPORT_GETFINDDATA -DEXPORT_GETOPENPANELINFO -DEXPORT_MAKEDIRECTORY \
-DEXPORT_PROCESSHOSTFILE -DEXPORT_PROCESSPANELEVENT -DEXPORT_PROCESSPANELINPUT \
-DEXPORT_PUTFILES -DEXPORT_SETDIRECTORY -DEXPORT_SETFINDLIST -DEXPORT_GETCONTENTDATA \
-DRUN_LUAFAR_INIT
USERLIBS = $(LUALIB) luasdk/$(DIRBIT)/lua$(LUAVER).dll
USERLIBS = $(LUALIB) luasdk/$(DIRBIT)/lua$(LUAVER).lib

DEF_NAME = -
include ../makefile_gcc_def_inc

SKIPCLEAN = 1
include ../makefile_gcc_target_inc

ifndef FAR_WORKDIR
FAR_WORKDIR := $(FARDIR)$(DIRNAME).$(DIRBIT).gcc
endif

$(DLLFULLNAME): lualib lualegacy

.PHONY: lualib lualegacy clean
Expand Down
6 changes: 2 additions & 4 deletions plugins/luamacro/makefile_lib_gcc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
include ../../far/makefile_gcc_common

NAME=luafar3
LUAVER=51
LUA_PROXY=lua5.1.dll
Expand Down Expand Up @@ -28,8 +26,8 @@ ifeq ($(LUAVER),52)
SRCS += luafar/compat52.c
endif

USERLIBS = luasdk/$(DIRBIT)/lua$(LUAVER).dll -lrpcrt4
USERCPP = -Iluasdk/include -DBUILD_DLL -DWINVER=0x500 -DLUADLL=\"lua$(LUAVER).dll\"
USERLIBS = luasdk/$(DIRBIT)/lua$(LUAVER).lib -lrpcrt4 -Wl,--out-implib,$(OBJDIR)/luafar3.lib
USERC = -Iluasdk/include -DBUILD_DLL -DWINVER=0x500 -DLUADLL=\"lua$(LUAVER).dll\"

RC_NAME = luafar/$(NAME)
DEF_NAME = -
Expand Down
28 changes: 17 additions & 11 deletions plugins/makefile_gcc_def_inc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# is a folder inside the default target folder.
# This is used in multiarc for building *.fmt.
#
#USERCPP - user defined switches for the compiler (added after the default
#USERC, USERCPP - user defined switches for the compiler (added after the default
# ones).
#
#USERLIBS - specify additional libs you need in the form -llib
Expand All @@ -34,13 +34,20 @@

.SILENT:

DEP_FILTER := $(dir $(lastword $(MAKEFILE_LIST)))dep_filter.awk
MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
MAKEFILE_DIR := $(dir $(MAKEFILE_PATH))

DEP_FILTER := $(MAKEFILE_DIR)dep_filter.awk

include $(MAKEFILE_DIR)../far/makefile_gcc_common

FORCEINCLUDE_DISABLED_WARNINGS = -include $(MAKEFILE_DIR)../far/disabled_warnings.hpp

ifndef ANSI
DIRSURF = W
RCWIDE = -D UNICODE -D _UNICODE
CXXWIDE = -D UNICODE -D _UNICODE
CCWIDE = -D UNICODE -D _UNICODE

ifdef ANSI
DIRSURF =
WIDE = -U UNICODE -U _UNICODE
endif

ifndef DEBUG
Expand Down Expand Up @@ -101,11 +108,10 @@ else
COMMONLIB =
endif

C_FLAGS := -m$(DIRBIT) -Wall -funsigned-char $(C_DEBUG) -fstrict-aliasing
CXXFLAGS := $(C_FLAGS) -std=c++1z -I $(COMMON) -I $(COMINC) $(CXXWIDE) $(USERCPP)
CCFLAGS := $(C_FLAGS) -I $(COMMON) -I $(COMINC) $(CCWIDE) $(USERCPP)
LNKFLAGS := -m$(DIRBIT) $(L_DEBUG) $(NOSTART) $(NODEFLIBS) -static-libgcc -static $(USERLIBSFIRST) $(COMMONLIB) -luser32 -lkernel32 -ladvapi32 -lshell32 -lole32 $(USERLIBS)
RCFLAGS := -I $(COMINC) $(RCWIDE) $(USERRC)
CFLAGS += -I $(COMMON) -I $(COMINC) $(WIDE) $(FORCEINCLUDE_DISABLED_WARNINGS) $(USERC)
CPPFLAGS += -Wno-old-style-cast $(USERCPP)
LNKFLAGS += $(USERLIBS)
RCFLAGS += -I $(COMINC) $(WIDE) $(USERRC)

C_OBJS = $(patsubst %.c,$(OBJDIR)/%.o,$(filter %.c,$(SRCS)))
CPP_OBJS = $(patsubst %.cpp,$(OBJDIR)/%.o,$(filter %.cpp,$(SRCS)))
Expand Down
8 changes: 4 additions & 4 deletions plugins/makefile_gcc_target_inc
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@ ifeq ($(findstring clean,$(MAKECMDGOALS)),)
$(OBJDIR)/%.d: %.cpp
@echo making depends for $<
@$(MKDIR) $(@D)
@$(CXX) -c -MM $(CXXFLAGS) $< | $(GAWK) -f $(DEP_FILTER) -v n=$(notdir $(basename $@)) -v r=$(OBJDIR) > $(call os_name,$@)
@$(CXX) -c -MM $(CPPFLAGS) $< | $(GAWK) -f $(DEP_FILTER) -v n=$(notdir $(basename $@)) -v r=$(OBJDIR) > $(call os_name,$@)

$(OBJDIR)/%.d: %.c
@echo making depends for $<
@$(MKDIR) $(@D)
@$(CC) -c -MM $(CCFLAGS) $< | $(GAWK) -f $(DEP_FILTER) -v n=$(notdir $(basename $@)) -v r=$(OBJDIR) > $(call os_name,$@)
@$(CC) -c -MM $(CFLAGS) $< | $(GAWK) -f $(DEP_FILTER) -v n=$(notdir $(basename $@)) -v r=$(OBJDIR) > $(call os_name,$@)
endif
endif

$(OBJDIR)/%.o: %.cpp
@echo compiling $<
@$(MKDIR) -p $(@D)
@$(CXX) $(CXXFLAGS) -c -o $@ $<
@$(CXX) $(CPPFLAGS) -c -o $@ $<

$(OBJDIR)/%.o: %.c
@echo compiling $<
@$(MKDIR) -p $(@D)
@$(CC) $(CCFLAGS) -c -o $@ $<
@$(CC) $(CFLAGS) -c -o $@ $<

$(RES): $(RC_NAME).rc $(COMINC)/farversion.hpp $(COMINC)/plugin.hpp
@echo compiling $<
Expand Down
3 changes: 0 additions & 3 deletions plugins/multiarc/makefile_gcc
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ SRCS = \
DOCS = \
MultiArc.TryIfNoOther.reg

include ../../far/makefile_gcc_common

include ../makefile_gcc_def_inc

include ../makefile_gcc_target_inc

all: fmt
Expand Down
2 changes: 1 addition & 1 deletion plugins/multiarc/makefile_gcc_fmt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ADDOUTDIR = /Formats
SRCS = $(NAME).cpp

USERCPP = -I ./libpcre
USERLIBSFIRST = -L $(OBJDIR) -lPCRE
USERLIBS = -L $(OBJDIR) -lPCRE

include ../../far/makefile_gcc_common

Expand Down
6 changes: 2 additions & 4 deletions plugins/multiarc/makefile_gcc_libpcre
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
ANSI = 1
USERCPP = -DWIN32 -DPCRE_STATIC -D_WIN32

include ../../far/makefile_gcc_common

include ../makefile_gcc_def_inc

DLLNAME = libPCRE.a
Expand All @@ -19,14 +17,14 @@ ifeq ($(findstring clean,$(MAKECMDGOALS)),)
$(OBJDIR)/%.d: ./libpcre/%.c
@echo making depends for $<
@$(MKDIR) $(@D)
@$(CXX) -c -MM $(CXXFLAGS) $< | $(GAWK) -f $(DEP_FILTER) -v n=$(notdir $(basename $@)) -v r=$(OBJDIR) > $(call os_name,$@)
@$(CC) -c -MM $(CFLAGS) $< | $(GAWK) -f $(DEP_FILTER) -v n=$(notdir $(basename $@)) -v r=$(OBJDIR) > $(call os_name,$@)
endif
endif

$(OBJDIR)/%.o: ./libpcre/%.c
@echo compiling $<
@$(MKDIR) -p $(@D)
@$(CC) $(CCFLAGS) -c -o $@ $<
@$(CC) $(CFLAGS) -c -o $@ $<

$(DLLFULLNAME): $(OBJS)
@echo linking $@
Expand Down
2 changes: 1 addition & 1 deletion plugins/multiarc/makefile_vc_libpcre
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ all: $(OUTPUTS)
<<
!else
{libpcre}.c{$(OBJDIR)}.obj:
$(CC) $(CPPFLAGS) { $< }
$(CC) $(CFLAGS) { $< }
!endif

$(OUTPUTS): $(OBJS)
Expand Down
6 changes: 0 additions & 6 deletions plugins/network/makefile_gcc
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,5 @@ SRCS = \
NetFavorites.cpp \
NetMix.cpp

NEEDDEFLIB=1
USERLIBS = -lmpr -lnetapi32

include ../../far/makefile_gcc_common

include ../makefile_gcc_def_inc

include ../makefile_gcc_target_inc
3 changes: 0 additions & 3 deletions plugins/proclist/makefile_gcc
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,5 @@ endif
USERCPP = -I ./WMI -I "$(FAR_DIRECTORY)/thirdparty/fmt"
USERLIBS = -lversion -lmpr -lole32 -loleaut32 -lpsapi

include ../../far/makefile_gcc_common

include ../makefile_gcc_def_inc

include ../makefile_gcc_target_inc
Loading

0 comments on commit 14b80a0

Please sign in to comment.