Skip to content

Commit

Permalink
Build linux/amd64 library based on version 1.4.0-1
Browse files Browse the repository at this point in the history
For #136 as it should provide Wayland support
It's first official release of FLTK 1.4, so I guess we should update our prebuilt
libraries to use it.
To makes the updating easier, make each target use separate include directory.
  • Loading branch information
pwiecz committed Nov 18, 2024
1 parent 49be1fb commit 2d602a1
Show file tree
Hide file tree
Showing 171 changed files with 30,809 additions and 28 deletions.
4 changes: 2 additions & 2 deletions cgo_linux_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
package fltk

// #cgo linux,amd64 CXXFLAGS: -std=c++11
// #cgo linux,amd64 CPPFLAGS: -I${SRCDIR}/lib/linux/amd64 -I${SRCDIR}/include -I${SRCDIR}/include/FL/images -I${SRCDIR}/include/png -I${SRCDIR}/include/zlib -I${SRCDIR}/include/jpeg -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_THREAD_SAFE -D_REENTRANT
// #cgo linux,amd64 LDFLAGS: ${SRCDIR}/lib/linux/amd64/libfltk_images.a ${SRCDIR}/lib/linux/amd64/libfltk_jpeg.a ${SRCDIR}/lib/linux/amd64/libfltk_png.a ${SRCDIR}/lib/linux/amd64/libfltk_z.a ${SRCDIR}/lib/linux/amd64/libfltk_gl.a -lGLU -lGL ${SRCDIR}/lib/linux/amd64/libfltk_forms.a ${SRCDIR}/lib/linux/amd64/libfltk.a -lm -lX11 -lXext -lpthread -lXinerama -lXfixes -lXcursor -lXft -lXrender -lm -lfontconfig -ldl
// #cgo linux,amd64 CPPFLAGS: -I${SRCDIR}/include/linux/amd64 -I${SRCDIR}/include/linux/amd64/png -I${SRCDIR}/include/linux/amd64/zlib -I${SRCDIR}/include/linux/amd64/jpeg -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_THREAD_SAFE -D_REENTRANT
// #cgo linux,amd64 LDFLAGS: ${SRCDIR}/lib/linux/amd64/libfltk_images.a /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib/x86_64-linux-gnu/libpng.so /usr/lib/x86_64-linux-gnu/libz.so ${SRCDIR}/lib/linux/amd64/libfltk_gl.a -L/usr/lib/x86_64-linux-gnu -lwayland-egl -lwayland-client -lEGL -lGLU -lGL ${SRCDIR}/lib/linux/amd64/libfltk_forms.a ${SRCDIR}/lib/linux/amd64/libfltk.a -lm -lpthread -lXinerama -lXfixes -lXcursor -L/usr/lib/x86_64-linux-gnu -lpangoxft-1.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lharfbuzz -lfontconfig -lfreetype -lXft -lpangocairo-1.0 -lcairo -lX11 -lXrender -lwayland-cursor -lwayland-client -lxkbcommon -ldbus-1 -ldecor-0 -ldl
import "C"
42 changes: 19 additions & 23 deletions fltk-build.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"strings"
)

const commit = "eb759cb118fbf09da51938c04978e609822dbb48"
const commit = "d547e1956778ed584248179d9141843b86101a0a"

func main() {
if runtime.GOOS == "" {
Expand All @@ -36,13 +36,20 @@ func main() {
os.Exit(1)
}

libdir := filepath.Join("lib", runtime.GOOS, runtime.GOARCH)
libDir := filepath.Join("lib", runtime.GOOS, runtime.GOARCH)

if err := os.MkdirAll(libdir, 0750); err != nil {
fmt.Printf("Could not create directory %s, %v\n", libdir, err)
if err := os.MkdirAll(libDir, 0750); err != nil {
fmt.Printf("Could not create directory %s, %v\n", libDir, err)
os.Exit(1)
}

includeDir := filepath.Join("include", runtime.GOOS, runtime.GOARCH)
if err := os.MkdirAll(includeDir, 0750); err != nil {
fmt.Printf("Could not create directory %s, %v\n", includeDir, err)
os.Exit(1)
}


if err := os.MkdirAll("fltk_build", 0750); err != nil {
fmt.Printf("Could not create directory fltk_build, %v\n", err)
os.Exit(1)
Expand Down Expand Up @@ -134,9 +141,9 @@ func main() {
"-DOPTION_USE_SYSTEM_LIBPNG=OFF",
"-DOPTION_USE_SYSTEM_ZLIB=OFF",
"-DCMAKE_INSTALL_PREFIX="+currentDir,
"-DCMAKE_INSTALL_INCLUDEDIR=include",
"-DCMAKE_INSTALL_LIBDIR="+libdir,
"-DFLTK_INCLUDEDIR="+filepath.Join(currentDir, "include"),
"-DCMAKE_INSTALL_INCLUDEDIR=" + includeDir,
"-DCMAKE_INSTALL_LIBDIR="+libDir,
"-DFLTK_INCLUDEDIR="+filepath.Join(currentDir, "include", runtime.GOOS, runtime.GOARCH),
"-DFLTK_LIBDIR="+filepath.Join(currentDir, "lib", runtime.GOOS, runtime.GOARCH))

if runtime.GOOS == "darwin" {
Expand Down Expand Up @@ -180,17 +187,6 @@ func main() {
os.Exit(1)
}

flConfigTargetDir := filepath.Join(libdir, "FL")
if err := os.MkdirAll(flConfigTargetDir, 0750); err != nil {
fmt.Printf("Error creating directory %s, %v", flConfigTargetDir, err)
os.Exit(1)
}
flConfigPath := filepath.Join("include", "FL", "fl_config.h")
if err := os.Rename(flConfigPath, filepath.Join(flConfigTargetDir, "fl_config.h")); err != nil {
fmt.Printf("Error moving %s to %s, %v", flConfigPath, flConfigTargetDir, err)
os.Exit(1)
}

cgoFilename := "cgo_" + runtime.GOOS + "_" + runtime.GOARCH + ".go"
cgoFile, err := os.Create(cgoFilename)
if err != nil {
Expand Down Expand Up @@ -227,15 +223,15 @@ func main() {
if runtime.GOOS == "openbsd" {
fltkConfigCxxFlags = "-I/usr/X11R6/include " + fltkConfigCxxFlags
}
fmt.Fprintf(cgoFile, "// #cgo %s,%s CPPFLAGS: -I${SRCDIR}/%s %s", runtime.GOOS, runtime.GOARCH, libdir, fltkConfigCxxFlags)
fmt.Fprintf(cgoFile, "// #cgo %s,%s CPPFLAGS: %s", runtime.GOOS, runtime.GOARCH, fltkConfigCxxFlags)
if fltkConfigCxxFlags[len(fltkConfigCxxFlags)-1] != '\n' {
fmt.Fprintln(cgoFile, "")
}

fltkConfigLdCmd := exec.Command(fltkConfigPath, "--use-gl", "--use-images", "--use-forms", "--ldstaticflags")
ldOutput, err := fltkConfigLdCmd.Output()
if err != nil {
fmt.Printf("Error running fltk-config --ldflags, %v\n", err)
fmt.Printf("Error running fltk-config --ldstaticflags, %v\n", err)
os.Exit(1)
}
fltkConfigLdFlags := strings.ReplaceAll(string(ldOutput), currentDir, "${SRCDIR}")
Expand All @@ -248,11 +244,11 @@ func main() {
}

} else {
// Switching to slashes in paths in cgo directives as backslashes are cause problems when being passed to gcc.
libdir := filepath.ToSlash(libdir)
// Switching to slashes in paths in cgo directives as backslashes are causing problems when being passed to gcc.
libdir := filepath.ToSlash(libDir)
// Hardcoding contents of cgo directive for windows,
// as we cannot extract it from fltk-config if we're not using a UNIX shell.
fmt.Fprintf(cgoFile, "// #cgo %s,%s CPPFLAGS: -I${SRCDIR}/%s -I${SRCDIR}/include -I${SRCDIR}/include/FL/images -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64\n", runtime.GOOS, runtime.GOARCH, libdir)
fmt.Fprintf(cgoFile, "// #cgo %s,%s CPPFLAGS: -I${SRCDIR}/%s -I${SRCDIR}/%s/FL/images -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64\n", runtime.GOOS, runtime.GOARCH, includeDir, includeDir)
fmt.Fprintf(cgoFile, "// #cgo %s,%s LDFLAGS: -mwindows ${SRCDIR}/%s/libfltk_images.a ${SRCDIR}/%s/libfltk_jpeg.a ${SRCDIR}/%s/libfltk_png.a ${SRCDIR}/%s/libfltk_z.a ${SRCDIR}/%s/libfltk_gl.a -lglu32 -lopengl32 ${SRCDIR}/%s/libfltk_forms.a ${SRCDIR}/%s/libfltk.a -lgdiplus -lole32 -luuid -lcomctl32 -lws2_32\n", runtime.GOOS, runtime.GOARCH, libdir, libdir, libdir, libdir, libdir, libdir, libdir)
}
fmt.Fprintln(cgoFile, "import \"C\"")
Expand Down
Loading

0 comments on commit 2d602a1

Please sign in to comment.