Fix linking problems on Linux (patch from Christian Ruppert (idl0r))
This was SVN commit r7077.
This commit is contained in:
parent
4bac6c8dd3
commit
65d3bd642c
@ -61,7 +61,7 @@ end
|
||||
-- library installation rules.
|
||||
extern_lib_defs = {
|
||||
boost = {
|
||||
unix_names = { "boost_signals-mt", "boost_filesystem-mt" },
|
||||
unix_names = { "boost_signals-mt", "boost_filesystem-mt", "boost_system-mt" },
|
||||
osx_names = { "boost_signals-mt", "boost_filesystem-mt", "boost_system-mt" }
|
||||
},
|
||||
cryptopp = {
|
||||
@ -95,7 +95,7 @@ extern_lib_defs = {
|
||||
tinsert(package.config["Testing"].links, "enet_dbg")
|
||||
tinsert(package.config["Release"].links, "enet")
|
||||
else
|
||||
tinsert(package.linkoptions, "-lenet")
|
||||
tinsert(package.links, "enet")
|
||||
end
|
||||
end,
|
||||
},
|
||||
@ -128,7 +128,7 @@ extern_lib_defs = {
|
||||
tinsert(package.config["Release"].links, "libxml2")
|
||||
else
|
||||
tinsert(package.buildoptions, "`pkg-config libxml-2.0 --cflags`")
|
||||
tinsert(package.linkoptions, "`pkg-config libxml-2.0 --libs`")
|
||||
tinsert(package.gnu_external, "`pkg-config libxml-2.0 --libs`")
|
||||
end
|
||||
end,
|
||||
},
|
||||
@ -149,7 +149,7 @@ extern_lib_defs = {
|
||||
add_extern_lib_paths("sdl")
|
||||
if OS ~= "windows" then
|
||||
tinsert(package.buildoptions, "`sdl-config --cflags`")
|
||||
tinsert(package.linkoptions, "`sdl-config --libs`")
|
||||
tinsert(package.gnu_external, "`sdl-config --libs`")
|
||||
end
|
||||
end
|
||||
},
|
||||
@ -175,7 +175,7 @@ extern_lib_defs = {
|
||||
tinsert(package.config["Release"].links, "wxmsw28u_gl")
|
||||
else
|
||||
tinsert(package.buildoptions, "`wx-config --unicode=yes --cxxflags`")
|
||||
tinsert(package.linkoptions, "`wx-config --unicode=yes --libs std,gl`")
|
||||
tinsert(package.gnu_external, "`wx-config --unicode=yes --libs std,gl`")
|
||||
end
|
||||
end,
|
||||
},
|
||||
|
@ -105,6 +105,7 @@ function package_set_build_flags()
|
||||
|
||||
package.buildflags = { "with-symbols", "no-edit-and-continue" }
|
||||
if not options["icc"] then
|
||||
-- adds the -Wall compiler flag
|
||||
tinsert(package.buildflags, "extra-warnings") -- this causes far too many warnings/remarks on ICC
|
||||
end
|
||||
|
||||
@ -150,7 +151,6 @@ function package_set_build_flags()
|
||||
else
|
||||
tinsert(package.buildoptions, {
|
||||
-- enable most of the standard warnings
|
||||
"-Wall",
|
||||
"-Wno-switch", -- enumeration value not handled in switch (this is sometimes useful, but results in lots of noise)
|
||||
"-Wno-reorder", -- order of initialization list in constructors (lots of noise)
|
||||
"-Wno-invalid-offsetof", -- offsetof on non-POD types (see comment in renderer/PatchRData.cpp)
|
||||
@ -185,6 +185,7 @@ function package_set_build_flags()
|
||||
if OS == "linux" then
|
||||
tinsert(package.linkoptions, {
|
||||
"-Wl,--no-undefined",
|
||||
"-Wl,--as-needed",
|
||||
})
|
||||
end
|
||||
end
|
||||
@ -662,6 +663,7 @@ function setup_atlas_package(package_name, target_type, rel_source_dirs, rel_inc
|
||||
elseif OS == "linux" then
|
||||
tinsert(package.buildoptions, "-rdynamic")
|
||||
tinsert(package.buildoptions, "-fPIC")
|
||||
tinsert(package.linkoptions, "-fPIC")
|
||||
tinsert(package.linkoptions, "-rdynamic")
|
||||
|
||||
if extra_params["no_unused_warnings"] then
|
||||
|
@ -13,7 +13,8 @@ ifeq ($(CONFIG),Debug)
|
||||
CPPFLAGS := -MD -D "_CRT_SECURE_NO_DEPRECATE"
|
||||
CFLAGS += $(CPPFLAGS) -g
|
||||
CXXFLAGS := $(CFLAGS)
|
||||
LDFLAGS += -L$(BINDIR) -L$(LIBDIR) -lm
|
||||
LDFLAGS += -L$(BINDIR) -L$(LIBDIR)
|
||||
LIBS = -lm
|
||||
LDDEPS :=
|
||||
TARGET := premake
|
||||
endif
|
||||
@ -26,7 +27,8 @@ ifeq ($(CONFIG),Release)
|
||||
CPPFLAGS := -MD -D "_CRT_SECURE_NO_DEPRECATE"
|
||||
CFLAGS += $(CPPFLAGS) -Os
|
||||
CXXFLAGS := $(CFLAGS)
|
||||
LDFLAGS += -L$(BINDIR) -L$(LIBDIR) -s -lm
|
||||
LDFLAGS += -L$(BINDIR) -L$(LIBDIR) -s
|
||||
LIBS = -lm
|
||||
LDDEPS :=
|
||||
TARGET := premake
|
||||
endif
|
||||
@ -105,7 +107,7 @@ $(OUTDIR)/$(TARGET): $(OBJECTS) $(LDDEPS) $(RESOURCES)
|
||||
-@$(CMD_MKBINDIR)
|
||||
-@$(CMD_MKLIBDIR)
|
||||
-@$(CMD_MKOUTDIR)
|
||||
@$(CC) -o $@ $(OBJECTS) $(LDFLAGS) $(RESOURCES)
|
||||
@$(CC) -o $@ $(LDFLAGS) $(OBJECTS) $(RESOURCES) $(LIBS)
|
||||
|
||||
clean:
|
||||
@echo Cleaning Premake
|
||||
|
@ -152,6 +152,7 @@ static int writeRootMakefile()
|
||||
|
||||
io_print("%s:", prj_get_pkgname());
|
||||
print_list(prj_get_links(), " ", "", "", listInterPackageDeps);
|
||||
print_list(prj_get_gnu_external(), " ", "", "", listInterPackageDeps);
|
||||
io_print("\n");
|
||||
|
||||
io_print("\t@echo ==== Building %s ====\n", prj_get_pkgname());
|
||||
|
@ -130,16 +130,14 @@ int gnu_cpp()
|
||||
// Use start-group and end-group to get around the problem with the
|
||||
// order of link arguments.
|
||||
|
||||
if (!os_is("macosx"))
|
||||
io_print(" -Xlinker --start-group");
|
||||
|
||||
print_list(prj_get_linkoptions(), " ", "", "", NULL);
|
||||
print_list(prj_get_libpaths(), " -L\"", "\"", "", NULL);
|
||||
print_list(prj_get_links(), " ", "", "", filterLinks);
|
||||
io_print("\n");
|
||||
|
||||
if (!os_is("macosx"))
|
||||
io_print(" -Xlinker --end-group");
|
||||
|
||||
/* Write dependencies */
|
||||
io_print(" LIBS = ");
|
||||
print_list(prj_get_links(), " ", "", "", filterLinks);
|
||||
print_list(prj_get_gnu_external(), " ", "", "", NULL);
|
||||
io_print("\n");
|
||||
|
||||
/* Build a list of libraries this target depends on */
|
||||
@ -164,7 +162,12 @@ int gnu_cpp()
|
||||
else if (prj_is_kind("run"))
|
||||
io_print("for a in $(LDDEPS); do echo Running $$a; $$a; done");
|
||||
else
|
||||
io_print("$(%s) -o $(OUTDIR)/$(TARGET) $(OBJECTS) $(LDFLAGS) $(RESOURCES)", prj_is_lang("c") ? "CC" : "CXX");
|
||||
{
|
||||
io_print("$(%s) -o $(OUTDIR)/$(TARGET) $(LDFLAGS) $(OBJECTS) $(RESOURCES) %s $(LIBS)",
|
||||
prj_is_lang("c") ? "CC" : "CXX",
|
||||
os_is("macosx") ? "$(LDDEPS)" : "-Xlinker --start-group $(LDDEPS) -Xlinker --end-group");
|
||||
}
|
||||
|
||||
io_print("\n");
|
||||
|
||||
io_print("endif\n\n");
|
||||
@ -353,6 +356,7 @@ static const char* filterLinks(const char* name)
|
||||
{
|
||||
const char* lang = prj_get_language_for(i);
|
||||
const char *kind = prj_get_config_for(i)->kind;
|
||||
|
||||
if (matches(kind, "cxxtestgen"))
|
||||
{
|
||||
return NULL;
|
||||
@ -365,10 +369,16 @@ static const char* filterLinks(const char* name)
|
||||
strcat(g_buffer, prj_get_targetname_for(i));
|
||||
return g_buffer;
|
||||
}
|
||||
else
|
||||
/*
|
||||
* Get a rid of library archives.
|
||||
* Might we even return NULL rather than check if kind != lib?
|
||||
*/
|
||||
else if (!matches(prj_get_kind_for(i), "lib"))
|
||||
{
|
||||
return prj_get_target_for(i);
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -63,6 +63,7 @@ void prj_close()
|
||||
free((void*)config->libpaths);
|
||||
free((void*)config->linkopts);
|
||||
free((void*)config->links);
|
||||
free((void*)config->gnu_external);
|
||||
prj_freelist((void**)config->fileconfigs);
|
||||
}
|
||||
|
||||
@ -453,6 +454,10 @@ const char** prj_get_links()
|
||||
return my_cfg->links;
|
||||
}
|
||||
|
||||
const char **prj_get_gnu_external()
|
||||
{
|
||||
return my_cfg->gnu_external;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* Return the name of the active object
|
||||
|
@ -49,6 +49,7 @@ typedef struct tagPkgConfig
|
||||
const char** libpaths;
|
||||
const char** linkopts;
|
||||
const char** links;
|
||||
const char** gnu_external;
|
||||
const char* objdir;
|
||||
const char* prefix;
|
||||
const char* target;
|
||||
@ -114,6 +115,7 @@ const char* prj_get_libdir_for(int i);
|
||||
const char** prj_get_libpaths();
|
||||
const char** prj_get_linkoptions();
|
||||
const char** prj_get_links();
|
||||
const char** prj_get_gnu_external();
|
||||
const char* prj_get_objdir();
|
||||
const char* prj_get_prefix();
|
||||
const char* prj_get_name();
|
||||
|
@ -368,6 +368,7 @@ static int export_pkgconfig(Package* package, int tbl)
|
||||
export_list(tbl, obj, "libpaths", &config->libpaths);
|
||||
export_list(tbl, obj, "linkoptions", &config->linkopts);
|
||||
export_list(tbl, obj, "links", &config->links);
|
||||
export_list(tbl, obj, "gnu_external", &config->gnu_external);
|
||||
|
||||
/* Build the file list */
|
||||
config->files = export_files(tbl, obj);
|
||||
@ -634,6 +635,10 @@ static void buildNewConfig(const char* name)
|
||||
lua_pushstring(L, "links");
|
||||
lua_newtable(L);
|
||||
lua_settable(L, -3);
|
||||
|
||||
lua_pushstring(L, "gnu_external");
|
||||
lua_newtable(L);
|
||||
lua_settable(L, -3);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user